| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Test that logical or-expressions don't introduce unnecessary nots. | 5 // Test that logical or-expressions don't introduce unnecessary nots. |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'compiler_helper.dart'; | 9 import 'compiler_helper.dart'; |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 """; | 25 """; |
| 26 | 26 |
| 27 main() { | 27 main() { |
| 28 asyncTest(() => Future.wait([ | 28 asyncTest(() => Future.wait([ |
| 29 // We want something like: | 29 // We want something like: |
| 30 // var t1 = bar.call$0() === true; | 30 // var t1 = bar.call$0() === true; |
| 31 // if (t1 || gee.call$0() === true) gee.call$0(); | 31 // if (t1 || gee.call$0() === true) gee.call$0(); |
| 32 // if (t1 || gee.call$0() === true) gee.call$0(); | 32 // if (t1 || gee.call$0() === true) gee.call$0(); |
| 33 compileAndDoNotMatchFuzzy( | 33 compileAndDoNotMatchFuzzy( |
| 34 TEST_ONE, | 34 TEST_ONE, 'foo', r"""var x = [a-zA-Z0-9$.]+\(\) == true; |
| 35 'foo', | |
| 36 r"""var x = [a-zA-Z0-9$.]+\(\) == true; | |
| 37 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+; | 35 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+; |
| 38 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;"""), | 36 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;"""), |
| 39 | 37 |
| 40 // We want something like: | 38 // We want something like: |
| 41 // var t1 = list == null; | 39 // var t1 = list == null; |
| 42 // if (t1) bar.call$0(); | 40 // if (t1) bar.call$0(); |
| 43 // if (t1 || bar.call$0() === true) bar.call$0(); | 41 // if (t1 || bar.call$0() === true) bar.call$0(); |
| 44 // if (t1 || bar.call$0() === true) bar.call$0(); | 42 // if (t1 || bar.call$0() === true) bar.call$0(); |
| 45 compileAndMatchFuzzy( | 43 compileAndMatchFuzzy(TEST_TWO, 'foo', r"""var x = x == null; |
| 46 TEST_TWO, | |
| 47 'foo', | |
| 48 r"""var x = x == null; | |
| 49 if \(x\) [^;]+; | 44 if \(x\) [^;]+; |
| 50 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+; | 45 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+; |
| 51 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;"""), | 46 if \(x \|\| [a-zA-Z0-9$.]+\(\) === true\) [^;]+;"""), |
| 52 ])); | 47 ])); |
| 53 } | 48 } |
| OLD | NEW |