Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: tests/compiler/dart2js/resolver_test.dart

Issue 710343002: Check enums in switch cases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
810 Future testEnumDeclaration() { 810 Future testEnumDeclaration() {
811 final MAIN = "main"; 811 final MAIN = "main";
812 return Future.wait([ 812 return Future.wait([
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(1, compiler.errors.length,
821 'Unexpected errors: ${compiler.errors}'); 821 'Unexpected errors: ${compiler.errors}');
822 }, enableEnums: true), 822 }, enableEnums: true),
823 823
824 MockCompiler.create((MockCompiler compiler) {
825 compiler.parseScript("""enum Enum {}
826 main() { Enum e = Enum.A; }""");
827 FunctionElement mainElement = compiler.mainApp.find(MAIN);
828 compiler.resolver.resolve(mainElement);
829 Expect.equals(1, compiler.warnings.length,
830 'Unexpected warnings: ${compiler.warnings}');
831 Expect.equals(MessageKind.MEMBER_NOT_FOUND,
832 compiler.warnings[0].message.kind);
833 Expect.equals(0, compiler.errors.length,
834 'Unexpected errors: ${compiler.errors}');
835 }, enableEnums: true),
836
837 MockCompiler.create((MockCompiler compiler) { 824 MockCompiler.create((MockCompiler compiler) {
838 compiler.parseScript("""enum Enum { A } 825 compiler.parseScript("""enum Enum { A }
839 main() { Enum e = Enum.A; }"""); 826 main() { Enum e = Enum.A; }""");
840 FunctionElement mainElement = compiler.mainApp.find(MAIN); 827 FunctionElement mainElement = compiler.mainApp.find(MAIN);
841 compiler.resolver.resolve(mainElement); 828 compiler.resolver.resolve(mainElement);
842 Expect.equals(0, compiler.warnings.length, 829 Expect.equals(0, compiler.warnings.length,
843 'Unexpected warnings: ${compiler.warnings}'); 830 'Unexpected warnings: ${compiler.warnings}');
844 Expect.equals(0, compiler.errors.length, 831 Expect.equals(0, compiler.errors.length,
845 'Unexpected errors: ${compiler.errors}'); 832 'Unexpected errors: ${compiler.errors}');
846 }, enableEnums: true), 833 }, enableEnums: true),
(...skipping 16 matching lines...) Expand all
863 main() { List values = Enum.values; }"""); 850 main() { List values = Enum.values; }""");
864 FunctionElement mainElement = compiler.mainApp.find(MAIN); 851 FunctionElement mainElement = compiler.mainApp.find(MAIN);
865 compiler.resolver.resolve(mainElement); 852 compiler.resolver.resolve(mainElement);
866 Expect.equals(0, compiler.warnings.length, 853 Expect.equals(0, compiler.warnings.length,
867 'Unexpected warnings: ${compiler.warnings}'); 854 'Unexpected warnings: ${compiler.warnings}');
868 Expect.equals(0, compiler.errors.length, 855 Expect.equals(0, compiler.errors.length,
869 'Unexpected errors: ${compiler.errors}'); 856 'Unexpected errors: ${compiler.errors}');
870 }, enableEnums: true), 857 }, enableEnums: true),
871 858
872 MockCompiler.create((MockCompiler compiler) { 859 MockCompiler.create((MockCompiler compiler) {
873 compiler.parseScript("""enum Enum {} 860 compiler.parseScript("""enum Enum { A }
874 main() { new Enum(0, ''); }"""); 861 main() { new Enum(0, ''); }""");
875 FunctionElement mainElement = compiler.mainApp.find(MAIN); 862 FunctionElement mainElement = compiler.mainApp.find(MAIN);
876 compiler.resolver.resolve(mainElement); 863 compiler.resolver.resolve(mainElement);
877 Expect.equals(0, compiler.warnings.length, 864 Expect.equals(0, compiler.warnings.length,
878 'Unexpected warnings: ${compiler.warnings}'); 865 'Unexpected warnings: ${compiler.warnings}');
879 Expect.equals(1, compiler.errors.length, 866 Expect.equals(1, compiler.errors.length,
880 'Unexpected errors: ${compiler.errors}'); 867 'Unexpected errors: ${compiler.errors}');
881 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, 868 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
882 compiler.errors[0].message.kind); 869 compiler.errors[0].message.kind);
883 }, enableEnums: true), 870 }, enableEnums: true),
884 871
885 MockCompiler.create((MockCompiler compiler) { 872 MockCompiler.create((MockCompiler compiler) {
886 compiler.parseScript("""enum Enum {} 873 compiler.parseScript("""enum Enum { A }
887 main() { const Enum(0, ''); }"""); 874 main() { const Enum(0, ''); }""");
888 FunctionElement mainElement = compiler.mainApp.find(MAIN); 875 FunctionElement mainElement = compiler.mainApp.find(MAIN);
889 compiler.resolver.resolve(mainElement); 876 compiler.resolver.resolve(mainElement);
890 Expect.equals(0, compiler.warnings.length, 877 Expect.equals(0, compiler.warnings.length,
891 'Unexpected warnings: ${compiler.warnings}'); 878 'Unexpected warnings: ${compiler.warnings}');
892 Expect.equals(1, compiler.errors.length, 879 Expect.equals(1, compiler.errors.length,
893 'Unexpected errors: ${compiler.errors}'); 880 'Unexpected errors: ${compiler.errors}');
894 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, 881 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
895 compiler.errors[0].message.kind); 882 compiler.errors[0].message.kind);
896 }, enableEnums: true), 883 }, enableEnums: true),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 }"""; 1142 }""";
1156 asyncTest(() => compileScript(script2).then((compiler) { 1143 asyncTest(() => compileScript(script2).then((compiler) {
1157 expect(compiler, 1144 expect(compiler,
1158 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], 1145 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS],
1159 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 1146 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
1160 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 1147 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
1161 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, 1148 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
1162 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); 1149 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]);
1163 })); 1150 }));
1164 } 1151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698