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 check(args) { | 6 check(args) { |
7 var list = args[0]; | 7 var list = args[0]; |
8 var string = args[1]; | 8 var string = args[1]; |
9 var nullObject = args[2]; | 9 var nullObject = args[2]; |
10 | 10 |
11 Expect.isTrue(list is Object); | 11 Expect.isTrue(list is Object); |
12 Expect.isTrue(list is List); | 12 Expect.isTrue(list is List); |
13 Expect.isTrue(list is Collection); | 13 Expect.isTrue(list is Collection); |
14 Expect.isTrue(list is Iterable); | 14 Expect.isTrue(list is Iterable); |
15 Expect.isFalse(list is Comparable); | 15 Expect.isFalse(list is Comparable); |
16 Expect.isFalse(list is Hashable); | |
17 Expect.isFalse(list is Pattern); | 16 Expect.isFalse(list is Pattern); |
18 Expect.isFalse(list is String); | 17 Expect.isFalse(list is String); |
19 | 18 |
20 Expect.isFalse(list is !List); | 19 Expect.isFalse(list is !List); |
21 Expect.isFalse(list is !Collection); | 20 Expect.isFalse(list is !Collection); |
22 Expect.isFalse(list is !Iterable); | 21 Expect.isFalse(list is !Iterable); |
23 Expect.isTrue(list is !Comparable); | 22 Expect.isTrue(list is !Comparable); |
24 Expect.isTrue(list is !Hashable); | |
25 Expect.isTrue(list is !Pattern); | 23 Expect.isTrue(list is !Pattern); |
26 Expect.isTrue(list is !String); | 24 Expect.isTrue(list is !String); |
27 | 25 |
28 Expect.isTrue(string is Object); | 26 Expect.isTrue(string is Object); |
29 Expect.isFalse(string is List); | 27 Expect.isFalse(string is List); |
30 Expect.isFalse(string is Collection); | 28 Expect.isFalse(string is Collection); |
31 Expect.isFalse(string is Iterable); | 29 Expect.isFalse(string is Iterable); |
32 Expect.isTrue(string is Comparable); | 30 Expect.isTrue(string is Comparable); |
33 Expect.isTrue(string is Hashable); | |
34 Expect.isTrue(string is Pattern); | 31 Expect.isTrue(string is Pattern); |
35 Expect.isTrue(string is String); | 32 Expect.isTrue(string is String); |
36 | 33 |
37 Expect.isTrue(string is !List); | 34 Expect.isTrue(string is !List); |
38 Expect.isTrue(string is !Collection); | 35 Expect.isTrue(string is !Collection); |
39 Expect.isTrue(string is !Iterable); | 36 Expect.isTrue(string is !Iterable); |
40 Expect.isFalse(string is !Comparable); | 37 Expect.isFalse(string is !Comparable); |
41 Expect.isFalse(string is !Hashable); | |
42 Expect.isFalse(string is !Pattern); | 38 Expect.isFalse(string is !Pattern); |
43 Expect.isFalse(string is !String); | 39 Expect.isFalse(string is !String); |
44 | 40 |
45 Expect.isTrue(nullObject is Object); | 41 Expect.isTrue(nullObject is Object); |
46 Expect.isFalse(nullObject is List); | 42 Expect.isFalse(nullObject is List); |
47 Expect.isFalse(nullObject is Collection); | 43 Expect.isFalse(nullObject is Collection); |
48 Expect.isFalse(nullObject is Iterable); | 44 Expect.isFalse(nullObject is Iterable); |
49 Expect.isFalse(nullObject is Comparable); | 45 Expect.isFalse(nullObject is Comparable); |
50 Expect.isFalse(nullObject is Hashable); | |
51 Expect.isFalse(nullObject is Pattern); | 46 Expect.isFalse(nullObject is Pattern); |
52 Expect.isFalse(nullObject is String); | 47 Expect.isFalse(nullObject is String); |
53 | 48 |
54 Expect.isTrue(nullObject is !List); | 49 Expect.isTrue(nullObject is !List); |
55 Expect.isTrue(nullObject is !Collection); | 50 Expect.isTrue(nullObject is !Collection); |
56 Expect.isTrue(nullObject is !Iterable); | 51 Expect.isTrue(nullObject is !Iterable); |
57 Expect.isTrue(nullObject is !Comparable); | 52 Expect.isTrue(nullObject is !Comparable); |
58 Expect.isTrue(nullObject is !Hashable); | |
59 Expect.isTrue(nullObject is !Pattern); | 53 Expect.isTrue(nullObject is !Pattern); |
60 Expect.isTrue(nullObject is !String); | 54 Expect.isTrue(nullObject is !String); |
61 } | 55 } |
62 | 56 |
63 main() { | 57 main() { |
64 // Try to make it hard for an optimizing compiler to inline the | 58 // Try to make it hard for an optimizing compiler to inline the |
65 // tests. | 59 // tests. |
66 check([[], 'string', null]); | 60 check([[], 'string', null]); |
67 | 61 |
68 // Try to make it even harder. | 62 // Try to make it even harder. |
69 var string = new String.fromCharCodes([new Date.now().year % 100 + 1]); | 63 var string = new String.fromCharCodes([new Date.now().year % 100 + 1]); |
70 check([string.charCodes(), string, null]); | 64 check([string.charCodes(), string, null]); |
71 } | 65 } |
OLD | NEW |