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

Side by Side Diff: tests/language/equality_test.dart

Issue 10855208: Implement new equality spec. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('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
6 class A {
7 bool _result;
8 A(this._result);
9 operator ==(x) { return _result; }
10 }
11
12
13 opaque(x) => [x,1,'y'][0]; // confuse the optimizers.
14
15 class Death {
16 operator ==(x) { throw 'Dead!'; }
17 }
18
19 death() => opaque(new Death());
20 nullFn() => opaque(null);
21
22 tests() {
23 var alwaysTrue = new A(true);
24 var alwaysFalse = new A(false);
25 Expect.isFalse(alwaysFalse == alwaysFalse);
26 Expect.isTrue(alwaysFalse != alwaysFalse);
27 Expect.isTrue(alwaysTrue == alwaysTrue);
28 Expect.isTrue(alwaysTrue == 5);
29 Expect.isFalse(alwaysTrue == null);
30 Expect.isFalse(null == alwaysTrue);
31 Expect.isTrue(alwaysTrue != null);
32 Expect.isTrue(null != alwaysTrue);
33 Expect.isTrue(null == null);
34 Expect.isFalse(null != null);
35
36 Expect.throws(() => death() == 5);
37 Expect.isFalse(death() == nullFn());
38 Expect.isFalse(nullFn() == death());
39 Expect.isTrue(nullFn() == nullFn());
40 Expect.isTrue(death() != nullFn());
41 Expect.isTrue(nullFn() != death());
42 Expect.isFalse(nullFn() != nullFn());
43 }
44
45 main() {
46 for (int i = 0; i < 1000; i++) tests();
47 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698