2020-07-05 09:27:00 -07:00
|
|
|
load("test-common.js");
|
2020-04-29 23:25:21 -07:00
|
|
|
|
|
|
|
|
try {
|
2020-07-05 09:27:00 -07:00
|
|
|
const s1 = Symbol("foo");
|
|
|
|
|
const s2 = Symbol("foo");
|
2020-04-29 23:25:21 -07:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
assert(s1 !== s2);
|
|
|
|
|
assert(s1.description === "foo");
|
|
|
|
|
assert(s2.description === "foo");
|
2020-04-29 23:25:21 -07:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
s1.description = "bar";
|
|
|
|
|
assert(s1.description === "foo");
|
2020-04-29 23:25:21 -07:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
assert(typeof s1 === "symbol");
|
2020-04-29 23:25:21 -07:00
|
|
|
|
2020-07-05 09:27:00 -07:00
|
|
|
assertThrowsError(
|
|
|
|
|
() => {
|
|
|
|
|
Symbol(Symbol("foo"));
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
error: TypeError,
|
|
|
|
|
message: "Cannot convert symbol to string",
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
console.log("PASS");
|
2020-04-29 23:25:21 -07:00
|
|
|
} catch (e) {
|
2020-07-05 09:27:00 -07:00
|
|
|
console.log("FAIL: " + e);
|
2020-04-29 23:25:21 -07:00
|
|
|
}
|