| 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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 return Future.wait([ | 810 return Future.wait([ |
| 811 MockCompiler.create((MockCompiler compiler) { | 811 MockCompiler.create((MockCompiler compiler) { |
| 812 compiler.parseScript("""enum Enum {} | 812 compiler.parseScript("""enum Enum {} |
| 813 main() { Enum e; }"""); | 813 main() { Enum e; }"""); |
| 814 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 814 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 815 compiler.resolver.resolve(mainElement); | 815 compiler.resolver.resolve(mainElement); |
| 816 Expect.equals(0, compiler.warnings.length, | 816 Expect.equals(0, compiler.warnings.length, |
| 817 'Unexpected warnings: ${compiler.warnings}'); | 817 'Unexpected warnings: ${compiler.warnings}'); |
| 818 Expect.equals(1, compiler.errors.length, | 818 Expect.equals(1, compiler.errors.length, |
| 819 'Unexpected errors: ${compiler.errors}'); | 819 'Unexpected errors: ${compiler.errors}'); |
| 820 }, enableEnums: true), | 820 }), |
| 821 | 821 |
| 822 MockCompiler.create((MockCompiler compiler) { | 822 MockCompiler.create((MockCompiler compiler) { |
| 823 compiler.parseScript("""enum Enum { A } | 823 compiler.parseScript("""enum Enum { A } |
| 824 main() { Enum e = Enum.A; }"""); | 824 main() { Enum e = Enum.A; }"""); |
| 825 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 825 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 826 compiler.resolver.resolve(mainElement); | 826 compiler.resolver.resolve(mainElement); |
| 827 Expect.equals(0, compiler.warnings.length, | 827 Expect.equals(0, compiler.warnings.length, |
| 828 'Unexpected warnings: ${compiler.warnings}'); | 828 'Unexpected warnings: ${compiler.warnings}'); |
| 829 Expect.equals(0, compiler.errors.length, | 829 Expect.equals(0, compiler.errors.length, |
| 830 'Unexpected errors: ${compiler.errors}'); | 830 'Unexpected errors: ${compiler.errors}'); |
| 831 }, enableEnums: true), | 831 }), |
| 832 | 832 |
| 833 MockCompiler.create((MockCompiler compiler) { | 833 MockCompiler.create((MockCompiler compiler) { |
| 834 compiler.parseScript("""enum Enum { A } | 834 compiler.parseScript("""enum Enum { A } |
| 835 main() { Enum e = Enum.B; }"""); | 835 main() { Enum e = Enum.B; }"""); |
| 836 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 836 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 837 compiler.resolver.resolve(mainElement); | 837 compiler.resolver.resolve(mainElement); |
| 838 Expect.equals(1, compiler.warnings.length, | 838 Expect.equals(1, compiler.warnings.length, |
| 839 'Unexpected warnings: ${compiler.warnings}'); | 839 'Unexpected warnings: ${compiler.warnings}'); |
| 840 Expect.equals(MessageKind.MEMBER_NOT_FOUND, | 840 Expect.equals(MessageKind.MEMBER_NOT_FOUND, |
| 841 compiler.warnings[0].message.kind); | 841 compiler.warnings[0].message.kind); |
| 842 Expect.equals(0, compiler.errors.length, | 842 Expect.equals(0, compiler.errors.length, |
| 843 'Unexpected errors: ${compiler.errors}'); | 843 'Unexpected errors: ${compiler.errors}'); |
| 844 }, enableEnums: true), | 844 }), |
| 845 | 845 |
| 846 MockCompiler.create((MockCompiler compiler) { | 846 MockCompiler.create((MockCompiler compiler) { |
| 847 compiler.parseScript("""enum Enum { A } | 847 compiler.parseScript("""enum Enum { A } |
| 848 main() { List values = Enum.values; }"""); | 848 main() { List values = Enum.values; }"""); |
| 849 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 849 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 850 compiler.resolver.resolve(mainElement); | 850 compiler.resolver.resolve(mainElement); |
| 851 Expect.equals(0, compiler.warnings.length, | 851 Expect.equals(0, compiler.warnings.length, |
| 852 'Unexpected warnings: ${compiler.warnings}'); | 852 'Unexpected warnings: ${compiler.warnings}'); |
| 853 Expect.equals(0, compiler.errors.length, | 853 Expect.equals(0, compiler.errors.length, |
| 854 'Unexpected errors: ${compiler.errors}'); | 854 'Unexpected errors: ${compiler.errors}'); |
| 855 }, enableEnums: true), | 855 }), |
| 856 | 856 |
| 857 MockCompiler.create((MockCompiler compiler) { | 857 MockCompiler.create((MockCompiler compiler) { |
| 858 compiler.parseScript("""enum Enum { A } | 858 compiler.parseScript("""enum Enum { A } |
| 859 main() { new Enum(0, ''); }"""); | 859 main() { new Enum(0, ''); }"""); |
| 860 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 860 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 861 compiler.resolver.resolve(mainElement); | 861 compiler.resolver.resolve(mainElement); |
| 862 Expect.equals(0, compiler.warnings.length, | 862 Expect.equals(0, compiler.warnings.length, |
| 863 'Unexpected warnings: ${compiler.warnings}'); | 863 'Unexpected warnings: ${compiler.warnings}'); |
| 864 Expect.equals(1, compiler.errors.length, | 864 Expect.equals(1, compiler.errors.length, |
| 865 'Unexpected errors: ${compiler.errors}'); | 865 'Unexpected errors: ${compiler.errors}'); |
| 866 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, | 866 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, |
| 867 compiler.errors[0].message.kind); | 867 compiler.errors[0].message.kind); |
| 868 }, enableEnums: true), | 868 }), |
| 869 | 869 |
| 870 MockCompiler.create((MockCompiler compiler) { | 870 MockCompiler.create((MockCompiler compiler) { |
| 871 compiler.parseScript("""enum Enum { A } | 871 compiler.parseScript("""enum Enum { A } |
| 872 main() { const Enum(0, ''); }"""); | 872 main() { const Enum(0, ''); }"""); |
| 873 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 873 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 874 compiler.resolver.resolve(mainElement); | 874 compiler.resolver.resolve(mainElement); |
| 875 Expect.equals(0, compiler.warnings.length, | 875 Expect.equals(0, compiler.warnings.length, |
| 876 'Unexpected warnings: ${compiler.warnings}'); | 876 'Unexpected warnings: ${compiler.warnings}'); |
| 877 Expect.equals(1, compiler.errors.length, | 877 Expect.equals(1, compiler.errors.length, |
| 878 'Unexpected errors: ${compiler.errors}'); | 878 'Unexpected errors: ${compiler.errors}'); |
| 879 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, | 879 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, |
| 880 compiler.errors[0].message.kind); | 880 compiler.errors[0].message.kind); |
| 881 }, enableEnums: true), | 881 }), |
| 882 ]); | 882 ]); |
| 883 } | 883 } |
| 884 | 884 |
| 885 Future testInitializers() { | 885 Future testInitializers() { |
| 886 return Future.forEach([ | 886 return Future.forEach([ |
| 887 () { | 887 () { |
| 888 String script = | 888 String script = |
| 889 """class A { | 889 """class A { |
| 890 int foo; int bar; | 890 int foo; int bar; |
| 891 A() : this.foo = 1, bar = 2; | 891 A() : this.foo = 1, bar = 2; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 }"""; | 1140 }"""; |
| 1141 asyncTest(() => compileScript(script2).then((compiler) { | 1141 asyncTest(() => compileScript(script2).then((compiler) { |
| 1142 expect(compiler, | 1142 expect(compiler, |
| 1143 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1143 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 1144 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1144 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1145 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1145 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1146 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1146 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 1147 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1147 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 1148 })); | 1148 })); |
| 1149 } | 1149 } |
| OLD | NEW |