mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
LibJS: Add Boolean constructor object
This commit is contained in:
parent
57bd194e5a
commit
edae926cb0
16 changed files with 400 additions and 0 deletions
35
Libraries/LibJS/Tests/Boolean.js
Normal file
35
Libraries/LibJS/Tests/Boolean.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
try {
|
||||
assert(Boolean.length === 1);
|
||||
assert(typeof new Boolean() === "object");
|
||||
assert(new Boolean().valueOf() === false);
|
||||
|
||||
var foo = new Boolean(true);
|
||||
var bar = new Boolean(true);
|
||||
|
||||
assert(foo !== bar);
|
||||
assert(foo.valueOf() === 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue