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

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

Issue 12852007: Improve code for !identical(a, b): (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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
« runtime/vm/intermediate_language.cc ('K') | « runtime/vm/token.h ('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) 2013, 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 // Test efficient and correct implementation of !identical(a, b).
5
6 notIdenticalTest1(a) {
7 if (!identical("ho", a)) {
8 return 2;
9 } else {
10 return 1;
11 }
12 }
13
14 notIdenticalTest2(a) {
15 var x = identical("ho", a);
16 if (!x) {
17 Expect.equals(false, x);
18 return x;
19 } else {
20 Expect.equals(true, x);
21 return 1;
22 }
23 }
24
25 notIdenticalTest3(a) {
26 var x = identical("ho", a);
27 return !x;
28 }
29
30 main() {
31 for (int i = 0; i < 10000; i++) {
32 Expect.equals(1, notIdenticalTest1("ho"));
33 Expect.equals(1, notIdenticalTest2("ho"));
34 Expect.equals(false, notIdenticalTest3("ho"));
35 }
36 }
OLDNEW
« runtime/vm/intermediate_language.cc ('K') | « runtime/vm/token.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698