Index: tests/corelib/null_test.dart |
diff --git a/tests/corelib/null_test.dart b/tests/corelib/null_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5815638445670609ddfaaf69221dd89bda1fb5ff |
--- /dev/null |
+++ b/tests/corelib/null_test.dart |
@@ -0,0 +1,38 @@ |
+// 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; |
+ |
+ Expect.isTrue(x is Object); |
+ Expect.isTrue(x is Dynamic); |
+ Expect.isTrue(x is! String); |
+ Expect.isTrue(x is! int); |
+ |
+ // These shouldn't throw. |
+ x.runtimeType; |
+ x.toString(); |
+ x.hashCode(); |
+ |
+ // operator== is inherited from Object. It's the same as identical. |
+ // It's not really testable. |
+ Expect.isTrue(identical(x, null)); |
+ Expect.isTrue(x == null); |
+ |
+ // noSuchMethod must throw a NullPointerException. |
+ Expect.throws(() => x.noSuchMethod(null, null), |
+ (e) => e is NullPointerException); |
+ Expect.throws(() => x.notThere(), |
+ (e) => e is NullPointerException); |
+ |
+ // Methods can be closurized and yields the same result. |
+ var hc = x.hashCode; |
+ Expect.equals(null.hashCode(), hc()); |
+ var ts = x.toString; |
+ Expect.equals(null.toString(), ts()); |
+ 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.
|
+ Expect.throws(() => nsm(null, null), (e) => e is NullPointerException); |
+} |