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 final String TEST_ONE = @""" | 8 const String TEST_ONE = @""" |
9 void foo(bar) { | 9 void foo(bar) { |
10 var a = 1; | 10 var a = 1; |
11 if (bar) { | 11 if (bar) { |
12 a = 2; | 12 a = 2; |
13 } else { | 13 } else { |
14 a = 3; | 14 a = 3; |
15 } | 15 } |
16 print(a); | 16 print(a); |
17 } | 17 } |
18 """; | 18 """; |
19 | 19 |
20 final String TEST_TWO = @""" | 20 const String TEST_TWO = @""" |
21 void main() { | 21 void main() { |
22 var t = 0; | 22 var t = 0; |
23 for (var i = 0; i == 0; i = i + 1) { | 23 for (var i = 0; i == 0; i = i + 1) { |
24 t = t + 10; | 24 t = t + 10; |
25 } | 25 } |
26 print(t); | 26 print(t); |
27 } | 27 } |
28 """; | 28 """; |
29 | 29 |
30 final String TEST_THREE = @""" | 30 const String TEST_THREE = @""" |
31 foo(b, c, d) { | 31 foo(b, c, d) { |
32 var val = 42; | 32 var val = 42; |
33 if (b) { | 33 if (b) { |
34 c = c && d; | 34 c = c && d; |
35 if (c) { | 35 if (c) { |
36 val = 43; | 36 val = 43; |
37 } | 37 } |
38 } | 38 } |
39 return val; | 39 return val; |
40 } | 40 } |
41 """; | 41 """; |
42 | 42 |
43 final String TEST_FOUR = @""" | 43 const String TEST_FOUR = @""" |
44 foo() { | 44 foo() { |
45 var cond1 = true; | 45 var cond1 = true; |
46 var cond2 = false; | 46 var cond2 = false; |
47 for (var i = 0; cond1; i = i + 1) { | 47 for (var i = 0; cond1; i = i + 1) { |
48 if (i == 9) cond1 = false; | 48 if (i == 9) cond1 = false; |
49 for (var j = 0; cond2; j = j + 1) { | 49 for (var j = 0; cond2; j = j + 1) { |
50 if (j == 9) cond2 = false; | 50 if (j == 9) cond2 = false; |
51 } | 51 } |
52 } | 52 } |
53 print(cond1); | 53 print(cond1); |
(...skipping 27 matching lines...) Expand all Loading... |
81 Expect.isTrue(regexp.hasMatch(generated)); | 81 Expect.isTrue(regexp.hasMatch(generated)); |
82 | 82 |
83 generated = compile(TEST_FOUR, 'foo'); | 83 generated = compile(TEST_FOUR, 'foo'); |
84 | 84 |
85 regexp = const RegExp("cond1 = cond1;"); | 85 regexp = const RegExp("cond1 = cond1;"); |
86 Expect.isTrue(!regexp.hasMatch(generated)); | 86 Expect.isTrue(!regexp.hasMatch(generated)); |
87 | 87 |
88 regexp = const RegExp("cond2 = cond2;"); | 88 regexp = const RegExp("cond2 = cond2;"); |
89 Expect.isTrue(!regexp.hasMatch(generated)); | 89 Expect.isTrue(!regexp.hasMatch(generated)); |
90 } | 90 } |
OLD | NEW |