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

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

Issue 698563005: Support parsing of enums in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add unparser test. 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
Index: tests/compiler/dart2js/unparser2_test.dart
diff --git a/tests/compiler/dart2js/unparser2_test.dart b/tests/compiler/dart2js/unparser2_test.dart
index bbf3e3de93494c52b2e184e263081ca717cbff1f..ad35e2ad60ef8fd9d635bbb7cb5cfb15f9bcbfe3 100644
--- a/tests/compiler/dart2js/unparser2_test.dart
+++ b/tests/compiler/dart2js/unparser2_test.dart
@@ -25,6 +25,11 @@ main() {
testClass1Field1Method();
testClass1Field2Method();
testClassDefTypeParam();
+ testEnumDef();
+ testEnum1Value();
+ testEnum2Value();
+ testEnum3Value();
+ testEnum3CommaValue();
}
testClassDef() {
@@ -51,10 +56,34 @@ testClassDefTypeParam() {
compareCode('class T<X>{}');
}
-void compareCode(String code) {
- Expect.equals(code, doUnparse(code));
+testEnumDef() {
+ compareCode('enum T {}');
}
+testEnum1Value() {
+ compareCode('enum T {A}');
+}
+
+testEnum2Value() {
+ compareCode('enum T {A,B}');
+}
+
+testEnum3Value() {
+ compareCode('enum T {A,B,C}');
+}
+
+testEnum3CommaValue() {
+ compareCode('enum T {A,B,C,}', expectedResult: 'enum T {A,B,C}');
+}
+
+void compareCode(String code, {String expectedResult}) {
+ if (expectedResult == null) {
+ expectedResult = code;
+ }
+ Expect.equals(expectedResult, doUnparse(code));
+}
+
+
String doUnparse(String source) {
MessageCollector diagnosticListener = new MessageCollector();
Script script = new Script(null, null, null);

Powered by Google App Engine
This is Rietveld 408576698