mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
LibJS: Allow conversion from Symbol to String via explicit String() call
https://tc39.es/ecma262/#sec-string-constructor-string-value has an explicit special case for Symbols allowing this: If NewTarget is undefined and Type(value) is Symbol, return SymbolDescriptiveString(value).
This commit is contained in:
parent
aa25fb8875
commit
ebd510ef5e
Notes:
sideshowbarker
2024-07-19 03:19:09 +09:00
Author: https://github.com/nico
Commit: ebd510ef5e
Pull-request: https://github.com/SerenityOS/serenity/pull/3256
Reviewed-by: https://github.com/linusg ✅
2 changed files with 6 additions and 2 deletions
|
@ -1,10 +1,12 @@
|
|||
describe("correct behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
const s1 = Symbol("baz");
|
||||
// const s2 = Symbol.for("qux");
|
||||
const s2 = Symbol.for("qux");
|
||||
|
||||
// Explicit conversions to string are fine, but implicit toString via concatenation throws.
|
||||
expect(s1.toString()).toBe("Symbol(baz)");
|
||||
// expect(s2.toString()).toBe("Symbol(qux)");
|
||||
expect(String(s1)).toBe("Symbol(baz)");
|
||||
expect(s2.toString()).toBe("Symbol(qux)");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue