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 // These shouldn't throw. | |
| 10 x.runtimeType; | |
| 11 x.toString(); | |
| 12 x.hashCode(); | |
| 13 | |
| 14 // operator== is inherited from Object. It's the same as identical. | |
| 15 // That's not really testable. | |
| 16 Expect.isTrue(identical(x, null)); | |
| 17 Expect.isTrue(x == null); | |
| 18 | |
| 19 // noSuchMethod must throw a NullPointerException. | |
| 20 Expect.throws(() => x.noSuchMethod(), (e) => e is NullPointerException); | |
| 21 Expect.throws(() => x.notThere(), (e) => e is NullPointerException); | |
| 22 | |
| 23 // Methods can be closurized. | |
| 24 // var nsm = null.noSuchMethod; | |
|
kasperl
2012/09/27 08:09:38
File a bug for this?
Lasse Reichstein Nielsen
2012/09/27 09:32:35
Done. And the code should have been uncommented.
| |
| 25 // Expect.throws(nsm, (e) => e is NullPointerException); | |
| 26 var hc = x.hashCode; | |
| 27 Expect.equals(hc(), null.hashCode()); | |
|
kasperl
2012/09/27 08:09:38
What's the expected? I guess null.hashCode() and n
Lasse Reichstein Nielsen
2012/09/27 09:32:35
Good point, yes they were intended as expectations
| |
| 28 var ts = x.toString; | |
| 29 Expect.equals(ts(), null.toString()); | |
| 30 } | |
| OLD | NEW |