mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 00:56:39 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
74
Libraries/LibJS/Tests/template-literals.js
Normal file
74
Libraries/LibJS/Tests/template-literals.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
test("plain literals with expression-like characters", () => {
|
||||
expect(`foo`).toBe("foo");
|
||||
expect(`foo{`).toBe("foo{");
|
||||
expect(`foo}`).toBe("foo}");
|
||||
expect(`foo$`).toBe("foo$");
|
||||
});
|
||||
|
||||
test("plain literals with escaped special characters", () => {
|
||||
expect(`foo\``).toBe("foo`");
|
||||
expect(`foo\\`).toBe("foo\\");
|
||||
expect(`foo\\\``).toBe("foo\\`");
|
||||
expect(`foo\\\\`).toBe("foo\\\\");
|
||||
expect(`foo\$`).toBe("foo$");
|
||||
expect(`foo \${"bar"}`).toBe('foo ${"bar"}');
|
||||
});
|
||||
|
||||
test("literals in expressions", () => {
|
||||
expect(`foo ${undefined}`).toBe("foo undefined");
|
||||
expect(`foo ${null}`).toBe("foo null");
|
||||
expect(`foo ${5}`).toBe("foo 5");
|
||||
expect(`foo ${true}`).toBe("foo true");
|
||||
expect(`foo ${"bar"}`).toBe("foo bar");
|
||||
});
|
||||
|
||||
test("objects in expressions", () => {
|
||||
expect(`foo ${{}}`).toBe("foo [object Object]");
|
||||
expect(`foo ${{ bar: { baz: "qux" } }}`).toBe("foo [object Object]");
|
||||
});
|
||||
|
||||
test("expressions at beginning of template literal", () => {
|
||||
expect(`${"foo"} bar baz`).toBe("foo bar baz");
|
||||
expect(`${"foo bar baz"}`).toBe("foo bar baz");
|
||||
});
|
||||
|
||||
test("multiple template literals", () => {
|
||||
expect(`foo ${"bar"} ${"baz"}`).toBe("foo bar baz");
|
||||
});
|
||||
|
||||
test("variables in expressions", () => {
|
||||
let a = 27;
|
||||
expect(`${a}`).toBe("27");
|
||||
expect(`foo ${a}`).toBe("foo 27");
|
||||
expect(`foo ${a ? "bar" : "baz"}`).toBe("foo bar");
|
||||
expect(`foo ${(() => a)()}`).toBe("foo 27");
|
||||
});
|
||||
|
||||
test("template literals in expressions", () => {
|
||||
expect(`foo ${`bar`}`).toBe("foo bar");
|
||||
expect(`${`${`${`${"foo"}`} bar`}`}`).toBe("foo bar");
|
||||
});
|
||||
|
||||
test("newline literals (not characters)", () => {
|
||||
expect(
|
||||
`foo
|
||||
bar`
|
||||
).toBe("foo\n bar");
|
||||
});
|
||||
|
||||
test("line continuation in literals (not characters)", () => {
|
||||
expect(
|
||||
`foo\
|
||||
bar`
|
||||
).toBe("foo bar");
|
||||
});
|
||||
|
||||
test("reference error from expressions", () => {
|
||||
expect(() => `${b}`).toThrowWithMessage(ReferenceError, "'b' is not defined");
|
||||
});
|
||||
|
||||
test("invalid escapes should give syntax error", () => {
|
||||
expect("`\\u`").not.toEval();
|
||||
expect("`\\01`").not.toEval();
|
||||
expect("`\\u{10FFFFF}`").not.toEval();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue