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 the "is" type test operator. | 4 // Dart test program for the "is" type test operator. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 abstract class I { } | 8 abstract class I {} |
9 | 9 |
10 abstract class AI implements I { } | 10 abstract class AI implements I {} |
11 | 11 |
12 class A implements AI { | 12 class A implements AI { |
13 const A(); | 13 const A(); |
14 } | 14 } |
15 | 15 |
16 class B implements I { | 16 class B implements I { |
17 const B(); | 17 const B(); |
18 } | 18 } |
19 | 19 |
20 class C extends A { | 20 class C extends A { |
21 const C() : super(); | 21 const C() : super(); |
22 } | 22 } |
23 | 23 |
24 class IsOperatorTest { | 24 class IsOperatorTest { |
25 static testMain() { | 25 static testMain() { |
26 var a = new A(); | 26 var a = new A(); |
27 var b = new B(); | 27 var b = new B(); |
28 var c = new C(); | 28 var c = new C(); |
29 var n = null; | 29 var n = null; |
30 Expect.equals(true, a is A); | 30 Expect.equals(true, a is A); |
31 Expect.equals(false, a is !A); | 31 Expect.equals(false, a is! A); |
32 Expect.equals(true, b is B); | 32 Expect.equals(true, b is B); |
33 Expect.equals(false, b is !B); | 33 Expect.equals(false, b is! B); |
34 Expect.equals(true, c is C); | 34 Expect.equals(true, c is C); |
35 Expect.equals(false, c is !C); | 35 Expect.equals(false, c is! C); |
36 Expect.equals(true, c is A); | 36 Expect.equals(true, c is A); |
37 Expect.equals(false, c is !A); | 37 Expect.equals(false, c is! A); |
38 | 38 |
39 Expect.equals(true, a is AI); | 39 Expect.equals(true, a is AI); |
40 Expect.equals(false, a is !AI); | 40 Expect.equals(false, a is! AI); |
41 Expect.equals(true, a is I); | 41 Expect.equals(true, a is I); |
42 Expect.equals(false, a is !I); | 42 Expect.equals(false, a is! I); |
43 Expect.equals(false, b is AI); | 43 Expect.equals(false, b is AI); |
44 Expect.equals(true, b is !AI); | 44 Expect.equals(true, b is! AI); |
45 Expect.equals(true, b is I); | 45 Expect.equals(true, b is I); |
46 Expect.equals(false, b is !I); | 46 Expect.equals(false, b is! I); |
47 Expect.equals(true, c is AI); | 47 Expect.equals(true, c is AI); |
48 Expect.equals(false, c is !AI); | 48 Expect.equals(false, c is! AI); |
49 Expect.equals(true, c is I); | 49 Expect.equals(true, c is I); |
50 Expect.equals(false, c is !I); | 50 Expect.equals(false, c is! I); |
51 Expect.equals(false, n is AI); | 51 Expect.equals(false, n is AI); |
52 Expect.equals(true, n is !AI); | 52 Expect.equals(true, n is! AI); |
53 Expect.equals(false, n is I); | 53 Expect.equals(false, n is I); |
54 Expect.equals(true, n is !I); | 54 Expect.equals(true, n is! I); |
55 | 55 |
56 Expect.equals(false, a is B); | 56 Expect.equals(false, a is B); |
57 Expect.equals(true, a is !B); | 57 Expect.equals(true, a is! B); |
58 Expect.equals(false, a is C); | 58 Expect.equals(false, a is C); |
59 Expect.equals(true, a is !C); | 59 Expect.equals(true, a is! C); |
60 Expect.equals(false, b is A); | 60 Expect.equals(false, b is A); |
61 Expect.equals(true, b is !A); | 61 Expect.equals(true, b is! A); |
62 Expect.equals(false, b is C); | 62 Expect.equals(false, b is C); |
63 Expect.equals(true, b is !C); | 63 Expect.equals(true, b is! C); |
64 Expect.equals(false, c is B); | 64 Expect.equals(false, c is B); |
65 Expect.equals(true, c is !B); | 65 Expect.equals(true, c is! B); |
66 Expect.equals(false, n is A); | 66 Expect.equals(false, n is A); |
67 Expect.equals(true, n is !A); | 67 Expect.equals(true, n is! A); |
68 | 68 |
69 Expect.equals(false, null is A); | 69 Expect.equals(false, null is A); |
70 Expect.equals(false, null is B); | 70 Expect.equals(false, null is B); |
71 Expect.equals(false, null is C); | 71 Expect.equals(false, null is C); |
72 Expect.equals(false, null is AI); | 72 Expect.equals(false, null is AI); |
73 Expect.equals(false, null is I); | 73 Expect.equals(false, null is I); |
74 | 74 |
75 Expect.equals(true, null is !A); | 75 Expect.equals(true, null is! A); |
76 Expect.equals(true, null is !B); | 76 Expect.equals(true, null is! B); |
77 Expect.equals(true, null is !C); | 77 Expect.equals(true, null is! C); |
78 Expect.equals(true, null is !AI); | 78 Expect.equals(true, null is! AI); |
79 Expect.equals(true, null is !I); | 79 Expect.equals(true, null is! I); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 main() { | 83 main() { |
84 IsOperatorTest.testMain(); | 84 IsOperatorTest.testMain(); |
85 } | 85 } |
OLD | NEW |