mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 22:08:59 +00:00
This commit adds the following classes: SymbolObject, SymbolConstructor, SymbolPrototype, and Symbol. This commit does not introduce any new functionality to the Object class, so they cannot be used as property keys in objects.
26 lines
525 B
JavaScript
26 lines
525 B
JavaScript
load("test-common.js")
|
|
|
|
try {
|
|
const s1 = Symbol("foo");
|
|
const s2 = Symbol("foo");
|
|
|
|
assert(s1 !== s2);
|
|
assert(s1.description === "foo");
|
|
assert(s2.description === "foo");
|
|
|
|
s1.description = "bar";
|
|
assert(s1.description === "foo");
|
|
|
|
assert(typeof s1 === "symbol");
|
|
|
|
assertThrowsError(() => {
|
|
Symbol(Symbol('foo'));
|
|
}, {
|
|
error: TypeError,
|
|
message: "Can't convert symbol to string"
|
|
})
|
|
|
|
console.log("PASS");
|
|
} catch (e) {
|
|
console.log("FAIL: " + e);
|
|
}
|