Chromium Code Reviews| 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 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 const String TEST_ONE = r""" | 8 const String TEST_ONE = r""" |
| 9 void foo(bar) { | 9 void foo(bar) { |
| 10 var a = 1; | 10 var a = 1; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 if (i == 9) a = false; | 48 if (i == 9) a = false; |
| 49 for (var j = 0; b; j = j + 1) { | 49 for (var j = 0; b; j = j + 1) { |
| 50 if (j == 9) b = false; | 50 if (j == 9) b = false; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 print(a); | 53 print(a); |
| 54 print(b); | 54 print(b); |
| 55 } | 55 } |
| 56 """; | 56 """; |
| 57 | 57 |
| 58 const String TEST_FIVE = r""" | |
| 59 void main() { | |
| 60 var hash = 0; | |
| 61 for (var i = 0; i == 0; i = i + 1) { | |
| 62 hash = hash + 10; | |
|
ngeoffray
2013/03/26 11:29:02
The codegen recognizes that "hash + 10" can be gen
| |
| 63 hash = hash + 42; | |
|
ngeoffray
2013/03/26 11:29:02
We would generate:
hash0 = hash + 10 + 42
Now we
| |
| 64 } | |
| 65 print(t); | |
| 66 } | |
| 67 """; | |
| 68 | |
| 58 main() { | 69 main() { |
| 59 compileAndMatchFuzzy(TEST_ONE, 'foo', "var x = x === true \\? 2 : 3;"); | 70 compileAndMatchFuzzy(TEST_ONE, 'foo', "var x = x === true \\? 2 : 3;"); |
| 60 compileAndMatchFuzzy(TEST_ONE, 'foo', "print\\(x\\);"); | 71 compileAndMatchFuzzy(TEST_ONE, 'foo', "print\\(x\\);"); |
| 61 | 72 |
| 62 compileAndMatchFuzzy(TEST_TWO, 'main', "x \\+= 10"); | 73 compileAndMatchFuzzy(TEST_TWO, 'main', "x \\+= 10"); |
| 63 compileAndMatchFuzzy(TEST_TWO, 'main', "\\+\\+x"); | 74 compileAndMatchFuzzy(TEST_TWO, 'main', "\\+\\+x"); |
| 64 | 75 |
| 65 // Check that we don't have 'd = d' (using regexp back references). | 76 // Check that we don't have 'd = d' (using regexp back references). |
| 66 compileAndDoNotMatchFuzzy(TEST_THREE, 'foo', '(x) = \1'); | 77 compileAndDoNotMatchFuzzy(TEST_THREE, 'foo', '(x) = \1'); |
| 67 compileAndMatchFuzzy(TEST_THREE, 'foo', 'return x'); | 78 compileAndMatchFuzzy(TEST_THREE, 'foo', 'return x'); |
| 68 // Check that a store just after the declaration of the local | 79 // Check that a store just after the declaration of the local |
| 69 // only generates one instruction. | 80 // only generates one instruction. |
| 70 compileAndMatchFuzzy(TEST_THREE, 'foo', 'x = 42'); | 81 compileAndMatchFuzzy(TEST_THREE, 'foo', 'x = 42'); |
| 71 | 82 |
| 72 var generated = compile(TEST_FOUR, entry: 'foo'); | |
| 73 compileAndDoNotMatchFuzzy(TEST_FOUR, 'foo', '(x) = \1;'); | 83 compileAndDoNotMatchFuzzy(TEST_FOUR, 'foo', '(x) = \1;'); |
| 84 | |
| 85 compileAndDoNotMatch(TEST_FIVE, 'main', new RegExp('hash0')); | |
| 74 } | 86 } |
| OLD | NEW |