OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 import 'package:compiler/src/util/command_line.dart'; | 6 import 'package:compiler/src/util/command_line.dart'; |
7 | 7 |
8 main() { | 8 main() { |
9 Expect.listEquals(["foo", "bar"], splitLine("foo bar")); | 9 Expect.listEquals(["foo", "bar"], splitLine("foo bar")); |
10 Expect.listEquals(["foo", "bar"], splitLine("foo bar", windows: true)); | 10 Expect.listEquals(["foo", "bar"], splitLine("foo bar", windows: true)); |
11 | 11 |
12 Expect.listEquals(["foo bar"], splitLine(r"foo\ bar")); | 12 Expect.listEquals(["foo bar"], splitLine(r"foo\ bar")); |
13 Expect.listEquals(["foo\\", "bar"], splitLine(r"foo\ bar", windows: true)); | 13 Expect.listEquals(["foo\\", "bar"], splitLine(r"foo\ bar", windows: true)); |
14 | 14 |
15 Expect.listEquals(["foo'", '"bar'], splitLine(r"""foo\' \"bar""")); | 15 Expect.listEquals(["foo'", '"bar'], splitLine(r"""foo\' \"bar""")); |
16 Expect.listEquals(["foo\\'", '"bar'], | 16 Expect.listEquals( |
17 splitLine(r"""foo\' \"bar""", windows: true)); | 17 ["foo\\'", '"bar'], splitLine(r"""foo\' \"bar""", windows: true)); |
18 | 18 |
19 Expect.listEquals(["foo'", '"bar'], splitLine(r"""foo"'" '"'bar""")); | 19 Expect.listEquals(["foo'", '"bar'], splitLine(r"""foo"'" '"'bar""")); |
20 Expect.throws(() => splitLine(r"""foo"'" '"'bar""", windows: true), | 20 Expect.throws(() => splitLine(r"""foo"'" '"'bar""", windows: true), |
21 (e) => e is FormatException); | 21 (e) => e is FormatException); |
22 Expect.listEquals(["foo'", "''bar"], | 22 Expect.listEquals( |
23 splitLine(r"""foo"'" '"'bar" """, windows: true)); | 23 ["foo'", "''bar"], splitLine(r"""foo"'" '"'bar" """, windows: true)); |
24 | 24 |
25 Expect.listEquals(["foo", "bar"], splitLine("'f''o''o' " + '"b""a""r"')); | 25 Expect.listEquals(["foo", "bar"], splitLine("'f''o''o' " + '"b""a""r"')); |
26 // TODO(johnniwinther): This is not actual Windows behavior: "b""a" is | 26 // TODO(johnniwinther): This is not actual Windows behavior: "b""a" is |
27 // interpreted as b"a but "b""a""r" is interpreted as b"ar. | 27 // interpreted as b"a but "b""a""r" is interpreted as b"ar. |
28 Expect.listEquals(["'f''o''o'", "bar"], | 28 Expect.listEquals(["'f''o''o'", "bar"], |
29 splitLine("'f''o''o' " + '"b""a""r"', windows: true)); | 29 splitLine("'f''o''o' " + '"b""a""r"', windows: true)); |
30 | 30 |
31 Expect.listEquals(["\n", "\r", "\t", "\b", "\f", "\v", "\\", | 31 Expect.listEquals( |
32 "a", "Z", "-", '"', "'"], | 32 ["\n", "\r", "\t", "\b", "\f", "\v", "\\", "a", "Z", "-", '"', "'"], |
33 splitLine(r"""\n \r \t \b \f \v \\ \a \Z \- \" \'""")); | 33 splitLine(r"""\n \r \t \b \f \v \\ \a \Z \- \" \'""")); |
34 Expect.listEquals(["\\n", "\\r", "\\t", "\\b", "\\f", "\\v", | 34 Expect.listEquals([ |
35 "\\", "\\a", "\\Z", "\\-", '"', "\\'"], | 35 "\\n", |
36 splitLine(r"""\n \r \t \b \f \v \\ \a \Z \- \" \'""", | 36 "\\r", |
37 windows: true)); | 37 "\\t", |
38 Expect.listEquals(["C:Users\foo\bar\baz.dart"], | 38 "\\b", |
39 splitLine(r"C:\Users\foo\bar\baz.dart")); | 39 "\\f", |
| 40 "\\v", |
| 41 "\\", |
| 42 "\\a", |
| 43 "\\Z", |
| 44 "\\-", |
| 45 '"', |
| 46 "\\'" |
| 47 ], splitLine(r"""\n \r \t \b \f \v \\ \a \Z \- \" \'""", windows: true)); |
| 48 Expect.listEquals( |
| 49 ["C:Users\foo\bar\baz.dart"], splitLine(r"C:\Users\foo\bar\baz.dart")); |
40 Expect.listEquals([r"C:\Users\foo\bar\baz.dart"], | 50 Expect.listEquals([r"C:\Users\foo\bar\baz.dart"], |
41 splitLine(r"C:\Users\foo\bar\baz.dart", windows: true)); | 51 splitLine(r"C:\Users\foo\bar\baz.dart", windows: true)); |
42 | 52 |
43 Expect.listEquals(["C:Users\foo\bar\name with spaces.dart"], | 53 Expect.listEquals(["C:Users\foo\bar\name with spaces.dart"], |
44 splitLine(r'"C:\Users\foo\bar\name with spaces.dart"')); | 54 splitLine(r'"C:\Users\foo\bar\name with spaces.dart"')); |
45 Expect.listEquals([r"C:\Users\foo\bar\name with spaces.dart"], | 55 Expect.listEquals([r"C:\Users\foo\bar\name with spaces.dart"], |
46 splitLine(r'"C:\Users\foo\bar\name with spaces.dart"', windows: true)); | 56 splitLine(r'"C:\Users\foo\bar\name with spaces.dart"', windows: true)); |
47 | 57 |
48 Expect.throws(() => splitLine(r"\"), (e) => e is FormatException); | 58 Expect.throws(() => splitLine(r"\"), (e) => e is FormatException); |
49 Expect.throws(() => splitLine(r"\", windows: true), | 59 Expect.throws( |
50 (e) => e is FormatException); | 60 () => splitLine(r"\", windows: true), (e) => e is FormatException); |
51 } | 61 } |
OLD | NEW |