mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibJS: Fix that windows style line endings were not ignored or converted
These are tested by test262 but the current test262-runner reads the files in python which automatically converts \r\n to \n. This meant that we passed the tests while we should not have.
This commit is contained in:
parent
f2512071f2
commit
3fee7b0d0b
4 changed files with 51 additions and 1 deletions
|
@ -61,6 +61,34 @@ test("line terminators can be mixed (but please don't)", () => {
|
|||
test("all line terminators are valid for line continuations", () => {
|
||||
expect(Function('return "a\\\nb"')()).toBe("ab");
|
||||
expect(Function('return "a\\\rb"')()).toBe("ab");
|
||||
expect(Function('return "a\\\r\nb"')()).toBe("ab");
|
||||
expect(Function('return "a\\
b"')()).toBe("ab");
|
||||
expect(Function('return "a\\
b"')()).toBe("ab");
|
||||
});
|
||||
|
||||
test("template-literals raw and real value", () => {
|
||||
let lastTemplate;
|
||||
let lastRaw;
|
||||
|
||||
function tag(cs) {
|
||||
lastTemplate = cs[0];
|
||||
lastRaw = cs.raw[0];
|
||||
}
|
||||
|
||||
function checkTemplate(string_value, expected_template, expected_raw) {
|
||||
eval("tag`" + string_value + "`");
|
||||
expect(lastTemplate).toBe(expected_template);
|
||||
expect(lastRaw).toBe(expected_raw);
|
||||
}
|
||||
|
||||
checkTemplate("", "", "");
|
||||
checkTemplate("\n", "\n", "\n");
|
||||
checkTemplate("\r", "\n", "\n");
|
||||
checkTemplate("\r\n", "\n", "\n");
|
||||
checkTemplate("\n\r\n", "\n\n", "\n\n");
|
||||
|
||||
checkTemplate("a\\\nb", "ab", "a\\\nb");
|
||||
checkTemplate("a\\\rb", "ab", "a\\\nb");
|
||||
checkTemplate("a\\
b", "ab", "a\\
b");
|
||||
checkTemplate("a\\
b", "ab", "a\\
b");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue