mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
LibJS: Fix test files indentation (4 spaces)
This commit is contained in:
parent
0040d6bf2d
commit
92a9fe0e49
8 changed files with 111 additions and 111 deletions
|
@ -1,35 +1,35 @@
|
||||||
try {
|
try {
|
||||||
assert(Boolean.length === 1);
|
assert(Boolean.length === 1);
|
||||||
assert(typeof new Boolean() === "object");
|
assert(typeof new Boolean() === "object");
|
||||||
assert(new Boolean().valueOf() === false);
|
assert(new Boolean().valueOf() === false);
|
||||||
|
|
||||||
var foo = new Boolean(true);
|
var foo = new Boolean(true);
|
||||||
var bar = new Boolean(true);
|
var bar = new Boolean(true);
|
||||||
|
|
||||||
assert(foo !== bar);
|
assert(foo !== bar);
|
||||||
assert(foo.valueOf() === bar.valueOf());
|
assert(foo.valueOf() === bar.valueOf());
|
||||||
|
|
||||||
assert(new Boolean(true).toString() === "true");
|
assert(new Boolean(true).toString() === "true");
|
||||||
assert(new Boolean(false).toString() === "false");
|
assert(new Boolean(false).toString() === "false");
|
||||||
|
|
||||||
assert(typeof Boolean() === "boolean");
|
assert(typeof Boolean() === "boolean");
|
||||||
assert(typeof Boolean(true) === "boolean");
|
assert(typeof Boolean(true) === "boolean");
|
||||||
|
|
||||||
assert(Boolean() === false);
|
assert(Boolean() === false);
|
||||||
assert(Boolean(false) === false);
|
assert(Boolean(false) === false);
|
||||||
assert(Boolean(null) === false);
|
assert(Boolean(null) === false);
|
||||||
assert(Boolean(undefined) === false);
|
assert(Boolean(undefined) === false);
|
||||||
assert(Boolean(NaN) === false);
|
assert(Boolean(NaN) === false);
|
||||||
assert(Boolean("") === false);
|
assert(Boolean("") === false);
|
||||||
assert(Boolean(0.0) === false);
|
assert(Boolean(0.0) === false);
|
||||||
assert(Boolean(-0.0) === false);
|
assert(Boolean(-0.0) === false);
|
||||||
assert(Boolean(true) === true);
|
assert(Boolean(true) === true);
|
||||||
assert(Boolean("0") === true);
|
assert(Boolean("0") === true);
|
||||||
assert(Boolean({}) === true);
|
assert(Boolean({}) === true);
|
||||||
assert(Boolean([]) === true);
|
assert(Boolean([]) === true);
|
||||||
assert(Boolean(1)) === true;
|
assert(Boolean(1)) === true;
|
||||||
|
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("FAIL: " + err);
|
console.log("FAIL: " + err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
try {
|
try {
|
||||||
assert(typeof Boolean.prototype === "object");
|
assert(typeof Boolean.prototype === "object");
|
||||||
assert(Boolean.prototype.valueOf() === false);
|
assert(Boolean.prototype.valueOf() === false);
|
||||||
|
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("FAIL: " + err);
|
console.log("FAIL: " + err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
try {
|
try {
|
||||||
var foo = true;
|
var foo = true;
|
||||||
assert(foo.toString() === "true");
|
assert(foo.toString() === "true");
|
||||||
assert(true.toString() === "true");
|
assert(true.toString() === "true");
|
||||||
|
|
||||||
assert(Boolean.prototype.toString.call(true) === "true");
|
assert(Boolean.prototype.toString.call(true) === "true");
|
||||||
assert(Boolean.prototype.toString.call(false) === "false");
|
assert(Boolean.prototype.toString.call(false) === "false");
|
||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
Boolean.prototype.toString.call("foo");
|
Boolean.prototype.toString.call("foo");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error = err;
|
error = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(error instanceof Error);
|
assert(error instanceof Error);
|
||||||
assert(error.name === "TypeError");
|
assert(error.name === "TypeError");
|
||||||
assert(error.message === "Not a Boolean");
|
assert(error.message === "Not a Boolean");
|
||||||
|
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("FAIL: " + err);
|
console.log("FAIL: " + err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
try {
|
try {
|
||||||
var foo = true;
|
var foo = true;
|
||||||
assert(foo.valueOf() === true);
|
assert(foo.valueOf() === true);
|
||||||
assert(true.valueOf() === true);
|
assert(true.valueOf() === true);
|
||||||
|
|
||||||
assert(Boolean.prototype.valueOf.call(true) === true);
|
assert(Boolean.prototype.valueOf.call(true) === true);
|
||||||
assert(Boolean.prototype.valueOf.call(false) === false);
|
assert(Boolean.prototype.valueOf.call(false) === false);
|
||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
Boolean.prototype.valueOf.call("foo");
|
Boolean.prototype.valueOf.call("foo");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error = err;
|
error = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(error instanceof Error);
|
assert(error instanceof Error);
|
||||||
assert(error.name === "TypeError");
|
assert(error.name === "TypeError");
|
||||||
assert(error.message === "Not a Boolean");
|
assert(error.message === "Not a Boolean");
|
||||||
|
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("FAIL: " + err);
|
console.log("FAIL: " + err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
try {
|
try {
|
||||||
let getNumber = () => 42;
|
let getNumber = () => 42;
|
||||||
assert(getNumber() === 42);
|
assert(getNumber() === 42);
|
||||||
|
|
||||||
let add = (a, b) => a + b;
|
let add = (a, b) => a + b;
|
||||||
assert(add(2, 3) === 5);
|
assert(add(2, 3) === 5);
|
||||||
|
|
||||||
const addBlock = (a, b) => {
|
const addBlock = (a, b) => {
|
||||||
let res = a + b;
|
let res = a + b;
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
assert(addBlock(5, 4) === 9);
|
assert(addBlock(5, 4) === 9);
|
||||||
|
|
||||||
const makeObject = (a, b) => ({ a, b });
|
const makeObject = (a, b) => ({ a, b });
|
||||||
const obj = makeObject(33, 44);
|
const obj = makeObject(33, 44);
|
||||||
assert(typeof obj === "object");
|
assert(typeof obj === "object");
|
||||||
assert(obj.a === 33);
|
assert(obj.a === 33);
|
||||||
assert(obj.b === 44);
|
assert(obj.b === 44);
|
||||||
|
|
||||||
let returnUndefined = () => {};
|
let returnUndefined = () => { };
|
||||||
assert(typeof returnUndefined() === "undefined");
|
assert(typeof returnUndefined() === "undefined");
|
||||||
|
|
||||||
const makeArray = (a, b) => [a, b];
|
const makeArray = (a, b) => [a, b];
|
||||||
const array = makeArray("3", { foo: 4 });
|
const array = makeArray("3", { foo: 4 });
|
||||||
assert(array[0] === "3");
|
assert(array[0] === "3");
|
||||||
assert(array[1].foo === 4);
|
assert(array[1].foo === 4);
|
||||||
|
|
||||||
let square = x => x * x;
|
let square = x => x * x;
|
||||||
assert(square(3) === 9);
|
assert(square(3) === 9);
|
||||||
|
|
||||||
let squareBlock = x => {
|
let squareBlock = x => {
|
||||||
return x * x;
|
return x * x;
|
||||||
};
|
};
|
||||||
assert(squareBlock(4) === 16);
|
assert(squareBlock(4) === 16);
|
||||||
|
|
||||||
const message = (who => "Hello " + who)("friends!");
|
const message = (who => "Hello " + who)("friends!");
|
||||||
assert(message === "Hello friends!");
|
assert(message === "Hello friends!");
|
||||||
|
|
||||||
const sum = ((x, y, z) => x + y + z)(1, 2, 3);
|
const sum = ((x, y, z) => x + y + z)(1, 2, 3);
|
||||||
assert(sum === 6);
|
assert(sum === 6);
|
||||||
|
|
||||||
const product = ((x, y, z) => {
|
const product = ((x, y, z) => {
|
||||||
let res = x * y * z;
|
let res = x * y * z;
|
||||||
return res;
|
return res;
|
||||||
})(5, 4, 2);
|
})(5, 4, 2);
|
||||||
assert(product === 40);
|
assert(product === 40);
|
||||||
|
|
||||||
const half = (x => {
|
const half = (x => {
|
||||||
return x / 2;
|
return x / 2;
|
||||||
})(10);
|
})(10);
|
||||||
assert(half === 5);
|
assert(half === 5);
|
||||||
|
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
} catch {
|
} catch {
|
||||||
console.log("FAIL");
|
console.log("FAIL");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@ var a = "foo";
|
||||||
|
|
||||||
switch (a + "bar") {
|
switch (a + "bar") {
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
case "foobar":
|
case "foobar":
|
||||||
case 2:
|
case 2:
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,5 @@ var a = "foo";
|
||||||
|
|
||||||
switch (100) {
|
switch (100) {
|
||||||
default:
|
default:
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
switch (1 + 2) {
|
switch (1 + 2) {
|
||||||
case 3:
|
case 3:
|
||||||
console.log("PASS");
|
console.log("PASS");
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue