| OLD | NEW |
| 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 // Dart test program for testing the instanceof operation. | 4 // Dart test program for testing the instanceof operation. |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // Tests involving generics. | 8 // Tests involving generics. |
| 9 | 9 |
| 10 abstract class I<T> { | 10 abstract class I<T> {} |
| 11 } | |
| 12 | 11 |
| 12 class A implements I<bool> {} |
| 13 | 13 |
| 14 class A implements I<bool> { | 14 class B<T> implements I<bool> {} |
| 15 } | |
| 16 | 15 |
| 16 abstract class K<T> {} |
| 17 | 17 |
| 18 class B<T> implements I<bool> { | 18 abstract class L<T> extends K<bool> {} |
| 19 } | |
| 20 | 19 |
| 20 class C implements L<String> {} |
| 21 | 21 |
| 22 abstract class K<T> { | 22 class D implements B<String> {} |
| 23 | |
| 24 } | |
| 25 | |
| 26 abstract class L<T> extends K<bool> { | |
| 27 | |
| 28 } | |
| 29 | |
| 30 | |
| 31 class C implements L<String> { | |
| 32 | |
| 33 } | |
| 34 | |
| 35 | |
| 36 class D implements B<String> { | |
| 37 | |
| 38 } | |
| 39 | |
| 40 | |
| 41 | 23 |
| 42 main() { | 24 main() { |
| 43 var a = new A(); | 25 var a = new A(); |
| 44 var b = new B<String>(); | 26 var b = new B<String>(); |
| 45 var c = new C(); | 27 var c = new C(); |
| 46 var d = new D(); | 28 var d = new D(); |
| 47 // Repeat type checks so that inlined tests can be tested as well. | 29 // Repeat type checks so that inlined tests can be tested as well. |
| 48 for (int i = 0; i < 5; i++) { | 30 for (int i = 0; i < 5; i++) { |
| 49 Expect.isFalse(a is I<String>); | 31 Expect.isFalse(a is I<String>); |
| 50 Expect.isTrue(a is I<bool>); | 32 Expect.isTrue(a is I<bool>); |
| 51 Expect.isFalse(b is I<String>); | 33 Expect.isFalse(b is I<String>); |
| 52 Expect.isFalse(c is K<String>); | 34 Expect.isFalse(c is K<String>); |
| 53 Expect.isFalse(c is K<String>); | 35 Expect.isFalse(c is K<String>); |
| 54 Expect.isTrue(c is L<String>); | 36 Expect.isTrue(c is L<String>); |
| 55 Expect.isFalse(c is L<bool>); | 37 Expect.isFalse(c is L<bool>); |
| 56 Expect.isTrue(c is K<bool>); | 38 Expect.isTrue(c is K<bool>); |
| 57 Expect.isFalse(c is K<String>); | 39 Expect.isFalse(c is K<String>); |
| 58 Expect.isFalse(d is I<String>); | 40 Expect.isFalse(d is I<String>); |
| 59 Expect.isTrue(d is I<bool>); | 41 Expect.isTrue(d is I<bool>); |
| 60 } | 42 } |
| 61 } | 43 } |
| OLD | NEW |