| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import 'compiler_helper.dart'; | 8 import 'compiler_helper.dart'; |
| 9 | 9 |
| 10 const String TEST_1 = r""" | 10 const String TEST_1 = r""" |
| 11 import 'dart:_foreign_helper'; | 11 import 'dart:_foreign_helper'; |
| 12 main() { | 12 main() { |
| 13 JS('', '#.toString()', -5); | 13 JS('', '#.toString()', -5); |
| 14 // absent: "5.toString" | 14 // absent: "5.toString" |
| 15 // present: "(-5).toString" | 15 // present: "(-5).toString" |
| 16 } | 16 } |
| 17 """; | 17 """; |
| 18 | 18 |
| 19 | |
| 20 main() { | 19 main() { |
| 21 RegExp directivePattern = new RegExp( | 20 RegExp directivePattern = new RegExp( |
| 22 // \1 \2 \3 | 21 // \1 \2 \3 |
| 23 r'''// *(present|absent): (?:"([^"]*)"|'([^'']*)')''', | 22 r'''// *(present|absent): (?:"([^"]*)"|'([^'']*)')''', |
| 24 multiLine: true); | 23 multiLine: true); |
| 25 | 24 |
| 26 Future check(String test) { | 25 Future check(String test) { |
| 27 Uri uri = new Uri(scheme: 'dart', path: 'test'); | 26 Uri uri = new Uri(scheme: 'dart', path: 'test'); |
| 28 var compiler = compilerFor(test, uri, expectedErrors: 0); | 27 var compiler = compilerFor(test, uri, expectedErrors: 0); |
| 29 return compiler.run(uri).then((_) { | 28 return compiler.run(uri).then((_) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 40 } else { | 39 } else { |
| 41 assert(directive == 'absent'); | 40 assert(directive == 'absent'); |
| 42 Expect.isFalse(generated.contains(pattern), | 41 Expect.isFalse(generated.contains(pattern), |
| 43 "Must not find '$pattern' in:\n$generated"); | 42 "Must not find '$pattern' in:\n$generated"); |
| 44 } | 43 } |
| 45 } | 44 } |
| 46 }); | 45 }); |
| 47 } | 46 } |
| 48 | 47 |
| 49 asyncTest(() => Future.wait([ | 48 asyncTest(() => Future.wait([ |
| 50 check(TEST_1), | 49 check(TEST_1), |
| 51 ])); | 50 ])); |
| 52 } | 51 } |
| OLD | NEW |