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

Unified Diff: tests/language_2/class_literal_test.dart

Issue 2999733002: Migrate test block 47 and downstream dependencies to Dart 2.0. (Closed)
Patch Set: Whitespace Created 3 years, 4 months 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/language_2/class_literal_test.dart
diff --git a/tests/language_2/class_literal_test.dart b/tests/language_2/class_literal_test.dart
index 8ce3560b0ef215b2b8fcf339b5d846004222975d..b532c297ff6d904d82c5ce63ccab07606aa760f2 100644
--- a/tests/language_2/class_literal_test.dart
+++ b/tests/language_2/class_literal_test.dart
@@ -18,39 +18,50 @@ main() {
// Verify references to a class literal are allowed.
Class;
+ var x = Class;
foo(Class);
Expect.isFalse(Class == null);
- dynamic x = Class;
-
- // Verify that dereferencing a class literal is a runtime error.
- Expect.throws(() { x(); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x[0]; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { var y = x[0]; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { var y = x[0].field; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { var y = x[0].method(); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { foo(x()); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { foo(x[0]); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { foo(x[0].field); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { foo(x[0].method()); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x[0] = 91; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x++; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { ++x; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x[0] += 3; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { ++x[0]; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x[0]++; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x.method(); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x.field; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { var y = x.method(); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { var y = x.field; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { foo(x.method()); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { foo(x.field); }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x / 3; }, (e) => e is NoSuchMethodError);
- Expect.throws(() { x += 3; }, (e) => e is NoSuchMethodError);
+
+ // Verify that dereferencing a class literal is a compile-time error.
+ // TODO(jcollins-g): several tests here seem to depend on being in their
+ // own namespace, but others do not. More tests seem to also depend on
+ // the complexities of Expect.throws() for other, unknown reasons to trigger
+ // bugs in the VM as of this writing.
+ //
+ // Remove the legacy Expect.throws and namespaces around statements that don't
+ // need it after a careful examination of each case.
+ Expect.throws(() { Class(); }, (e) => e is NoSuchMethodError); //# 01: compile-time error
+ Expect.throws(() { Class[0]; }, (e) => e is NoSuchMethodError); //# 02: compile-time error
+ Expect.throws(() { var x = Class();}, (e) => e is NoSuchMethodError); //# 03: compile-time error
+ Expect.throws(() { var x = Class[0]; }, (e) => e is NoSuchMethodError); //# 04: compile-time error
+ Expect.throws(() { var x = Class[0].field; }, (e) => e is NoSuchMethodError); //# 05: compile-time error
+ Expect.throws(() { var x = Class[0].method(); }, (e) => e is NoSuchMethodError); //# 06: compile-time error
+ Expect.throws(() { foo(Class()); }, (e) => e is NoSuchMethodError); //# 07: compile-time error
+ Expect.throws(() { foo(Class[0]); }, (e) => e is NoSuchMethodError); //# 08: compile-time error
+ Expect.throws(() { foo(Class[0].field); }, (e) => e is NoSuchMethodError); //# 09: compile-time error
+ Expect.throws(() { foo(Class[0].method()); }, (e) => e is NoSuchMethodError); //# 10: compile-time error
+ Expect.throws(() { Class[0] = 91; }, (e) => e is NoSuchMethodError); //# 11: compile-time error
+ Expect.throws(() { Class++; }, (e) => e is NoSuchMethodError); //# 12: compile-time error
+ Expect.throws(() { ++Class; }, (e) => e is NoSuchMethodError); //# 13: compile-time error
+ Expect.throws(() { Class[0] += 3; }, (e) => e is NoSuchMethodError); //# 14: compile-time error
+ Expect.throws(() { ++Class[0]; }, (e) => e is NoSuchMethodError); //# 15: compile-time error
+ Expect.throws(() { Class[0]++; }, (e) => e is NoSuchMethodError); //# 16: compile-time error
+ Expect.throws(() { Class.method(); }, (e) => e is NoSuchMethodError); //# 17: compile-time error
+ Expect.throws(() { Class.field; }, (e) => e is NoSuchMethodError); //# 18: compile-time error
+ Expect.throws(() { var x = Class.method(); }, (e) => e is NoSuchMethodError); //# 19: compile-time error
+ Expect.throws(() { var x = Class.field; }, (e) => e is NoSuchMethodError); //# 20: compile-time error
+ Expect.throws(() { foo(Class.method()); }, (e) => e is NoSuchMethodError); //# 21: compile-time error
+ Expect.throws(() { foo(Class.field); }, (e) => e is NoSuchMethodError); //# 22: compile-time error
+ Expect.throws(() { Class / 3; }, (e) => e is NoSuchMethodError); //# 23: compile-time error
+ Expect.throws(() { Class += 3; }, (e) => e is NoSuchMethodError); //# 24: compile-time error
// Verify that a class literal isn't a string literal.
Expect.notEquals(Class, "Class");
// Verify toString() works for class literals.
Expect.isTrue((Class).toString() is String);
- Expect.isTrue(x.toString() is String);
+ var y = Class;
+ Expect.isTrue(y.toString() is String);
+
+ Expect.throws(() { Class.toString(); }, (e) => e is NoSuchMethodError); //# 25: compile-time error
}

Powered by Google App Engine
This is Rietveld 408576698