| OLD | NEW |
| (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 main () { |
| 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 } |
| OLD | NEW |