Index: tests/corelib/null.dart |
diff --git a/tests/corelib/null.dart b/tests/corelib/null.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..864669347cd906788fe9880b858ed3674c5c96d1 |
--- /dev/null |
+++ b/tests/corelib/null.dart |
@@ -0,0 +1,30 @@ |
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+// Test that Null inherits properties from Object. |
+ |
+main() { |
+ var x; |
+ // These shouldn't throw. |
+ x.runtimeType; |
+ x.toString(); |
+ x.hashCode(); |
+ |
+ // operator== is inherited from Object. It's the same as identical. |
+ // That's not really testable. |
+ Expect.isTrue(identical(x, null)); |
+ Expect.isTrue(x == null); |
+ |
+ // noSuchMethod must throw a NullPointerException. |
+ Expect.throws(() => x.noSuchMethod(), (e) => e is NullPointerException); |
+ Expect.throws(() => x.notThere(), (e) => e is NullPointerException); |
+ |
+ // Methods can be closurized. |
+ // 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.
|
+ // Expect.throws(nsm, (e) => e is NullPointerException); |
+ var hc = x.hashCode; |
+ 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
|
+ var ts = x.toString; |
+ Expect.equals(ts(), null.toString()); |
+} |