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

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

Issue 3001803002: Migrate block 114 (and some of 113). (Closed)
Patch Set: Tweak app_jit status. 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/generic_instanceof.dart ('k') | tests/language/generic_instanceof3_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) 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 import "package:expect/expect.dart";
7
8 // Test that partially typed generic instances are correctly constructed.
9
10 // Test factory case.
11 class Foo<K, V> {
12 Foo() {}
13
14 factory Foo.fac() {
15 return new Foo<K, V>();
16 }
17
18 FooString() {
19 return new Foo<K, String>.fac();
20 }
21 }
22
23 // Test constructor case.
24 class Moo<K, V> {
25 Moo() {}
26
27 MooString() {
28 return new Moo<K, String>();
29 }
30 }
31
32 testAll() {
33 var foo_int_num = new Foo<int, num>();
34 Expect.isTrue(foo_int_num is Foo<int, num>);
35 Expect.isTrue(foo_int_num is! Foo<int, String>);
36 // foo_int_num.FooString() returns a Foo<int, String>
37 Expect.isTrue(foo_int_num.FooString() is! Foo<int, num>);
38 Expect.isTrue(foo_int_num.FooString() is Foo<int, String>);
39
40 var foo_raw = new Foo();
41 Expect.isTrue(foo_raw is Foo<int, num>);
42 Expect.isTrue(foo_raw is Foo<int, String>);
43 // foo_raw.FooString() returns a Foo<dynamic, String>
44 Expect.isTrue(foo_raw.FooString() is! Foo<int, num>);
45 Expect.isTrue(foo_raw.FooString() is Foo<int, String>);
46
47 var moo_int_num = new Moo<int, num>();
48 Expect.isTrue(moo_int_num is Moo<int, num>);
49 Expect.isTrue(moo_int_num is! Moo<int, String>);
50 // moo_int_num.MooString() returns a Moo<int, String>
51 Expect.isTrue(moo_int_num.MooString() is! Moo<int, num>);
52 Expect.isTrue(moo_int_num.MooString() is Moo<int, String>);
53
54 var moo_raw = new Moo();
55 Expect.isTrue(moo_raw is Moo<int, num>);
56 Expect.isTrue(moo_raw is Moo<int, String>);
57 // moo_raw.MooString() returns a Moo<dynamic, String>
58 Expect.isTrue(moo_raw.MooString() is! Moo<int, num>);
59 Expect.isTrue(moo_raw.MooString() is Moo<int, String>);
60 }
61
62 main() {
63 // Repeat type checks so that inlined tests can be tested as well.
64 for (int i = 0; i < 5; i++) {
65 testAll();
66 }
67 }
OLDNEW
« no previous file with comments | « tests/language/generic_instanceof.dart ('k') | tests/language/generic_instanceof3_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698