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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class A { | 7 class A {} |
8 } | |
9 | 8 |
10 class B extends A { | 9 class B extends A {} |
11 } | |
12 | 10 |
13 class C extends B { | 11 class C extends B {} |
14 } | |
15 | 12 |
16 class D implements C { | 13 class D implements C {} |
17 } | |
18 | 14 |
19 int inscrutable(int x) => (x == 0) ? 0 : (x | inscrutable(x & (x - 1))); | 15 int inscrutable(int x) => (x == 0) ? 0 : (x | inscrutable(x & (x - 1))); |
20 | 16 |
21 main() { | 17 main() { |
22 var things = [new A(), new B(), new C(), new D()]; | 18 var things = [new A(), new B(), new C(), new D()]; |
23 | 19 |
24 var a = things[inscrutable(0)]; | 20 var a = things[inscrutable(0)]; |
25 Expect.isTrue(a is A); | 21 Expect.isTrue(a is A); |
26 Expect.isFalse(a is B); | 22 Expect.isFalse(a is B); |
27 Expect.isFalse(a is C); | 23 Expect.isFalse(a is C); |
(...skipping 10 matching lines...) Expand all Loading... |
38 Expect.isTrue(c is B); | 34 Expect.isTrue(c is B); |
39 Expect.isTrue(c is C); | 35 Expect.isTrue(c is C); |
40 Expect.isFalse(c is D); | 36 Expect.isFalse(c is D); |
41 | 37 |
42 var d = things[inscrutable(3)]; | 38 var d = things[inscrutable(3)]; |
43 Expect.isTrue(d is A); | 39 Expect.isTrue(d is A); |
44 Expect.isTrue(d is B); | 40 Expect.isTrue(d is B); |
45 Expect.isTrue(d is C); | 41 Expect.isTrue(d is C); |
46 Expect.isTrue(d is D); | 42 Expect.isTrue(d is D); |
47 } | 43 } |
OLD | NEW |