| 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 '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 // Tests for | 10 // Tests for |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 """; | 39 """; |
| 40 | 40 |
| 41 main() { | 41 main() { |
| 42 Future check(String test, String contained) { | 42 Future check(String test, String contained) { |
| 43 return compile(test, entry: 'foo').then((String generated) { | 43 return compile(test, entry: 'foo').then((String generated) { |
| 44 Expect.isTrue(generated.contains(contained), contained); | 44 Expect.isTrue(generated.contains(contained), contained); |
| 45 }); | 45 }); |
| 46 } | 46 } |
| 47 | 47 |
| 48 asyncTest(() => Future.wait([ | 48 asyncTest(() => Future.wait([ |
| 49 // Full substitution. | 49 // Full substitution. |
| 50 check(TEST_1, r'"u120vhellow"'), | 50 check(TEST_1, r'"u120vhellow"'), |
| 51 | 51 |
| 52 // Adjacent string fragments get merged. | 52 // Adjacent string fragments get merged. |
| 53 check(TEST_2, r'"xxxxxyyyyy"'), | 53 check(TEST_2, r'"xxxxxyyyyy"'), |
| 54 | 54 |
| 55 // 1. No merging of fragments that are multi-use. Prevents exponential code | 55 // 1. No merging of fragments that are multi-use. Prevents exponential
code |
| 56 // and keeps author's manual CSE. | 56 // and keeps author's manual CSE. |
| 57 // 2. Know string values require no stringification. | 57 // 2. Know string values require no stringification. |
| 58 check(TEST_3, r'return b + "x" + b'), | 58 check(TEST_3, r'return b + "x" + b'), |
| 59 | 59 |
| 60 // Known int value can be formatted directly. | 60 // Known int value can be formatted directly. |
| 61 check(TEST_4, r'return "" + b.length'), | 61 check(TEST_4, r'return "" + b.length'), |
| 62 ])); | 62 ])); |
| 63 } | 63 } |
| OLD | NEW |