mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:27:46 +00:00
LibJS: Convert most builtin tests to new system
This commit is contained in:
parent
46581773c1
commit
3f97d75778
107 changed files with 2031 additions and 2243 deletions
|
@ -1,40 +1,32 @@
|
|||
load("test-common.js");
|
||||
test("constructor properties", () => {
|
||||
expect(Boolean).toHaveLength(1);
|
||||
expect(Boolean.name).toBe("Boolean");
|
||||
});
|
||||
|
||||
try {
|
||||
assert(Boolean.length === 1);
|
||||
assert(Boolean.name === "Boolean");
|
||||
assert(Boolean.prototype.length === undefined);
|
||||
|
||||
assert(typeof new Boolean() === "object");
|
||||
assert(new Boolean().valueOf() === false);
|
||||
test("typeof", () => {
|
||||
expect(typeof new Boolean()).toBe("object");
|
||||
expect(typeof Boolean()).toBe("boolean");
|
||||
expect(typeof Boolean(true)).toBe("boolean");
|
||||
})
|
||||
|
||||
test("basic functionality", () => {
|
||||
var foo = new Boolean(true);
|
||||
var bar = new Boolean(true);
|
||||
|
||||
assert(foo !== bar);
|
||||
assert(foo.valueOf() === bar.valueOf());
|
||||
expect(foo).not.toBe(bar);
|
||||
expect(foo.valueOf()).toBe(bar.valueOf());
|
||||
|
||||
assert(new Boolean(true).toString() === "true");
|
||||
assert(new Boolean(false).toString() === "false");
|
||||
|
||||
assert(typeof Boolean() === "boolean");
|
||||
assert(typeof Boolean(true) === "boolean");
|
||||
|
||||
assert(Boolean() === false);
|
||||
assert(Boolean(false) === false);
|
||||
assert(Boolean(null) === false);
|
||||
assert(Boolean(undefined) === false);
|
||||
assert(Boolean(NaN) === false);
|
||||
assert(Boolean("") === false);
|
||||
assert(Boolean(0.0) === false);
|
||||
assert(Boolean(-0.0) === false);
|
||||
assert(Boolean(true) === true);
|
||||
assert(Boolean("0") === true);
|
||||
assert(Boolean({}) === true);
|
||||
assert(Boolean([]) === true);
|
||||
assert(Boolean(1)) === true;
|
||||
|
||||
console.log("PASS");
|
||||
} catch (err) {
|
||||
console.log("FAIL: " + err);
|
||||
}
|
||||
expect(Boolean()).toBeFalse();
|
||||
expect(Boolean(false)).toBeFalse();
|
||||
expect(Boolean(null)).toBeFalse();
|
||||
expect(Boolean(undefined)).toBeFalse();
|
||||
expect(Boolean(NaN)).toBeFalse();
|
||||
expect(Boolean("")).toBeFalse();
|
||||
expect(Boolean(0.0)).toBeFalse();
|
||||
expect(Boolean(-0.0)).toBeFalse();
|
||||
expect(Boolean(true)).toBeTrue();
|
||||
expect(Boolean("0")).toBeTrue();
|
||||
expect(Boolean({})).toBeTrue();
|
||||
expect(Boolean([])).toBeTrue();
|
||||
expect(Boolean(1)).toBeTrue();
|
||||
});
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(typeof Boolean.prototype === "object");
|
||||
assert(Boolean.prototype.valueOf() === false);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (err) {
|
||||
console.log("FAIL: " + err);
|
||||
}
|
||||
test("basic functionality", () => {
|
||||
expect(typeof Boolean.prototype).toBe("object");
|
||||
expect(Boolean.prototype.valueOf()).toBeFalse();
|
||||
expect(Boolean.prototype.length).toBeUndefined();
|
||||
});
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
test("basic functionality", () => {
|
||||
var foo = true;
|
||||
assert(foo.toString() === "true");
|
||||
assert(true.toString() === "true");
|
||||
expect(foo.toString()).toBe("true");
|
||||
expect(true.toString()).toBe("true");
|
||||
|
||||
assert(Boolean.prototype.toString.call(true) === "true");
|
||||
assert(Boolean.prototype.toString.call(false) === "false");
|
||||
expect(Boolean.prototype.toString.call(true)).toBe("true");
|
||||
expect(Boolean.prototype.toString.call(false)).toBe("false");
|
||||
|
||||
assertThrowsError(() => {
|
||||
expect(new Boolean(true).toString()).toBe("true");
|
||||
expect(new Boolean(false).toString()).toBe("false");
|
||||
});
|
||||
|
||||
test("errors on non-boolean |this|", () => {
|
||||
expect(() => {
|
||||
Boolean.prototype.toString.call("foo");
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: "Not a Boolean object"
|
||||
});
|
||||
|
||||
console.log("PASS");
|
||||
} catch (err) {
|
||||
console.log("FAIL: " + err);
|
||||
}
|
||||
}).toThrowWithMessage(TypeError, "Not a Boolean object");
|
||||
});
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
test("basic functionality", () => {
|
||||
var foo = true;
|
||||
assert(foo.valueOf() === true);
|
||||
assert(true.valueOf() === true);
|
||||
expect(foo.valueOf()).toBeTrue();
|
||||
expect(true.valueOf()).toBeTrue();
|
||||
|
||||
assert(Boolean.prototype.valueOf.call(true) === true);
|
||||
assert(Boolean.prototype.valueOf.call(false) === false);
|
||||
expect(Boolean.prototype.valueOf.call(true)).toBeTrue();
|
||||
expect(Boolean.prototype.valueOf.call(false)).toBeFalse();
|
||||
|
||||
assertThrowsError(() => {
|
||||
expect(new Boolean().valueOf()).toBeFalse();
|
||||
});
|
||||
|
||||
test("errors on non-boolean |this|", () => {
|
||||
expect(() => {
|
||||
Boolean.prototype.valueOf.call("foo");
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: "Not a Boolean object"
|
||||
});
|
||||
|
||||
console.log("PASS");
|
||||
} catch (err) {
|
||||
console.log("FAIL: " + err);
|
||||
}
|
||||
}).toThrowWithMessage(TypeError, "Not a Boolean object");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue