Chromium Code Reviews| 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"\n\r\u2028\u2029")); | 20 Expect.isTrue(generated.contains(r"\r\u2028\u2029")); |
| 21 }), | 21 }), |
| 22 compileExpression("r''' \n\r\u2028\u2029'''").then((String generated) { | 22 compileExpression("r''' \n\r\u2028\u2029'''").then((String generated) { |
| 23 Expect.isTrue(generated.contains(r"\n\r\u2028\u2029")); | 23 Expect.isTrue(generated.contains(r"\r\u2028\u2029")); |
|
Johnni Winther
2014/06/18 08:43:44
Add tests for \r, \n, \r\n adn \n\r.
Lasse Reichstein Nielsen
2014/06/18 09:05:32
.. where \n\r is not a line-terminator sequence, s
floitsch
2014/06/18 12:14:23
Done.
floitsch
2014/06/18 12:14:23
Done.
| |
| 24 }), | |
| 25 compileExpression("r'''\t\t \t\t \t\t \t \t \n\r\u2028\u2029'''") | |
| 26 .then((String generated) { | |
| 27 Expect.isTrue(generated.contains(r"\r\u2028\u2029")); | |
| 28 }), | |
| 29 compileExpression("r'''\t\t \t\t \t\t \t \t \\\n\r\u2028\u2029'''") | |
| 30 .then((String generated) { | |
| 31 Expect.isTrue(generated.contains(r"\r\u2028\u2029")); | |
| 24 }), | 32 }), |
|
Lasse Reichstein Nielsen
2014/06/17 15:56:52
Also test backslashes before other whitespace char
floitsch
2014/06/18 12:14:23
Not tested (and not being accepted):
\\\r\\\n
That
| |
| 25 compileExpression("'\u2028\u2029'").then((String generated) { | 33 compileExpression("'\u2028\u2029'").then((String generated) { |
| 26 Expect.isTrue(generated.contains(r"\u2028\u2029")); | 34 Expect.isTrue(generated.contains(r"\u2028\u2029")); |
| 27 }), | 35 }), |
| 28 ])); | 36 ])); |
| 29 } | 37 } |
| OLD | NEW |