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

Side by Side Diff: tests/corelib/null_test.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: And Nicolas' comments too. 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
10 Expect.isTrue(x is Object);
11 Expect.isTrue(x is Dynamic);
12 Expect.isTrue(x is! String);
13 Expect.isTrue(x is! int);
14
15 // These shouldn't throw.
16 x.runtimeType;
17 x.toString();
18 x.hashCode();
19
20 // operator== is inherited from Object. It's the same as identical.
21 // It's not really testable.
22 Expect.isTrue(identical(x, null));
23 Expect.isTrue(x == null);
24
25 // noSuchMethod must throw a NullPointerException.
26 Expect.throws(() => x.noSuchMethod(null, null),
27 (e) => e is NullPointerException);
28 Expect.throws(() => x.notThere(),
29 (e) => e is NullPointerException);
30
31 // Methods can be closurized and yields the same result.
32 var hc = x.hashCode;
33 Expect.equals(null.hashCode(), hc());
34 var ts = x.toString;
35 Expect.equals(null.toString(), ts());
36 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.
37 Expect.throws(() => nsm(null, null), (e) => e is NullPointerException);
38 }
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