Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // Test that Null inherits properties from Object. | |
| 6 | |
| 7 main() { | |
| 8 var x; | |
| 9 | |
| 10 Expect.isTrue(x is Object); | |
| 11 Expect.isTrue(x is Dynamic); | |
| 12 Expect.isTrue(x is! String); | |
| 13 Expect.isTrue(x is! int); | |
| 14 | |
| 15 // These shouldn't throw. | |
| 16 x.runtimeType; | |
| 17 x.toString(); | |
| 18 x.hashCode(); | |
| 19 | |
| 20 // operator== is inherited from Object. It's the same as identical. | |
| 21 // It's not really testable. | |
| 22 Expect.isTrue(identical(x, null)); | |
| 23 Expect.isTrue(x == null); | |
| 24 | |
| 25 // noSuchMethod must throw a NullPointerException. | |
| 26 Expect.throws(() => x.noSuchMethod(null, null), | |
| 27 (e) => e is NullPointerException); | |
| 28 Expect.throws(() => x.notThere(), | |
| 29 (e) => e is NullPointerException); | |
| 30 | |
| 31 // Methods can be closurized and yields the same result. | |
| 32 var hc = x.hashCode; | |
| 33 Expect.equals(null.hashCode(), hc()); | |
| 34 var ts = x.toString; | |
| 35 Expect.equals(null.toString(), ts()); | |
| 36 var nsm = null.noSuchMethod; | |
|
ngeoffray
2012/09/27 11:00:29
Maybe you can remove these two lines, so that dart
Lasse Reichstein Nielsen
2012/09/27 11:25:13
Done.
| |
| 37 Expect.throws(() => nsm(null, null), (e) => e is NullPointerException); | |
| 38 } | |
| OLD | NEW |