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

Side by Side Diff: tests/language/src/GenericInstanceof2Test.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // Test that instanceof works correctly with type variables.
5
6 // Test that partially typed generic instances are correctly constructed.
7
8 // Test factory case.
9 class Foo<K, V> {
10 Foo() { }
11
12 factory Foo.fac() {
13 return new Foo<K, V>();
14 }
15
16 FooString() {
17 return new Foo<K, String>.fac();
18 }
19 }
20
21 // Test constructor case.
22 class Moo<K, V> {
23 Moo() { }
24
25 MooString() {
26 return new Moo<K, String>();
27 }
28 }
29
30 testAll () {
31 var foo_int_num = new Foo<int, num>();
32 Expect.isTrue(foo_int_num is Foo<int, num>);
33 Expect.isTrue(foo_int_num is !Foo<int, String>);
34 // foo_int_num.FooString() returns a Foo<int, String>
35 Expect.isTrue(foo_int_num.FooString() is !Foo<int, num>);
36 Expect.isTrue(foo_int_num.FooString() is Foo<int, String>);
37
38 var foo_raw = new Foo();
39 Expect.isTrue(foo_raw is Foo<int, num>);
40 Expect.isTrue(foo_raw is Foo<int, String>);
41 // foo_raw.FooString() returns a Foo<Dynamic, String>
42 Expect.isTrue(foo_raw.FooString() is !Foo<int, num>);
43 Expect.isTrue(foo_raw.FooString() is Foo<int, String>);
44
45 var moo_int_num = new Moo<int, num>();
46 Expect.isTrue(moo_int_num is Moo<int, num>);
47 Expect.isTrue(moo_int_num is !Moo<int, String>);
48 // moo_int_num.MooString() returns a Moo<int, String>
49 Expect.isTrue(moo_int_num.MooString() is !Moo<int, num>);
50 Expect.isTrue(moo_int_num.MooString() is Moo<int, String>);
51
52 var moo_raw = new Moo();
53 Expect.isTrue(moo_raw is Moo<int, num>);
54 Expect.isTrue(moo_raw is Moo<int, String>);
55 // moo_raw.MooString() returns a Moo<Dynamic, String>
56 Expect.isTrue(moo_raw.MooString() is !Moo<int, num>);
57 Expect.isTrue(moo_raw.MooString() is Moo<int, String>);
58 }
59
60
61 main() {
62 // Repeat type checks so that inlined tests can be tested as well.
63 for (int i = 0; i < 5; i++) {
64 testAll();
65 }
66 }
OLDNEW
« no previous file with comments | « tests/language/src/GenericInstanceof.dart ('k') | tests/language/src/GenericInstanceof3Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698