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 FOO = @""" | 8 const String FOO = @""" |
9 void foo(var a, var b) { | 9 void foo(var a, var b) { |
10 } | 10 } |
11 """; | 11 """; |
12 | 12 |
13 | 13 |
14 final String BAR = @""" | 14 const String BAR = @""" |
15 void bar(var eval, var $eval) { | 15 void bar(var eval, var $eval) { |
16 } | 16 } |
17 """; | 17 """; |
18 | 18 |
19 | 19 |
20 final String PARAMETER_AND_TEMP = @""" | 20 const String PARAMETER_AND_TEMP = @""" |
21 void bar(var t0, var b) { | 21 void bar(var t0, var b) { |
22 { | 22 { |
23 var t0 = 2; | 23 var t0 = 2; |
24 if (b) { | 24 if (b) { |
25 t0 = 4; | 25 t0 = 4; |
26 } else { | 26 } else { |
27 t0 = 3; | 27 t0 = 3; |
28 } | 28 } |
29 print(t0); | 29 print(t0); |
30 } | 30 } |
31 print(t0); | 31 print(t0); |
32 } | 32 } |
33 """; | 33 """; |
34 | 34 |
35 final String NO_LOCAL = @""" | 35 const String NO_LOCAL = @""" |
36 foo(bar, baz) { | 36 foo(bar, baz) { |
37 if (bar) { | 37 if (bar) { |
38 baz = 2; | 38 baz = 2; |
39 } else { | 39 } else { |
40 baz = 3; | 40 baz = 3; |
41 } | 41 } |
42 return baz; | 42 return baz; |
43 } | 43 } |
44 """; | 44 """; |
45 | 45 |
46 final String MULTIPLE_PHIS_ONE_LOCAL = @""" | 46 const String MULTIPLE_PHIS_ONE_LOCAL = @""" |
47 foo(param1, param2, param3) { | 47 foo(param1, param2, param3) { |
48 var a = 2; | 48 var a = 2; |
49 if (param1) { | 49 if (param1) { |
50 if (param2) { | 50 if (param2) { |
51 if (param3) { | 51 if (param3) { |
52 a = 42; | 52 a = 42; |
53 } | 53 } |
54 } | 54 } |
55 } | 55 } |
56 return a; | 56 return a; |
57 } | 57 } |
58 """; | 58 """; |
59 | 59 |
60 final String PARAMETER_INIT = @""" | 60 const String PARAMETER_INIT = @""" |
61 int foo(var start, bool test) { | 61 int foo(var start, bool test) { |
62 var result = start; | 62 var result = start; |
63 if (test) { | 63 if (test) { |
64 result = 42; | 64 result = 42; |
65 } | 65 } |
66 return result; | 66 return result; |
67 } | 67 } |
68 """; | 68 """; |
69 | 69 |
70 main() { | 70 main() { |
(...skipping 30 matching lines...) Expand all Loading... |
101 regexp = const RegExp(@"a = 2;"); | 101 regexp = const RegExp(@"a = 2;"); |
102 Iterator matches = regexp.allMatches(generated).iterator(); | 102 Iterator matches = regexp.allMatches(generated).iterator(); |
103 Expect.isTrue(matches.hasNext()); | 103 Expect.isTrue(matches.hasNext()); |
104 matches.next(); | 104 matches.next(); |
105 Expect.isFalse(matches.hasNext()); | 105 Expect.isFalse(matches.hasNext()); |
106 | 106 |
107 generated = compile(PARAMETER_INIT, 'foo'); | 107 generated = compile(PARAMETER_INIT, 'foo'); |
108 regexp = const RegExp("var result = start;"); | 108 regexp = const RegExp("var result = start;"); |
109 Expect.isTrue(regexp.hasMatch(generated)); | 109 Expect.isTrue(regexp.hasMatch(generated)); |
110 } | 110 } |
OLD | NEW |