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

Side by Side Diff: tests/language_2/class_literal_test.dart

Issue 2997723002: Revert "Migrating a block of dart 2:" (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 // Test class literal expressions.
8
9 class Class {
10 static fisk() => 42;
11 }
12
13 foo(x) {}
14
15 main() {
16 Expect.equals(42, Class.fisk());
17 Expect.equals(null, foo(Class.fisk()));
18
19 // Verify references to a class literal are allowed.
20 Class;
21 foo(Class);
22 Expect.isFalse(Class == null);
23 dynamic x = Class;
24
25 // Verify that dereferencing a class literal is a runtime error.
26 Expect.throws(() { x(); }, (e) => e is NoSuchMethodError);
27 Expect.throws(() { x[0]; }, (e) => e is NoSuchMethodError);
28 Expect.throws(() { var y = x[0]; }, (e) => e is NoSuchMethodError);
29 Expect.throws(() { var y = x[0].field; }, (e) => e is NoSuchMethodError);
30 Expect.throws(() { var y = x[0].method(); }, (e) => e is NoSuchMethodError);
31 Expect.throws(() { foo(x()); }, (e) => e is NoSuchMethodError);
32 Expect.throws(() { foo(x[0]); }, (e) => e is NoSuchMethodError);
33 Expect.throws(() { foo(x[0].field); }, (e) => e is NoSuchMethodError);
34 Expect.throws(() { foo(x[0].method()); }, (e) => e is NoSuchMethodError);
35 Expect.throws(() { x[0] = 91; }, (e) => e is NoSuchMethodError);
36 Expect.throws(() { x++; }, (e) => e is NoSuchMethodError);
37 Expect.throws(() { ++x; }, (e) => e is NoSuchMethodError);
38 Expect.throws(() { x[0] += 3; }, (e) => e is NoSuchMethodError);
39 Expect.throws(() { ++x[0]; }, (e) => e is NoSuchMethodError);
40 Expect.throws(() { x[0]++; }, (e) => e is NoSuchMethodError);
41 Expect.throws(() { x.method(); }, (e) => e is NoSuchMethodError);
42 Expect.throws(() { x.field; }, (e) => e is NoSuchMethodError);
43 Expect.throws(() { var y = x.method(); }, (e) => e is NoSuchMethodError);
44 Expect.throws(() { var y = x.field; }, (e) => e is NoSuchMethodError);
45 Expect.throws(() { foo(x.method()); }, (e) => e is NoSuchMethodError);
46 Expect.throws(() { foo(x.field); }, (e) => e is NoSuchMethodError);
47 Expect.throws(() { x / 3; }, (e) => e is NoSuchMethodError);
48 Expect.throws(() { x += 3; }, (e) => e is NoSuchMethodError);
49
50 // Verify that a class literal isn't a string literal.
51 Expect.notEquals(Class, "Class");
52
53 // Verify toString() works for class literals.
54 Expect.isTrue((Class).toString() is String);
55 Expect.isTrue(x.toString() is String);
56 }
OLDNEW
« 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