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

Side by Side Diff: tests/language/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 unified diff | Download patch
« no previous file with comments | « tests/language/class_keyword_test.dart ('k') | tests/language/class_override_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var x = Class;
22 foo(Class);
23 Expect.isFalse(Class == null);
24
25 // Verify that dereferencing a class literal is a runtime error.
26 Expect.throws(() { Class(); }, (e) => e is NoSuchMethodError); //# 01: static type warning
27 Expect.throws(() { Class[0]; }, (e) => e is NoSuchMethodError); //# 02: static type warning
28 Expect.throws(() { var x = Class(); }, (e) => e is NoSuchMethodError); //# 03: static type warning
29 Expect.throws(() { var x = Class[0]; }, (e) => e is NoSuchMethodError); //# 04 : static type warning
30 Expect.throws(() { var x = Class[0].field; }, (e) => e is NoSuchMethodError); //# 05: static type warning
31 Expect.throws(() { var x = Class[0].method(); }, (e) => e is NoSuchMethodError ); //# 06: static type warning
32 Expect.throws(() { foo(Class()); }, (e) => e is NoSuchMethodError); //# 07: st atic type warning
33 Expect.throws(() { foo(Class[0]); }, (e) => e is NoSuchMethodError); //# 08: s tatic type warning
34 Expect.throws(() { foo(Class[0].field); }, (e) => e is NoSuchMethodError); //# 09: static type warning
35 Expect.throws(() { foo(Class[0].method()); }, (e) => e is NoSuchMethodError); //# 10: static type warning
36 Expect.throws(() { Class[0] = 91; }, (e) => e is NoSuchMethodError); //# 11: s tatic type warning
37 Expect.throws(() { Class++; }, (e) => e is NoSuchMethodError); //# 12: static type warning
38 Expect.throws(() { ++Class; }, (e) => e is NoSuchMethodError); //# 13: static type warning
39 Expect.throws(() { Class[0] += 3; }, (e) => e is NoSuchMethodError); //# 14: s tatic type warning
40 Expect.throws(() { ++Class[0]; }, (e) => e is NoSuchMethodError); //# 15: stat ic type warning
41 Expect.throws(() { Class[0]++; }, (e) => e is NoSuchMethodError); //# 16: stat ic type warning
42 Expect.throws(() { Class.method(); }, (e) => e is NoSuchMethodError); //# 17: static type warning
43 Expect.throws(() { Class.field; }, (e) => e is NoSuchMethodError); //# 18: sta tic type warning
44 Expect.throws(() { var x = Class.method(); }, (e) => e is NoSuchMethodError); //# 19: static type warning
45 Expect.throws(() { var x = Class.field; }, (e) => e is NoSuchMethodError); //# 20: static type warning
46 Expect.throws(() { foo(Class.method()); }, (e) => e is NoSuchMethodError); //# 21: static type warning
47 Expect.throws(() { foo(Class.field); }, (e) => e is NoSuchMethodError); //# 22 : static type warning
48 Expect.throws(() { Class / 3; }, (e) => e is NoSuchMethodError); //# 23: stati c type warning
49 Expect.throws(() { Class += 3; }, (e) => e is NoSuchMethodError); //# 24: stat ic type warning
50
51 // Verify that a class literal isn't a string literal.
52 Expect.notEquals(Class, "Class");
53
54 // Verify toString() works for class literals.
55 Expect.isTrue((Class).toString() is String);
56 var y = Class;
57 Expect.isTrue(y.toString() is String);
58
59 Expect.throws(() { Class.toString(); }, (e) => e is NoSuchMethodError); //# 25 : static type warning
60 }
OLDNEW
« no previous file with comments | « tests/language/class_keyword_test.dart ('k') | tests/language/class_override_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698