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