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

Side by Side Diff: tests/language/first_class_types_literals_test.dart

Issue 11360228: Simplify runtime type support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class C<T> {} 5 class C<T, U, V> {}
6 6
7 class D {} 7 class D {}
8 8
9 typedef int Foo(bool b); 9 typedef int Foo(bool b);
10 10
11 sameType(a, b) { 11 sameType(a, b) {
12 Expect.equals(a.runtimeType, b.runtimeType); 12 Expect.equals(a.runtimeType, b.runtimeType);
13 } 13 }
14 14
15 main() { 15 main() {
16 // Test type literals. 16 // Test type literals.
17 Expect.equals(int, int); 17 Expect.equals(int, int);
18 Expect.notEquals(int, num); 18 Expect.notEquals(int, num);
19 Expect.equals(Foo, Foo); 19 Expect.equals(Foo, Foo);
20 20
21 // Test that class literals return instances of Type. 21 // Test that class literals return instances of Type.
22 Expect.isTrue((D).runtimeType is Type); 22 Expect.isTrue((D).runtimeType is Type);
23 23
24 // Test that types from runtimeType and literals agree. 24 // Test that types from runtimeType and literals agree.
25 Expect.equals(int, 1.runtimeType); 25 Expect.equals(int, 1.runtimeType);
26 Expect.equals(String, 'hest'.runtimeType);
27 Expect.equals(double, (0.5).runtimeType);
28 Expect.equals(bool, true.runtimeType);
26 Expect.equals(C, new C().runtimeType); 29 Expect.equals(C, new C().runtimeType);
27 Expect.equals(D, new D().runtimeType); 30 Expect.equals(D, new D().runtimeType);
28 31
29 // runtimeType on type is idempotent. 32 // runtimeType on type is idempotent.
30 Expect.equals((D).runtimeType, (D).runtimeType.runtimeType); 33 Expect.equals((D).runtimeType, (D).runtimeType.runtimeType);
31 34
32 // Test that operator calls on class literals go to Type. 35 // Test that operator calls on class literals go to Type.
33 Expect.throws(() => C = 1, (e) => e is NoSuchMethodError); 36 Expect.throws(() => C = 1, (e) => e is NoSuchMethodError);
34 Expect.throws(() => C++, (e) => e is NoSuchMethodError); 37 Expect.throws(() => C++, (e) => e is NoSuchMethodError);
35 Expect.throws(() => C + 1, (e) => e is NoSuchMethodError); 38 Expect.throws(() => C + 1, (e) => e is NoSuchMethodError);
36 Expect.throws(() => C[2], (e) => e is NoSuchMethodError); 39 Expect.throws(() => C[2], (e) => e is NoSuchMethodError);
37 Expect.throws(() => C[2] = 'hest', (e) => e is NoSuchMethodError); 40 Expect.throws(() => C[2] = 'hest', (e) => e is NoSuchMethodError);
38 } 41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698