| 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 final String TEST_ONE = @""" |
| 8 foo(a) { | 8 foo(a) { |
| 9 int c = foo(1); | 9 int c = foo(1); |
| 10 if (a) c = foo(2); | 10 if (a) c = foo(2); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 return a + c; | 22 return a + c; |
| 23 } | 23 } |
| 24 """; | 24 """; |
| 25 | 25 |
| 26 final String TEST_THREE = @""" | 26 final 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 = @""" | |
| 33 foo(int param1, int param2) { | |
| 34 var t; | |
| 35 for (int i = 0; i < 1; i++) { | |
| 36 t = 0 + param1 + param2; | |
| 37 } | |
| 38 return t; | |
| 39 } | |
| 40 """; | |
| 41 | 32 |
| 42 main() { | 33 main() { |
| 43 String generated = compile(TEST_ONE, 'foo'); | 34 String generated = compile(TEST_ONE, 'foo'); |
| 44 RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier)); | 35 RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier)); |
| 45 Iterator<Match> matches = regexp.allMatches(generated).iterator(); | 36 Iterator<Match> matches = regexp.allMatches(generated).iterator(); |
| 46 checkNumberOfMatches(matches, 0); | 37 checkNumberOfMatches(matches, 0); |
| 47 | 38 |
| 48 regexp = const RegExp("return c;"); | 39 regexp = const RegExp("return c;"); |
| 49 Expect.isTrue(regexp.hasMatch(generated)); | 40 Expect.isTrue(regexp.hasMatch(generated)); |
| 50 | 41 |
| 51 generated = compile(TEST_TWO, 'foo'); | 42 generated = compile(TEST_TWO, 'foo'); |
| 52 regexp = const RegExp("foo\\(1\\)"); | 43 regexp = const RegExp("foo\\(1\\)"); |
| 53 matches = regexp.allMatches(generated).iterator(); | 44 matches = regexp.allMatches(generated).iterator(); |
| 54 checkNumberOfMatches(matches, 1); | 45 checkNumberOfMatches(matches, 1); |
| 55 | 46 |
| 56 generated = compile(TEST_THREE, 'foo'); | 47 generated = compile(TEST_THREE, 'foo'); |
| 57 regexp = new RegExp(getNumberTypeCheck('param1')); | 48 regexp = new RegExp(getNumberTypeCheck('param1')); |
| 58 Expect.isTrue(!regexp.hasMatch(generated)); | |
| 59 regexp = new RegExp(getNumberTypeCheck('param2')); | |
| 60 Expect.isTrue(!regexp.hasMatch(generated)); | |
| 61 | |
| 62 generated = compile(TEST_THREE_WITH_BAILOUT, 'foo'); | |
| 63 regexp = new RegExp(getNumberTypeCheck('param1')); | |
| 64 Expect.isTrue(regexp.hasMatch(generated)); | 49 Expect.isTrue(regexp.hasMatch(generated)); |
| 65 regexp = new RegExp(getNumberTypeCheck('param2')); | 50 regexp = new RegExp(getNumberTypeCheck('param2')); |
| 66 Expect.isTrue(regexp.hasMatch(generated)); | 51 Expect.isTrue(regexp.hasMatch(generated)); |
| 67 } | 52 } |
| OLD | NEW |