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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 MockCompiler.create((MockCompiler compiler) { | 813 MockCompiler.create((MockCompiler compiler) { |
814 compiler.parseScript("""enum Enum {} | 814 compiler.parseScript("""enum Enum {} |
815 main() { Enum e; }"""); | 815 main() { Enum e; }"""); |
816 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 816 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
817 compiler.resolver.resolve(mainElement); | 817 compiler.resolver.resolve(mainElement); |
818 Expect.equals(0, compiler.warnings.length, | 818 Expect.equals(0, compiler.warnings.length, |
819 'Unexpected warnings: ${compiler.warnings}'); | 819 'Unexpected warnings: ${compiler.warnings}'); |
820 Expect.equals(0, compiler.errors.length, | 820 Expect.equals(0, compiler.errors.length, |
821 'Unexpected errors: ${compiler.errors}'); | 821 'Unexpected errors: ${compiler.errors}'); |
822 }, enableEnums: true), | 822 }, enableEnums: true), |
| 823 |
823 MockCompiler.create((MockCompiler compiler) { | 824 MockCompiler.create((MockCompiler compiler) { |
824 compiler.parseScript("""enum Enum {} | 825 compiler.parseScript("""enum Enum {} |
825 main() { Enum e = Enum.A; }"""); | 826 main() { Enum e = Enum.A; }"""); |
826 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 827 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
827 compiler.resolver.resolve(mainElement); | 828 compiler.resolver.resolve(mainElement); |
828 Expect.equals(1, compiler.warnings.length, | 829 Expect.equals(1, compiler.warnings.length, |
829 'Unexpected warnings: ${compiler.warnings}'); | 830 'Unexpected warnings: ${compiler.warnings}'); |
830 Expect.equals(MessageKind.MEMBER_NOT_FOUND, | 831 Expect.equals(MessageKind.MEMBER_NOT_FOUND, |
831 compiler.warnings[0].message.kind); | 832 compiler.warnings[0].message.kind); |
832 Expect.equals(0, compiler.errors.length, | 833 Expect.equals(0, compiler.errors.length, |
833 'Unexpected errors: ${compiler.errors}'); | 834 'Unexpected errors: ${compiler.errors}'); |
834 }, enableEnums: true), | 835 }, enableEnums: true), |
| 836 |
835 MockCompiler.create((MockCompiler compiler) { | 837 MockCompiler.create((MockCompiler compiler) { |
836 compiler.parseScript("""enum Enum { A } | 838 compiler.parseScript("""enum Enum { A } |
837 main() { Enum e = Enum.A; }"""); | 839 main() { Enum e = Enum.A; }"""); |
838 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 840 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
839 compiler.resolver.resolve(mainElement); | 841 compiler.resolver.resolve(mainElement); |
840 Expect.equals(0, compiler.warnings.length, | 842 Expect.equals(0, compiler.warnings.length, |
841 'Unexpected warnings: ${compiler.warnings}'); | 843 'Unexpected warnings: ${compiler.warnings}'); |
842 Expect.equals(0, compiler.errors.length, | 844 Expect.equals(0, compiler.errors.length, |
843 'Unexpected errors: ${compiler.errors}'); | 845 'Unexpected errors: ${compiler.errors}'); |
844 }, enableEnums: true), | 846 }, enableEnums: true), |
| 847 |
845 MockCompiler.create((MockCompiler compiler) { | 848 MockCompiler.create((MockCompiler compiler) { |
846 compiler.parseScript("""enum Enum { A } | 849 compiler.parseScript("""enum Enum { A } |
847 main() { Enum e = Enum.B; }"""); | 850 main() { Enum e = Enum.B; }"""); |
848 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 851 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
849 compiler.resolver.resolve(mainElement); | 852 compiler.resolver.resolve(mainElement); |
850 Expect.equals(1, compiler.warnings.length, | 853 Expect.equals(1, compiler.warnings.length, |
851 'Unexpected warnings: ${compiler.warnings}'); | 854 'Unexpected warnings: ${compiler.warnings}'); |
852 Expect.equals(MessageKind.MEMBER_NOT_FOUND, | 855 Expect.equals(MessageKind.MEMBER_NOT_FOUND, |
853 compiler.warnings[0].message.kind); | 856 compiler.warnings[0].message.kind); |
854 Expect.equals(0, compiler.errors.length, | 857 Expect.equals(0, compiler.errors.length, |
855 'Unexpected errors: ${compiler.errors}'); | 858 'Unexpected errors: ${compiler.errors}'); |
856 }, enableEnums: true), | 859 }, enableEnums: true), |
| 860 |
857 MockCompiler.create((MockCompiler compiler) { | 861 MockCompiler.create((MockCompiler compiler) { |
858 compiler.parseScript("""enum Enum { A } | 862 compiler.parseScript("""enum Enum { A } |
859 main() { List values = Enum.values; }"""); | 863 main() { List values = Enum.values; }"""); |
860 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 864 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
861 compiler.resolver.resolve(mainElement); | 865 compiler.resolver.resolve(mainElement); |
862 Expect.equals(0, compiler.warnings.length, | 866 Expect.equals(0, compiler.warnings.length, |
863 'Unexpected warnings: ${compiler.warnings}'); | 867 'Unexpected warnings: ${compiler.warnings}'); |
864 Expect.equals(0, compiler.errors.length, | 868 Expect.equals(0, compiler.errors.length, |
865 'Unexpected errors: ${compiler.errors}'); | 869 'Unexpected errors: ${compiler.errors}'); |
866 }, enableEnums: true), | 870 }, enableEnums: true), |
| 871 |
| 872 MockCompiler.create((MockCompiler compiler) { |
| 873 compiler.parseScript("""enum Enum {} |
| 874 main() { new Enum(0, ''); }"""); |
| 875 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 876 compiler.resolver.resolve(mainElement); |
| 877 Expect.equals(0, compiler.warnings.length, |
| 878 'Unexpected warnings: ${compiler.warnings}'); |
| 879 Expect.equals(1, compiler.errors.length, |
| 880 'Unexpected errors: ${compiler.errors}'); |
| 881 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, |
| 882 compiler.errors[0].message.kind); |
| 883 }, enableEnums: true), |
| 884 |
| 885 MockCompiler.create((MockCompiler compiler) { |
| 886 compiler.parseScript("""enum Enum {} |
| 887 main() { const Enum(0, ''); }"""); |
| 888 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| 889 compiler.resolver.resolve(mainElement); |
| 890 Expect.equals(0, compiler.warnings.length, |
| 891 'Unexpected warnings: ${compiler.warnings}'); |
| 892 Expect.equals(1, compiler.errors.length, |
| 893 'Unexpected errors: ${compiler.errors}'); |
| 894 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, |
| 895 compiler.errors[0].message.kind); |
| 896 }, enableEnums: true), |
867 ]); | 897 ]); |
868 } | 898 } |
869 | 899 |
870 Future testInitializers() { | 900 Future testInitializers() { |
871 return Future.forEach([ | 901 return Future.forEach([ |
872 () { | 902 () { |
873 String script = | 903 String script = |
874 """class A { | 904 """class A { |
875 int foo; int bar; | 905 int foo; int bar; |
876 A() : this.foo = 1, bar = 2; | 906 A() : this.foo = 1, bar = 2; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 }"""; | 1155 }"""; |
1126 asyncTest(() => compileScript(script2).then((compiler) { | 1156 asyncTest(() => compileScript(script2).then((compiler) { |
1127 expect(compiler, | 1157 expect(compiler, |
1128 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1158 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
1129 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1159 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
1130 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1160 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
1131 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1161 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
1132 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1162 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
1133 })); | 1163 })); |
1134 } | 1164 } |
OLD | NEW |