| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 testInitializers, | 75 testInitializers, |
| 76 testThis, | 76 testThis, |
| 77 testSuperCalls, | 77 testSuperCalls, |
| 78 testSwitch, | 78 testSwitch, |
| 79 testTypeVariables, | 79 testTypeVariables, |
| 80 testToString, | 80 testToString, |
| 81 testIndexedOperator, | 81 testIndexedOperator, |
| 82 testIncrementsAndDecrements, | 82 testIncrementsAndDecrements, |
| 83 testOverrideHashCodeCheck, | 83 testOverrideHashCodeCheck, |
| 84 testSupertypeOrder, | 84 testSupertypeOrder, |
| 85 testConstructorArgumentMismatch, | |
| 86 testConstConstructorAndNonFinalFields, | 85 testConstConstructorAndNonFinalFields, |
| 87 ], (f) => f())); | 86 ], (f) => f())); |
| 88 } | 87 } |
| 89 | 88 |
| 90 Future testSupertypeOrder() { | 89 Future testSupertypeOrder() { |
| 91 return Future.wait([ | 90 return Future.wait([ |
| 92 MockCompiler.create((MockCompiler compiler) { | 91 MockCompiler.create((MockCompiler compiler) { |
| 93 compiler.parseScript(""" | 92 compiler.parseScript(""" |
| 94 class I1 {} | 93 class I1 {} |
| 95 class I2 {} | 94 class I2 {} |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 638 |
| 640 TreeElements elements = compiler.resolveStatement("new A();"); | 639 TreeElements elements = compiler.resolveStatement("new A();"); |
| 641 NewExpression expression = | 640 NewExpression expression = |
| 642 compiler.parsedTree.asExpressionStatement().expression; | 641 compiler.parsedTree.asExpressionStatement().expression; |
| 643 Element element = elements[expression.send]; | 642 Element element = elements[expression.send]; |
| 644 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind); | 643 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind); |
| 645 Expect.isTrue(element.isSynthesized); | 644 Expect.isTrue(element.isSynthesized); |
| 646 }); | 645 }); |
| 647 } | 646 } |
| 648 | 647 |
| 649 Future testConstructorArgumentMismatch() { | |
| 650 return MockCompiler.create((MockCompiler compiler) { | |
| 651 String script = "class A {} foo() { print(new A(42)); }"; | |
| 652 compiler.parseScript(script); | |
| 653 FunctionElement fooElement = compiler.mainApp.find('foo'); | |
| 654 Expect.isNotNull(fooElement); | |
| 655 fooElement.parseNode(compiler); | |
| 656 compiler.resolver.resolve(fooElement); | |
| 657 | |
| 658 compareWarningKinds( | |
| 659 script, [MessageKind.INVALID_ARGUMENTS], compiler.warnings); | |
| 660 compareWarningKinds(script, [], compiler.errors); | |
| 661 }); | |
| 662 } | |
| 663 | |
| 664 Future testTopLevelFields() { | 648 Future testTopLevelFields() { |
| 665 return MockCompiler.create((MockCompiler compiler) { | 649 return MockCompiler.create((MockCompiler compiler) { |
| 666 compiler.parseScript("int a;"); | 650 compiler.parseScript("int a;"); |
| 667 VariableElementX element = compiler.mainApp.find("a"); | 651 VariableElementX element = compiler.mainApp.find("a"); |
| 668 Expect.equals(ElementKind.FIELD, element.kind); | 652 Expect.equals(ElementKind.FIELD, element.kind); |
| 669 VariableDefinitions node = element.variables.parseNode(element, compiler); | 653 VariableDefinitions node = element.variables.parseNode(element, compiler); |
| 670 Identifier typeName = node.type.typeName; | 654 Identifier typeName = node.type.typeName; |
| 671 Expect.equals(typeName.source, 'int'); | 655 Expect.equals(typeName.source, 'int'); |
| 672 | 656 |
| 673 compiler.parseScript("var b, c;"); | 657 compiler.parseScript("var b, c;"); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 }"""; | 1077 }"""; |
| 1094 asyncTest(() => compileScript(script2).then((compiler) { | 1078 asyncTest(() => compileScript(script2).then((compiler) { |
| 1095 expect(compiler, | 1079 expect(compiler, |
| 1096 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1080 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 1097 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1081 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1098 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1082 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1099 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1083 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 1100 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1084 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 1101 })); | 1085 })); |
| 1102 } | 1086 } |
| OLD | NEW |