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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 // Test class literal expressions. 7 // Test class literal expressions.
8 8
9 class Class { 9 class Class {
10 static fisk() => 42; 10 static fisk() => 42;
11 } 11 }
12 12
13 foo(x) {} 13 foo(x) {}
14 14
15 main() { 15 main() {
16 Expect.equals(42, Class.fisk()); 16 Expect.equals(42, Class.fisk());
17 Expect.equals(null, foo(Class.fisk())); 17 Expect.equals(null, foo(Class.fisk()));
18 18
19 // Verify references to a class literal are allowed. 19 // Verify references to a class literal are allowed.
20 Class; 20 Class;
21 var x = Class;
21 foo(Class); 22 foo(Class);
22 Expect.isFalse(Class == null); 23 Expect.isFalse(Class == null);
23 dynamic x = Class;
24 24
25 // Verify that dereferencing a class literal is a runtime error. 25 // Verify that dereferencing a class literal is a compile-time error.
26 Expect.throws(() { x(); }, (e) => e is NoSuchMethodError); 26 // TODO(jcollins-g): several tests here seem to depend on being in their
27 Expect.throws(() { x[0]; }, (e) => e is NoSuchMethodError); 27 // own namespace, but others do not. More tests seem to also depend on
28 Expect.throws(() { var y = x[0]; }, (e) => e is NoSuchMethodError); 28 // the complexities of Expect.throws() for other, unknown reasons to trigger
29 Expect.throws(() { var y = x[0].field; }, (e) => e is NoSuchMethodError); 29 // bugs in the VM as of this writing.
30 Expect.throws(() { var y = x[0].method(); }, (e) => e is NoSuchMethodError); 30 //
31 Expect.throws(() { foo(x()); }, (e) => e is NoSuchMethodError); 31 // Remove the legacy Expect.throws and namespaces around statements that don't
32 Expect.throws(() { foo(x[0]); }, (e) => e is NoSuchMethodError); 32 // need it after a careful examination of each case.
33 Expect.throws(() { foo(x[0].field); }, (e) => e is NoSuchMethodError); 33 Expect.throws(() { Class(); }, (e) => e is NoSuchMethodError); //# 01: compile -time error
34 Expect.throws(() { foo(x[0].method()); }, (e) => e is NoSuchMethodError); 34 Expect.throws(() { Class[0]; }, (e) => e is NoSuchMethodError); //# 02: compil e-time error
35 Expect.throws(() { x[0] = 91; }, (e) => e is NoSuchMethodError); 35 Expect.throws(() { var x = Class();}, (e) => e is NoSuchMethodError); //# 03: compile-time error
36 Expect.throws(() { x++; }, (e) => e is NoSuchMethodError); 36 Expect.throws(() { var x = Class[0]; }, (e) => e is NoSuchMethodError); //# 04 : compile-time error
37 Expect.throws(() { ++x; }, (e) => e is NoSuchMethodError); 37 Expect.throws(() { var x = Class[0].field; }, (e) => e is NoSuchMethodError); //# 05: compile-time error
38 Expect.throws(() { x[0] += 3; }, (e) => e is NoSuchMethodError); 38 Expect.throws(() { var x = Class[0].method(); }, (e) => e is NoSuchMethodError ); //# 06: compile-time error
39 Expect.throws(() { ++x[0]; }, (e) => e is NoSuchMethodError); 39 Expect.throws(() { foo(Class()); }, (e) => e is NoSuchMethodError); //# 07: co mpile-time error
40 Expect.throws(() { x[0]++; }, (e) => e is NoSuchMethodError); 40 Expect.throws(() { foo(Class[0]); }, (e) => e is NoSuchMethodError); //# 08: c ompile-time error
41 Expect.throws(() { x.method(); }, (e) => e is NoSuchMethodError); 41 Expect.throws(() { foo(Class[0].field); }, (e) => e is NoSuchMethodError); //# 09: compile-time error
42 Expect.throws(() { x.field; }, (e) => e is NoSuchMethodError); 42 Expect.throws(() { foo(Class[0].method()); }, (e) => e is NoSuchMethodError); //# 10: compile-time error
43 Expect.throws(() { var y = x.method(); }, (e) => e is NoSuchMethodError); 43 Expect.throws(() { Class[0] = 91; }, (e) => e is NoSuchMethodError); //# 11: c ompile-time error
44 Expect.throws(() { var y = x.field; }, (e) => e is NoSuchMethodError); 44 Expect.throws(() { Class++; }, (e) => e is NoSuchMethodError); //# 12: compile -time error
45 Expect.throws(() { foo(x.method()); }, (e) => e is NoSuchMethodError); 45 Expect.throws(() { ++Class; }, (e) => e is NoSuchMethodError); //# 13: compile -time error
46 Expect.throws(() { foo(x.field); }, (e) => e is NoSuchMethodError); 46 Expect.throws(() { Class[0] += 3; }, (e) => e is NoSuchMethodError); //# 14: c ompile-time error
47 Expect.throws(() { x / 3; }, (e) => e is NoSuchMethodError); 47 Expect.throws(() { ++Class[0]; }, (e) => e is NoSuchMethodError); //# 15: comp ile-time error
48 Expect.throws(() { x += 3; }, (e) => e is NoSuchMethodError); 48 Expect.throws(() { Class[0]++; }, (e) => e is NoSuchMethodError); //# 16: comp ile-time error
49 Expect.throws(() { Class.method(); }, (e) => e is NoSuchMethodError); //# 17: compile-time error
50 Expect.throws(() { Class.field; }, (e) => e is NoSuchMethodError); //# 18: com pile-time error
51 Expect.throws(() { var x = Class.method(); }, (e) => e is NoSuchMethodError); //# 19: compile-time error
52 Expect.throws(() { var x = Class.field; }, (e) => e is NoSuchMethodError); //# 20: compile-time error
53 Expect.throws(() { foo(Class.method()); }, (e) => e is NoSuchMethodError); //# 21: compile-time error
54 Expect.throws(() { foo(Class.field); }, (e) => e is NoSuchMethodError); //# 22 : compile-time error
55 Expect.throws(() { Class / 3; }, (e) => e is NoSuchMethodError); //# 23: compi le-time error
56 Expect.throws(() { Class += 3; }, (e) => e is NoSuchMethodError); //# 24: comp ile-time error
49 57
50 // Verify that a class literal isn't a string literal. 58 // Verify that a class literal isn't a string literal.
51 Expect.notEquals(Class, "Class"); 59 Expect.notEquals(Class, "Class");
52 60
53 // Verify toString() works for class literals. 61 // Verify toString() works for class literals.
54 Expect.isTrue((Class).toString() is String); 62 Expect.isTrue((Class).toString() is String);
55 Expect.isTrue(x.toString() is String); 63 var y = Class;
64 Expect.isTrue(y.toString() is String);
65
66 Expect.throws(() { Class.toString(); }, (e) => e is NoSuchMethodError); //# 25 : compile-time error
56 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698