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

Unified Diff: tests/language_2/class_literal_test.dart

Issue 3001433002: Migrating a block of dart 1 tests to dart 2 (Closed)
Patch Set: Fixed merge conflict characters 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
« no previous file with comments | « tests/language_2/class_literal_static_test.dart ('k') | tests/language_2/class_override_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..8ce3560b0ef215b2b8fcf339b5d846004222975d
--- /dev/null
+++ b/tests/language_2/class_literal_test.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Test class literal expressions.
+
+class Class {
+ static fisk() => 42;
+}
+
+foo(x) {}
+
+main() {
+ Expect.equals(42, Class.fisk());
+ Expect.equals(null, foo(Class.fisk()));
+
+ // Verify references to a class literal are allowed.
+ 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 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);
+}
« no previous file with comments | « tests/language_2/class_literal_static_test.dart ('k') | tests/language_2/class_override_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698