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

Unified Diff: tests/language/logical_rewrite_test.dart

Issue 284213002: dart2dart: Logical operators and related rewrite rules in dart_tree. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: SVN rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/language/if_flatten2_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/logical_rewrite_test.dart
diff --git a/tests/language/logical_rewrite_test.dart b/tests/language/logical_rewrite_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..506bff31ab98034e2e9ee05d13209a4067ad0c9e
--- /dev/null
+++ b/tests/language/logical_rewrite_test.dart
@@ -0,0 +1,111 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+
+cneg_and(x, y) {
+ if ((x && y) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+cneg_and_not(x, y) {
+ if ((x && (y ? false : true)) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+cneg_not_and(x, y) {
+ if (((x ? false : true) && y) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+cneg_not_and_not(x, y) {
+ if (((x ? false : true) && (y ? false : true)) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+cneg_or(x, y) {
+ if ((x || y) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+cneg_or_not(x, y) {
+ if ((x || (y ? false : true)) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+cneg_not_or(x, y) {
+ if (((x ? false : true) || y) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+cneg_not_or_not(x, y) {
+ if (((x ? false : true) || (y ? false : true)) ? false : true) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+main() {
+ Expect.equals(1, cneg_and(true, true));
+ Expect.equals(0, cneg_and(true, false));
+ Expect.equals(0, cneg_and(false, true));
+ Expect.equals(0, cneg_and(false, false));
+
+ Expect.equals(0, cneg_and_not(true, true));
+ Expect.equals(1, cneg_and_not(true, false));
+ Expect.equals(0, cneg_and_not(false, true));
+ Expect.equals(0, cneg_and_not(false, false));
+
+ Expect.equals(0, cneg_not_and(true, true));
+ Expect.equals(0, cneg_not_and(true, false));
+ Expect.equals(1, cneg_not_and(false, true));
+ Expect.equals(0, cneg_not_and(false, false));
+
+ Expect.equals(0, cneg_not_and_not(true, true));
+ Expect.equals(0, cneg_not_and_not(true, false));
+ Expect.equals(0, cneg_not_and_not(false, true));
+ Expect.equals(1, cneg_not_and_not(false, false));
+
+ Expect.equals(1, cneg_or(true, true));
+ Expect.equals(1, cneg_or(true, false));
+ Expect.equals(1, cneg_or(false, true));
+ Expect.equals(0, cneg_or(false, false));
+
+ Expect.equals(1, cneg_or_not(true, true));
+ Expect.equals(1, cneg_or_not(true, false));
+ Expect.equals(0, cneg_or_not(false, true));
+ Expect.equals(1, cneg_or_not(false, false));
+
+ Expect.equals(1, cneg_not_or(true, true));
+ Expect.equals(0, cneg_not_or(true, false));
+ Expect.equals(1, cneg_not_or(false, true));
+ Expect.equals(1, cneg_not_or(false, false));
+
+ Expect.equals(0, cneg_not_or_not(true, true));
+ Expect.equals(1, cneg_not_or_not(true, false));
+ Expect.equals(1, cneg_not_or_not(false, true));
+ Expect.equals(1, cneg_not_or_not(false, false));
+}
« no previous file with comments | « tests/language/if_flatten2_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698