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 '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 // Test that the compiler handles string literals containing line terminators. | 10 // Test that the compiler handles string literals containing line terminators. |
11 | 11 |
12 Future<String> compileExpression(String expression) { | 12 Future<String> compileExpression(String expression) { |
13 var source = "foo() { return $expression; }"; | 13 var source = "foo() { return $expression; }"; |
14 return compile(source, entry: "foo"); | 14 return compile(source, entry: "foo"); |
15 } | 15 } |
16 | 16 |
17 main() { | 17 main() { |
18 asyncTest(() => Future.wait([ | 18 asyncTest(() => Future.wait([ |
19 compileExpression("''' \n\r\u2028\u2029'''").then((String generated) { | 19 compileExpression("''' \n\r\u2028\u2029'''").then((String generated) { |
20 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || | 20 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || |
21 generated.contains(r"'\r\u2028\u2029'")); | 21 generated.contains(r"'\r\u2028\u2029'")); |
22 }), | 22 }), |
23 compileExpression("r''' \n\r\u2028\u2029'''").then((String generated) { | 23 compileExpression("r''' \n\r\u2028\u2029'''").then((String generated) { |
24 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || | 24 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || |
25 generated.contains(r"'\r\u2028\u2029'")); | 25 generated.contains(r"'\r\u2028\u2029'")); |
26 }), | 26 }), |
27 compileExpression("r''' \r\n\u2028\u2029'''").then((String generated) { | 27 compileExpression("r''' \r\n\u2028\u2029'''").then((String generated) { |
28 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || | 28 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || |
29 generated.contains(r"'\u2028\u2029'")); | 29 generated.contains(r"'\u2028\u2029'")); |
30 }), | 30 }), |
31 compileExpression("r''' \r\u2028\u2029'''").then((String generated) { | 31 compileExpression("r''' \r\u2028\u2029'''").then((String generated) { |
32 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || | 32 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || |
33 generated.contains(r"'\u2028\u2029'")); | 33 generated.contains(r"'\u2028\u2029'")); |
34 }), | 34 }), |
35 compileExpression("r''' \n\u2028\u2029'''").then((String generated) { | 35 compileExpression("r''' \n\u2028\u2029'''").then((String generated) { |
36 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || | 36 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || |
37 generated.contains(r"'\u2028\u2029'")); | 37 generated.contains(r"'\u2028\u2029'")); |
38 }), | 38 }), |
39 compileExpression("r'''\t\t \t\t \t\t \t \t \n\r\u2028\u2029'''") | 39 compileExpression("r'''\t\t \t\t \t\t \t \t \n\r\u2028\u2029'''") |
40 .then((String generated) { | 40 .then((String generated) { |
41 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || | 41 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || |
42 generated.contains(r"'\r\u2028\u2029'")); | 42 generated.contains(r"'\r\u2028\u2029'")); |
43 }), | 43 }), |
44 compileExpression("r'''\\\t\\\t \\ \\ \t\\\t \t \\\n\r\u2028\u2029'''") | 44 compileExpression( |
45 .then((String generated) { | 45 "r'''\\\t\\\t \\ \\ \t\\\t \t \\\n\r\u2028\u2029'''") |
46 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || | 46 .then((String generated) { |
47 generated.contains(r"'\r\u2028\u2029'")); | 47 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || |
48 }), | 48 generated.contains(r"'\r\u2028\u2029'")); |
49 compileExpression("r'''\t\t \t\t \t\t \t \t \\\n\r\u2028\u2029'''") | 49 }), |
50 .then((String generated) { | 50 compileExpression( |
51 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || | 51 "r'''\t\t \t\t \t\t \t \t \\\n\r\u2028\u2029'''") |
52 generated.contains(r"'\r\u2028\u2029'")); | 52 .then((String generated) { |
53 }), | 53 Expect.isTrue(generated.contains(r'"\r\u2028\u2029"') || |
54 compileExpression("r'''\\\t\\\t \\ \\ \t\\\t \\\r\n\u2028\u2029'''") | 54 generated.contains(r"'\r\u2028\u2029'")); |
55 .then((String generated) { | 55 }), |
56 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || | 56 compileExpression( |
57 generated.contains(r"'\u2028\u2029'")); | 57 "r'''\\\t\\\t \\ \\ \t\\\t \\\r\n\u2028\u2029'''") |
58 }), | 58 .then((String generated) { |
59 compileExpression("r'''\\\t\\\t \\ \\ \t\\\t \\\r\u2028\u2029'''") | 59 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || |
60 .then((String generated) { | 60 generated.contains(r"'\u2028\u2029'")); |
61 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || | 61 }), |
62 generated.contains(r"'\u2028\u2029'")); | 62 compileExpression("r'''\\\t\\\t \\ \\ \t\\\t \\\r\u2028\u2029'''") |
63 }), | 63 .then((String generated) { |
64 compileExpression("'\u2028\u2029'").then((String generated) { | 64 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || |
65 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || | 65 generated.contains(r"'\u2028\u2029'")); |
66 generated.contains(r"'\u2028\u2029'")); | 66 }), |
67 }), | 67 compileExpression("'\u2028\u2029'").then((String generated) { |
68 ])); | 68 Expect.isTrue(generated.contains(r'"\u2028\u2029"') || |
| 69 generated.contains(r"'\u2028\u2029'")); |
| 70 }), |
| 71 ])); |
69 } | 72 } |
OLD | NEW |