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

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

Issue 1185333002: dart2js cps: Use JS semantics for logical operators in the tree IR. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Renamed method Created 5 years, 6 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
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/logical_rewriter.dart ('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) 2015, 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 import "package:expect/expect.dart";
6
7 // Test that dart2js does not rewrite conditional into logical operators
8 // in cases where it changes which falsy value is returned.
9
10 posFalse(x, y) => x != null ? y : false;
11 negFalse(x, y) => x != null ? !y : false;
12 posNull(x, y) => x != null ? y : null;
13 negNull(x, y) => x != null ? !y : null;
14
15 main() {
16 bool isCheckedMode = false;
17 assert((isCheckedMode = true));
18
19 Expect.equals(false, posFalse(null, false));
20 Expect.equals(false, negFalse(null, false));
21 Expect.equals(null, posNull(null, false));
22 Expect.equals(null, negNull(null, false));
23
24 Expect.equals(false, posFalse(null, true));
25 Expect.equals(false, negFalse(null, true));
26 Expect.equals(null, posNull(null, true));
27 Expect.equals(null, negNull(null, true));
28
29 Expect.equals(false, posFalse([], false));
30 Expect.equals(true, negFalse([], false));
31 Expect.equals(false, posNull([], false));
32 Expect.equals(true, negNull([], false));
33
34 Expect.equals(true, posFalse([], true));
35 Expect.equals(false, negFalse([], true));
36 Expect.equals(true, posNull([], true));
37 Expect.equals(false, negNull([], true));
38
39 if (!isCheckedMode) {
40 Expect.equals(null, posFalse([], null));
41 Expect.equals(true, negFalse([], null));
42 Expect.equals(null, posNull([], null));
43 Expect.equals(true, negNull([], null));
44
45 var y = {};
46 Expect.identical(y, posFalse([], y));
47 Expect.equals(true, negFalse([], y));
48 Expect.identical(y, posNull([], y));
49 Expect.equals(true, negNull([], y));
50 }
51 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/optimization/logical_rewriter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698