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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« tests/corelib/corelib.status ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« 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