| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Test constant folding on numbers. | 4 // Test constant folding on numbers. |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 """; | 52 """; |
| 53 | 53 |
| 54 const String RANGE_ERROR_INDEX_FOLDING = """ | 54 const String RANGE_ERROR_INDEX_FOLDING = """ |
| 55 foo() { | 55 foo() { |
| 56 return [1][1]; | 56 return [1][1]; |
| 57 } | 57 } |
| 58 """; | 58 """; |
| 59 | 59 |
| 60 main() { | 60 main() { |
| 61 asyncTest(() => Future.wait([ | 61 asyncTest(() => Future.wait([ |
| 62 compileAndMatch( | 62 compileAndMatch(NUMBER_FOLDING, 'main', new RegExp(r"print\(7\)")), |
| 63 NUMBER_FOLDING, 'main', new RegExp(r"print\(7\)")), | 63 compileAndMatch( |
| 64 compileAndMatch( | 64 NEGATIVE_NUMBER_FOLDING, 'main', new RegExp(r"print\(1\)")), |
| 65 NEGATIVE_NUMBER_FOLDING, 'main', new RegExp(r"print\(1\)")), | 65 compile(NULL_EQUALS_FOLDING, entry: 'foo', check: (String generated) { |
| 66 RegExp regexp = new RegExp(r'a == null'); |
| 67 Expect.isTrue(regexp.hasMatch(generated)); |
| 66 | 68 |
| 67 compile(NULL_EQUALS_FOLDING, entry: 'foo', check: (String generated) { | 69 regexp = new RegExp(r'null == b'); |
| 68 RegExp regexp = new RegExp(r'a == null'); | 70 Expect.isTrue(regexp.hasMatch(generated)); |
| 69 Expect.isTrue(regexp.hasMatch(generated)); | |
| 70 | 71 |
| 71 regexp = new RegExp(r'null == b'); | 72 regexp = new RegExp(r'4 === c'); |
| 72 Expect.isTrue(regexp.hasMatch(generated)); | 73 Expect.isTrue(regexp.hasMatch(generated)); |
| 73 | 74 |
| 74 regexp = new RegExp(r'4 === c'); | 75 regexp = new RegExp('"foo" === d'); |
| 75 Expect.isTrue(regexp.hasMatch(generated)); | 76 Expect.isTrue(regexp.hasMatch(generated)); |
| 76 | 77 }), |
| 77 regexp = new RegExp('"foo" === d'); | 78 compileAndMatch(LIST_LENGTH_FOLDING, 'foo', new RegExp(r"return 3")), |
| 78 Expect.isTrue(regexp.hasMatch(generated)); | 79 compileAndMatch(LIST_INDEX_FOLDING, 'foo', new RegExp(r"return 1")), |
| 79 }), | 80 compileAndDoNotMatch(LIST_INDEX_FOLDING, 'foo', new RegExp(r"ioore")), |
| 80 | 81 compileAndMatch(STRING_LENGTH_FOLDING, 'foo', new RegExp(r"return 3")), |
| 81 compileAndMatch( | 82 compileAndMatch(RANGE_ERROR_INDEX_FOLDING, 'foo', new RegExp(r"ioore")), |
| 82 LIST_LENGTH_FOLDING, 'foo', new RegExp(r"return 3")), | 83 ])); |
| 83 | |
| 84 compileAndMatch( | |
| 85 LIST_INDEX_FOLDING, 'foo', new RegExp(r"return 1")), | |
| 86 | |
| 87 compileAndDoNotMatch( | |
| 88 LIST_INDEX_FOLDING, 'foo', new RegExp(r"ioore")), | |
| 89 | |
| 90 compileAndMatch( | |
| 91 STRING_LENGTH_FOLDING, 'foo', new RegExp(r"return 3")), | |
| 92 | |
| 93 compileAndMatch( | |
| 94 RANGE_ERROR_INDEX_FOLDING, 'foo', new RegExp(r"ioore")), | |
| 95 ])); | |
| 96 } | 84 } |
| OLD | NEW |