OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 // Second dart test program. | |
5 | |
6 class NullTest { | |
7 static int foo(var obj) { | |
8 Expect.equals(null, obj); | |
9 } | |
10 | |
11 static bool compareToNull(var value) { | |
12 return null == value; | |
13 } | |
14 | |
15 static bool compareWithNull(var value) { | |
16 return value == null; | |
17 } | |
18 | |
19 static int testMain() { | |
20 var val = 1; | |
21 var obj = null; | |
22 | |
23 Expect.equals(null, obj); | |
24 Expect.equals(null, null); | |
25 | |
26 foo(obj); | |
27 foo(null); | |
28 | |
29 if (obj != null) { | |
30 foo(null); | |
31 } else { | |
32 foo(obj); | |
33 } | |
34 | |
35 Expect.isFalse(compareToNull(val)); | |
36 Expect.isTrue(compareToNull(obj)); | |
37 Expect.isFalse(compareWithNull(val)); | |
38 Expect.isTrue(compareWithNull(obj)); | |
39 Expect.isTrue(obj is Object); | |
40 Expect.isFalse(obj is String); | |
41 Expect.isTrue(obj is !String); | |
42 Expect.isFalse(obj is !Object); | |
43 Expect.isFalse(val is !Object); | |
44 | |
45 return 0; | |
46 } | |
47 } | |
48 | |
49 | |
50 main() { | |
51 NullTest.testMain(); | |
52 } | |
OLD | NEW |