mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
Libraries: Move to Userland/Libraries/
This commit is contained in:
parent
dc28c07fa5
commit
13d7c09125
1857 changed files with 266 additions and 274 deletions
|
@ -1,65 +0,0 @@
|
|||
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 \${"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");
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue