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

Unified Diff: tests/compiler/dart2js/resolver_test.dart

Issue 709603003: Add compile-time errors for enums. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/warnings.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/resolver_test.dart
diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart
index 18aa61025ce27aa87100d8f326cbfc4e8ab79d82..bc88820da25ed8b3fe490a95ce3b69f4b6d73cfd 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -820,6 +820,7 @@ Future testEnumDeclaration() {
Expect.equals(0, compiler.errors.length,
'Unexpected errors: ${compiler.errors}');
}, enableEnums: true),
+
MockCompiler.create((MockCompiler compiler) {
compiler.parseScript("""enum Enum {}
main() { Enum e = Enum.A; }""");
@@ -832,6 +833,7 @@ Future testEnumDeclaration() {
Expect.equals(0, compiler.errors.length,
'Unexpected errors: ${compiler.errors}');
}, enableEnums: true),
+
MockCompiler.create((MockCompiler compiler) {
compiler.parseScript("""enum Enum { A }
main() { Enum e = Enum.A; }""");
@@ -842,6 +844,7 @@ Future testEnumDeclaration() {
Expect.equals(0, compiler.errors.length,
'Unexpected errors: ${compiler.errors}');
}, enableEnums: true),
+
MockCompiler.create((MockCompiler compiler) {
compiler.parseScript("""enum Enum { A }
main() { Enum e = Enum.B; }""");
@@ -854,6 +857,7 @@ Future testEnumDeclaration() {
Expect.equals(0, compiler.errors.length,
'Unexpected errors: ${compiler.errors}');
}, enableEnums: true),
+
MockCompiler.create((MockCompiler compiler) {
compiler.parseScript("""enum Enum { A }
main() { List values = Enum.values; }""");
@@ -864,6 +868,32 @@ Future testEnumDeclaration() {
Expect.equals(0, compiler.errors.length,
'Unexpected errors: ${compiler.errors}');
}, enableEnums: true),
+
+ MockCompiler.create((MockCompiler compiler) {
+ compiler.parseScript("""enum Enum {}
+ main() { new Enum(0, ''); }""");
+ FunctionElement mainElement = compiler.mainApp.find(MAIN);
+ compiler.resolver.resolve(mainElement);
+ Expect.equals(0, compiler.warnings.length,
+ 'Unexpected warnings: ${compiler.warnings}');
+ Expect.equals(1, compiler.errors.length,
+ 'Unexpected errors: ${compiler.errors}');
+ Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
+ compiler.errors[0].message.kind);
+ }, enableEnums: true),
+
+ MockCompiler.create((MockCompiler compiler) {
+ compiler.parseScript("""enum Enum {}
+ main() { const Enum(0, ''); }""");
+ FunctionElement mainElement = compiler.mainApp.find(MAIN);
+ compiler.resolver.resolve(mainElement);
+ Expect.equals(0, compiler.warnings.length,
+ 'Unexpected warnings: ${compiler.warnings}');
+ Expect.equals(1, compiler.errors.length,
+ 'Unexpected errors: ${compiler.errors}');
+ Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
+ compiler.errors[0].message.kind);
+ }, enableEnums: true),
]);
}
« no previous file with comments | « pkg/compiler/lib/src/warnings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698