| 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""" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 '#.toLowerCase()', s); | 50 '#.toLowerCase()', s); |
| 51 var s2 = JS('returns:String;depends:none;effects:none;throws:null(1)', | 51 var s2 = JS('returns:String;depends:none;effects:none;throws:null(1)', |
| 52 '#.toUpperCase()', s); | 52 '#.toUpperCase()', s); |
| 53 print(s2); | 53 print(s2); |
| 54 | 54 |
| 55 // absent: 'toLowerCase' - removed since s.toUpperCase() generates the same | 55 // absent: 'toLowerCase' - removed since s.toUpperCase() generates the same |
| 56 // noSuchMethod. | 56 // noSuchMethod. |
| 57 } | 57 } |
| 58 """; | 58 """; |
| 59 | 59 |
| 60 const String TEST_4 = r""" |
| 61 import 'dart:_foreign_helper'; |
| 62 main() { |
| 63 var s = JS('String|Null', '"Hello"'); |
| 64 var s1 = JS('returns:String;depends:none;effects:none;throws:null(1)', |
| 65 '#.toLowerCase()', s); |
| 66 var s2 = JS('returns:String;depends:none;effects:none;throws:null(1)', |
| 67 '#.toUpperCase()', s); |
| 68 |
| 69 // present: 'erCase' - retained at least one call to guarantee exception. |
| 70 } |
| 71 """; |
| 72 |
| 73 const String TEST_5 = r""" |
| 74 import 'dart:_foreign_helper'; |
| 75 main() { |
| 76 var s = JS('String', '"Hello"'); |
| 77 var s1 = JS('returns:String;depends:none;effects:none;throws:null(1)', |
| 78 '#.toLowerCase()', s); |
| 79 var s2 = JS('returns:String;depends:none;effects:none;throws:null(1)', |
| 80 '#.toUpperCase()', s); |
| 81 |
| 82 // absent: 'erCase' - neither call needs to be retained since there is no |
| 83 // exception. |
| 84 } |
| 85 """; |
| 86 |
| 60 main() { | 87 main() { |
| 61 RegExp directivePattern = new RegExp( | 88 RegExp directivePattern = new RegExp( |
| 62 // \1 \2 \3 | 89 // \1 \2 \3 |
| 63 r'''// *(present|absent): (?:"([^"]*)"|'([^'']*)')''', | 90 r'''// *(present|absent): (?:"([^"]*)"|'([^'']*)')''', |
| 64 multiLine: true); | 91 multiLine: true); |
| 65 | 92 |
| 66 Future check(String test) { | 93 Future check(String test) { |
| 67 Uri uri = new Uri(scheme: 'dart', path: 'test'); | 94 Uri uri = new Uri(scheme: 'dart', path: 'test'); |
| 68 var compiler = compilerFor(test, uri, expectedErrors: 0); | 95 var compiler = compilerFor(test, uri, expectedErrors: 0); |
| 69 return compiler.run(uri).then((_) { | 96 return compiler.run(uri).then((_) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 83 "Must not find '$pattern' in:\n$generated"); | 110 "Must not find '$pattern' in:\n$generated"); |
| 84 } | 111 } |
| 85 } | 112 } |
| 86 }); | 113 }); |
| 87 } | 114 } |
| 88 | 115 |
| 89 asyncTest(() => Future.wait([ | 116 asyncTest(() => Future.wait([ |
| 90 check(TEST_1), | 117 check(TEST_1), |
| 91 check(TEST_2), | 118 check(TEST_2), |
| 92 check(TEST_3), | 119 check(TEST_3), |
| 120 check(TEST_4), |
| 121 check(TEST_5), |
| 93 ])); | 122 ])); |
| 94 } | 123 } |
| OLD | NEW |