| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 that parameters keep their names in the output. | 4 // Test that parameters keep their names in the output. |
| 5 | 5 |
| 6 #import("compiler_helper.dart"); | 6 #import("compiler_helper.dart"); |
| 7 | 7 |
| 8 final String TEST_ONE = @""" | 8 final String TEST_ONE = @""" |
| 9 void foo(bar) { | 9 void foo(bar) { |
| 10 var a = 1; | 10 var a = 1; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 RegExp regexp = const RegExp(@"a = 2"); | 59 RegExp regexp = const RegExp(@"a = 2"); |
| 60 Expect.isTrue(regexp.hasMatch(generated)); | 60 Expect.isTrue(regexp.hasMatch(generated)); |
| 61 | 61 |
| 62 regexp = const RegExp(@"a = 3"); | 62 regexp = const RegExp(@"a = 3"); |
| 63 Expect.isTrue(regexp.hasMatch(generated)); | 63 Expect.isTrue(regexp.hasMatch(generated)); |
| 64 | 64 |
| 65 regexp = const RegExp(@"print\(a\)"); | 65 regexp = const RegExp(@"print\(a\)"); |
| 66 Expect.isTrue(regexp.hasMatch(generated)); | 66 Expect.isTrue(regexp.hasMatch(generated)); |
| 67 | 67 |
| 68 generated = compile(TEST_TWO, 'main'); | 68 generated = compile(TEST_TWO, 'main'); |
| 69 // TODO(ngeoffray): Add live range analysis to the codegen | |
| 70 // to make this test pass. | |
| 71 regexp = new RegExp("t = \\(?$anyIdentifier +"); | 69 regexp = new RegExp("t = \\(?$anyIdentifier +"); |
| 72 Expect.isFalse(regexp.hasMatch(generated)); | 70 Expect.isTrue(regexp.hasMatch(generated)); |
| 73 | 71 |
| 74 // TODO(ngeoffray): Add live range analysis to the codegen | |
| 75 // to make this test pass. | |
| 76 regexp = new RegExp("i = \\(?$anyIdentifier +"); | 72 regexp = new RegExp("i = \\(?$anyIdentifier +"); |
| 77 Expect.isFalse(regexp.hasMatch(generated)); | 73 Expect.isTrue(regexp.hasMatch(generated)); |
| 78 | 74 |
| 79 generated = compile(TEST_THREE, 'foo'); | 75 generated = compile(TEST_THREE, 'foo'); |
| 80 | 76 |
| 81 // Check that we don't have 'val = val'. | 77 // Check that we don't have 'val = val'. |
| 82 regexp = const RegExp("val = val;"); | 78 regexp = const RegExp("val = val;"); |
| 83 Expect.isTrue(!regexp.hasMatch(generated)); | 79 Expect.isTrue(!regexp.hasMatch(generated)); |
| 84 | 80 |
| 85 regexp = const RegExp("return val"); | 81 regexp = const RegExp("return val"); |
| 86 Expect.isTrue(regexp.hasMatch(generated)); | 82 Expect.isTrue(regexp.hasMatch(generated)); |
| 87 // Check that a store just after the declaration of the local | 83 // Check that a store just after the declaration of the local |
| 88 // only generates one instruction. | 84 // only generates one instruction. |
| 89 regexp = const RegExp(@"val = 42"); | 85 regexp = const RegExp(@"val = 42"); |
| 90 Expect.isTrue(regexp.hasMatch(generated)); | 86 Expect.isTrue(regexp.hasMatch(generated)); |
| 91 | 87 |
| 92 generated = compile(TEST_FOUR, 'foo'); | 88 generated = compile(TEST_FOUR, 'foo'); |
| 93 | 89 |
| 94 regexp = const RegExp("cond1 = cond1;"); | 90 regexp = const RegExp("cond1 = cond1;"); |
| 95 Expect.isTrue(!regexp.hasMatch(generated)); | 91 Expect.isTrue(!regexp.hasMatch(generated)); |
| 96 | 92 |
| 97 regexp = const RegExp("cond2 = cond2;"); | 93 regexp = const RegExp("cond2 = cond2;"); |
| 98 Expect.isTrue(!regexp.hasMatch(generated)); | 94 Expect.isTrue(!regexp.hasMatch(generated)); |
| 99 } | 95 } |
| OLD | NEW |