Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: tests/corelib/null.dart

Issue 10979050: Ensure that hashCode and runtimeType work on null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tests/corelib/corelib.status ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
« tests/corelib/corelib.status ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698