| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package com.google.dart.compiler.parser; | 5 package com.google.dart.compiler.parser; |
| 6 | 6 |
| 7 import com.google.dart.compiler.DartCompilationError; | 7 import com.google.dart.compiler.DartCompilationError; |
| 8 import com.google.dart.compiler.DartCompilerErrorCode; | 8 import com.google.dart.compiler.DartCompilerErrorCode; |
| 9 import com.google.dart.compiler.DartCompilerListener; | 9 import com.google.dart.compiler.DartCompilerListener; |
| 10 import com.google.dart.compiler.DartSourceTest; | 10 import com.google.dart.compiler.DartSourceTest; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 parseUnitErrors("TryCatchNegative.dart", | 147 parseUnitErrors("TryCatchNegative.dart", |
| 148 DartCompilerErrorCode.CATCH_OR_FINALLY_EXPECTED, 8, 3); | 148 DartCompilerErrorCode.CATCH_OR_FINALLY_EXPECTED, 8, 3); |
| 149 } | 149 } |
| 150 | 150 |
| 151 public void testArrayLiteral() { | 151 public void testArrayLiteral() { |
| 152 DartUnit unit = parseUnit("phony_array_literal.dart", "var x = <int>[1,2,3];
"); | 152 DartUnit unit = parseUnit("phony_array_literal.dart", "var x = <int>[1,2,3];
"); |
| 153 List<DartNode> nodes = unit.getTopLevelNodes(); | 153 List<DartNode> nodes = unit.getTopLevelNodes(); |
| 154 assertEquals(1, nodes.size()); | 154 assertEquals(1, nodes.size()); |
| 155 DartFieldDefinition f = (DartFieldDefinition)nodes.get(0); | 155 DartFieldDefinition f = (DartFieldDefinition)nodes.get(0); |
| 156 DartField fieldX = (DartField)f.getFields().get(0); | 156 DartField fieldX = f.getFields().get(0); |
| 157 DartArrayLiteral array = (DartArrayLiteral) fieldX.getValue(); | 157 DartArrayLiteral array = (DartArrayLiteral) fieldX.getValue(); |
| 158 assertEquals(3, array.getExpressions().size()); | 158 assertEquals(3, array.getExpressions().size()); |
| 159 assertEquals(1, ((DartIntegerLiteral)array.getExpressions().get(0)).getValue
().intValue()); | 159 assertEquals(1, ((DartIntegerLiteral)array.getExpressions().get(0)).getValue
().intValue()); |
| 160 assertEquals(2, ((DartIntegerLiteral)array.getExpressions().get(1)).getValue
().intValue()); | 160 assertEquals(2, ((DartIntegerLiteral)array.getExpressions().get(1)).getValue
().intValue()); |
| 161 assertEquals(3, ((DartIntegerLiteral)array.getExpressions().get(2)).getValue
().intValue()); | 161 assertEquals(3, ((DartIntegerLiteral)array.getExpressions().get(2)).getValue
().intValue()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 public void testMapLiteral() { | 164 public void testMapLiteral() { |
| 165 DartUnit unit = parseUnit("phony_map_literal.dart", "var x = <int>{'a':1,'b'
:2,'c':3};"); | 165 DartUnit unit = parseUnit("phony_map_literal.dart", "var x = <int>{'a':1,'b'
:2,'c':3};"); |
| 166 List<DartNode> nodes = unit.getTopLevelNodes(); | 166 List<DartNode> nodes = unit.getTopLevelNodes(); |
| 167 assertEquals(1, nodes.size()); | 167 assertEquals(1, nodes.size()); |
| 168 DartFieldDefinition f = (DartFieldDefinition)nodes.get(0); | 168 DartFieldDefinition f = (DartFieldDefinition)nodes.get(0); |
| 169 DartField fieldX = (DartField)f.getFields().get(0); | 169 DartField fieldX = f.getFields().get(0); |
| 170 DartMapLiteral map = (DartMapLiteral) fieldX.getValue(); | 170 DartMapLiteral map = (DartMapLiteral) fieldX.getValue(); |
| 171 assertEquals(3, map.getEntries().size()); | 171 assertEquals(3, map.getEntries().size()); |
| 172 assertEquals(1, ((DartIntegerLiteral) (map.getEntries().get(0)).getValue()).
getValue() | 172 assertEquals(1, ((DartIntegerLiteral) (map.getEntries().get(0)).getValue()).
getValue() |
| 173 .intValue()); | 173 .intValue()); |
| 174 } | 174 } |
| 175 } | 175 } |
| OLD | NEW |