| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'compiler_helper.dart'; | 6 import 'compiler_helper.dart'; |
| 7 | 7 |
| 8 const String TEST_ONE = r""" | 8 const String TEST_ONE = r""" |
| 9 foo(a) { | 9 foo(a) { |
| 10 // Make sure there is a bailout version. | 10 // Make sure there is a bailout version. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 main() { | 36 main() { |
| 37 var generated = compile(TEST_ONE, entry: 'foo'); | 37 var generated = compile(TEST_ONE, entry: 'foo'); |
| 38 // Check that the one shot interceptor got converted to a direct | 38 // Check that the one shot interceptor got converted to a direct |
| 39 // call to the interceptor object. | 39 // call to the interceptor object. |
| 40 Expect.isTrue(generated.contains('JSNumber_methods.get\$toString(a + 42);')); | 40 Expect.isTrue(generated.contains('JSNumber_methods.get\$toString(a + 42);')); |
| 41 | 41 |
| 42 // Check that one-shot interceptors preserve variable names, see | 42 // Check that one-shot interceptors preserve variable names, see |
| 43 // https://code.google.com/p/dart/issues/detail?id=8106. | 43 // https://code.google.com/p/dart/issues/detail?id=8106. |
| 44 generated = compile(TEST_TWO, entry: 'foo'); | 44 generated = compile(TEST_TWO, entry: 'foo'); |
| 45 Expect.isTrue(generated.contains(r'$.$add$n(a, 42)')); | 45 Expect.isTrue(generated.contains(new RegExp(r'[$a-z]+\.\$add\$n\(a, 42\)'))); |
| 46 Expect.isTrue(generated.contains('myVariableName')); | 46 Expect.isTrue(generated.contains('myVariableName')); |
| 47 | 47 |
| 48 // Check that an intercepted getter that does not need to be | 48 // Check that an intercepted getter that does not need to be |
| 49 // intercepted, is turned into a regular getter call or field | 49 // intercepted, is turned into a regular getter call or field |
| 50 // access. | 50 // access. |
| 51 generated = compile(TEST_THREE, entry: 'foo'); | 51 generated = compile(TEST_THREE, entry: 'foo'); |
| 52 Expect.isFalse(generated.contains(r'a.get$length()')); | 52 Expect.isFalse(generated.contains(r'a.get$length()')); |
| 53 Expect.isTrue(generated.contains(r'$.A$().length')); | 53 Expect.isTrue(generated.contains(new RegExp(r'[$a-z]+\.A\$\(\)\.length'))); |
| 54 Expect.isTrue(generated.contains(r'$.get$length$a(a)')); | 54 Expect.isTrue( |
| 55 generated.contains(new RegExp(r'[$a-z]+\.get\$length\$a\(a\)'))); |
| 55 } | 56 } |
| OLD | NEW |