Skip to content

Commit 0070331

Browse files
lrhnCommit Queue
authored andcommitted
Only mark tests non-text if they actually depend on line ending.
Some test files were included, where only their data actually depended on line endings. Some tests didn't actually depend on line ending at all. (They may date back to a time where multiline strings didn't normalize their newlines.) Fix some syntax tests that had been formatted, and exempt all files depending on line endings from formatting. Change-Id: I6c003e9c4f03d3b2af102bfca59d4a7bc8e6d63f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434380 Reviewed-by: Devon Carew <[email protected]> Commit-Queue: Lasse Nielsen <[email protected]>
1 parent 390d3f4 commit 0070331

File tree

7 files changed

+116
-459
lines changed

7 files changed

+116
-459
lines changed

.gitattributes

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@
1616

1717
# File that should not be converted.
1818
tests/web/eof_line_ending_test.dart -text
19-
tests/web/string_interpolation_test.dart -text
20-
tests/web/string_interpolation_dynamic_test.dart -text
21-
tests/web/literal_string_juxtaposition_test.dart -text
22-
tests/language/string/raw_string_test.dart -text
23-
tests/language/string/multiline_strings_test.dart -text
2419
tests/language/string/multiline_newline_cr.dart -text
2520
tests/language/string/multiline_newline_crlf.dart -text
2621
tests/language/string/multiline_newline_lf.dart -text
2722
tests/lib/mirrors/method_mirror_source_line_ending_cr.dart -text
2823
tests/lib/mirrors/method_mirror_source_line_ending_crlf.dart -text
2924
tests/lib/mirrors/method_mirror_source_line_ending_lf.dart -text
30-
tests/lib/mirrors/method_mirror_source_line_ending_test.dart -text
3125
tests/lib/mirrors/method_mirror_source_other.dart -text
32-
tests/lib/mirrors/method_mirror_source_test.dart -text
3326

3427
# Files to leave alone and not diff.
3528
*.png binary

tests/language/string/multiline_newline_cr.dart

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,16 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
library multiline_newline_cr;
5+
// Test depends on specific line endings,
6+
// and requires an entry in the .gitattributes file.
67

7-
const constantMultilineString = """
8-
a
9-
b
10-
""";
8+
// dart format off
119

12-
var nonConstantMultilineString = """
13-
a
14-
b
15-
""";
10+
// All line endings inside string literals are Carriage Return, U+000D
11+
const constantMultilineString = """ab""";
1612

17-
const constantRawMultilineString = r"""
18-
\a
19-
\b
20-
""";
13+
var nonConstantMultilineString = """ab""";
2114

22-
var nonConstantRawMultilineString = r"""
23-
\a
24-
\b
25-
""";
15+
const constantRawMultilineString = r"""\a\b""";
16+
17+
var nonConstantRawMultilineString = r"""\a\b""";

tests/language/string/multiline_strings_test.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// Note: This test relies on LF line endings in the source file.
6-
75
import "package:expect/expect.dart";
86

9-
main() {
7+
void main() {
8+
// Spaces after '''.
109
Expect.equals('foo', '''
1110
foo''');
1211

12+
// Tab characters after '''.
13+
Expect.equals('foo', '''
14+
foo''');
15+
1316
Expect.equals('\\\nfoo', '''\\
1417
foo''');
1518

1619
Expect.equals('\t\nfoo', '''\t
1720
foo''');
1821

22+
// Backslash just before newline.
1923
Expect.equals('foo', '''\
2024
foo''');
2125

22-
Expect.equals('foo', '''\ \
26+
// Backslash before space, tab and newline.
27+
Expect.equals('foo', '''\ \ \
2328
foo''');
2429

2530
Expect.equals(' \nfoo', '''\x20
@@ -29,18 +34,25 @@ foo''');
2934
Expect.equals(' \nfoo', '''$x
3035
foo''');
3136

37+
/// Spaces after '''.
3238
Expect.equals('foo', r'''
3339
foo''');
3440

41+
/// Tab characters after '''.
42+
Expect.equals('foo', r'''
43+
foo''');
44+
3545
Expect.equals('\\\\\nfoo', r'''\\
3646
foo''');
3747

3848
Expect.equals('\\t\nfoo', r'''\t
3949
foo''');
4050

51+
// Backslash before newline.
4152
Expect.equals('foo', r'''\
4253
foo''');
4354

44-
Expect.equals('foo', r'''\ \
55+
// Backslash before space, tab and newline.
56+
Expect.equals('foo', r'''\ \ \
4557
foo''');
4658
}

tests/language/string/raw_string_test.dart

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,40 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// Note: This test relies on LF line endings in the source file.
6-
75
import "package:expect/expect.dart";
86

9-
class RawStringTest {
10-
static testMain() {
11-
Expect.equals("abcd", r"abcd");
12-
Expect.equals("", r"");
13-
Expect.equals("", r'');
14-
Expect.equals("", r"""""");
15-
Expect.equals("", r'''''');
16-
Expect.equals("''''", r"''''");
17-
Expect.equals('""""', r'""""');
18-
Expect.equals("1\n2\n3", r"""1
7+
void main() {
8+
Expect.equals("abcd", r"abcd");
9+
Expect.equals("", r"");
10+
Expect.equals("", r'');
11+
Expect.equals("", r"""""");
12+
Expect.equals("", r'''''');
13+
Expect.equals("''''", r"''''");
14+
Expect.equals('""""', r'""""');
15+
Expect.equals("1\n2\n3", r"""1
1916
2
2017
3""");
21-
Expect.equals("1\n2\n3", r'''1
18+
Expect.equals("1\n2\n3", r'''1
2219
2
2320
3''');
24-
Expect.equals("1", r"""
21+
Expect.equals("1", r"""
2522
1""");
26-
Expect.equals("1", r'''
23+
Expect.equals("1", r'''
2724
1''');
28-
Expect.equals("'", r"'");
29-
Expect.equals('"', r'"');
30-
Expect.equals("1", r"1");
31-
Expect.equals("1", r"1");
32-
Expect.equals("\$", r"$");
33-
Expect.equals("\\", r"\");
34-
Expect.equals("\\", r'\');
35-
Expect.equals("\${12}", r"${12}");
36-
Expect.equals(
37-
"\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m",
38-
r"\a\b\c\d\e\f\g\h\i\j\k\l\m",
39-
);
40-
Expect.equals(
41-
"\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z",
42-
r"\n\o\p\q\r\s\t\u\v\w\x\y\z",
43-
);
44-
}
45-
}
46-
47-
main() {
48-
RawStringTest.testMain();
25+
Expect.equals("'", r"'");
26+
Expect.equals('"', r'"');
27+
Expect.equals("1", r"1");
28+
Expect.equals("1", r"1");
29+
Expect.equals("\$", r"$");
30+
Expect.equals("\\", r"\");
31+
Expect.equals("\\", r'\');
32+
Expect.equals("\${12}", r"${12}");
33+
Expect.equals(
34+
"\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m",
35+
r"\a\b\c\d\e\f\g\h\i\j\k\l\m",
36+
);
37+
Expect.equals(
38+
"\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z",
39+
r"\n\o\p\q\r\s\t\u\v\w\x\y\z",
40+
);
4941
}

0 commit comments

Comments
 (0)