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 | 4 |
5 #import("compiler_helper.dart"); | 5 #import("compiler_helper.dart"); |
6 | 6 |
7 final String TEST_ONE = @""" | 7 const String TEST_ONE = @""" |
8 foo(a) { | 8 foo(a) { |
9 int c = foo(true); | 9 int c = foo(true); |
10 if (a) c = foo(2); | 10 if (a) c = foo(2); |
11 return c; | 11 return c; |
12 } | 12 } |
13 """; | 13 """; |
14 | 14 |
15 | 15 |
16 final String TEST_TWO = @""" | 16 const String TEST_TWO = @""" |
17 bar(a) {} | 17 bar(a) {} |
18 foo(d) { | 18 foo(d) { |
19 int a = 1; | 19 int a = 1; |
20 int c = foo(1); | 20 int c = foo(1); |
21 if (true) {} | 21 if (true) {} |
22 return a + c; | 22 return a + c; |
23 } | 23 } |
24 """; | 24 """; |
25 | 25 |
26 final String TEST_THREE = @""" | 26 const String TEST_THREE = @""" |
27 foo(int param1, int param2) { | 27 foo(int param1, int param2) { |
28 return 0 + param1 + param2; | 28 return 0 + param1 + param2; |
29 } | 29 } |
30 """; | 30 """; |
31 | 31 |
32 final String TEST_THREE_WITH_BAILOUT = @""" | 32 const String TEST_THREE_WITH_BAILOUT = @""" |
33 foo(int param1, int param2) { | 33 foo(int param1, int param2) { |
34 var t; | 34 var t; |
35 for (int i = 0; i < 1; i++) { | 35 for (int i = 0; i < 1; i++) { |
36 t = 0 + param1 + param2; | 36 t = 0 + param1 + param2; |
37 } | 37 } |
38 return t; | 38 return t; |
39 } | 39 } |
40 """; | 40 """; |
41 | 41 |
42 main() { | 42 main() { |
(...skipping 13 matching lines...) Expand all Loading... |
56 Expect.isTrue(regexp.hasMatch(generated)); | 56 Expect.isTrue(regexp.hasMatch(generated)); |
57 regexp = new RegExp(getNumberTypeCheck('param2')); | 57 regexp = new RegExp(getNumberTypeCheck('param2')); |
58 Expect.isTrue(regexp.hasMatch(generated)); | 58 Expect.isTrue(regexp.hasMatch(generated)); |
59 | 59 |
60 generated = compile(TEST_THREE_WITH_BAILOUT, 'foo'); | 60 generated = compile(TEST_THREE_WITH_BAILOUT, 'foo'); |
61 regexp = new RegExp(getNumberTypeCheck('param1')); | 61 regexp = new RegExp(getNumberTypeCheck('param1')); |
62 Expect.isTrue(regexp.hasMatch(generated)); | 62 Expect.isTrue(regexp.hasMatch(generated)); |
63 regexp = new RegExp(getNumberTypeCheck('param2')); | 63 regexp = new RegExp(getNumberTypeCheck('param2')); |
64 Expect.isTrue(regexp.hasMatch(generated)); | 64 Expect.isTrue(regexp.hasMatch(generated)); |
65 } | 65 } |
OLD | NEW |