| 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); |
| 11 return c; | 11 return c; |
| 12 } | 12 } |
| 13 """; | 13 """; |
| 14 | 14 |
| 15 | 15 |
| 16 final String TEST_TWO = @""" | 16 final String TEST_TWO = @""" |
| 17 bar(a) {} | 17 bar(a) {} |
| 18 foo() { | 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 final String TEST_THREE = @""" |
| 27 foo(int param1, int param2) { | 27 foo(int param1, int param2) { |
| 28 return param1 + param2; | 28 return param1 + param2; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 main() { | 40 main() { |
| 41 String generated = compile(TEST_ONE, 'foo'); | 41 String generated = compile(TEST_ONE, 'foo'); |
| 42 RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier)); | 42 RegExp regexp = new RegExp(getIntTypeCheck(anyIdentifier)); |
| 43 Iterator<Match> matches = regexp.allMatches(generated).iterator(); | 43 Iterator<Match> matches = regexp.allMatches(generated).iterator(); |
| 44 checkNumberOfMatches(matches, 0); | 44 checkNumberOfMatches(matches, 0); |
| 45 | 45 |
| 46 regexp = const RegExp("return c;"); | 46 regexp = const RegExp("return c;"); |
| 47 Expect.isTrue(regexp.hasMatch(generated)); | 47 Expect.isTrue(regexp.hasMatch(generated)); |
| 48 | 48 |
| 49 generated = compile(TEST_TWO, 'foo'); | 49 generated = compile(TEST_TWO, 'foo'); |
| 50 regexp = const RegExp("foo\\(1\\)"); | 50 regexp = const RegExp("foo\\\$1\\(1\\)"); |
| 51 matches = regexp.allMatches(generated).iterator(); | 51 matches = regexp.allMatches(generated).iterator(); |
| 52 checkNumberOfMatches(matches, 1); | 52 checkNumberOfMatches(matches, 1); |
| 53 | 53 |
| 54 generated = compile(TEST_THREE, 'foo'); | 54 generated = compile(TEST_THREE, 'foo'); |
| 55 regexp = new RegExp(getIntTypeCheck('param1')); | 55 regexp = new RegExp(getIntTypeCheck('param1')); |
| 56 Expect.isTrue(regexp.hasMatch(generated)); | 56 Expect.isTrue(regexp.hasMatch(generated)); |
| 57 regexp = new RegExp(getIntTypeCheck('param2')); | 57 regexp = new RegExp(getIntTypeCheck('param2')); |
| 58 Expect.isTrue(regexp.hasMatch(generated)); | 58 Expect.isTrue(regexp.hasMatch(generated)); |
| 59 } | 59 } |
| OLD | NEW |