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

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

Issue 707463003: Support enums in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. 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 | « tests/compiler/dart2js/mock_compiler.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 5c02c5b6ae87b239af6ddc91f93003dde7398b2b..18aa61025ce27aa87100d8f326cbfc4e8ab79d82 100644
--- a/tests/compiler/dart2js/resolver_test.dart
+++ b/tests/compiler/dart2js/resolver_test.dart
@@ -76,6 +76,7 @@ main() {
testNewExpression,
testTopLevelFields,
testClassHierarchy,
+ testEnumDeclaration,
testInitializers,
testThis,
testSuperCalls,
@@ -806,6 +807,66 @@ Future testClassHierarchy() {
]);
}
+Future testEnumDeclaration() {
+ final MAIN = "main";
+ return Future.wait([
+ MockCompiler.create((MockCompiler compiler) {
+ compiler.parseScript("""enum Enum {}
+ main() { Enum e; }""");
+ FunctionElement mainElement = compiler.mainApp.find(MAIN);
+ compiler.resolver.resolve(mainElement);
+ Expect.equals(0, compiler.warnings.length,
+ 'Unexpected warnings: ${compiler.warnings}');
+ 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; }""");
+ FunctionElement mainElement = compiler.mainApp.find(MAIN);
+ compiler.resolver.resolve(mainElement);
+ Expect.equals(1, compiler.warnings.length,
+ 'Unexpected warnings: ${compiler.warnings}');
+ Expect.equals(MessageKind.MEMBER_NOT_FOUND,
+ compiler.warnings[0].message.kind);
+ 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; }""");
+ FunctionElement mainElement = compiler.mainApp.find(MAIN);
+ compiler.resolver.resolve(mainElement);
+ Expect.equals(0, compiler.warnings.length,
+ 'Unexpected warnings: ${compiler.warnings}');
+ 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; }""");
+ FunctionElement mainElement = compiler.mainApp.find(MAIN);
+ compiler.resolver.resolve(mainElement);
+ Expect.equals(1, compiler.warnings.length,
+ 'Unexpected warnings: ${compiler.warnings}');
+ Expect.equals(MessageKind.MEMBER_NOT_FOUND,
+ compiler.warnings[0].message.kind);
+ 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; }""");
+ FunctionElement mainElement = compiler.mainApp.find(MAIN);
+ compiler.resolver.resolve(mainElement);
+ Expect.equals(0, compiler.warnings.length,
+ 'Unexpected warnings: ${compiler.warnings}');
+ Expect.equals(0, compiler.errors.length,
+ 'Unexpected errors: ${compiler.errors}');
+ }, enableEnums: true),
+ ]);
+}
+
Future testInitializers() {
return Future.forEach([
() {
« no previous file with comments | « tests/compiler/dart2js/mock_compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698