1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 15:07:45 +00:00

test-js: Use prettier and format all files

This commit is contained in:
Matthew Olsson 2020-07-05 09:27:00 -07:00 committed by Andreas Kling
parent e532888242
commit 6d58c48c2f
248 changed files with 8291 additions and 7725 deletions

View file

@ -1,30 +1,33 @@
load("test-common.js")
load("test-common.js");
try {
const localSym = Symbol("foo");
const globalSym = Symbol.for("foo");
const localSym = Symbol("foo");
const globalSym = Symbol.for("foo");
assert(localSym !== globalSym);
assert(localSym !== Symbol("foo"));
assert(globalSym !== Symbol("foo"));
assert(globalSym === Symbol.for("foo"));
assert(localSym.toString() === "Symbol(foo)");
assert(globalSym.toString() === "Symbol(foo)");
assert(localSym !== globalSym);
assert(localSym !== Symbol("foo"));
assert(globalSym !== Symbol("foo"));
assert(globalSym === Symbol.for("foo"));
assert(localSym.toString() === "Symbol(foo)");
assert(globalSym.toString() === "Symbol(foo)");
assert(Symbol.for(1).description === "1");
assert(Symbol.for(true).description === "true");
assert(Symbol.for({}).description === "[object Object]");
assert(Symbol.for().description === "undefined");
assert(Symbol.for(null).description === "null");
assert(Symbol.for(1).description === "1");
assert(Symbol.for(true).description === "true");
assert(Symbol.for({}).description === "[object Object]");
assert(Symbol.for().description === "undefined");
assert(Symbol.for(null).description === "null");
assertThrowsError(() => {
Symbol.for(Symbol());
}, {
error: TypeError,
message: "Cannot convert symbol to string",
});
assertThrowsError(
() => {
Symbol.for(Symbol());
},
{
error: TypeError,
message: "Cannot convert symbol to string",
}
);
console.log("PASS");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,26 +1,29 @@
load("test-common.js")
load("test-common.js");
try {
const s1 = Symbol("foo");
const s2 = Symbol("foo");
const s1 = Symbol("foo");
const s2 = Symbol("foo");
assert(s1 !== s2);
assert(s1.description === "foo");
assert(s2.description === "foo");
assert(s1 !== s2);
assert(s1.description === "foo");
assert(s2.description === "foo");
s1.description = "bar";
assert(s1.description === "foo");
s1.description = "bar";
assert(s1.description === "foo");
assert(typeof s1 === "symbol");
assert(typeof s1 === "symbol");
assertThrowsError(() => {
Symbol(Symbol('foo'));
}, {
error: TypeError,
message: "Cannot convert symbol to string"
})
console.log("PASS");
assertThrowsError(
() => {
Symbol(Symbol("foo"));
},
{
error: TypeError,
message: "Cannot convert symbol to string",
}
);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,31 +1,34 @@
load("test-common.js")
load("test-common.js");
try {
const localSym = Symbol("foo");
const globalSym = Symbol.for("foo");
const localSym = Symbol("foo");
const globalSym = Symbol.for("foo");
assert(Symbol.keyFor(localSym) === undefined);
assert(Symbol.keyFor(globalSym) === "foo");
assert(Symbol.keyFor(localSym) === undefined);
assert(Symbol.keyFor(globalSym) === "foo");
const testThrows = (value, str) => {
assertThrowsError(() => {
Symbol.keyFor(value);
}, {
error: TypeError,
message: str + " is not a symbol",
});
};
const testThrows = (value, str) => {
assertThrowsError(
() => {
Symbol.keyFor(value);
},
{
error: TypeError,
message: str + " is not a symbol",
}
);
};
testThrows(1, "1");
testThrows(null, "null");
testThrows(undefined, "undefined");
testThrows([], "[object Array]");
testThrows({}, "[object Object]");
testThrows(true, "true");
testThrows("foobar", "foobar");
testThrows(function(){}, "[object ScriptFunction]"); // FIXME: Better function stringification
testThrows(1, "1");
testThrows(null, "null");
testThrows(undefined, "undefined");
testThrows([], "[object Array]");
testThrows({}, "[object Object]");
testThrows(true, "true");
testThrows("foobar", "foobar");
testThrows(function () {}, "[object ScriptFunction]"); // FIXME: Better function stringification
console.log("PASS");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
console.log("FAIL: " + e);
}

View file

@ -1,27 +1,33 @@
load("test-common.js")
load("test-common.js");
try {
const s1 = Symbol("foo");
const s2 = Symbol.for("bar");
const s1 = Symbol("foo");
const s2 = Symbol.for("bar");
assert(s1.toString() === "Symbol(foo)");
assert(s2.toString() === "Symbol(bar)");
assertThrowsError(() => {
s1 + "";
}, {
error: TypeError,
message: "Cannot convert symbol to string",
});
assertThrowsError(() => {
s1 + 1;
}, {
error: TypeError,
message: "Cannot convert symbol to number",
});
console.log("PASS");
assert(s1.toString() === "Symbol(foo)");
assert(s2.toString() === "Symbol(bar)");
assertThrowsError(
() => {
s1 + "";
},
{
error: TypeError,
message: "Cannot convert symbol to string",
}
);
assertThrowsError(
() => {
s1 + 1;
},
{
error: TypeError,
message: "Cannot convert symbol to number",
}
);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
console.log("FAIL: " + e);
}

View file

@ -1,22 +1,25 @@
load("test-common.js");
try {
let local = Symbol('foo');
let global = Symbol.for('foo');
assert(local.valueOf() === local);
assert(global.valueOf() === global);
let local = Symbol("foo");
let global = Symbol.for("foo");
assert(local.valueOf() === local);
assert(global.valueOf() === global);
assert(Symbol.prototype.valueOf.call(local) === local);
assert(Symbol.prototype.valueOf.call(global) === global);
assert(Symbol.prototype.valueOf.call(local) === local);
assert(Symbol.prototype.valueOf.call(global) === global);
assertThrowsError(() => {
Symbol.prototype.valueOf.call("foo");
}, {
error: TypeError,
message: "Not a Symbol object",
});
assertThrowsError(
() => {
Symbol.prototype.valueOf.call("foo");
},
{
error: TypeError,
message: "Not a Symbol object",
}
);
console.log("PASS");
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
console.log("FAIL: " + err);
}