| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; | 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // testVarSuperclass(); // The parser crashes with 'class Foo extends var'. | 65 // testVarSuperclass(); // The parser crashes with 'class Foo extends var'. |
| 66 // testOneInterface(); // Generates unexpected error message. | 66 // testOneInterface(); // Generates unexpected error message. |
| 67 // testTwoInterfaces(); // Generates unexpected error message. | 67 // testTwoInterfaces(); // Generates unexpected error message. |
| 68 testFunctionExpression(); | 68 testFunctionExpression(); |
| 69 testNewExpression(); | 69 testNewExpression(); |
| 70 testTopLevelFields(); | 70 testTopLevelFields(); |
| 71 testClassHierarchy(); | 71 testClassHierarchy(); |
| 72 testInitializers(); | 72 testInitializers(); |
| 73 testThis(); | 73 testThis(); |
| 74 testSuperCalls(); | 74 testSuperCalls(); |
| 75 testSwitch(); |
| 75 testTypeVariables(); | 76 testTypeVariables(); |
| 76 testToString(); | 77 testToString(); |
| 77 testIndexedOperator(); | 78 testIndexedOperator(); |
| 78 testIncrementsAndDecrements(); | 79 testIncrementsAndDecrements(); |
| 79 testOverrideHashCodeCheck(); | 80 testOverrideHashCodeCheck(); |
| 80 testSupertypeOrder(); | 81 testSupertypeOrder(); |
| 81 testConstructorArgumentMismatch(); | 82 testConstructorArgumentMismatch(); |
| 82 testConstConstructorAndNonFinalFields(); | 83 testConstConstructorAndNonFinalFields(); |
| 83 } | 84 } |
| 84 | 85 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 FunctionExpression node = fooB.parseNode(compiler); | 197 FunctionExpression node = fooB.parseNode(compiler); |
| 197 visitor.visit(node.body); | 198 visitor.visit(node.body); |
| 198 Map mapping = map(visitor); | 199 Map mapping = map(visitor); |
| 199 | 200 |
| 200 Send superCall = node.body.asReturn().expression; | 201 Send superCall = node.body.asReturn().expression; |
| 201 FunctionElement called = mapping[superCall]; | 202 FunctionElement called = mapping[superCall]; |
| 202 Expect.isNotNull(called); | 203 Expect.isNotNull(called); |
| 203 Expect.equals(fooA, called); | 204 Expect.equals(fooA, called); |
| 204 } | 205 } |
| 205 | 206 |
| 207 testSwitch() { |
| 208 MockCompiler compiler = new MockCompiler(); |
| 209 compiler.parseScript("class Foo { foo() {" |
| 210 "switch (null) { case '': break; case 2: break; } } }"); |
| 211 compiler.resolveStatement("Foo foo;"); |
| 212 ClassElement fooElement = compiler.mainApp.find("Foo"); |
| 213 FunctionElement funElement = fooElement.lookupLocalMember("foo"); |
| 214 compiler.processQueue(compiler.enqueuer.resolution, funElement); |
| 215 Expect.equals(0, compiler.warnings.length); |
| 216 Expect.equals(1, compiler.errors.length); |
| 217 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL, |
| 218 compiler.errors[0].message.kind); |
| 219 Expect.equals(2, compiler.infos.length); |
| 220 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, |
| 221 compiler.infos[0].message.kind); |
| 222 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, |
| 223 compiler.infos[1].message.kind); |
| 224 } |
| 225 |
| 206 testThis() { | 226 testThis() { |
| 207 MockCompiler compiler = new MockCompiler(); | 227 MockCompiler compiler = new MockCompiler(); |
| 208 compiler.parseScript("class Foo { foo() { return this; } }"); | 228 compiler.parseScript("class Foo { foo() { return this; } }"); |
| 209 compiler.resolveStatement("Foo foo;"); | 229 compiler.resolveStatement("Foo foo;"); |
| 210 ClassElement fooElement = compiler.mainApp.find("Foo"); | 230 ClassElement fooElement = compiler.mainApp.find("Foo"); |
| 211 FunctionElement funElement = fooElement.lookupLocalMember("foo"); | 231 FunctionElement funElement = fooElement.lookupLocalMember("foo"); |
| 212 ResolverVisitor visitor = | 232 ResolverVisitor visitor = |
| 213 new ResolverVisitor(compiler, funElement, | 233 new ResolverVisitor(compiler, funElement, |
| 214 new CollectingTreeElements(funElement)); | 234 new CollectingTreeElements(funElement)); |
| 215 FunctionExpression function = funElement.parseNode(compiler); | 235 FunctionExpression function = funElement.parseNode(compiler); |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 }"""; | 1010 }"""; |
| 991 asyncTest(() => compileScript(script2).then((compiler) { | 1011 asyncTest(() => compileScript(script2).then((compiler) { |
| 992 expect(compiler, | 1012 expect(compiler, |
| 993 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1013 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 994 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1014 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 995 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1015 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 996 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1016 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 997 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1017 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 998 })); | 1018 })); |
| 999 } | 1019 } |
| OLD | NEW |