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

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

Issue 288343014: dart2dart: Test cases for better code coverage in dart_tree rewritings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 cneg_and(x, y) {
8 if ((x && y) ? false : true) {
9 return 0;
10 } else {
11 return 1;
12 }
13 }
14
15 cneg_and_not(x, y) {
16 if ((x && (y ? false : true)) ? false : true) {
17 return 0;
18 } else {
19 return 1;
20 }
21 }
22
23 cneg_not_and(x, y) {
24 if (((x ? false : true) && y) ? false : true) {
25 return 0;
26 } else {
27 return 1;
28 }
29 }
30
31 cneg_not_and_not(x, y) {
32 if (((x ? false : true) && (y ? false : true)) ? false : true) {
33 return 0;
34 } else {
35 return 1;
36 }
37 }
38
39 cneg_or(x, y) {
40 if ((x || y) ? false : true) {
41 return 0;
42 } else {
43 return 1;
44 }
45 }
46
47 cneg_or_not(x, y) {
48 if ((x || (y ? false : true)) ? false : true) {
49 return 0;
50 } else {
51 return 1;
52 }
53 }
54
55 cneg_not_or(x, y) {
56 if (((x ? false : true) || y) ? false : true) {
57 return 0;
58 } else {
59 return 1;
60 }
61 }
62
63 cneg_not_or_not(x, y) {
64 if (((x ? false : true) || (y ? false : true)) ? false : true) {
65 return 0;
66 } else {
67 return 1;
68 }
69 }
70
71 main() {
72 Expect.equals(1, cneg_and(true, true));
73 Expect.equals(0, cneg_and(true, false));
74 Expect.equals(0, cneg_and(false, true));
75 Expect.equals(0, cneg_and(false, false));
76
77 Expect.equals(0, cneg_and_not(true, true));
78 Expect.equals(1, cneg_and_not(true, false));
79 Expect.equals(0, cneg_and_not(false, true));
80 Expect.equals(0, cneg_and_not(false, false));
81
82 Expect.equals(0, cneg_not_and(true, true));
83 Expect.equals(0, cneg_not_and(true, false));
84 Expect.equals(1, cneg_not_and(false, true));
85 Expect.equals(0, cneg_not_and(false, false));
86
87 Expect.equals(0, cneg_not_and_not(true, true));
88 Expect.equals(0, cneg_not_and_not(true, false));
89 Expect.equals(0, cneg_not_and_not(false, true));
90 Expect.equals(1, cneg_not_and_not(false, false));
91
92 Expect.equals(1, cneg_or(true, true));
93 Expect.equals(1, cneg_or(true, false));
94 Expect.equals(1, cneg_or(false, true));
95 Expect.equals(0, cneg_or(false, false));
96
97 Expect.equals(1, cneg_or_not(true, true));
98 Expect.equals(1, cneg_or_not(true, false));
99 Expect.equals(0, cneg_or_not(false, true));
100 Expect.equals(1, cneg_or_not(false, false));
101
102 Expect.equals(1, cneg_not_or(true, true));
103 Expect.equals(0, cneg_not_or(true, false));
104 Expect.equals(1, cneg_not_or(false, true));
105 Expect.equals(1, cneg_not_or(false, false));
106
107 Expect.equals(0, cneg_not_or_not(true, true));
108 Expect.equals(1, cneg_not_or_not(true, false));
109 Expect.equals(1, cneg_not_or_not(false, true));
110 Expect.equals(1, cneg_not_or_not(false, false));
111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698