ladybird/Libraries/LibJS/Tests/Symbol.js
mattco98 4ced126704 LibJS: Add symbol objects
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.
2020-05-17 18:05:15 +02:00

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);
}