ladybird/Libraries/LibJS/Tests/Symbol.js
Matthew Olsson 78155a6668 LibJS: Consolidate error messages into ErrorTypes.h
Now, exceptions can be thrown with
interpreter.throw_exception<T>(ErrorType:TYPE, "format", "args",
"here").
2020-06-11 07:46:20 +02:00

26 lines
526 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: "Cannot convert symbol to string"
})
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}