| 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 "package:compiler/src/resolution/resolution.dart"; | 10 import "package:compiler/src/resolution/resolution.dart"; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 testFor, | 69 testFor, |
| 70 testTypeAnnotation, | 70 testTypeAnnotation, |
| 71 testSuperclass, | 71 testSuperclass, |
| 72 // testVarSuperclass, // The parser crashes with 'class Foo extends var'. | 72 // testVarSuperclass, // The parser crashes with 'class Foo extends var'. |
| 73 // testOneInterface, // Generates unexpected error message. | 73 // testOneInterface, // Generates unexpected error message. |
| 74 // testTwoInterfaces, // Generates unexpected error message. | 74 // testTwoInterfaces, // Generates unexpected error message. |
| 75 testFunctionExpression, | 75 testFunctionExpression, |
| 76 testNewExpression, | 76 testNewExpression, |
| 77 testTopLevelFields, | 77 testTopLevelFields, |
| 78 testClassHierarchy, | 78 testClassHierarchy, |
| 79 testEnumDeclaration, |
| 79 testInitializers, | 80 testInitializers, |
| 80 testThis, | 81 testThis, |
| 81 testSuperCalls, | 82 testSuperCalls, |
| 82 testSwitch, | 83 testSwitch, |
| 83 testTypeVariables, | 84 testTypeVariables, |
| 84 testToString, | 85 testToString, |
| 85 testIndexedOperator, | 86 testIndexedOperator, |
| 86 testIncrementsAndDecrements, | 87 testIncrementsAndDecrements, |
| 87 testOverrideHashCodeCheck, | 88 testOverrideHashCodeCheck, |
| 88 testSupertypeOrder, | 89 testSupertypeOrder, |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 compiler.resolver.resolve(mainElement); | 800 compiler.resolver.resolve(mainElement); |
| 800 Expect.equals(0, compiler.warnings.length); | 801 Expect.equals(0, compiler.warnings.length); |
| 801 Expect.equals(1, compiler.errors.length); | 802 Expect.equals(1, compiler.errors.length); |
| 802 Expect.equals(MessageKind.MULTI_INHERITANCE, | 803 Expect.equals(MessageKind.MULTI_INHERITANCE, |
| 803 compiler.errors[0].message.kind); | 804 compiler.errors[0].message.kind); |
| 804 Expect.equals(0, compiler.crashes.length); | 805 Expect.equals(0, compiler.crashes.length); |
| 805 }), | 806 }), |
| 806 ]); | 807 ]); |
| 807 } | 808 } |
| 808 | 809 |
| 810 Future testEnumDeclaration() { |
| 811 final MAIN = "main"; |
| 812 return Future.wait([ |
| 813 MockCompiler.create((MockCompiler compiler) { |
| 814 compiler.parseScript("""enum Enum {} |
| 815 main() { Enum e; }"""); |
| 816 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 817 compiler.resolver.resolve(mainElement); |
| 818 Expect.equals(0, compiler.warnings.length, |
| 819 'Unexpected warnings: ${compiler.warnings}'); |
| 820 Expect.equals(0, compiler.errors.length, |
| 821 'Unexpected errors: ${compiler.errors}'); |
| 822 }, enableEnums: true), |
| 823 MockCompiler.create((MockCompiler compiler) { |
| 824 compiler.parseScript("""enum Enum {} |
| 825 main() { Enum e = Enum.A; }"""); |
| 826 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 827 compiler.resolver.resolve(mainElement); |
| 828 Expect.equals(1, compiler.warnings.length, |
| 829 'Unexpected warnings: ${compiler.warnings}'); |
| 830 Expect.equals(MessageKind.MEMBER_NOT_FOUND, |
| 831 compiler.warnings[0].message.kind); |
| 832 Expect.equals(0, compiler.errors.length, |
| 833 'Unexpected errors: ${compiler.errors}'); |
| 834 }, enableEnums: true), |
| 835 MockCompiler.create((MockCompiler compiler) { |
| 836 compiler.parseScript("""enum Enum { A } |
| 837 main() { Enum e = Enum.A; }"""); |
| 838 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 839 compiler.resolver.resolve(mainElement); |
| 840 Expect.equals(0, compiler.warnings.length, |
| 841 'Unexpected warnings: ${compiler.warnings}'); |
| 842 Expect.equals(0, compiler.errors.length, |
| 843 'Unexpected errors: ${compiler.errors}'); |
| 844 }, enableEnums: true), |
| 845 MockCompiler.create((MockCompiler compiler) { |
| 846 compiler.parseScript("""enum Enum { A } |
| 847 main() { Enum e = Enum.B; }"""); |
| 848 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 849 compiler.resolver.resolve(mainElement); |
| 850 Expect.equals(1, compiler.warnings.length, |
| 851 'Unexpected warnings: ${compiler.warnings}'); |
| 852 Expect.equals(MessageKind.MEMBER_NOT_FOUND, |
| 853 compiler.warnings[0].message.kind); |
| 854 Expect.equals(0, compiler.errors.length, |
| 855 'Unexpected errors: ${compiler.errors}'); |
| 856 }, enableEnums: true), |
| 857 MockCompiler.create((MockCompiler compiler) { |
| 858 compiler.parseScript("""enum Enum { A } |
| 859 main() { List values = Enum.values; }"""); |
| 860 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 861 compiler.resolver.resolve(mainElement); |
| 862 Expect.equals(0, compiler.warnings.length, |
| 863 'Unexpected warnings: ${compiler.warnings}'); |
| 864 Expect.equals(0, compiler.errors.length, |
| 865 'Unexpected errors: ${compiler.errors}'); |
| 866 }, enableEnums: true), |
| 867 ]); |
| 868 } |
| 869 |
| 809 Future testInitializers() { | 870 Future testInitializers() { |
| 810 return Future.forEach([ | 871 return Future.forEach([ |
| 811 () { | 872 () { |
| 812 String script = | 873 String script = |
| 813 """class A { | 874 """class A { |
| 814 int foo; int bar; | 875 int foo; int bar; |
| 815 A() : this.foo = 1, bar = 2; | 876 A() : this.foo = 1, bar = 2; |
| 816 }"""; | 877 }"""; |
| 817 return resolveConstructor(script, "A a = new A();", "A", "", 2); | 878 return resolveConstructor(script, "A a = new A();", "A", "", 2); |
| 818 }, | 879 }, |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 }"""; | 1125 }"""; |
| 1065 asyncTest(() => compileScript(script2).then((compiler) { | 1126 asyncTest(() => compileScript(script2).then((compiler) { |
| 1066 expect(compiler, | 1127 expect(compiler, |
| 1067 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1128 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 1068 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1129 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1069 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1130 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1070 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1131 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 1071 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1132 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 1072 })); | 1133 })); |
| 1073 } | 1134 } |
| OLD | NEW |