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 <devoncarew@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
This commit is contained in:
Lasse R.H. Nielsen
2025-06-13 16:16:13 -07:00
committed by Commit Queue
parent 390d3f4ede
commit 007033109d
7 changed files with 116 additions and 459 deletions
-7
View File
@@ -16,20 +16,13 @@
# File that should not be converted. # File that should not be converted.
tests/web/eof_line_ending_test.dart -text tests/web/eof_line_ending_test.dart -text
tests/web/string_interpolation_test.dart -text
tests/web/string_interpolation_dynamic_test.dart -text
tests/web/literal_string_juxtaposition_test.dart -text
tests/language/string/raw_string_test.dart -text
tests/language/string/multiline_strings_test.dart -text
tests/language/string/multiline_newline_cr.dart -text tests/language/string/multiline_newline_cr.dart -text
tests/language/string/multiline_newline_crlf.dart -text tests/language/string/multiline_newline_crlf.dart -text
tests/language/string/multiline_newline_lf.dart -text tests/language/string/multiline_newline_lf.dart -text
tests/lib/mirrors/method_mirror_source_line_ending_cr.dart -text tests/lib/mirrors/method_mirror_source_line_ending_cr.dart -text
tests/lib/mirrors/method_mirror_source_line_ending_crlf.dart -text tests/lib/mirrors/method_mirror_source_line_ending_crlf.dart -text
tests/lib/mirrors/method_mirror_source_line_ending_lf.dart -text tests/lib/mirrors/method_mirror_source_line_ending_lf.dart -text
tests/lib/mirrors/method_mirror_source_line_ending_test.dart -text
tests/lib/mirrors/method_mirror_source_other.dart -text tests/lib/mirrors/method_mirror_source_other.dart -text
tests/lib/mirrors/method_mirror_source_test.dart -text
# Files to leave alone and not diff. # Files to leave alone and not diff.
*.png binary *.png binary
@@ -2,24 +2,16 @@
// for details. All rights reserved. Use of this source code is governed by a // for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
library multiline_newline_cr; // Test depends on specific line endings,
// and requires an entry in the .gitattributes file.
const constantMultilineString = """ // dart format off
a
b
""";
var nonConstantMultilineString = """ // All line endings inside string literals are Carriage Return, U+000D
a const constantMultilineString = """
b
""";
a a
const constantRawMultilineString = r""" b
\a
\b
""";
"""; """;
var nonConstantRawMultilineString = r"""
\a var nonConstantMultilineString = """
\b a
""";
@@ -2,24 +2,29 @@
// for details. All rights reserved. Use of this source code is governed by a // for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
// Note: This test relies on LF line endings in the source file.
import "package:expect/expect.dart"; import "package:expect/expect.dart";
main() { void main() {
// Spaces after '''.
Expect.equals('foo', ''' Expect.equals('foo', '''
foo'''); foo''');
// Tab characters after '''.
Expect.equals('foo', '''
foo''');
Expect.equals('\\\nfoo', '''\\ Expect.equals('\\\nfoo', '''\\
foo'''); foo''');
Expect.equals('\t\nfoo', '''\t Expect.equals('\t\nfoo', '''\t
foo'''); foo''');
// Backslash just before newline.
Expect.equals('foo', '''\ Expect.equals('foo', '''\
foo'''); foo''');
Expect.equals('foo', '''\ \ // Backslash before space, tab and newline.
Expect.equals('foo', '''\ \ \
foo'''); foo''');
Expect.equals(' \nfoo', '''\x20 Expect.equals(' \nfoo', '''\x20
@@ -29,18 +34,25 @@ foo''');
Expect.equals(' \nfoo', '''$x Expect.equals(' \nfoo', '''$x
foo'''); foo''');
/// Spaces after '''.
Expect.equals('foo', r''' Expect.equals('foo', r'''
foo'''); foo''');
/// Tab characters after '''.
Expect.equals('foo', r'''
foo''');
Expect.equals('\\\\\nfoo', r'''\\ Expect.equals('\\\\\nfoo', r'''\\
foo'''); foo''');
Expect.equals('\\t\nfoo', r'''\t Expect.equals('\\t\nfoo', r'''\t
foo'''); foo''');
// Backslash before newline.
Expect.equals('foo', r'''\ Expect.equals('foo', r'''\
foo'''); foo''');
Expect.equals('foo', r'''\ \ // Backslash before space, tab and newline.
Expect.equals('foo', r'''\ \ \
foo'''); foo''');
} }
+28 -36
View File
@@ -2,48 +2,40 @@
// for details. All rights reserved. Use of this source code is governed by a // for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
// Note: This test relies on LF line endings in the source file.
import "package:expect/expect.dart"; import "package:expect/expect.dart";
class RawStringTest { void main() {
static testMain() { Expect.equals("abcd", r"abcd");
Expect.equals("abcd", r"abcd"); Expect.equals("", r"");
Expect.equals("", r""); Expect.equals("", r'');
Expect.equals("", r''); Expect.equals("", r"""""");
Expect.equals("", r""""""); Expect.equals("", r'''''');
Expect.equals("", r''''''); Expect.equals("''''", r"''''");
Expect.equals("''''", r"''''"); Expect.equals('""""', r'""""');
Expect.equals('""""', r'""""'); Expect.equals("1\n2\n3", r"""1
Expect.equals("1\n2\n3", r"""1
2 2
3"""); 3""");
Expect.equals("1\n2\n3", r'''1 Expect.equals("1\n2\n3", r'''1
2 2
3'''); 3''');
Expect.equals("1", r""" Expect.equals("1", r"""
1"""); 1""");
Expect.equals("1", r''' Expect.equals("1", r'''
1'''); 1''');
Expect.equals("'", r"'"); Expect.equals("'", r"'");
Expect.equals('"', r'"'); Expect.equals('"', r'"');
Expect.equals("1", r"1"); Expect.equals("1", r"1");
Expect.equals("1", r"1"); Expect.equals("1", r"1");
Expect.equals("\$", r"$"); Expect.equals("\$", r"$");
Expect.equals("\\", r"\"); Expect.equals("\\", r"\");
Expect.equals("\\", r'\'); Expect.equals("\\", r'\');
Expect.equals("\${12}", r"${12}"); Expect.equals("\${12}", r"${12}");
Expect.equals( Expect.equals(
"\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m", "\\a\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m",
r"\a\b\c\d\e\f\g\h\i\j\k\l\m", r"\a\b\c\d\e\f\g\h\i\j\k\l\m",
); );
Expect.equals( Expect.equals(
"\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z", "\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z",
r"\n\o\p\q\r\s\t\u\v\w\x\y\z", r"\n\o\p\q\r\s\t\u\v\w\x\y\z",
); );
}
}
main() {
RawStringTest.testMain();
} }
+62 -390
View File
@@ -2,7 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a // for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
// Note: This test relies on LF line endings in the source file. // dart format off
// Note: This test relies on specific formatting of adjacent expressions.
import "package:expect/expect.dart"; import "package:expect/expect.dart";
@@ -10,32 +11,10 @@ main() {
{ {
// Generates identical compile time constants. // Generates identical compile time constants.
var s1 = "abcdefgh"; var s1 = "abcdefgh";
var s2 = var s2 = "abcd" "efgh";
"abcd" var s3 = "ab" "cd" "ef" "gh";
"efgh"; var s4 = "a" "b" "c" "d" "e" "f" "g" "h";
var s3 = var s5 = "a" 'b' r"c" r'd' """e""" '''f''' r"""g""" r'''h''';
"ab"
"cd"
"ef"
"gh";
var s4 =
"a"
"b"
"c"
"d"
"e"
"f"
"g"
"h";
var s5 =
"a"
'b'
r"c"
r'd'
"""e"""
'''f'''
r"""g"""
r'''h''';
Expect.isTrue(identical(s1, s2)); Expect.isTrue(identical(s1, s2));
Expect.isTrue(identical(s1, s3)); Expect.isTrue(identical(s1, s3));
Expect.isTrue(identical(s1, s4)); Expect.isTrue(identical(s1, s4));
@@ -44,105 +23,42 @@ main() {
{ {
// Separating whitespace isn't necessary for the tokenizer. // Separating whitespace isn't necessary for the tokenizer.
var s1 = "abcdefgh"; var s1 = "abcdefgh";
var s2 = var s2 = "abcd""efgh";
"abcd" var s3 = "ab""cd""ef""gh";
"efgh"; var s4 = "a""b""c""d""e""f""g""h";
var s3 = var s5 = "a"'b'r"c"r'd'"""e"""'''f'''r"""g"""r'''h''';
"ab"
"cd"
"ef"
"gh";
var s4 =
"a"
"b"
"c"
"d"
"e"
"f"
"g"
"h";
var s5 =
"a"
'b'
r"c"
r'd'
"""e"""
'''f'''
r"""g"""
r'''h''';
Expect.isTrue(identical(s1, s2)); Expect.isTrue(identical(s1, s2));
Expect.isTrue(identical(s1, s3)); Expect.isTrue(identical(s1, s3));
Expect.isTrue(identical(s1, s4)); Expect.isTrue(identical(s1, s4));
Expect.isTrue(identical(s1, s5)); Expect.isTrue(identical(s1, s5));
// "a""""""b""" should be tokenized as "a" """""b""", aka. "a" '""b'. // "a""""""b""" should be tokenized as "a" """""b""", aka. "a" '""b'.
Expect.isTrue( Expect.isTrue(identical('a""b', "a""""""b"""));
identical(
'a""b',
"a"
"""""b""",
),
);
// """a""""""""b""" is 'a' '""b'. // """a""""""""b""" is 'a' '""b'.
Expect.isTrue( Expect.isTrue(identical('a""b', """a""""""""b"""));
identical(
'a""b',
"""a"""
"""""b""",
),
);
// Raw strings. // Raw strings.
Expect.isTrue( Expect.isTrue(identical('ab', "a"r"b"));
identical( Expect.isTrue(identical('ab', r"a""b"));
'ab', Expect.isTrue(identical('ab', r"a"r"b"));
"a"
r"b",
),
);
Expect.isTrue(
identical(
'ab',
r"a"
"b",
),
);
Expect.isTrue(
identical(
'ab',
r"a"
r"b",
),
);
} }
// Newlines are just whitespace. // Newlines are just whitespace.
var ms1 = var ms1 = "abc"
"abc" "def"
"def" "ghi"
"ghi" "jkl";
"jkl";
Expect.isTrue(identical("abcdefghijkl", ms1)); Expect.isTrue(identical("abcdefghijkl", ms1));
// Works with multiline strings too. // Works with multiline strings too.
var ms2 = var ms2 = """abc
"""abc
def""" def"""
""" """
ghi ghi
jkl jkl
"""; """;
Expect.isTrue( Expect.isTrue(identical("abc\n def ghi\n jkl\n ", ms2), "Multiline: $ms2");
identical("abc\n def ghi\n jkl\n ", ms2),
"Multiline: $ms2",
);
// Binds stronger than property access (it's considered one literal). // Binds stronger than property access (it's considered one literal).
Expect.equals( Expect.equals(5, "ab" "cde".length, "Associativity");
5,
"ab"
"cde"
.length,
"Associativity",
);
// Check that interpolations are handled correctly. // Check that interpolations are handled correctly.
{ {
@@ -150,295 +66,51 @@ main() {
var y = 42; var y = 42;
var z = true; var z = true;
String e1 = "$x$y$z"; String e1 = "$x$y$z";
Expect.equals( Expect.equals(e1, "$x" "$y$z");
e1, Expect.equals(e1, "$x$y" "$z");
"$x" Expect.equals(e1, "$x" "$y" "$z");
"$y$z",
);
Expect.equals(
e1,
"$x$y"
"$z",
);
Expect.equals(
e1,
"$x"
"$y"
"$z",
);
String e2 = "-$x-$y-$z-"; String e2 = "-$x-$y-$z-";
Expect.equals( Expect.equals(e2, "-" "$x" "-" "$y" "-" "$z" "-", "a");
e2, Expect.equals(e2, "-$x" "-" "$y" "-" "$z" "-", "b");
"-" Expect.equals(e2, "-" "$x-" "$y" "-" "$z" "-", "c");
"$x" Expect.equals(e2, "-" "$x" "-$y" "-" "$z" "-", "d");
"-" Expect.equals(e2, "-" "$x" "-" "$y-" "$z" "-", "e");
"$y" Expect.equals(e2, "-" "$x" "-" "$y" "-$z" "-", "f");
"-" Expect.equals(e2, "-" "$x" "-" "$y" "-" "$z-", "g");
"$z" Expect.equals(e2, "-" "$x-$y" "-" "$z" "-", "h");
"-", Expect.equals(e2, "-" "$x-$y-$z" "-", "i");
"a",
);
Expect.equals(
e2,
"-$x"
"-"
"$y"
"-"
"$z"
"-",
"b",
);
Expect.equals(
e2,
"-"
"$x-"
"$y"
"-"
"$z"
"-",
"c",
);
Expect.equals(
e2,
"-"
"$x"
"-$y"
"-"
"$z"
"-",
"d",
);
Expect.equals(
e2,
"-"
"$x"
"-"
"$y-"
"$z"
"-",
"e",
);
Expect.equals(
e2,
"-"
"$x"
"-"
"$y"
"-$z"
"-",
"f",
);
Expect.equals(
e2,
"-"
"$x"
"-"
"$y"
"-"
"$z-",
"g",
);
Expect.equals(
e2,
"-"
"$x-$y"
"-"
"$z"
"-",
"h",
);
Expect.equals(
e2,
"-"
"$x-$y-$z"
"-",
"i",
);
Expect.equals( Expect.equals("-$x-$y-", "-" "$x" "-" "$y" "-");
"-$x-$y-", Expect.equals("-$x-$y", "-" "$x" "-" "$y");
"-" Expect.equals("-$x$y-", "-" "$x" "$y" "-");
"$x" Expect.equals("$x-$y-", "$x" "-" "$y" "-");
"-"
"$y"
"-",
);
Expect.equals(
"-$x-$y",
"-"
"$x"
"-"
"$y",
);
Expect.equals(
"-$x$y-",
"-"
"$x"
"$y"
"-",
);
Expect.equals(
"$x-$y-",
"$x"
"-"
"$y"
"-",
);
Expect.equals( Expect.equals("$x$y", "$x" "$y");
"$x$y", Expect.equals("$x$y", "$x" "" "$y");
"$x" Expect.equals("$x$y", "$x" "" "" "$y");
"$y", Expect.equals("$x-$y", "$x" "-" "$y");
); Expect.equals("$x-$y", "$x" "-" "" "$y");
Expect.equals( Expect.equals("$x-$y", "$x" "" "-" "$y");
"$x$y", Expect.equals("$x-$y", "$x" "" "-" "" "$y");
"$x"
""
"$y",
);
Expect.equals(
"$x$y",
"$x"
""
""
"$y",
);
Expect.equals(
"$x-$y",
"$x"
"-"
"$y",
);
Expect.equals(
"$x-$y",
"$x"
"-"
""
"$y",
);
Expect.equals(
"$x-$y",
"$x"
""
"-"
"$y",
);
Expect.equals(
"$x-$y",
"$x"
""
"-"
""
"$y",
);
Expect.equals( Expect.equals("$x--$y", "$x" "-" "-" "$y");
"$x--$y", Expect.equals("$x--$y", "$x" "-" "-" "" "$y");
"$x" Expect.equals("$x--$y", "$x" "-" "" "-" "$y");
"-" Expect.equals("$x--$y", "$x" "" "-" "-" "$y");
"-"
"$y",
);
Expect.equals(
"$x--$y",
"$x"
"-"
"-"
""
"$y",
);
Expect.equals(
"$x--$y",
"$x"
"-"
""
"-"
"$y",
);
Expect.equals(
"$x--$y",
"$x"
""
"-"
"-"
"$y",
);
Expect.equals( Expect.equals("$x---$y", "$x" "-" "-" "-" "$y");
"$x---$y", Expect.equals("$x---", "$x" "-" "-" "-");
"$x" Expect.equals("---$y", "-" "-" "-" "$y");
"-"
"-"
"-"
"$y",
);
Expect.equals(
"$x---",
"$x"
"-"
"-"
"-",
);
Expect.equals(
"---$y",
"-"
"-"
"-"
"$y",
);
Expect.equals( Expect.equals("$x-$y-$z", "${'$x' '-' '$y'}" "-" "$z");
"$x-$y-$z",
"${'$x'
'-'
'$y'}"
"-"
"$z",
);
Expect.equals( Expect.equals(r"-foo-42-true-",
r"-foo-42-true-", r"-" "$x" r"""-""" """$y""" r'-' '$z' r'''-''', "j");
r"-" Expect.equals(r"-$x-42-true-",
"$x" r"-" r"$x" r"""-""" """$y""" r'-' '$z' r'''-''', "k");
r"""-""" Expect.equals(r"-foo-$y-true-",
"""$y""" r"-" "$x" r"""-""" r"""$y""" r'-' '$z' r'''-''', "l");
r'-' Expect.equals(r"-foo-42-$z-",
'$z' r"-" "$x" r"""-""" """$y""" r'-' r'$z' r'''-''', "m");
r'''-''',
"j",
);
Expect.equals(
r"-$x-42-true-",
r"-"
r"$x"
r"""-"""
"""$y"""
r'-'
'$z'
r'''-''',
"k",
);
Expect.equals(
r"-foo-$y-true-",
r"-"
"$x"
r"""-"""
r"""$y"""
r'-'
'$z'
r'''-''',
"l",
);
Expect.equals(
r"-foo-42-$z-",
r"-"
"$x"
r"""-"""
"""$y"""
r'-'
r'$z'
r'''-''',
"m",
);
} }
} }
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a // for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
// Note: This test relies on LF line endings in the source file.
import "package:expect/expect.dart"; import "package:expect/expect.dart";
import 'dart:math'; import 'dart:math';
-2
View File
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a // for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file. // BSD-style license that can be found in the LICENSE file.
// Note: This test relies on LF line endings in the source file.
import "package:expect/expect.dart"; import "package:expect/expect.dart";
// Test that String interpolation works in the code generated by the leg // Test that String interpolation works in the code generated by the leg