LibJS: Convert most builtin tests to new system

This commit is contained in:
Matthew Olsson 2020-07-04 10:09:48 -07:00 committed by Andreas Kling
parent 46581773c1
commit 3f97d75778
Notes: sideshowbarker 2024-07-19 05:04:44 +09:00
107 changed files with 2031 additions and 2243 deletions

View file

@ -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();
});

View file

@ -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();
});

View file

@ -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");
});

View file

@ -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");
});

View file

@ -1,11 +1,5 @@
load("test-common.js");
try {
assert(Date.length === 7);
assert(Date.name === "Date");
assert(Date.prototype.length === undefined);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("basic functionality", () => {
expect(Date).toHaveLength(7);
expect(Date.name === "Date");
expect(Date.prototype).not.toHaveProperty("length");
});

View file

@ -1,15 +1,10 @@
load("test-common.js");
try {
test("basic functionality", () => {
var last = 0;
for (var i = 0; i < 100; ++i) {
var now = Date.now();
assert(!isNaN(now))
assert(now > 1580000000000);
assert(now >= last);
expect(now).not.toBeNaN();
expect(now).toBeGreaterThan(1580000000000);
expect(now).toBeGreaterThanOrEqual(last);
last = now;
}
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
var d = new Date();
assert(!isNaN(d.getDate()));
assert(1 <= d.getDate() <= 31);
assert(d.getDate() === d.getDate());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("basic functionality", () => {
let d = new Date();
expect(d.getDate()).toBe(d.getDate());
expect(d.getDate()).not.toBeNaN();
expect(d.getDate()).toBeGreaterThanOrEqual(1);
expect(d.getDate()).toBeLessThanOrEqual(31);
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getDay()));
assert(0 <= d.getDay() <= 6);
assert(d.getDay() === d.getDay());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getDay()).toBe(d.getDay());
expect(d.getDay()).not.toBeNaN();
expect(d.getDay()).toBeGreaterThanOrEqual(0);
expect(d.getDay()).toBeLessThanOrEqual(6);
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getFullYear()));
assert(d.getFullYear() >= 2020);
assert(d.getFullYear() === d.getFullYear());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getFullYear()).toBe(d.getFullYear());
expect(d.getFullYear()).not.toBeNaN();
expect(d.getFullYear()).toBe(d.getFullYear());
expect(d.getFullYear()).toBeGreaterThanOrEqual(2020);
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getHours()));
assert(0 <= d.getHours() <= 23);
assert(d.getHours() === d.getHours());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getHours()).toBe(d.getHours());
expect(d.getHours()).not.toBeNaN();
expect(d.getHours()).toBeGreaterThanOrEqual(0);
expect(d.getHours()).toBeLessThanOrEqual(23);
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getMilliseconds()));
assert(0 <= d.getMilliseconds() <= 999);
assert(d.getMilliseconds() === d.getMilliseconds());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getMilliseconds()).toBe(d.getMilliseconds());
expect(d.getMilliseconds()).not.toBeNaN();
expect(d.getMilliseconds()).toBeGreaterThanOrEqual(0);
expect(d.getMilliseconds()).toBeLessThanOrEqual(999);
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getMinutes()));
assert(0 <= d.getMinutes() <= 59);
assert(d.getMinutes() === d.getMinutes());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getMinutes()).toBe(d.getMinutes());
expect(d.getMinutes()).not.toBeNaN();
expect(d.getMinutes()).toBeGreaterThanOrEqual(0);
expect(d.getMinutes()).toBeLessThanOrEqual(59);
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getMonth()));
assert(0 <= d.getMonth() <= 11);
assert(d.getMonth() === d.getMonth());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getMonth()).toBe(d.getMonth());
expect(d.getMonth()).not.toBeNaN();
expect(d.getMonth()).toBeGreaterThanOrEqual(0);
expect(d.getMonth()).toBeLessThanOrEqual(11);
});

View file

@ -1,11 +1,7 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getSeconds()));
assert(0 <= d.getSeconds() <= 59);
assert(d.getSeconds() === d.getSeconds());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getSeconds()).toBe(d.getSeconds());
expect(d.getSeconds()).not.toBeNaN();
expect(d.getSeconds()).toBeGreaterThanOrEqual(0);
expect(d.getSeconds()).toBeLessThanOrEqual(59);
});

View file

@ -1,11 +1,6 @@
load("test-common.js");
try {
test("basic functionality", () => {
var d = new Date();
assert(!isNaN(d.getTime()));
assert(d.getTime() > 1580000000000);
assert(d.getTime() === d.getTime());
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(d.getTime()).toBe(d.getTime());
expect(d.getTime()).not.toBeNaN();
expect(d.getTime()).toBeGreaterThanOrEqual(1580000000000);
});

View file

@ -1,33 +1,18 @@
load("test-common.js");
test("basic functionality", () => {
expect(Error).toHaveLength(1);
expect(Error.name).toBe("Error");
});
try {
assert(Error.length === 1);
assert(Error.name === "Error");
assert(Error.prototype.length === undefined);
test("name", () => {
[Error(), Error(undefined), Error("test"), Error(42), Error(null)].forEach(error => {
expect(error.name).toBe("Error");
});
});
var e;
e = Error();
assert(e.name === "Error");
assert(e.message === "");
e = Error(undefined);
assert(e.name === "Error");
assert(e.message === "");
e = Error("test");
assert(e.name === "Error");
assert(e.message === "test");
e = Error(42);
assert(e.name === "Error");
assert(e.message === "42");
e = Error(null);
assert(e.name === "Error");
assert(e.message === "null");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("message", () => {
expect(Error().message).toBe("");
expect(Error(undefined).message).toBe("");
expect(Error("test").message).toBe("test");
expect(Error(42).message).toBe("42");
expect(Error(null).message).toBe("null");
});

View file

@ -1,14 +1,10 @@
load("test-common.js");
try {
test("basic functionality", () => {
expect(Error.prototype).not.toHaveProperty("length");
var changedInstance = new Error("");
changedInstance.name = 'NewCustomError';
assert(changedInstance.name === "NewCustomError");
changedInstance.name = "NewCustomError";
expect(changedInstance.name).toBe("NewCustomError");
var normalInstance = new Error("");
assert(normalInstance.name === "Error");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}
expect(normalInstance.name).toBe("Error");
});

View file

@ -1,13 +1,7 @@
load("test-common.js");
try {
assert(Error().toString() === "Error");
assert(Error(undefined).toString() === "Error");
assert(Error(null).toString() === "Error: null");
assert(Error("test").toString() === "Error: test");
assert(Error(42).toString() === "Error: 42");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("basic functionality", () => {
expect(Error().toString()).toBe("Error");
expect(Error(undefined).toString()).toBe("Error");
expect(Error(null).toString()).toBe("Error: null");
expect(Error("test").toString()).toBe("Error: test");
expect(Error(42).toString()).toBe("Error: 42");
});

View file

@ -1,42 +1,44 @@
load("test-common.js");
try {
assert(Function.length === 1);
assert(Function.name === "Function");
assert(Function.prototype.length === 0);
assert(Function.prototype.name === "");
assert(typeof Function() === "function");
assert(typeof new Function() === "function");
assert(Function()() === undefined);
assert(new Function()() === undefined);
assert(Function("return 42")() === 42);
assert(new Function("return 42")() === 42);
assert(new Function("foo", "return foo")(42) === 42);
assert(new Function("foo,bar", "return foo + bar")(1, 2) === 3);
assert(new Function("foo", "bar", "return foo + bar")(1, 2) === 3);
assert(new Function("foo", "bar,baz", "return foo + bar + baz")(1, 2, 3) === 6);
assert(new Function("foo", "bar", "baz", "return foo + bar + baz")(1, 2, 3) === 6);
assert(new Function("foo", "if (foo) { return 42; } else { return 'bar'; }")(true) === 42);
assert(new Function("foo", "if (foo) { return 42; } else { return 'bar'; }")(false) === "bar");
assert(new Function("return typeof Function()")() === "function");
assert(new Function("x", "return function (y) { return x + y };")(1)(2) === 3);
assert(new Function().name === "anonymous");
assert(new Function().toString() === "function anonymous() {\n ???\n}");
assertThrowsError(() => {
new Function("[");
}, {
error: SyntaxError,
// This might be confusing at first but keep in mind it's actually parsing
// function anonymous() { [ }
// This is in line with what other engines are reporting.
message: "Unexpected token CurlyClose. Expected BracketClose (line: 1, column: 26)"
describe("correct behavior", () => {
test("constructor properties", () => {
expect(Function).toHaveLength(1);
expect(Function.name).toBe("Function");
expect(Function.prototype).toHaveLength(0);
expect(Function.prototype.name).toBe("");
});
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}
test("typeof", () => {
expect(typeof Function()).toBe("function");
expect(typeof new Function()).toBe("function");
});
test("basic functionality", () => {
expect(Function()()).toBe(undefined);
expect(new Function()()).toBe(undefined);
expect(Function("return 42")()).toBe(42);
expect(new Function("return 42")()).toBe(42);
expect(new Function("foo", "return foo")(42)).toBe(42);
expect(new Function("foo,bar", "return foo + bar")(1, 2)).toBe(3);
expect(new Function("foo", "bar", "return foo + bar")(1, 2)).toBe(3);
expect(new Function("foo", "bar,baz", "return foo + bar + baz")(1, 2, 3)).toBe(6);
expect(new Function("foo", "bar", "baz", "return foo + bar + baz")(1, 2, 3)).toBe(6);
expect(new Function("foo", "if (foo) { return 42; } else { return 'bar'; }")(true)).toBe(42);
expect(new Function("foo", "if (foo) { return 42; } else { return 'bar'; }")(false)).toBe("bar");
expect(new Function("return typeof Function()")()).toBe("function");
expect(new Function("x", "return function (y) { return x + y };")(1)(2)).toBe(3);
expect(new Function().name).toBe("anonymous");
expect(new Function().toString()).toBe("function anonymous() {\n ???\n}");
});
});
describe("errors", () => {
test("syntax error", () => {
expect(() => {
new Function("[");
})
// This might be confusing at first but keep in mind it's actually parsing
// function anonymous() { [ }
// This is in line with what other engines are reporting.
.toThrowWithMessage(SyntaxError, "Unexpected token CurlyClose. Expected BracketClose (line: 1, column: 26)");
});
});

View file

@ -1,6 +1,4 @@
load("test-common.js");
try {
test("basic functionality", () => {
function Foo(arg) {
this.foo = arg;
}
@ -17,39 +15,35 @@ try {
this.baz = arg;
}
assert(Function.prototype.apply.length === 2);
expect(Function.prototype.apply).toHaveLength(2);
var foo = new Foo("test");
assert(foo.foo === "test");
assert(foo.bar === undefined);
assert(foo.baz === undefined);
expect(foo.foo).toBe("test");
expect(foo.bar).toBeUndefined();
expect(foo.baz).toBeUndefined();
var bar = new Bar("test");
assert(bar.foo === undefined);
assert(bar.bar === "test");
assert(bar.baz === undefined);
expect(bar.foo).toBeUndefined();
expect(bar.bar).toBe("test");
expect(bar.baz).toBeUndefined();
var foobar = new FooBar("test");
assert(foobar.foo === "test");
assert(foobar.bar === "test");
assert(foobar.baz === undefined);
expect(foobar.foo).toBe("test");
expect(foobar.bar).toBe("test");
expect(foobar.baz).toBeUndefined();
var foobarbaz = new FooBarBaz("test");
assert(foobarbaz.foo === "test");
assert(foobarbaz.bar === "test");
assert(foobarbaz.baz === "test");
expect(foobarbaz.foo).toBe("test");
expect(foobarbaz.bar).toBe("test");
expect(foobarbaz.baz).toBe("test");
assert(Math.abs.apply(null, [-1]) === 1);
expect(Math.abs.apply(null, [-1])).toBe(1);
var add = (x, y) => x + y;
assert(add.apply(null, [1, 2]) === 3);
expect(add.apply(null, [1, 2])).toBe(3);
var multiply = function (x, y) { return x * y; };
assert(multiply.apply(null, [3, 4]) === 12);
expect(multiply.apply(null, [3, 4])).toBe(12);
assert((() => this).apply("foo") === globalThis);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect((() => this).apply("foo")).toBe(globalThis);
});

View file

@ -1,124 +1,138 @@
load("test-common.js");
describe("basic behavior", () => {
test("basic binding", () => {
expect(Function.prototype.bind.length).toBe(1);
try {
assert(Function.prototype.bind.length === 1);
var charAt = String.prototype.charAt.bind("bar");
expect(charAt(0) + charAt(1) + charAt(2)).toBe("bar");
var charAt = String.prototype.charAt.bind("bar");
assert(charAt(0) + charAt(1) + charAt(2) === "bar");
function getB() {
return this.toUpperCase().charAt(0);
}
expect(getB.bind("bar")()).toBe("B");
});
function getB() {
return this.toUpperCase().charAt(0);
}
assert(getB.bind("bar")() === "B");
test("bound functions work with array functions", () => {
var Make3 = Number.bind(null, 3);
expect([55].map(Make3)[0]).toBe(3);
// Bound functions should work with array functions
var Make3 = Number.bind(null, 3);
assert([55].map(Make3)[0] === 3);
var MakeTrue = Boolean.bind(null, true);
var MakeTrue = Boolean.bind(null, true);
assert([1, 2, 3].filter(MakeTrue).length === 3);
assert([1, 2, 3].reduce((function (acc, x) { return acc + x }).bind(null, 4, 5)) === 9);
assert([1, 2, 3].reduce((function (acc, x) { return acc + x + this; }).bind(3)) === 12);
expect([1, 2, 3].filter(MakeTrue).length).toBe(3);
expect([1, 2, 3].reduce((function (acc, x) { return acc + x }).bind(null, 4, 5))).toBe(9);
expect([1, 2, 3].reduce((function (acc, x) { return acc + x + this; }).bind(3))).toBe(12);
});
});
describe("bound function arguments", () => {
function sum(a, b, c) {
return a + b + c;
}
// Arguments should be able to be bound to a function.
var boundSum = sum.bind(null, 10, 5);
assert(isNaN(boundSum()));
assert(boundSum(5) === 20);
assert(boundSum(5, 6, 7) === 20);
test("arguments are bound to the function", () => {
expect(boundSum()).toBeNaN();
expect(boundSum(5)).toBe(20);
expect(boundSum(5, 6, 7)).toBe(20);
});
// Arguments should be appended to a BoundFunction's bound arguments.
assert(boundSum.bind(null, 5)() === 20);
test("arguments are appended to a BoundFunction's bound arguments", () => {
expect(boundSum.bind(null, 5)()).toBe(20);
});
// A BoundFunction's length property should be adjusted based on the number
// of bound arguments.
assert(sum.length === 3);
assert(boundSum.length === 1);
assert(boundSum.bind(null, 5).length === 0);
assert(boundSum.bind(null, 5, 6, 7, 8).length === 0);
test("binding a constructor's arguments", () => {
var Make5 = Number.bind(null, 5);
expect(Make5()).toBe(5);
expect(new Make5().valueOf()).toBe(5);
});
test("length property", () => {
expect(sum).toHaveLength(3);
expect(boundSum).toHaveLength(1);
expect(boundSum.bind(null, 5)).toHaveLength(0);
expect(boundSum.bind(null, 5, 6, 7, 8)).toHaveLength(0);
});
})
describe("bound function |this|", () => {
function identity() {
return this;
}
// It should capture the global object if the |this| value is null or undefined.
assert(identity.bind()() === globalThis);
assert(identity.bind(null)() === globalThis);
assert(identity.bind(undefined)() === globalThis);
test("captures global object as |this| if |this| is null or undefined", () => {
expect(identity.bind()()).toBe(globalThis);
expect(identity.bind(null)()).toBe(globalThis);
expect(identity.bind(undefined)()).toBe(globalThis);
function Foo() {
assert(identity.bind()() === globalThis);
assert(identity.bind(this)() === this);
}
new Foo();
function Foo() {
expect(identity.bind()()).toBe(globalThis);
expect(identity.bind(this)()).toBe(this);
}
new Foo();
});
// Primitive |this| values should be converted to objects.
assert(identity.bind("foo")() instanceof String);
assert(identity.bind(123)() instanceof Number);
assert(identity.bind(true)() instanceof Boolean);
test("does not capture global object as |this| if |this| is null or undefined in strict mode", () => {
"use strict";
// It should retain |this| values passed to it.
var obj = { foo: "bar" };
function strictIdentity() {
return this;
}
assert(identity.bind(obj)() === obj);
expect(strictIdentity.bind()()).toBeUndefined();
expect(strictIdentity.bind(null)()).toBeNull();
expect(strictIdentity.bind(undefined)()).toBeUndefined();
});
// The bound |this| can not be changed once set
assert(identity.bind("foo").bind(123)() instanceof String);
test("primitive |this| values are converted to objects", () => {
expect(identity.bind("foo")()).toBeInstanceOf(String);
expect(identity.bind(123)()).toBeInstanceOf(Number);
expect(identity.bind(true)()).toBeInstanceOf(Boolean);
});
// The bound |this| value should have no effect on a constructor.
test("bound functions retain |this| values passed to them", () => {
var obj = { foo: "bar" };
expect(identity.bind(obj)()).toBe(obj);
});
test("bound |this| cannot be changed after being set", () => {
expect(identity.bind("foo").bind(123)()).toBeInstanceOf(String);
});
test("arrow functions cannot be bound", () => {
expect((() => this).bind("foo")()).toBe(globalThis)
});
})
describe("bound function constructors", () => {
function Bar() {
this.x = 3;
this.y = 4;
}
Bar.prototype.baz = "baz";
var BoundBar = Bar.bind({ u: 5, v: 6 });
var bar = new BoundBar();
assert(bar.x === 3);
assert(bar.y === 4);
assert(typeof bar.u === "undefined");
assert(typeof bar.v === "undefined");
// Objects constructed from BoundFunctions should retain the prototype of the original function.
assert(bar.baz === "baz");
// BoundFunctions should not have a prototype property.
assert(typeof BoundBar.prototype === "undefined");
// Function.prototype.bind should not accept non-function values.
assertThrowsError(() => {
Function.prototype.bind.call("foo");
}, {
error: TypeError,
message: "Not a Function object"
test("bound |this| value does not affect constructor", () => {
expect(bar.x).toBe(3);
expect(bar.y).toBe(4);
expect(typeof bar.u).toBe("undefined");
expect(typeof bar.v).toBe("undefined");
});
// A constructor's arguments should be able to be bound.
var Make5 = Number.bind(null, 5);
assert(Make5() === 5);
assert(new Make5().valueOf() === 5);
test("bound functions retain original prototype", () => {
expect(bar.baz).toBe("baz");
});
// Null or undefined should be passed through as a |this| value in strict mode.
(() => {
"use strict";
function strictIdentity() {
return this;
}
test("bound functions do not have a prototype property", () => {
expect(BoundBar).not.toHaveProperty("prototype");
});
});
assert(strictIdentity.bind()() === undefined);
assert(strictIdentity.bind(null)() === null);
assert(strictIdentity.bind(undefined)() === undefined);
})();
// Arrow functions can not have their |this| value set.
assert((() => this).bind("foo")() === globalThis)
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
describe("errors", () => {
test("does not accept non-function values", () => {
expect(() => {
Function.prototype.bind.call("foo");
}).toThrowWithMessage(TypeError, "Not a Function object");
});
});

View file

@ -1,6 +1,8 @@
load("test-common.js");
test("length", () => {
expect(Function.prototype.call).toHaveLength(1);
});
try {
test("basic functionality", () => {
function Foo(arg) {
this.foo = arg;
}
@ -17,39 +19,33 @@ try {
this.baz = arg;
}
assert(Function.prototype.call.length === 1);
var foo = new Foo("test");
assert(foo.foo === "test");
assert(foo.bar === undefined);
assert(foo.baz === undefined);
expect(foo.foo).toBe("test");
expect(foo.bar).toBeUndefined();
expect(foo.baz).toBeUndefined();
var bar = new Bar("test");
assert(bar.foo === undefined);
assert(bar.bar === "test");
assert(bar.baz === undefined);
expect(bar.foo).toBeUndefined();
expect(bar.bar).toBe("test");
expect(bar.baz).toBeUndefined();
var foobar = new FooBar("test");
assert(foobar.foo === "test");
assert(foobar.bar === "test");
assert(foobar.baz === undefined);
expect(foobar.foo).toBe("test");
expect(foobar.bar).toBe("test");
expect(foobar.baz).toBeUndefined();
var foobarbaz = new FooBarBaz("test");
assert(foobarbaz.foo === "test");
assert(foobarbaz.bar === "test");
assert(foobarbaz.baz === "test");
expect(foobarbaz.foo).toBe("test");
expect(foobarbaz.bar).toBe("test");
expect(foobarbaz.baz).toBe("test");
assert(Math.abs.call(null, -1) === 1);
expect(Math.abs.call(null, -1)).toBe(1);
var add = (x, y) => x + y;
assert(add.call(null, 1, 2) === 3);
expect(add.call(null, 1, 2)).toBe(3);
var multiply = function (x, y) { return x * y; };
assert(multiply.call(null, 3, 4) === 12);
expect(multiply.call(null, 3, 4)).toBe(12);
assert((() => this).call("foo") === globalThis);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect((() => this).call("foo")).toBe(globalThis);
});

View file

@ -1,21 +1,15 @@
load("test-common.js");
try {
assert((function() {}).toString() === "function () {\n ???\n}");
assert((function(foo) {}).toString() === "function (foo) {\n ???\n}");
assert((function(foo, bar, baz) {}).toString() === "function (foo, bar, baz) {\n ???\n}");
assert((function(foo, bar, baz) {
test("basic functionality", () => {
expect((function() {}).toString()).toBe("function () {\n ???\n}");
expect((function(foo) {}).toString()).toBe("function (foo) {\n ???\n}");
expect((function(foo, bar, baz) {}).toString()).toBe("function (foo, bar, baz) {\n ???\n}");
expect((function(foo, bar, baz) {
if (foo) {
return baz;
} else if (bar) {
return foo;
}
return bar + 42;
}).toString() === "function (foo, bar, baz) {\n ???\n}");
assert(console.log.toString() === "function log() {\n [NativeFunction]\n}");
assert(Function.toString() === "function Function() {\n [FunctionConstructor]\n}");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
}).toString()).toBe("function (foo, bar, baz) {\n ???\n}");
expect(console.debug.toString()).toBe("function debug() {\n [NativeFunction]\n}");
expect(Function.toString()).toBe("function Function() {\n [FunctionConstructor]\n}");
});

View file

@ -1,27 +0,0 @@
load("test-common.js");
try {
assert(Infinity + "" === "Infinity");
assert(-Infinity + "" === "-Infinity");
assert(Infinity === Infinity);
assert(Infinity - 1 === Infinity);
assert(Infinity + 1 === Infinity);
assert(-Infinity === -Infinity);
assert(-Infinity - 1 === -Infinity);
assert(-Infinity + 1 === -Infinity);
assert(1 / Infinity === 0);
assert(1 / -Infinity === 0);
assert(1 / 0 === Infinity);
assert(-1 / 0 === -Infinity);
assert(-100 < Infinity);
assert(0 < Infinity);
assert(100 < Infinity);
assert(-Infinity < Infinity);
assert(-100 > -Infinity);
assert(0 > -Infinity);
assert(100 > -Infinity);
assert(Infinity > -Infinity);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,22 @@
test("basic functionality", () => {
expect(Infinity + "").toBe("Infinity");
expect(-Infinity + "").toBe("-Infinity");
expect(Infinity).toBe(Infinity);
expect(Infinity - 1).toBe(Infinity);
expect(Infinity + 1).toBe(Infinity);
expect(-Infinity).toBe(-Infinity);
expect(-Infinity - 1).toBe(-Infinity);
expect(-Infinity + 1).toBe(-Infinity);
expect(1 / Infinity).toBe(0);
expect(1 / -Infinity).toBe(-0);
expect(1 / 0).toBe(Infinity);
expect(-1 / 0).toBe(-Infinity);
expect(-100).toBeLessThan(Infinity);
expect(0).toBeLessThan(Infinity);
expect(100).toBeLessThan(Infinity);
expect(-Infinity).toBeLessThan(Infinity);
expect(-100).toBeGreaterThan(-Infinity);
expect(0).toBeGreaterThan(-Infinity);
expect(100).toBeGreaterThan(-Infinity);
expect(Infinity).toBeGreaterThan(-Infinity);
});

View file

@ -1,15 +1,9 @@
load("test-common.js");
try {
test("basic functionality", () => {
let string = `{"var1":10,"var2":"hello","var3":{"nested":5}}`;
let object = JSON.parse(string, (key, value) => typeof value === "number" ? value * 2 : value);
assertDeepEquals(object, { var1: 20, var2: "hello", var3: { nested: 10 } });
expect(object).toEqual({ var1: 20, var2: "hello", var3: { nested: 10 } });
object = JSON.parse(string, (key, value) => typeof value === "number" ? undefined : value);
assertDeepEquals(object, { var2: "hello", var3: {} });
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(object).toEqual({ var2: "hello", var3: {} });
});

View file

@ -1,7 +1,5 @@
load("test-common.js");
try {
assert(JSON.parse.length === 2);
test("basic functionality", () => {
expect(JSON.parse).toHaveLength(2);
const properties = [
["5", 5],
@ -14,10 +12,12 @@ try {
];
properties.forEach(testCase => {
assertDeepEquals(JSON.parse(testCase[0]), testCase[1]);
expect(JSON.parse(testCase[0])).toEqual(testCase[1]);
});
});
let syntaxErrors = [
test("syntax errors", () => {
[
undefined,
NaN,
-NaN,
@ -29,15 +29,9 @@ try {
"[1,2,3, ]",
'{ "foo": "bar",}',
'{ "foo": "bar", }',
];
syntaxErrors.forEach(error => assertThrowsError(() => {
JSON.parse(error);
}, {
error: SyntaxError,
}));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
].forEach(test => {
expect(() => {
JSON.parse(test);
}).toThrow(SyntaxError);
});
});

View file

@ -1,8 +1,4 @@
load("test-common.js");
try {
assert(JSON.stringify.length === 3);
test("basic functionality", () => {
let o = {
key1: "key1",
key2: "key2",
@ -28,9 +24,5 @@ try {
o.key1 = "key1";
assert(JSON.stringify(o) === '{"0":0,"1":1,"2":2,"key2":"key2","defined":"defined","key4":"key4","key1":"key1"}');
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(JSON.stringify(o)).toBe('{"0":0,"1":1,"2":2,"key2":"key2","defined":"defined","key4":"key4","key1":"key1"}');
});

View file

@ -1,6 +1,4 @@
load("test-common.js");
try {
test("basic functionality", () => {
let p = new Proxy([], {
get(_, key) {
if (key === "length")
@ -9,10 +7,6 @@ try {
},
});
assert(JSON.stringify(p) === "[0,1,2]");
assert(JSON.stringify([[new Proxy(p, {})]]) === "[[[0,1,2]]]");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(JSON.stringify(p)).toBe("[0,1,2]");
expect(JSON.stringify([[new Proxy(p, {})]])).toBe("[[[0,1,2]]]");
});

View file

@ -1,6 +1,4 @@
load("test-common.js");
try {
test("basic functionality", () => {
let o = {
var1: "foo",
var2: 42,
@ -25,15 +23,11 @@ try {
return value;
});
assert(string === '{"var1":"foo","var2":42,"arr":[1,2,{"nested":{},"x":20}],"obj":{"subarr":[3,4,5]}}');
expect(string).toBe('{"var1":"foo","var2":42,"arr":[1,2,{"nested":{},"x":20}],"obj":{"subarr":[3,4,5]}}');
string = JSON.stringify(o, ["var1", "var1", "var2", "obj"]);
assert(string == '{"var1":"foo","var2":42,"obj":{}}');
expect(string).toBe('{"var1":"foo","var2":42,"obj":{}}');
string = JSON.stringify(o, ["var1", "var1", "var2", "obj", "subarr"]);
assert(string == '{"var1":"foo","var2":42,"obj":{"subarr":[3]}}');
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(string).toBe('{"var1":"foo","var2":42,"obj":{"subarr":[3]}}');
});

View file

@ -1,6 +1,4 @@
load("test-common.js");
try {
test("basic functionality", () => {
let o = {
foo: 1,
bar: "baz",
@ -26,7 +24,7 @@ try {
}
}`;
assert(string === expected);
expect(string).toBe(expected);
string = JSON.stringify(o, null, "abcd");
expected =
@ -43,9 +41,5 @@ abcdabcd]
abcd}
}`;
assert(string === expected);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(string).toBe(expected);
});

View file

@ -1,71 +1,71 @@
load("test-common.js");
try {
assert(JSON.stringify.length === 3);
assertThrowsError(() => {
JSON.stringify(5n);
}, {
error: TypeError,
message: "Cannot serialize BigInt value to JSON",
describe("correct behavior", () => {
test("length", () => {
expect(JSON.stringify).toHaveLength(3);
});
const properties = [
[5, "5"],
[undefined, undefined],
[null, "null"],
[NaN, "null"],
[-NaN, "null"],
[Infinity, "null"],
[-Infinity, "null"],
[true, "true"],
[false, "false"],
["test", '"test"'],
[new Number(5), "5"],
[new Boolean(false), "false"],
[new String("test"), '"test"'],
[() => {}, undefined],
[[1, 2, "foo"], '[1,2,"foo"]'],
[{ foo: 1, bar: "baz", qux() {} }, '{"foo":1,"bar":"baz"}'],
test("basic functionality", () => {
[
{
var1: 1,
var2: 2,
toJSON(key) {
let o = this;
o.var2 = 10;
return o;
}
},
'{"var1":1,"var2":10}',
],
];
properties.forEach(testCase => {
assert(JSON.stringify(testCase[0]) === testCase[1]);
[5, "5"],
[undefined, undefined],
[null, "null"],
[NaN, "null"],
[-NaN, "null"],
[Infinity, "null"],
[-Infinity, "null"],
[true, "true"],
[false, "false"],
["test", '"test"'],
[new Number(5), "5"],
[new Boolean(false), "false"],
[new String("test"), '"test"'],
[() => {}, undefined],
[[1, 2, "foo"], '[1,2,"foo"]'],
[{ foo: 1, bar: "baz", qux() {} }, '{"foo":1,"bar":"baz"}'],
[
{
var1: 1,
var2: 2,
toJSON(key) {
let o = this;
o.var2 = 10;
return o;
}
},
'{"var1":1,"var2":10}',
],
].forEach(testCase => {
expect(JSON.stringify(testCase[0])).toEqual(testCase[1]);
});
});
let bad1 = {};
bad1.foo = bad1;
let bad2 = [];
bad2[5] = [[[bad2]]];
test("ignores non-enumerable properties", () => {
let o = { foo: "bar" };
Object.defineProperty(o, "baz", { value: "qux", enumerable: false });
expect(JSON.stringify(o)).toBe('{"foo":"bar"}');
});
});
let bad3a = { foo: "bar" };
let bad3b = [1, 2, bad3a];
bad3a.bad = bad3b;
describe("errors", () => {
test("cannot serialize BigInt", () => {
expect(() => {
JSON.stringify(5n);
}).toThrow(TypeError, "Cannot serialize BigInt value to JSON");
});
[bad1, bad2, bad3a].forEach(bad => assertThrowsError(() => {
JSON.stringify(bad);
}, {
error: TypeError,
message: "Cannot stringify circular object",
}));
test("cannot serialize circular structures", () => {
let bad1 = {};
bad1.foo = bad1;
let bad2 = [];
bad2[5] = [[[bad2]]];
let o = { foo: "bar" };
Object.defineProperty(o, "baz", { value: "qux", enumerable: false });
assert(JSON.stringify(o) === '{"foo":"bar"}');
let bad3a = { foo: "bar" };
let bad3b = [1, 2, bad3a];
bad3a.bad = bad3b;
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
[bad1, bad2, bad3a].forEach(bad => {
expect(() => {
JSON.stringify(bad);
}).toThrow(TypeError, "Cannot stringify circular object");
});
});
});

View file

@ -1,16 +1,10 @@
load("test-common.js");
try {
assert(isClose(Math.E, 2.718281));
assert(isClose(Math.LN2, 0.693147));
assert(isClose(Math.LN10, 2.302585));
assert(isClose(Math.LOG2E, 1.442695));
assert(isClose(Math.LOG10E, 0.434294));
assert(isClose(Math.PI, 3.1415926));
assert(isClose(Math.SQRT1_2, 0.707106));
assert(isClose(Math.SQRT2, 1.414213));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("basic functionality", () => {
expect(Math.E).toBeCloseTo(2.718281);
expect(Math.LN2).toBeCloseTo(0.693147);
expect(Math.LN10).toBeCloseTo(2.302585);
expect(Math.LOG2E).toBeCloseTo(1.442695);
expect(Math.LOG10E).toBeCloseTo(0.434294);
expect(Math.PI).toBeCloseTo(3.1415926);
expect(Math.SQRT1_2).toBeCloseTo(0.707106);
expect(Math.SQRT2).toBeCloseTo(1.414213);
});

View file

@ -1,16 +1,14 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.abs).toHaveLength(1);
try {
assert(Math.abs('-1') === 1);
assert(Math.abs(-2) === 2);
assert(Math.abs(null) === 0);
assert(Math.abs('') === 0);
assert(Math.abs([]) === 0);
assert(Math.abs([2]) === 2);
assert(isNaN(Math.abs([1, 2])));
assert(isNaN(Math.abs({})));
assert(isNaN(Math.abs('string')));
assert(isNaN(Math.abs()));
console.log("PASS");
} catch {
}
expect(Math.abs('-1')).toBe(1);
expect(Math.abs(-2)).toBe(2);
expect(Math.abs(null)).toBe(0);
expect(Math.abs('')).toBe(0);
expect(Math.abs([])).toBe(0);
expect(Math.abs([2])).toBe(2);
expect(Math.abs([1, 2])).toBeNaN();
expect(Math.abs({})).toBeNaN();
expect(Math.abs('string')).toBeNaN();
expect(Math.abs()).toBeNaN();
});

View file

@ -1,13 +1,9 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.acosh).toHaveLength(1);
try {
assert(isNaN(Math.acosh(-1)));
assert(isNaN(Math.acosh(0)));
assert(isNaN(Math.acosh(0.5)));
assert(isClose(Math.acosh(1), 0));
// FIXME: assert(isClose(Math.acosh(2), 1.316957));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.acosh(-1)).toBeNaN();
expect(Math.acosh(0)).toBeNaN();
expect(Math.acosh(0.5)).toBeNaN();
expect(Math.acosh(1)).toBeCloseTo(0);
// FIXME: expect(Math.acosh(2)).toBeCloseTo(1.316957);
});

View file

@ -1,11 +1,6 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.asinh).toHaveLength(1);
try {
assert(isClose(Math.asinh(0), 0));
// FIXME: assert(isClose(Math.asinh(1), 0.881373));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.asinh(0)).toBeCloseTo(0);
// FIXME: expect(Math.asinh(1)).toBeCloseTo(0.881373);
});

View file

@ -1,14 +1,10 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.atanh).toHaveLength(1);
try {
assert(isNaN(Math.atanh(-2)));
assert(Math.atanh(-1) === -Infinity);
// FIXME: assert(Math.atanh(0) === 0);
assert(isClose(Math.atanh(0.5), 0.549306));
// FIXME: assert(Math.atanh(1) === Infinity);
assert(isNaN(Math.atanh(2)));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.atanh(-2)).toBeNaN();
expect(Math.atanh(2)).toBeNaN();
expect(Math.atanh(-1)).toBe(-Infinity);
// FIXME: expect(Math.atanh(0)).toBe(0);
expect(Math.atanh(0.5)).toBeCloseTo(0.549306);
// FIXME: expect(Math.atanh(1)).toBe(Infinity);
});

View file

@ -1,16 +1,12 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.cbrt).toHaveLength(1);
try {
assert(isNaN(Math.cbrt(NaN)));
// FIXME: assert(Math.cbrt(-1) === -1);
assert(Math.cbrt(-0) === -0);
// FIXME: assert(Math.cbrt(-Infinity) === -Infinity);
// FIXME: assert(Math.cbrt(1) === 1);
// FIXME: assert(Math.cbrt(Infinity) === Infinity);
assert(Math.cbrt(null) === 0);
// FIXME: assert(isClose(Math.cbrt(2), 1.259921));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.cbrt(NaN)).toBeNaN();
// FIXME: expect(Math.cbrt(-1)).toBe(-1);
expect(Math.cbrt(-0)).toBe(-0);
// FIXME: expect(Math.cbrt(-Infinity)).toBe(-Infinity);
// FIXME: expect(Math.cbrt(1)).toBe(1);
// FIXME: expect(Math.cbrt(Infinity)).toBe(Infinity);
expect(Math.cbrt(null)).toBe(0);
// FIXME: expect(Math.cbrt(2)).toBeCloseTo(1.259921));
});

View file

@ -1,19 +1,13 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.ceil).toHaveLength(1);
try {
assert(Math.ceil(0.95) === 1);
assert(Math.ceil(4) === 4);
assert(Math.ceil(7.004) == 8);
assert(Math.ceil(-0.95) === -0);
assert(Math.ceil(-4) === -4);
assert(Math.ceil(-7.004) === -7);
expect(Math.ceil(0.95)).toBe(1);
expect(Math.ceil(4)).toBe(4);
expect(Math.ceil(7.004)).toBe(8);
expect(Math.ceil(-0.95)).toBe(-0);
expect(Math.ceil(-4) ).toBe(-4);
expect(Math.ceil(-7.004)).toBe(-7);
assert(isNaN(Math.ceil()));
assert(isNaN(Math.ceil(NaN)));
assert(Math.ceil.length === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.ceil()).toBeNaN();
expect(Math.ceil(NaN)).toBeNaN();
});

View file

@ -1,50 +1,44 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.clz32).toHaveLength(1);
try {
assert(Math.clz32.length === 1);
expect(Math.clz32(0)).toBe(32);
expect(Math.clz32(1)).toBe(31);
expect(Math.clz32(2)).toBe(30);
expect(Math.clz32(3)).toBe(30);
expect(Math.clz32(4)).toBe(29);
expect(Math.clz32(5)).toBe(29);
expect(Math.clz32(-1)).toBe(0);
expect(Math.clz32(-10)).toBe(0);
expect(Math.clz32(-100)).toBe(0);
expect(Math.clz32(-1000)).toBe(0);
expect(Math.clz32(-0.123)).toBe(32);
expect(Math.clz32(0.123)).toBe(32);
expect(Math.clz32(1.23)).toBe(31);
expect(Math.clz32(12)).toBe(28);
expect(Math.clz32(123)).toBe(25);
expect(Math.clz32(1234)).toBe(21);
expect(Math.clz32(12345)).toBe(18);
expect(Math.clz32(123456)).toBe(15);
expect(Math.clz32(1234567)).toBe(11);
expect(Math.clz32(12345678)).toBe(8);
expect(Math.clz32(123456789)).toBe(5);
expect(Math.clz32(999999999)).toBe(2);
expect(Math.clz32(9999999999)).toBe(1);
expect(Math.clz32(99999999999)).toBe(1);
expect(Math.clz32(999999999999)).toBe(0);
expect(Math.clz32(9999999999999)).toBe(1);
expect(Math.clz32(99999999999999)).toBe(3);
expect(Math.clz32(999999999999999)).toBe(0);
assert(Math.clz32(0) === 32);
assert(Math.clz32(1) === 31);
assert(Math.clz32(2) === 30);
assert(Math.clz32(3) === 30);
assert(Math.clz32(4) === 29);
assert(Math.clz32(5) === 29);
assert(Math.clz32(-1) === 0);
assert(Math.clz32(-10) === 0);
assert(Math.clz32(-100) === 0);
assert(Math.clz32(-1000) === 0);
assert(Math.clz32(-0.123) === 32);
assert(Math.clz32(0.123) === 32);
assert(Math.clz32(1.23) === 31);
assert(Math.clz32(12) === 28);
assert(Math.clz32(123) === 25);
assert(Math.clz32(1234) === 21);
assert(Math.clz32(12345) === 18);
assert(Math.clz32(123456) === 15);
assert(Math.clz32(1234567) === 11);
assert(Math.clz32(12345678) === 8);
assert(Math.clz32(123456789) === 5);
assert(Math.clz32(999999999) === 2);
assert(Math.clz32(9999999999) === 1);
assert(Math.clz32(99999999999) === 1);
assert(Math.clz32(999999999999) === 0);
assert(Math.clz32(9999999999999) === 1);
assert(Math.clz32(99999999999999) === 3);
assert(Math.clz32(999999999999999) === 0);
assert(Math.clz32() === 32);
assert(Math.clz32(NaN) === 32);
assert(Math.clz32(Infinity) === 32);
assert(Math.clz32(-Infinity) === 32);
assert(Math.clz32(false) === 32);
assert(Math.clz32(true) === 31);
assert(Math.clz32(null) === 32);
assert(Math.clz32(undefined) === 32);
assert(Math.clz32([]) === 32);
assert(Math.clz32({}) === 32);
assert(Math.clz32("foo") === 32);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.clz32()).toBe(32);
expect(Math.clz32(NaN)).toBe(32);
expect(Math.clz32(Infinity)).toBe(32);
expect(Math.clz32(-Infinity)).toBe(32);
expect(Math.clz32(false)).toBe(32);
expect(Math.clz32(true)).toBe(31);
expect(Math.clz32(null)).toBe(32);
expect(Math.clz32(undefined)).toBe(32);
expect(Math.clz32([])).toBe(32);
expect(Math.clz32({})).toBe(32);
expect(Math.clz32("foo")).toBe(32);
});

View file

@ -1,18 +1,14 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.cos).toHaveLength(1);
try {
assert(Math.cos(0) === 1);
assert(Math.cos(null) === 1);
assert(Math.cos('') === 1);
assert(Math.cos([]) === 1);
assert(Math.cos(Math.PI) === -1);
assert(isNaN(Math.cos()));
assert(isNaN(Math.cos(undefined)));
assert(isNaN(Math.cos([1, 2, 3])));
assert(isNaN(Math.cos({})));
assert(isNaN(Math.cos("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.cos(0)).toBe(1);
expect(Math.cos(null)).toBe(1);
expect(Math.cos('')).toBe(1);
expect(Math.cos([])).toBe(1);
expect(Math.cos(Math.PI)).toBe(-1);
expect(Math.cos()).toBeNaN();
expect(Math.cos(undefined)).toBeNaN();
expect(Math.cos([1, 2, 3])).toBeNaN();
expect(Math.cos({})).toBeNaN();
expect(Math.cos("foo")).toBeNaN();
});

View file

@ -1,19 +1,13 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.exp).toHaveLength(1);
try {
assert(Math.exp.length === 1);
expect(Math.exp(0)).toBe(1);
expect(Math.exp(-2)).toBeCloseTo(0.135335);
expect(Math.exp(-1)).toBeCloseTo(0.367879);
expect(Math.exp(1)).toBeCloseTo(2.718281);
expect(Math.exp(2)).toBeCloseTo(7.389056);
assert(Math.exp(0) === 1);
assert(isClose(Math.exp(-2), 0.135335));
assert(isClose(Math.exp(-1), 0.367879));
assert(isClose(Math.exp(1), 2.718281));
assert(isClose(Math.exp(2), 7.389056));
assert(isNaN(Math.exp()));
assert(isNaN(Math.exp(undefined)));
assert(isNaN(Math.exp("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.exp()).toBeNaN();
expect(Math.exp(undefined)).toBeNaN();
expect(Math.exp("foo")).toBeNaN();
});

View file

@ -1,19 +1,13 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.expm1).toHaveLength(1);
try {
assert(Math.expm1.length === 1);
expect(Math.expm1(0)).toBe(0);
expect(Math.expm1(-2)).toBeCloseTo(-0.864664);
expect(Math.expm1(-1)).toBeCloseTo(-0.632120);
expect(Math.expm1(1)).toBeCloseTo(1.718281);
expect(Math.expm1(2)).toBeCloseTo(6.389056);
assert(Math.expm1(0) === 0);
assert(isClose(Math.expm1(-2), -0.864664));
assert(isClose(Math.expm1(-1), -0.632120));
assert(isClose(Math.expm1(1), 1.718281));
assert(isClose(Math.expm1(2), 6.389056));
assert(isNaN(Math.expm1()));
assert(isNaN(Math.expm1(undefined)));
assert(isNaN(Math.expm1("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.expm1()).toBeNaN();
expect(Math.expm1(undefined)).toBeNaN();
expect(Math.expm1("foo")).toBeNaN();
});

View file

@ -1,19 +1,13 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.floor).toHaveLength(1);
try {
assert(Math.floor(0.95) === 0);
assert(Math.floor(4) === 4);
assert(Math.floor(7.004) == 7);
assert(Math.floor(-0.95) === -1);
assert(Math.floor(-4) === -4);
assert(Math.floor(-7.004) === -8);
expect(Math.floor(0.95)).toBe(0);
expect(Math.floor(4)).toBe(4);
expect(Math.floor(7.004)).toBe(7);
expect(Math.floor(-0.95)).toBe(-1);
expect(Math.floor(-4)).toBe(-4);
expect(Math.floor(-7.004)).toBe(-8);
assert(isNaN(Math.floor()));
assert(isNaN(Math.floor(NaN)));
assert(Math.floor.length === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.floor()).toBeNaN();
expect(Math.floor(NaN)).toBeNaN();
});

View file

@ -1,13 +1,8 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.log1p).toHaveLength(1);
try {
assert(isNaN(Math.log1p(-2)));
assert(Math.log1p(-1) === -Infinity);
// FIXME: assert(Math.log1p(0) === 0);
// FIXME: assert(isClose(Math.log1p(1), 0.693147));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.log1p(-2)).toBeNaN();
expect(Math.log1p(-1)).toBe(-Infinity);
// FIXME: expect(Math.log1p(0)).toBe(0);
// FIXME: expect(Math.log1p(1)).toBeCloseTo(0.693147);
});

View file

@ -1,15 +1,10 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.max).toHaveLength(2);
try {
assert(Math.max.length === 2);
assert(Math.max() === -Infinity);
assert(Math.max(1) === 1);
assert(Math.max(2, 1) === 2);
assert(Math.max(1, 2, 3) === 3);
assert(isNaN(Math.max(NaN)));
assert(isNaN(Math.max("String", 1)));
console.log("PASS");
} catch {
console.log("FAIL");
}
expect(Math.max()).toBe(-Infinity);
expect(Math.max(1)).toBe(1);
expect(Math.max(2, 1)).toBe(2);
expect(Math.max(1, 2, 3)).toBe(3);
expect(Math.max(NaN)).toBeNaN();
expect(Math.max("String", 1)).toBeNaN();
});

View file

@ -1,14 +1,9 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.min).toHaveLength(2);
try {
assert(Math.min.length === 2);
assert(Math.min(1) === 1);
assert(Math.min(2, 1) === 1);
assert(Math.min(1, 2, 3) === 1);
assert(isNaN(Math.min(NaN)));
assert(isNaN(Math.min("String", 1)));
console.log("PASS");
} catch {
console.log("FAIL");
}
expect(Math.min(1)).toBe(1);
expect(Math.min(2, 1)).toBe(1);
expect(Math.min(1, 2, 3)).toBe(1);
expect(Math.min(NaN)).toBeNaN();
expect(Math.min("String", 1)).toBeNaN();
});

View file

@ -1,29 +1,25 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.pow).toHaveLength(2);
try {
assert(Math.pow(2, 0) === 1);
assert(Math.pow(2, 1) === 2);
assert(Math.pow(2, 2) === 4);
assert(Math.pow(2, 3) === 8);
assert(Math.pow(2, -3) === 0.125);
assert(Math.pow(3, 2) === 9);
assert(Math.pow(0, 0) === 1);
assert(Math.pow(2, Math.pow(3, 2)) === 512);
assert(Math.pow(Math.pow(2, 3), 2) === 64);
assert(Math.pow("2", "3") === 8);
assert(Math.pow("", []) === 1);
assert(Math.pow([], null) === 1);
assert(Math.pow(null, null) === 1);
assert(Math.pow(undefined, null) === 1);
assert(isNaN(Math.pow(NaN, 2)));
assert(isNaN(Math.pow(2, NaN)));
assert(isNaN(Math.pow(undefined, 2)));
assert(isNaN(Math.pow(2, undefined)));
assert(isNaN(Math.pow(null, undefined)));
assert(isNaN(Math.pow(2, "foo")));
assert(isNaN(Math.pow("foo", 2)));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.pow(2, 0)).toBe(1);
expect(Math.pow(2, 1)).toBe(2);
expect(Math.pow(2, 2)).toBe(4);
expect(Math.pow(2, 3)).toBe(8);
expect(Math.pow(2, -3)).toBe(0.125);
expect(Math.pow(3, 2)).toBe(9);
expect(Math.pow(0, 0)).toBe(1);
expect(Math.pow(2, Math.pow(3, 2))).toBe(512);
expect(Math.pow(Math.pow(2, 3), 2)).toBe(64);
expect(Math.pow("2", "3")).toBe(8);
expect(Math.pow("", [])).toBe(1);
expect(Math.pow([], null)).toBe(1);
expect(Math.pow(null, null)).toBe(1);
expect(Math.pow(undefined, null)).toBe(1);
expect(Math.pow(NaN, 2)).toBeNaN();
expect(Math.pow(2, NaN)).toBeNaN();
expect(Math.pow(undefined, 2)).toBeNaN();
expect(Math.pow(2, undefined)).toBeNaN();
expect(Math.pow(null, undefined)).toBeNaN();
expect(Math.pow(2, "foo")).toBeNaN();
expect(Math.pow("foo", 2)).toBeNaN();
});

View file

@ -1,5 +1,3 @@
load("test-common.js");
function isPositiveZero(value) {
return value === 0 && 1 / value === Infinity;
}
@ -8,35 +6,33 @@ function isNegativeZero(value) {
return value === 0 && 1 / value === -Infinity;
}
try {
assert(Math.sign.length === 1);
test("basic functionality", () => {
expect(Math.sign).toHaveLength(1);
assert(Math.sign(0.0001) === 1);
assert(Math.sign(1) === 1);
assert(Math.sign(42) === 1);
assert(Math.sign(Infinity) === 1);
assert(isPositiveZero(Math.sign(0)));
assert(isPositiveZero(Math.sign(null)));
assert(isPositiveZero(Math.sign('')));
assert(isPositiveZero(Math.sign([])));
expect(Math.sign.length).toBe(1);
assert(Math.sign(-0.0001) === -1);
assert(Math.sign(-1) === -1);
assert(Math.sign(-42) === -1);
assert(Math.sign(-Infinity) === -1);
assert(isNegativeZero(Math.sign(-0)));
assert(isNegativeZero(Math.sign(-null)));
assert(isNegativeZero(Math.sign(-'')));
assert(isNegativeZero(Math.sign(-[])));
expect(Math.sign(0.0001)).toBe(1);
expect(Math.sign(1)).toBe(1);
expect(Math.sign(42)).toBe(1);
expect(Math.sign(Infinity)).toBe(1);
expect(isPositiveZero(Math.sign(0))).toBeTrue();
expect(isPositiveZero(Math.sign(null))).toBeTrue();
expect(isPositiveZero(Math.sign(''))).toBeTrue();
expect(isPositiveZero(Math.sign([]))).toBeTrue();
assert(isNaN(Math.sign()));
assert(isNaN(Math.sign(undefined)));
assert(isNaN(Math.sign([1, 2, 3])));
assert(isNaN(Math.sign({})));
assert(isNaN(Math.sign(NaN)));
assert(isNaN(Math.sign("foo")));
expect(Math.sign(-0.0001)).toBe(-1);
expect(Math.sign(-1)).toBe(-1);
expect(Math.sign(-42)).toBe(-1);
expect(Math.sign(-Infinity)).toBe(-1);
expect(isNegativeZero(Math.sign(-0))).toBeTrue();
expect(isNegativeZero(Math.sign(-null))).toBeTrue();
expect(isNegativeZero(Math.sign(-''))).toBeTrue();
expect(isNegativeZero(Math.sign(-[]))).toBeTrue();
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.sign()).toBeNaN();
expect(Math.sign(undefined)).toBeNaN();
expect(Math.sign([1, 2, 3])).toBeNaN();
expect(Math.sign({})).toBeNaN();
expect(Math.sign(NaN)).toBeNaN();
expect(Math.sign("foo")).toBeNaN();
});

View file

@ -1,19 +1,15 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.sin).toHaveLength(1);
try {
assert(Math.sin(0) === 0);
assert(Math.sin(null) === 0);
assert(Math.sin('') === 0);
assert(Math.sin([]) === 0);
assert(Math.sin(Math.PI * 3 / 2) === -1);
assert(Math.sin(Math.PI / 2) === 1);
assert(isNaN(Math.sin()));
assert(isNaN(Math.sin(undefined)));
assert(isNaN(Math.sin([1, 2, 3])));
assert(isNaN(Math.sin({})));
assert(isNaN(Math.sin("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.sin(0)).toBe(0);
expect(Math.sin(null)).toBe(0);
expect(Math.sin('')).toBe(0);
expect(Math.sin([])).toBe(0);
expect(Math.sin(Math.PI * 3 / 2)).toBe(-1);
expect(Math.sin(Math.PI / 2)).toBe(1);
expect(Math.sin()).toBeNaN();
expect(Math.sin(undefined)).toBeNaN();
expect(Math.sin([1, 2, 3])).toBeNaN();
expect(Math.sin({})).toBeNaN();
expect(Math.sin("foo")).toBeNaN();
});

View file

@ -1,7 +1,4 @@
load("test-common.js");
try {
assert(Math.sqrt(9) === 3);
console.log("PASS");
} catch {
}
test("basic functionality", () => {
expect(Math.sqrt).toHaveLength(1);
expect(Math.sqrt(9)).toBe(3);
});

View file

@ -1,18 +1,14 @@
load("test-common.js");
test("basic functionality", () => {
expect(Math.tan).toHaveLength(1);
try {
assert(Math.tan(0) === 0);
assert(Math.tan(null) === 0);
assert(Math.tan('') === 0);
assert(Math.tan([]) === 0);
assert(Math.ceil(Math.tan(Math.PI / 4)) === 1);
assert(isNaN(Math.tan()));
assert(isNaN(Math.tan(undefined)));
assert(isNaN(Math.tan([1, 2, 3])));
assert(isNaN(Math.tan({})));
assert(isNaN(Math.tan("foo")));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.tan(0)).toBe(0);
expect(Math.tan(null)).toBe(0);
expect(Math.tan('')).toBe(0);
expect(Math.tan([])).toBe(0);
expect(Math.ceil(Math.tan(Math.PI / 4))).toBe(1);
expect(Math.tan()).toBeNaN();
expect(Math.tan(undefined)).toBeNaN();
expect(Math.tan([1, 2, 3])).toBeNaN();
expect(Math.tan({})).toBeNaN();
expect(Math.tan("foo")).toBeNaN();
});

View file

@ -1,18 +1,12 @@
load("test-common.js")
test("basic functionality", () => {
expect(Math.trunc).toHaveLength(1);
try {
assert(Math.trunc(13.37) === 13);
assert(Math.trunc(42.84) === 42);
assert(Math.trunc(0.123) === 0);
assert(Math.trunc(-0.123) === -0);
expect(Math.trunc(13.37)).toBe(13);
expect(Math.trunc(42.84)).toBe(42);
expect(Math.trunc(0.123)).toBe( 0);
expect(Math.trunc(-0.123)).toBe(-0);
assert(isNaN(Math.trunc(NaN)));
assert(isNaN(Math.trunc('foo')));
assert(isNaN(Math.trunc()));
assert(Math.trunc.length === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Math.trunc(NaN)).toBeNaN();
expect(Math.trunc('foo')).toBeNaN();
expect(Math.trunc()).toBeNaN();
});

View file

@ -1,21 +0,0 @@
load("test-common.js");
try {
var nan = undefined + 1;
assert(nan + "" == "NaN");
assert(NaN + "" == "NaN");
assert(nan !== nan);
assert(NaN !== NaN);
assert(isNaN(nan) === true);
assert(isNaN(NaN) === true);
assert(isNaN(0) === false);
assert(isNaN(undefined) === true);
assert(isNaN(null) === false);
assert(isNaN(Infinity) === false);
assert(!!NaN === false);
assert(!!nan === false);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}

View file

@ -0,0 +1,13 @@
test("basic functionality", () => {
const nan = undefined + 1;
expect(nan + "").toBe("NaN");
expect(NaN + "").toBe("NaN");
expect(nan !== nan).toBeTrue();
expect(NaN !== NaN).toBeTrue();
expect(nan).toBeNaN();
expect(NaN).toBeNaN();
expect(0).not.toBeNaN();
expect(!!nan).toBeFalse();
expect(!!NaN).toBeFalse();
});

View file

@ -1,17 +1,11 @@
load("test-common.js");
try {
assert(Number.EPSILON === 2 ** -52);
assert(Number.EPSILON > 0);
assert(Number.MAX_SAFE_INTEGER === 2 ** 53 - 1);
assert(Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2);
assert(Number.MIN_SAFE_INTEGER === -(2 ** 53 - 1));
assert(Number.MIN_SAFE_INTEGER - 1 === Number.MIN_SAFE_INTEGER - 2);
assert(Number.POSITIVE_INFINITY === Infinity);
assert(Number.NEGATIVE_INFINITY === -Infinity);
assert(isNaN(Number.NaN));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("basic functionality", () => {
expect(Number.EPSILON).toBe(2 ** -52);
expect(Number.EPSILON).toBeGreaterThan(0);
expect(Number.MAX_SAFE_INTEGER).toBe(2 ** 53 - 1);
expect(Number.MAX_SAFE_INTEGER + 1).toBe(Number.MAX_SAFE_INTEGER + 2);
expect(Number.MIN_SAFE_INTEGER).toBe(-(2 ** 53 - 1));
expect(Number.MIN_SAFE_INTEGER - 1).toBe(Number.MIN_SAFE_INTEGER - 2);
expect(Number.POSITIVE_INFINITY).toBe(Infinity);
expect(Number.NEGATIVE_INFINITY).toBe(-Infinity);
expect(Number.NaN).toBeNaN();
});

View file

@ -1,30 +1,24 @@
load("test-common.js");
test("basic functionality", () => {
expect(Number.isFinite).toHaveLength(1);
expect(Number.isFinite).not.toBe(isFinite);
try {
assert(Number.isFinite !== isFinite);
assert(Number.isFinite.length === 1);
expect(Number.isFinite(0)).toBeTrue();
expect(Number.isFinite(1.23)).toBeTrue();
expect(Number.isFinite(42)).toBeTrue();
assert(Number.isFinite(0) === true);
assert(Number.isFinite(1.23) === true);
assert(Number.isFinite(42) === true);
assert(Number.isFinite("") === false);
assert(Number.isFinite("0") === false);
assert(Number.isFinite("42") === false);
assert(Number.isFinite(true) === false);
assert(Number.isFinite(false) === false);
assert(Number.isFinite(null) === false);
assert(Number.isFinite([]) === false);
assert(Number.isFinite() === false);
assert(Number.isFinite(NaN) === false);
assert(Number.isFinite(undefined) === false);
assert(Number.isFinite(Infinity) === false);
assert(Number.isFinite(-Infinity) === false);
assert(Number.isFinite("foo") === false);
assert(Number.isFinite({}) === false);
assert(Number.isFinite([1, 2, 3]) === false);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}
expect(Number.isFinite("")).toBeFalse();
expect(Number.isFinite("0")).toBeFalse();
expect(Number.isFinite("42")).toBeFalse();
expect(Number.isFinite(true)).toBeFalse();
expect(Number.isFinite(false)).toBeFalse();
expect(Number.isFinite(null)).toBeFalse();
expect(Number.isFinite([])).toBeFalse();
expect(Number.isFinite()).toBeFalse();
expect(Number.isFinite(NaN)).toBeFalse();
expect(Number.isFinite(undefined)).toBeFalse();
expect(Number.isFinite(Infinity)).toBeFalse();
expect(Number.isFinite(-Infinity)).toBeFalse();
expect(Number.isFinite("foo")).toBeFalse();
expect(Number.isFinite({})).toBeFalse();
expect(Number.isFinite([1, 2, 3])).toBeFalse();
});

View file

@ -1,38 +1,32 @@
load("test-common.js");
test("basic functionality", () => {
expect(Number.isInteger).toHaveLength(1);
try {
assert(Number.isInteger.length === 1);
assert(Number.isInteger(0) === true);
assert(Number.isInteger(42) === true);
assert(Number.isInteger(-10000) === true);
assert(Number.isInteger(5) === true);
assert(Number.isInteger(5.0) === true);
assert(Number.isInteger(5 + 1/10000000000000000) === true);
expect(Number.isInteger(0)).toBeTrue();
expect(Number.isInteger(42)).toBeTrue();
expect(Number.isInteger(-10000)).toBeTrue();
expect(Number.isInteger(5)).toBeTrue();
expect(Number.isInteger(5.0)).toBeTrue();
expect(Number.isInteger(5 + 1/10000000000000000)).toBeTrue();
// FIXME: values outside of i32's range should still return true
// assert(Number.isInteger(+2147483647 + 1) === true);
// assert(Number.isInteger(-2147483648 - 1) === true);
// assert(Number.isInteger(99999999999999999999999999999999999) === true);
// expect(Number.isInteger(+2147483647 + 1)).toBeTrue();
// expect(Number.isInteger(-2147483648 - 1)).toBeTrue();
// expect(Number.isInteger(99999999999999999999999999999999999)).toBeTrue();
assert(Number.isInteger(5 + 1/1000000000000000) === false);
assert(Number.isInteger(1.23) === false);
assert(Number.isInteger("") === false);
assert(Number.isInteger("0") === false);
assert(Number.isInteger("42") === false);
assert(Number.isInteger(true) === false);
assert(Number.isInteger(false) === false);
assert(Number.isInteger(null) === false);
assert(Number.isInteger([]) === false);
assert(Number.isInteger(Infinity) === false);
assert(Number.isInteger(-Infinity) === false);
assert(Number.isInteger(NaN) === false);
assert(Number.isInteger() === false);
assert(Number.isInteger(undefined) === false);
assert(Number.isInteger("foo") === false);
assert(Number.isInteger({}) === false);
assert(Number.isInteger([1, 2, 3]) === false);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}
expect(Number.isInteger(5 + 1/1000000000000000)).toBeFalse();
expect(Number.isInteger(1.23)).toBeFalse();
expect(Number.isInteger("")).toBeFalse();
expect(Number.isInteger("0")).toBeFalse();
expect(Number.isInteger("42")).toBeFalse();
expect(Number.isInteger(true)).toBeFalse();
expect(Number.isInteger(false)).toBeFalse();
expect(Number.isInteger(null)).toBeFalse();
expect(Number.isInteger([])).toBeFalse();
expect(Number.isInteger(Infinity)).toBeFalse();
expect(Number.isInteger(-Infinity)).toBeFalse();
expect(Number.isInteger(NaN)).toBeFalse();
expect(Number.isInteger()).toBeFalse();
expect(Number.isInteger(undefined)).toBeFalse();
expect(Number.isInteger("foo")).toBeFalse();
expect(Number.isInteger({})).toBeFalse();
expect(Number.isInteger([1, 2, 3])).toBeFalse();
});

View file

@ -1,31 +1,25 @@
load("test-common.js");
test("basic functionality", () => {
expect(Number.isNaN).toHaveLength(1);
expect(Number.isNaN).not.toBe(isNaN);
try {
assert(Number.isNaN !== isNaN);
assert(Number.isNaN.length === 1);
expect(Number.isNaN(0)).toBeFalse();
expect(Number.isNaN(42)).toBeFalse();
expect(Number.isNaN("")).toBeFalse();
expect(Number.isNaN("0")).toBeFalse();
expect(Number.isNaN("42")).toBeFalse();
expect(Number.isNaN(true)).toBeFalse();
expect(Number.isNaN(false)).toBeFalse();
expect(Number.isNaN(null)).toBeFalse();
expect(Number.isNaN([])).toBeFalse();
expect(Number.isNaN(Infinity)).toBeFalse();
expect(Number.isNaN(-Infinity)).toBeFalse();
expect(Number.isNaN()).toBeFalse();
expect(Number.isNaN(undefined)).toBeFalse();
expect(Number.isNaN("foo")).toBeFalse();
expect(Number.isNaN({})).toBeFalse();
expect(Number.isNaN([1, 2, 3])).toBeFalse();
assert(Number.isNaN(0) === false);
assert(Number.isNaN(42) === false);
assert(Number.isNaN("") === false);
assert(Number.isNaN("0") === false);
assert(Number.isNaN("42") === false);
assert(Number.isNaN(true) === false);
assert(Number.isNaN(false) === false);
assert(Number.isNaN(null) === false);
assert(Number.isNaN([]) === false);
assert(Number.isNaN(Infinity) === false);
assert(Number.isNaN(-Infinity) === false);
assert(Number.isNaN() === false);
assert(Number.isNaN(undefined) === false);
assert(Number.isNaN("foo") === false);
assert(Number.isNaN({}) === false);
assert(Number.isNaN([1, 2, 3]) === false);
assert(Number.isNaN(NaN) === true);
assert(Number.isNaN(Number.NaN) === true);
assert(Number.isNaN(0 / 0) === true);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}
expect(Number.isNaN(NaN)).toBeTrue();
expect(Number.isNaN(Number.NaN)).toBeTrue();
expect(Number.isNaN(0 / 0)).toBeTrue();
});

View file

@ -1,30 +1,24 @@
load("test-common.js");
test("basic functionality", () => {
expect(Number.isSafeInteger).toHaveLength(1);
try {
assert(Number.isSafeInteger.length === 1);
expect(Number.isSafeInteger(0)).toBeTrue();
expect(Number.isSafeInteger(1)).toBeTrue();
expect(Number.isSafeInteger(2.0)).toBeTrue();
expect(Number.isSafeInteger(42)).toBeTrue();
expect(Number.isSafeInteger(Number.MAX_SAFE_INTEGER)).toBeTrue();
expect(Number.isSafeInteger(Number.MIN_SAFE_INTEGER)).toBeTrue();
assert(Number.isSafeInteger(0) === true);
assert(Number.isSafeInteger(1) === true);
assert(Number.isSafeInteger(2.0) === true);
assert(Number.isSafeInteger(42) === true);
assert(Number.isSafeInteger(Number.MAX_SAFE_INTEGER) === true);
assert(Number.isSafeInteger(Number.MIN_SAFE_INTEGER) === true);
assert(Number.isSafeInteger() === false);
assert(Number.isSafeInteger("1") === false);
assert(Number.isSafeInteger(2.1) === false);
assert(Number.isSafeInteger(42.42) === false);
assert(Number.isSafeInteger("") === false);
assert(Number.isSafeInteger([]) === false);
assert(Number.isSafeInteger(null) === false);
assert(Number.isSafeInteger(undefined) === false);
assert(Number.isSafeInteger(NaN) === false);
assert(Number.isSafeInteger(Infinity) === false);
assert(Number.isSafeInteger(-Infinity) === false);
assert(Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 1) === false);
assert(Number.isSafeInteger(Number.MIN_SAFE_INTEGER - 1) === false);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}
expect(Number.isSafeInteger()).toBeFalse();
expect(Number.isSafeInteger("1")).toBeFalse();
expect(Number.isSafeInteger(2.1)).toBeFalse();
expect(Number.isSafeInteger(42.42)).toBeFalse();
expect(Number.isSafeInteger("")).toBeFalse();
expect(Number.isSafeInteger([])).toBeFalse();
expect(Number.isSafeInteger(null)).toBeFalse();
expect(Number.isSafeInteger(undefined)).toBeFalse();
expect(Number.isSafeInteger(NaN)).toBeFalse();
expect(Number.isSafeInteger(Infinity)).toBeFalse();
expect(Number.isSafeInteger(-Infinity)).toBeFalse();
expect(Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 1)).toBeFalse();
expect(Number.isSafeInteger(Number.MIN_SAFE_INTEGER - 1)).toBeFalse();
});

View file

@ -1,39 +1,33 @@
load("test-common.js");
test("basic functionality", () => {
expect(Number).toHaveLength(1);
expect(Number.name).toBe("Number");
expect(Number.prototype).not.toHaveProperty("length");
try {
assert(Number.length === 1);
assert(Number.name === "Number");
assert(Number.prototype.length === undefined);
expect(typeof Number()).toBe("number");
expect(typeof new Number()).toBe("object");
assert(typeof Number() === "number");
assert(typeof new Number() === "object");
assert(Number() === 0);
assert(new Number().valueOf() === 0);
assert(Number("42") === 42);
assert(new Number("42").valueOf() === 42);
assert(Number(null) === 0);
assert(new Number(null).valueOf() === 0);
assert(Number(true) === 1);
assert(new Number(true).valueOf() === 1);
assert(Number("Infinity") === Infinity);
assert(new Number("Infinity").valueOf() === Infinity);
assert(Number("+Infinity") === Infinity);
assert(new Number("+Infinity").valueOf() === Infinity);
assert(Number("-Infinity") === -Infinity);
assert(new Number("-Infinity").valueOf() === -Infinity);
assert(isNaN(Number(undefined)));
assert(isNaN(new Number(undefined).valueOf()));
assert(isNaN(Number({})));
assert(isNaN(new Number({}).valueOf()));
assert(isNaN(Number({a: 1})));
assert(isNaN(new Number({a: 1}).valueOf()));
assert(isNaN(Number([1, 2, 3])));
assert(isNaN(new Number([1, 2, 3]).valueOf()));
assert(isNaN(Number("foo")));
assert(isNaN(new Number("foo").valueOf()));
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e.message);
}
expect(Number()).toBe(0);
expect(new Number().valueOf()).toBe(0);
expect(Number("42")).toBe(42);
expect(new Number("42").valueOf()).toBe(42);
expect(Number(null)).toBe(0);
expect(new Number(null).valueOf()).toBe(0);
expect(Number(true)).toBe(1);
expect(new Number(true).valueOf()).toBe(1);
expect(Number("Infinity")).toBe(Infinity);
expect(new Number("Infinity").valueOf()).toBe(Infinity);
expect(Number("+Infinity")).toBe(Infinity);
expect(new Number("+Infinity").valueOf()).toBe(Infinity);
expect(Number("-Infinity")).toBe(-Infinity);
expect(new Number("-Infinity").valueOf()).toBe(-Infinity);
expect(Number(undefined)).toBeNaN();
expect(new Number(undefined).valueOf()).toBeNaN();
expect(Number({})).toBeNaN();
expect(new Number({}).valueOf()).toBeNaN();
expect(Number({a: 1})).toBeNaN();
expect(new Number({a: 1}).valueOf()).toBeNaN();
expect(Number([1, 2, 3])).toBeNaN();
expect(new Number([1, 2, 3]).valueOf()).toBeNaN();
expect(Number("foo")).toBeNaN();
expect(new Number("foo").valueOf()).toBeNaN();
});

View file

@ -1,11 +1,5 @@
load("test-common.js");
try {
test("basic functionality", () => {
// Ensuring it's the same function as the global
// parseFloat() is enough as that already has tests :^)
assert(Number.parseFloat === parseFloat);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Number.parseFloat).toBe(parseFloat);
});

View file

@ -1,10 +1,4 @@
load("test-common.js");
try {
assert(typeof Number.prototype === "object");
assert(Number.prototype.valueOf() === 0);
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}
test("basic functionality", () => {
expect(typeof Number.prototype).toBe("object");
expect(Number.prototype.valueOf()).toBe(0);
});

View file

@ -1,123 +1,127 @@
load("test-common.js");
describe("normal functionality", () => {
test("non-configurable property", () => {
let o = {};
Object.defineProperty(o, "foo", { value: 1, writable: false, enumerable: false });
try {
var o = {};
Object.defineProperty(o, "foo", { value: 1, writable: false, enumerable: false });
expect(o.foo).toBe(1);
o.foo = 2;
expect(o.foo).toBe(1);
assert(o.foo === 1);
o.foo = 2;
assert(o.foo === 1);
Object.defineProperty(o, 2, { get() { return 10; } });
assert(o[2] === 10);
var d = Object.getOwnPropertyDescriptor(o, "foo");
assert(d.configurable === false);
assert(d.enumerable === false);
assert(d.writable === false);
assert(d.value === 1);
Object.defineProperty(o, "bar", { value: "hi", writable: true, enumerable: true });
assert(o.bar === "hi");
o.bar = "ho";
assert(o.bar === "ho");
d = Object.getOwnPropertyDescriptor(o, "bar");
assert(d.configurable === false);
assert(d.enumerable === true);
assert(d.writable === true);
assert(d.value === "ho");
assertThrowsError(() => {
Object.defineProperty(o, "bar", { value: "xx", enumerable: false });
}, {
error: TypeError
expect(o).not.toHaveConfigurableProperty("foo");
expect(o).not.toHaveEnumerableProperty("foo");
expect(o).not.toHaveWritableProperty("foo");
expect(o).toHaveValueProperty("foo", 1);
});
Object.defineProperty(o, "baz", { value: 9, configurable: true, writable: false });
Object.defineProperty(o, "baz", { configurable: true, writable: true });
d = Object.getOwnPropertyDescriptor(o, "baz");
assert(d.configurable === true);
assert(d.writable === true);
assert(d.value === 9);
Object.defineProperty(o, "qux", {
configurable: true,
get() {
return o.secret_qux + 1;
},
set(value) {
this.secret_qux = value + 1;
},
test("array index getter", () => {
let o = {};
Object.defineProperty(o, 2, { get() { return 10; } });
expect(o[2]).toBe(10);
});
o.qux = 10;
assert(o.qux === 12);
o.qux = 20;
assert(o.qux = 22);
test("configurable property", () => {
let o = {};
Object.defineProperty(o, "foo", { value: "hi", writable: true, enumerable: true });
Object.defineProperty(o, "qux", { configurable: true, value: 4 });
expect(o.foo).toBe("hi");
o.foo = "ho";
expect(o.foo).toBe("ho");
assert(o.qux === 4);
o.qux = 5;
assert(o.qux = 4);
Object.defineProperty(o, "qux", {
configurable: false,
get() {
return this.secret_qux + 2;
},
set(value) {
o.secret_qux = value + 2;
},
expect(o).not.toHaveConfigurableProperty("foo");
expect(o).toHaveEnumerableProperty("foo");
expect(o).toHaveWritableProperty("foo");
expect(o).toHaveValueProperty("foo", "ho");
});
o.qux = 10;
assert(o.qux === 14);
o.qux = 20;
assert(o.qux = 24);
test("reconfigure configurable property", () => {
let o = {};
Object.defineProperty(o, "foo", { value: 9, configurable: true, writable: false });
Object.defineProperty(o, "foo", { configurable: true, writable: true });
assertThrowsError(() => {
Object.defineProperty(o, "qux", {
configurable: false,
expect(o).toHaveConfigurableProperty("foo");
expect(o).toHaveWritableProperty("foo");
expect(o).not.toHaveEnumerableProperty("foo");
expect(o).toHaveValueProperty("foo", 9);
});
test("define accessor", () => {
let o = {};
Object.defineProperty(o, "foo", {
configurable: true,
get() {
return this.secret_qux + 2;
return o.secret_foo + 1;
},
set(value) {
this.secret_foo = value + 1;
},
});
}, {
error: TypeError,
message: "Cannot change attributes of non-configurable property 'qux'",
o.foo = 10;
expect(o.foo).toBe(12);
o.foo = 20;
expect(o.foo).toBe(22);
Object.defineProperty(o, "foo", { configurable: true, value: 4 });
expect(o.foo).toBe(4);
expect(o.foo = 5).toBe(5);
expect(o.foo = 4).toBe(4);
});
});
describe("errors", () => {
test("redefine non-configurable property", () => {
let o = {};
Object.defineProperty(o, "foo", { value: 1, writable: true, enumerable: true });
expect(() => {
Object.defineProperty(o, "foo", { value: 2, writable: false, enumerable: true });
}).toThrowWithMessage(TypeError, "Cannot change attributes of non-configurable property 'foo'");
});
assertThrowsError(() => {
Object.defineProperty(o, "qux", { value: 2 });
}, {
error: TypeError,
message: "Cannot change attributes of non-configurable property 'qux'",
test("cannot define 'value' and 'get' in the same descriptor", () => {
let o = {};
expect(() => {
Object.defineProperty(o, "a", {
get() {},
value: 9,
});
}).toThrowWithMessage(TypeError, "Accessor property descriptor cannot specify a value or writable key");
});
assertThrowsError(() => {
Object.defineProperty(o, "a", {
get() {},
value: 9,
test("cannot define 'value' and 'set' in the same descriptor", () => {
let o = {};
expect(() => {
Object.defineProperty(o, "a", {
set() {},
writable: true,
});
}).toThrowWithMessage(TypeError, "Accessor property descriptor cannot specify a value or writable key");
});
test("redefine non-configurable accessor", () => {
let o = {};
Object.defineProperty(o, "foo", {
configurable: false,
get() {
return this.secret_foo + 2;
},
set(value) {
o.secret_foo = value + 2;
},
});
}, {
error: TypeError,
message: "Accessor property descriptor cannot specify a value or writable key",
});
assertThrowsError(() => {
Object.defineProperty(o, "a", {
set() {},
writable: true,
});
}, {
error: TypeError,
message: "Accessor property descriptor cannot specify a value or writable key",
expect(() => {
Object.defineProperty(o, "foo", {
configurable: false,
get() {
return this.secret_foo + 2;
},
});
}).toThrowWithMessage(TypeError, "Cannot change attributes of non-configurable property 'foo'");
});
console.log("PASS");
} catch (e) {
console.log(e)
}
});

View file

@ -1,54 +1,45 @@
load("test-common.js");
try {
assert(Object.entries.length === 1);
assert(Object.entries(true).length === 0);
assert(Object.entries(45).length === 0);
assert(Object.entries(-998).length === 0);
assert(Object.entries("abcd").length === 4);
assert(Object.entries([1, 2, 3]).length === 3);
assert(Object.entries({ a: 1, b: 2, c: 3 }).length === 3);
assertThrowsError(() => {
Object.entries(null);
}, {
error: TypeError,
message: "ToObject on null or undefined",
describe("basic functionality", () => {
test("length", () => {
expect(Object.entries).toHaveLength(1);
expect(Object.entries(true)).toHaveLength(0);
expect(Object.entries(45)).toHaveLength(0);
expect(Object.entries(-998)).toHaveLength(0);
expect(Object.entries("abcd")).toHaveLength(4);
expect(Object.entries([1, 2, 3])).toHaveLength(3);
expect(Object.entries({ a: 1, b: 2, c: 3 })).toHaveLength(3);
});
assertThrowsError(() => {
Object.entries(undefined);
}, {
error: TypeError,
message: "ToObject on null or undefined",
test("entries with object", () => {
let entries = Object.entries({ foo: 1, bar: 2, baz: 3 });
expect(entries).toEqual([["foo", 1], ["bar", 2], ["baz", 3]]);
});
let entries = Object.entries({ foo: 1, bar: 2, baz: 3 });
assert(
entries.length === 3 && entries[0].length === 2 &&
entries[1].length === 2 && entries[2].length === 2 &&
entries[0][0] === "foo" && entries[0][1] === 1 &&
entries[1][0] === "bar" && entries[1][1] === 2 &&
entries[2][0] === "baz" && entries[2][1] === 3
);
entries = Object.entries(["a", "b", "c"]);
assert(
entries.length === 3 && entries[0].length === 2 &&
entries[1].length === 2 && entries[2].length === 2 &&
entries[0][0] === "0" && entries[0][1] === "a" &&
entries[1][0] === "1" && entries[1][1] === "b" &&
entries[2][0] === "2" && entries[2][1] === "c"
);
let obj = { foo: 1 };
Object.defineProperty(obj, "getFoo", {
value: function() { return this.foo; },
test("entries with array", () => {
entries = Object.entries(["a", "b", "c"]);
expect(entries).toEqual([["0", "a"], ["1", "b"], ["2", "c"]]);
});
let entries = Object.entries(obj);
assert(entries.length === 1 && entries[0][0] === "foo" && entries[0][1] === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("ignores non-enumerable properties", () => {
let obj = { foo: 1 };
Object.defineProperty(obj, "getFoo", {
value: function() { return this.foo; },
});
let entries = Object.entries(obj);
expect(entries).toEqual([["foo", 1]]);
});
});
describe("errors", () => {
test("null argument", () => {
expect(() => {
Object.entries(null);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
});
test("undefined argument", () => {
expect(() => {
Object.entries(undefined);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
})
});

View file

@ -1,51 +1,49 @@
load("test-common.js");
test("plain property", () => {
let o = { foo: "bar" };
try {
let o = {
foo: "bar",
get x() { },
set ["hi" + 1](_) { },
};
expect(o).toHaveConfigurableProperty("foo");
expect(o).toHaveEnumerableProperty("foo");
expect(o).toHaveWritableProperty("foo");
expect(o).toHaveValueProperty("foo", "bar");
expect(o).not.toHaveGetterProperty("foo");
expect(o).not.toHaveSetterProperty("foo");
});
Object.defineProperty(o, "baz", {
test("getter property", () => {
let o = { get foo() {} };
expect(o).toHaveConfigurableProperty("foo");
expect(o).toHaveEnumerableProperty("foo");
expect(o).not.toHaveWritableProperty("foo");
expect(o).not.toHaveValueProperty("foo");
expect(o).toHaveGetterProperty("foo");
expect(o).not.toHaveSetterProperty("foo");
});
test("setter property", () => {
let o = { set foo(_) {} };
expect(o).toHaveConfigurableProperty("foo");
expect(o).toHaveEnumerableProperty("foo");
expect(o).not.toHaveWritableProperty("foo");
expect(o).not.toHaveValueProperty("foo");
expect(o).not.toHaveGetterProperty("foo");
expect(o).toHaveSetterProperty("foo");
});
test("defined property", () => {
let o = {};
Object.defineProperty(o, "foo", {
enumerable: false,
writable: true,
value: 10,
});
let d = Object.getOwnPropertyDescriptor(o, "foo");
assert(d.enumerable === true);
assert(d.configurable === true);
assert(d.writable === true);
assert(d.value === "bar");
assert(d.get === undefined);
assert(d.set === undefined);
let d = Object.getOwnPropertyDescriptor(o, "x");
assert(d.enumerable === true);
assert(d.configurable === true);
assert(d.writable === undefined);
assert(d.value === undefined);
assert(typeof d.get === "function");
assert(d.set === undefined);
let d = Object.getOwnPropertyDescriptor(o, "hi1");
assert(d.enumerable === true);
assert(d.configurable === true);
assert(d.writable === undefined);
assert(d.value === undefined);
assert(d.get === undefined);
assert(typeof d.set === "function");
let d = Object.getOwnPropertyDescriptor(o, "baz");
assert(d.enumerable === false);
assert(d.configurable === false);
assert(d.writable === true);
assert(d.value === 10);
assert(d.get === undefined);
assert(d.set === undefined);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(o).not.toHaveConfigurableProperty("foo");
expect(o).not.toHaveEnumerableProperty("foo");
expect(o).toHaveWritableProperty("foo");
expect(o).toHaveValueProperty("foo", 10);
expect(o).not.toHaveGetterProperty("foo");
expect(o).not.toHaveSetterProperty("foo");
});

View file

@ -1,21 +1,9 @@
load("test-common.js");
try {
test("use with array", () => {
let names = Object.getOwnPropertyNames([1, 2, 3]);
expect(names).toEqual(["0", "1", "2", "length"]);
});
assert(names.length === 4);
assert(names[0] === "0");
assert(names[1] === "1");
assert(names[2] === "2");
assert(names[3] === "length");
names = Object.getOwnPropertyNames({ foo: 1, bar: 2, baz: 3 });
assert(names.length === 3);
assert(names[0] === "foo");
assert(names[1] === "bar");
assert(names[2] === "baz");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("use with object", () => {
let names = Object.getOwnPropertyNames({ foo: 1, bar: 2, baz: 3 });
expect(names).toEqual(["foo", "bar", "baz"]);
});

View file

@ -1,11 +1,10 @@
load("test-common.js");
test("basic functionality", () => {
let o1 = new Object();
let o2 = {};
try {
var o1 = new Object();
var o2 = {};
assert(Object.getPrototypeOf(o1) === Object.getPrototypeOf(o2));
assert(Object.getPrototypeOf(Object.getPrototypeOf(o1)) === null);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Object.getPrototypeOf(o1)).toBe(Object.getPrototypeOf(o2));
expect(Object.getPrototypeOf(Object.getPrototypeOf(o1))).toBe(null);
Object.setPrototypeOf(o1, o2);
expect(Object.getPrototypeOf(o1)).toBe(o2);
});

View file

@ -1,53 +1,54 @@
load("test-common.js");
test("length", () => {
expect(Object.is).toHaveLength(2);
});
try {
assert(Object.is.length === 2);
test("arguments that evaluate to true", () => {
let a = [1, 2, 3];
let o = { foo: "bar" };
var a = [1, 2, 3];
var o = {foo: "bar"};
expect(Object.is("", "")).toBeTrue();
expect(Object.is("foo", "foo")).toBeTrue();
expect(Object.is(0, 0)).toBeTrue();
expect(Object.is(+0, +0)).toBeTrue();
expect(Object.is(-0, -0)).toBeTrue();
expect(Object.is(1.23, 1.23)).toBeTrue();
expect(Object.is(42, 42)).toBeTrue();
expect(Object.is(NaN, NaN)).toBeTrue();
expect(Object.is(Infinity, Infinity)).toBeTrue();
expect(Object.is(+Infinity, +Infinity)).toBeTrue();
expect(Object.is(-Infinity, -Infinity)).toBeTrue();
expect(Object.is(true, true)).toBeTrue();
expect(Object.is(false, false)).toBeTrue();
expect(Object.is(null, null)).toBeTrue();
expect(Object.is(undefined, undefined)).toBeTrue();
expect(Object.is(undefined)).toBeTrue();
expect(Object.is()).toBeTrue();
expect(Object.is(a, a)).toBeTrue();
expect(Object.is(o, o)).toBeTrue();
});
assert(Object.is("", "") === true);
assert(Object.is("foo", "foo") === true);
assert(Object.is(0, 0) === true);
assert(Object.is(+0, +0) === true);
assert(Object.is(-0, -0) === true);
assert(Object.is(1.23, 1.23) === true);
assert(Object.is(42, 42) === true);
assert(Object.is(NaN, NaN) === true);
assert(Object.is(Infinity, Infinity) === true);
assert(Object.is(+Infinity, +Infinity) === true);
assert(Object.is(-Infinity, -Infinity) === true);
assert(Object.is(true, true) === true);
assert(Object.is(false, false) === true);
assert(Object.is(null, null) === true);
assert(Object.is(undefined, undefined) === true);
assert(Object.is(undefined) === true);
assert(Object.is() === true);
assert(Object.is(a, a) === true);
assert(Object.is(o, o) === true);
test("arguments that evaluate to false", () => {
let a = [1, 2, 3];
let o = { foo: "bar" };
assert(Object.is("test") === false);
assert(Object.is("foo", "bar") === false);
assert(Object.is(1, "1") === false);
assert(Object.is(+0, -0) === false);
assert(Object.is(-0, +0) === false);
assert(Object.is(42, 24) === false);
assert(Object.is(Infinity, -Infinity) === false);
assert(Object.is(-Infinity, +Infinity) === false);
assert(Object.is(true, false) === false);
assert(Object.is(false, true) === false);
assert(Object.is(undefined, null) === false);
assert(Object.is(null, undefined) === false);
assert(Object.is([], []) === false);
assert(Object.is(a, [1, 2, 3]) === false);
assert(Object.is([1, 2, 3], a) === false);
assert(Object.is({}, {}) === false);
assert(Object.is(o, {foo: "bar"}) === false);
assert(Object.is({foo: "bar"}, o) === false);
assert(Object.is(a, o) === false);
assert(Object.is(o, a) === false);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Object.is("test")).toBeFalse();
expect(Object.is("foo", "bar")).toBeFalse();
expect(Object.is(1, "1")).toBeFalse();
expect(Object.is(+0, -0)).toBeFalse();
expect(Object.is(-0, +0)).toBeFalse();
expect(Object.is(42, 24)).toBeFalse();
expect(Object.is(Infinity, -Infinity)).toBeFalse();
expect(Object.is(-Infinity, +Infinity)).toBeFalse();
expect(Object.is(true, false)).toBeFalse();
expect(Object.is(false, true)).toBeFalse();
expect(Object.is(undefined, null)).toBeFalse();
expect(Object.is(null, undefined)).toBeFalse();
expect(Object.is([], [])).toBeFalse();
expect(Object.is(a, [1, 2, 3])).toBeFalse();
expect(Object.is([1, 2, 3], a)).toBeFalse();
expect(Object.is({}, {})).toBeFalse();
expect(Object.is(o, {foo: "bar"})).toBeFalse();
expect(Object.is({foo: "bar"}, o)).toBeFalse();
expect(Object.is(a, o)).toBeFalse();
expect(Object.is(o, a)).toBeFalse();
});

View file

@ -1,22 +1,18 @@
load("test-common.js");
test("basic functionality", () => {
expect(Object.isExtensible).toHaveLength(1);
try {
assert(Object.isExtensible() === false);
assert(Object.isExtensible(undefined) === false);
assert(Object.isExtensible(null) === false);
assert(Object.isExtensible(true) === false);
assert(Object.isExtensible(6) === false);
assert(Object.isExtensible("test") === false);
expect(Object.isExtensible()).toBeFalse();
expect(Object.isExtensible(undefined)).toBeFalse();
expect(Object.isExtensible(null)).toBeFalse();
expect(Object.isExtensible(true)).toBeFalse();
expect(Object.isExtensible(6)).toBeFalse();
expect(Object.isExtensible("test")).toBeFalse();
let s = Symbol();
assert(Object.isExtensible(s) === false);
expect(Object.isExtensible(s)).toBeFalse();
let o = { foo: "foo" };
assert(Object.isExtensible(o) === true);
expect(Object.isExtensible(o)).toBeTrue();
Object.preventExtensions(o);
assert(Object.isExtensible(o) === false);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Object.isExtensible(o)).toBeFalse();
});

View file

@ -1,14 +1,8 @@
load("test-common.js");
test("basic functionality", () => {
expect(Object).toHaveLength(1);
expect(Object.name).toBe("Object");
expect(Object.prototype.length).toBe(undefined);
try {
assert(Object.length === 1);
assert(Object.name === "Object");
assert(Object.prototype.length === undefined);
assert(typeof Object() === "object");
assert(typeof new Object() === "object");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(typeof Object()).toBe("object");
expect(typeof new Object()).toBe("object");
});

View file

@ -1,42 +1,44 @@
load("test-common.js");
try {
assert(Object.keys.length === 1);
assert(Object.keys(true).length === 0);
assert(Object.keys(45).length === 0);
assert(Object.keys(-998).length === 0);
assert(Object.keys("abcd").length === 4);
assert(Object.keys([1, 2, 3]).length === 3);
assert(Object.keys({ a: 1, b: 2, c: 3 }).length === 3);
assertThrowsError(() => {
Object.keys(null);
}, {
error: TypeError,
message: "ToObject on null or undefined",
describe("correct behavior", () => {
test("length", () => {
expect(Object.keys).toHaveLength(1);
expect(Object.keys(true)).toHaveLength(0);
expect(Object.keys(45)).toHaveLength(0);
expect(Object.keys(-998)).toHaveLength(0);
expect(Object.keys("abcd")).toHaveLength(4);
expect(Object.keys([1, 2, 3])).toHaveLength(3);
expect(Object.keys({ a: 1, b: 2, c: 3 })).toHaveLength(3);
});
assertThrowsError(() => {
Object.keys(undefined);
}, {
error: TypeError,
message: "ToObject on null or undefined",
test("object argument", () => {
let keys = Object.keys({ foo: 1, bar: 2, baz: 3 });
expect(keys).toEqual(["foo", "bar", "baz"]);
});
let keys = Object.keys({ foo: 1, bar: 2, baz: 3 });
assert(keys[0] === "foo" && keys[1] === "bar" && keys[2] === "baz");
keys = Object.keys(["a", "b", "c"]);
assert(keys[0] === "0" && keys[1] === "1" && keys[2] === "2");
let obj = { foo: 1 };
Object.defineProperty(obj, 'getFoo', {
value: function() { return this.foo; },
test("array argument", () => {
let keys = Object.keys(["a", "b", "c"]);
expect(keys).toEqual(["0", "1", "2"]);
});
keys = Object.keys(obj);
assert(keys.length === 1 && keys[0] === 'foo');
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("ignores non-enumerable properties", () => {
let obj = { foo: 1 };
Object.defineProperty(obj, "getFoo", {
value: function() { return this.foo; },
});
keys = Object.keys(obj);
expect(keys).toEqual(["foo"]);
});
});
describe("errors", () => {
test("null argument value", () => {
expect(() => {
Object.keys(null);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
});
test("undefined argument value", () => {
expect(() => {
Object.keys(undefined);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
});
});

View file

@ -1,54 +1,53 @@
load("test-common.js");
describe("correct behavior", () => {
test("non-object arguments", () => {
expect(Object.preventExtensions()).toBeUndefined();
expect(Object.preventExtensions(undefined)).toBeUndefined();
expect(Object.preventExtensions(null)).toBeNull();
expect(Object.preventExtensions(true)).toBeTrue();
expect(Object.preventExtensions(6)).toBe(6);
expect(Object.preventExtensions("test")).toBe("test");
try {
assert(Object.preventExtensions() === undefined);
assert(Object.preventExtensions(undefined) === undefined);
assert(Object.preventExtensions(null) === null);
assert(Object.preventExtensions(true) === true);
assert(Object.preventExtensions(6) === 6);
assert(Object.preventExtensions("test") === "test");
let s = Symbol();
assert(Object.preventExtensions(s) === s);
let o = { foo: "foo" };
assert(o.foo === "foo");
o.bar = "bar";
assert(o.bar === "bar");
assert(Object.preventExtensions(o) === o);
assert(o.foo === "foo");
assert(o.bar === "bar");
o.baz = "baz";
assert(o.baz === undefined);
assertThrowsError(() => {
Object.defineProperty(o, "baz", { value: "baz" });
}, {
error: TypeError,
message: "Cannot define property baz on non-extensible object",
let s = Symbol();
expect(Object.preventExtensions(s)).toBe(s);
});
assert(o.baz === undefined);
test("basic functionality", () => {
let o = { foo: "foo" };
expect(o.foo).toBe("foo");
o.bar = "bar";
expect(o.bar).toBe("bar");
expect(Object.preventExtensions(o)).toBe(o);
expect(o.foo).toBe("foo");
expect(o.bar).toBe("bar");
assertThrowsError(() => {
"use strict";
o.baz = "baz";
}, {
error: TypeError,
message: "Cannot define property baz on non-extensible object",
expect(o.baz).toBeUndefined();
});
});
describe("errors", () => {
test("defining a property on a non-extensible object", () => {
let o = {};
Object.preventExtensions(o);
expect(() => {
Object.defineProperty(o, "baz", { value: "baz" });
}).toThrowWithMessage(TypeError, "Cannot define property baz on non-extensible object");
expect(o.baz).toBeUndefined();
});
assertThrowsError(() => {
"use strict";
Object.defineProperty(o, "baz", { value: "baz" });
}, {
error: TypeError,
message: "Cannot define property baz on non-extensible object",
});
test("putting property on a non-extensible object", () => {
let o = {};
Object.preventExtensions(o);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(() => {
"use strict";
o.foo = "foo";
}).toThrowWithMessage(TypeError, "Cannot define property foo on non-extensible object");
expect(o.foo = "foo").toBe("foo");
expect(o.foo).toBeUndefined();
});
});

View file

@ -1,36 +1,18 @@
load("test-common.js");
test("basic functionality", () => {
[Array, BigInt, Boolean, Date, Error, Function, Number, Object, String].forEach(constructor => {
expect(constructor.prototype.constructor).toBe(constructor);
if (constructor !== BigInt)
expect(Reflect.construct(constructor, []).constructor).toBe(constructor);
});
try {
assert(Array.prototype.constructor === Array);
assert(Boolean.prototype.constructor === Boolean);
assert(Date.prototype.constructor === Date);
assert(Error.prototype.constructor === Error);
assert(Function.prototype.constructor === Function);
assert(Number.prototype.constructor === Number);
assert(Object.prototype.constructor === Object);
o = {};
assert(o.constructor === Object);
o = new Object();
assert(o.constructor === Object);
let o = {};
expect(o.constructor).toBe(Object);
a = [];
assert(a.constructor === Array);
expect(a.constructor).toBe(Array);
a = new Array();
assert(a.constructor === Array);
n = new Number(3);
assert(n.constructor === Number);
d = Object.getOwnPropertyDescriptor(Object.prototype, "constructor");
assert(d.configurable === true);
assert(d.enumerable === false);
assert(d.writable === true);
assert(d.value === Object);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(Object.prototype).toHaveConfigurableProperty("constructor");
expect(Object.prototype).not.toHaveEnumerableProperty("constructor");
expect(Object.prototype).toHaveWritableProperty("constructor");
expect(Object.prototype).toHaveValueProperty("constructor", Object);
});

View file

@ -1,17 +1,13 @@
load("test-common.js");
try {
test("basic functionality", () => {
var o = {};
o.foo = 1;
assert(o.hasOwnProperty("foo") === true);
assert(o.hasOwnProperty("bar") === false);
assert(o.hasOwnProperty() === false);
assert(o.hasOwnProperty(undefined) === false);
o.undefined = 2;
assert(o.hasOwnProperty() === true);
assert(o.hasOwnProperty(undefined) === true);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
o.foo = 1;
expect(o.hasOwnProperty("foo")).toBeTrue();
expect(o.hasOwnProperty("bar")).toBeFalse();
expect(o.hasOwnProperty()).toBeFalse();
expect(o.hasOwnProperty(undefined)).toBeFalse();
o.undefined = 2;
expect(o.hasOwnProperty()).toBeTrue();
expect(o.hasOwnProperty(undefined)).toBeTrue();
});

View file

@ -1,10 +1,5 @@
load("test-common.js");
try {
test("basic functionality", () => {
var o = new Object();
Object.prototype.foo = 123;
assert(o.foo === 123);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(o.foo).toBe(123);
});

View file

@ -1,32 +1,31 @@
load("test-common.js");
describe("correct behavior", () => {
test("length", () => {
expect(Object.prototype.toLocaleString).toHaveLength(0);
})
try {
assert(Object.prototype.toLocaleString.length === 0);
test("basic functionality", () => {
let o;
var o;
o = {};
expect(o.toString()).toBe(o.toLocaleString());
o = {};
assert(o.toString() === o.toLocaleString());
o = { toString: () => 42 };
expect(o.toString()).toBe(42);
});
});
o = { toString: () => 42 };
assert(o.toString() === 42);
o = { toString: () => { throw Error(); } };
assertThrowsError(() => {
o.toLocaleString();
}, {
error: Error
describe("errors", () => {
test("toString that throws error", () => {
let o = { toString: () => { throw new Error(); } };
expect(() => {
o.toLocaleString();
}).toThrow(Error);
});
o = { toString: "foo" };
assertThrowsError(() => {
o.toLocaleString();
}, {
error: TypeError,
message: "foo is not a function"
test("toString that is not a function", () => {
let o = { toString: "foo" };
expect(() => {
o.toLocaleString();
}).toThrowWithMessage(TypeError, "foo is not a function");
});
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
});

View file

@ -1,8 +1,8 @@
load("test-common.js");
try {
assert(typeof Object.prototype.toString() === "string");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("basic functionality", () => {
expect(Object.prototype.toString).toHaveLength(0);
// FIXME: The tag is ObjectPrototype, but should be Object
// expect(Object.prototype.toString()).toBe("[object Object]");
expect({ foo: 1 }.toString()).toBe("[object Object]");
expect([].toString()).toBe("");
expect(Object.prototype.toString.call([])).toBe("[object Array]");
});

View file

@ -1,36 +1,43 @@
load("test-common.js");
try {
assert(Object.setPrototypeOf.length === 2);
assertThrowsError(() => {
Object.setPrototypeOf();
}, {
error: TypeError,
message: "Object.setPrototypeOf requires at least two arguments",
describe("correct behavior", () => {
test("length", () => {
expect(Object.setPrototypeOf).toHaveLength(2);
});
assertThrowsError(() => {
Object.setPrototypeOf({}, "foo");
}, {
error: TypeError,
message: "Prototype must be an object or null"
test("basic functionality", () => {
let o = {};
let p = {};
expect(Object.setPrototypeOf(o, p)).toBe(o);
expect(Object.getPrototypeOf(o)).toBe(p);
});
});
describe("errors", () => {
test("requires two arguments", () => {
expect(() => {
Object.setPrototypeOf();
}).toThrowWithMessage(TypeError, "Object.setPrototypeOf requires at least two arguments");
expect(() => {
Object.setPrototypeOf({});
}).toThrowWithMessage(TypeError, "Object.setPrototypeOf requires at least two arguments");
});
o = {};
p = {};
assert(Object.setPrototypeOf(o, p) === o);
Object.preventExtensions(o);
assertThrowsError(() => {
Object.setPrototypeOf(o, {});
}, {
error: TypeError,
message: "Object's [[SetPrototypeOf]] method returned false"
test("prototype must be an object", () => {
expect(() => {
Object.setPrototypeOf({}, "foo");
}).toThrowWithMessage(TypeError, "Prototype must be an object or null");
});
assert(Object.setPrototypeOf(o, p) === o);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("non-extensible target", () => {
let o = {};
let p = {};
Object.setPrototypeOf(o, p);
Object.preventExtensions(o);
expect(() => {
Object.setPrototypeOf(o, {});
}).toThrowWithMessage(TypeError, "Object's [[SetPrototypeOf]] method returned false");
expect(Object.setPrototypeOf(o, p)).toBe(o);
});
});

View file

@ -1,42 +1,44 @@
load("test-common.js");
try {
assert(Object.values.length === 1);
assert(Object.values(true).length === 0);
assert(Object.values(45).length === 0);
assert(Object.values(-998).length === 0);
assert(Object.values("abcd").length === 4);
assert(Object.values([1, 2, 3]).length === 3);
assert(Object.values({ a: 1, b: 2, c: 3 }).length === 3);
assertThrowsError(() => {
Object.values(null);
}, {
error: TypeError,
message: "ToObject on null or undefined",
describe("correct behavior", () => {
test("lengths", () => {
expect(Object.values).toHaveLength(1);
expect(Object.values(true)).toHaveLength(0);
expect(Object.values(45)).toHaveLength(0);
expect(Object.values(-998)).toHaveLength(0);
expect(Object.values("abcd")).toHaveLength(4);
expect(Object.values([1, 2, 3])).toHaveLength(3);
expect(Object.values({ a: 1, b: 2, c: 3 })).toHaveLength(3);
});
assertThrowsError(() => {
Object.values(undefined);
}, {
error: TypeError,
message: "ToObject on null or undefined",
test("object argument", () => {
let values = Object.values({ foo: 1, bar: 2, baz: 3 });
expect(values).toEqual([1, 2, 3]);
});
let values = Object.values({ foo: 1, bar: 2, baz: 3 });
assert(values[0] === 1 && values[1] === 2 && values[2] === 3);
values = Object.values(["a", "b", "c"]);
assert(values[0] === "a" && values[1] === "b" && values[2] === "c");
let obj = { foo: 1 };
Object.defineProperty(obj, 'getFoo', {
value: function() { return this.foo; },
test("array argument", () => {
let values = Object.values(["a", "b", "c"]);
expect(values).toEqual(["a", "b", "c"]);
});
let values = Object.values(obj);
assert(values.length === 1 && values[0] === 1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("ignores non-enumerable properties", () => {
let obj = { foo: 1 };
Object.defineProperty(obj, 'getFoo', {
value: function() { return this.foo; },
});
let values = Object.values(obj);
expect(values).toEqual([1]);
});
});
describe("errors", () => {
test("null argument", () => {
expect(() => {
Object.values(null);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
});
test("undefined argument", () => {
expect(() => {
Object.values(undefined);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
});
});

View file

@ -1,23 +1,17 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.fromCharCode).toHaveLength(1);
try {
assert(String.fromCharCode.length === 1);
assert(String.fromCharCode() === "");
assert(String.fromCharCode(0) === "\u0000");
assert(String.fromCharCode(false) === "\u0000");
assert(String.fromCharCode(null) === "\u0000");
assert(String.fromCharCode(undefined) === "\u0000");
assert(String.fromCharCode(1) === "\u0001");
assert(String.fromCharCode(true) === "\u0001");
assert(String.fromCharCode(-1) === "\uffff");
assert(String.fromCharCode(0xffff) === "\uffff");
assert(String.fromCharCode(0x123ffff) === "\uffff");
assert(String.fromCharCode(65) === "A");
assert(String.fromCharCode(65, 66, 67) === "ABC");
assert(String.fromCharCode(228, 246, 252) === "äöü");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(String.fromCharCode()).toBe("");
expect(String.fromCharCode(0)).toBe("\u0000");
expect(String.fromCharCode(false)).toBe("\u0000");
expect(String.fromCharCode(null)).toBe("\u0000");
expect(String.fromCharCode(undefined)).toBe("\u0000");
expect(String.fromCharCode(1)).toBe("\u0001");
expect(String.fromCharCode(true)).toBe("\u0001");
expect(String.fromCharCode(-1)).toBe("\uffff");
expect(String.fromCharCode(0xffff)).toBe("\uffff");
expect(String.fromCharCode(0x123ffff)).toBe("\uffff");
expect(String.fromCharCode(65)).toBe("A");
expect(String.fromCharCode(65, 66, 67)).toBe("ABC");
expect(String.fromCharCode(228, 246, 252)).toBe("äöü");
});

View file

@ -1,23 +1,9 @@
load("test-common.js");
test("constructor properties", () => {
expect(String).toHaveLength(1);
expect(String.name).toBe("String");
});
try {
assert(String.length === 1);
assert(String.name === "String");
assert(String.prototype.length === 0);
assert(typeof String() === "string");
assert(typeof new String() === "object");
assert(String() === "");
assert(new String().valueOf() === "");
assert(String("foo") === "foo");
assert(new String("foo").valueOf() === "foo");
assert(String(123) === "123");
assert(new String(123).valueOf() === "123");
assert(String(123) === "123");
assert(new String(123).valueOf() === "123");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
test("typeof", () => {
expect(typeof String()).toBe("string");
expect(typeof new String()).toBe("object");
});

View file

@ -1,6 +1,4 @@
load("test-common.js");
try {
test("basic functionality", () => {
const genericStringPrototypeFunctions = [
"charAt",
"repeat",
@ -24,29 +22,16 @@ try {
String.prototype[name].call({ toString: () => 123 });
String.prototype[name].call({ toString: () => undefined });
assertThrowsError(() => {
expect(() => {
String.prototype[name].call({ toString: () => new String() });
}, {
error: TypeError,
message: "Cannot convert object to string"
});
}).toThrowWithMessage(TypeError, "Cannot convert object to string");
assertThrowsError(() => {
expect(() => {
String.prototype[name].call({ toString: () => [] });
}, {
error: TypeError,
message: "Cannot convert object to string"
});
}).toThrowWithMessage(TypeError, "Cannot convert object to string");
assertThrowsError(() => {
expect(() => {
String.prototype[name].call({ toString: () => ({}) });
}, {
error: TypeError,
message: "Cannot convert object to string"
});
}).toThrowWithMessage(TypeError, "Cannot convert object to string");
});
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}
});

View file

@ -1,24 +1,20 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.charAt).toHaveLength(1);
try {
var s = "foobar"
assert(typeof s === "string");
assert(s.length === 6);
expect(typeof s).toBe("string");
expect(s).toHaveLength(6);
assert(s.charAt(0) === 'f');
assert(s.charAt(1) === 'o');
assert(s.charAt(2) === 'o');
assert(s.charAt(3) === 'b');
assert(s.charAt(4) === 'a');
assert(s.charAt(5) === 'r');
assert(s.charAt(6) === '');
expect(s.charAt(0)).toBe("f");
expect(s.charAt(1)).toBe("o");
expect(s.charAt(2)).toBe("o");
expect(s.charAt(3)).toBe("b");
expect(s.charAt(4)).toBe("a");
expect(s.charAt(5)).toBe("r");
expect(s.charAt(6)).toBe("");
assert(s.charAt() === 'f');
assert(s.charAt(NaN) === 'f');
assert(s.charAt("foo") === 'f');
assert(s.charAt(undefined) === 'f');
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(s.charAt()).toBe("f");
expect(s.charAt(NaN)).toBe("f");
expect(s.charAt("foo")).toBe("f");
expect(s.charAt(undefined)).toBe("f");
});

View file

@ -1,22 +1,17 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.concat).toHaveLength(1);
try {
assert(String.prototype.concat.length === 1);
assert("".concat(1) === "1");
assert("".concat(3,2,1) === "321");
assert("hello".concat(" ", "friends") === "hello friends");
assert("".concat(null) === "null");
assert("".concat(false) === "false");
assert("".concat(true) === "true");
assert("".concat([]) === "");
assert("".concat([1, 2, 3, 'hello']) === "1,2,3,hello");
assert("".concat(true, []) === "true");
assert("".concat(true, false) === "truefalse");
assert("".concat({}) === "[object Object]");
assert("".concat(1, {}) === "1[object Object]");
assert("".concat(1, {}, false) === "1[object Object]false");
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}
expect("".concat(1)).toBe("1");
expect("".concat(3,2,1)).toBe("321");
expect("hello".concat(" ", "friends")).toBe("hello friends");
expect("".concat(null)).toBe("null");
expect("".concat(false)).toBe("false");
expect("".concat(true)).toBe("true");
expect("".concat([])).toBe("");
expect("".concat([1, 2, 3, 'hello'])).toBe("1,2,3,hello");
expect("".concat(true, [])).toBe("true");
expect("".concat(true, false)).toBe("truefalse");
expect("".concat({})).toBe("[object Object]");
expect("".concat(1, {})).toBe("1[object Object]");
expect("".concat(1, {}, false)).toBe("1[object Object]false");
});

View file

@ -1,18 +1,12 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.includes).toHaveLength(1);
try {
assert(String.prototype.includes.length === 1);
assert("hello friends".includes("hello") === true);
assert("hello friends".includes("hello", 100) === false);
assert("hello friends".includes("hello", -10) === true);
assert("hello friends".includes("friends", 6) === true);
assert("hello friends".includes("hello", 6) === false);
assert("hello friends false".includes(false) === true);
assert("hello 10 friends".includes(10) === true);
assert("hello friends undefined".includes() === true);
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}
expect("hello friends".includes("hello")).toBe(true);
expect("hello friends".includes("hello", 100)).toBe(false);
expect("hello friends".includes("hello", -10)).toBe(true);
expect("hello friends".includes("friends", 6)).toBe(true);
expect("hello friends".includes("hello", 6)).toBe(false);
expect("hello friends false".includes(false)).toBe(true);
expect("hello 10 friends".includes(10)).toBe(true);
expect("hello friends undefined".includes()).toBe(true);
});

View file

@ -1,12 +1,8 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.indexOf).toHaveLength(1);
try {
var s = "hello friends"
assert(s.indexOf("friends") === 6);
assert(s.indexOf("enemies") === -1);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(s.indexOf("friends")).toBe(6);
expect(s.indexOf("enemies")).toBe(-1);
});

View file

@ -1,13 +1,9 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype).toHaveLength(0);
expect(typeof Object.getPrototypeOf("")).toBe("object");
expect(Object.getPrototypeOf("").valueOf()).toBe("");
try {
assert(typeof Object.getPrototypeOf("") === "object");
assert(Object.getPrototypeOf("").valueOf() === '');
assert(typeof String.prototype === "object");
assert(String.prototype.valueOf() === '');
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}
expect(typeof String.prototype).toBe("object");
expect(String.prototype.valueOf()).toBe("");
});

View file

@ -1,27 +1,22 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.lastIndexOf).toHaveLength(1);
try {
assert(String.prototype.lastIndexOf.length === 1);
assert("hello friends".lastIndexOf() === -1);
assert("hello friends".lastIndexOf("e") === 9);
assert("hello friends".lastIndexOf("e", -7) === -1);
assert("hello friends".lastIndexOf("e", 100) === 9);
assert("hello friends".lastIndexOf("") === 13);
assert("hello friends".lastIndexOf("Z") === -1);
assert("hello friends".lastIndexOf("serenity") === -1);
assert("hello friends".lastIndexOf("", 4) === 4);
assert("hello serenity friends".lastIndexOf("serenity") === 6);
assert("hello serenity friends serenity".lastIndexOf("serenity") === 23);
assert("hello serenity friends serenity".lastIndexOf("serenity", 14) === 6);
assert("".lastIndexOf("") === 0);
assert("".lastIndexOf("", 1) === 0);
assert("".lastIndexOf("", -1) === 0);
assert("hello friends serenity".lastIndexOf("h", 10) === 0);
assert("hello friends serenity".lastIndexOf("l", 4) === 3);
assert("hello friends serenity".lastIndexOf("s", 13) === 12);
assert("hello".lastIndexOf("serenity") === -1);
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}
expect("hello friends".lastIndexOf()).toBe(-1);
expect("hello friends".lastIndexOf("e")).toBe(9);
expect("hello friends".lastIndexOf("e", -7)).toBe(-1);
expect("hello friends".lastIndexOf("e", 100)).toBe(9);
expect("hello friends".lastIndexOf("")).toBe(13);
expect("hello friends".lastIndexOf("Z")).toBe(-1);
expect("hello friends".lastIndexOf("serenity")).toBe(-1);
expect("hello friends".lastIndexOf("", 4)).toBe(4);
expect("hello serenity friends".lastIndexOf("serenity")).toBe(6);
expect("hello serenity friends serenity".lastIndexOf("serenity")).toBe(23);
expect("hello serenity friends serenity".lastIndexOf("serenity", 14)).toBe(6);
expect("".lastIndexOf("")).toBe(0);
expect("".lastIndexOf("", 1)).toBe(0);
expect("".lastIndexOf("", -1)).toBe(0);
expect("hello friends serenity".lastIndexOf("h", 10)).toBe(0);
expect("hello friends serenity".lastIndexOf("l", 4)).toBe(3);
expect("hello friends serenity".lastIndexOf("s", 13)).toBe(12);
expect("hello".lastIndexOf("serenity")).toBe(-1);
});

View file

@ -1,24 +1,18 @@
load("test-common.js");
try {
assert(String.prototype.padEnd.length === 1);
test("basic functionality", () => {
expect(String.prototype.padEnd).toHaveLength(1);
var s = "foo";
assert(s.padEnd(-1) === "foo");
assert(s.padEnd(0) === "foo");
assert(s.padEnd(3) === "foo");
assert(s.padEnd(5) === "foo ");
assert(s.padEnd(10) === "foo ");
assert(s.padEnd("5") === "foo ");
assert(s.padEnd([[["5"]]]) === "foo ");
assert(s.padEnd(2, "+") === "foo");
assert(s.padEnd(5, "+") === "foo++");
assert(s.padEnd(5, 1) === "foo11");
assert(s.padEnd(10, null) === "foonullnul");
assert(s.padEnd(10, "bar") === "foobarbarb");
assert(s.padEnd(10, "123456789") === "foo1234567");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(s.padEnd(-1)).toBe("foo");
expect(s.padEnd(0)).toBe("foo");
expect(s.padEnd(3)).toBe("foo");
expect(s.padEnd(5)).toBe("foo ");
expect(s.padEnd(10)).toBe("foo ");
expect(s.padEnd("5")).toBe("foo ");
expect(s.padEnd([[["5"]]])).toBe("foo ");
expect(s.padEnd(2, "+")).toBe("foo");
expect(s.padEnd(5, "+")).toBe("foo++");
expect(s.padEnd(5, 1)).toBe("foo11");
expect(s.padEnd(10, null)).toBe("foonullnul");
expect(s.padEnd(10, "bar")).toBe("foobarbarb");
expect(s.padEnd(10, "123456789")).toBe("foo1234567");
});

View file

@ -1,24 +1,18 @@
load("test-common.js");
try {
assert(String.prototype.padStart.length === 1);
test("basic functionality", () => {
expect(String.prototype.padStart).toHaveLength(1);
var s = "foo";
assert(s.padStart(-1) === "foo");
assert(s.padStart(0) === "foo");
assert(s.padStart(3) === "foo");
assert(s.padStart(5) === " foo");
assert(s.padStart(10) === " foo");
assert(s.padStart("5") === " foo");
assert(s.padStart([[["5"]]]) === " foo");
assert(s.padStart(2, "+") === "foo");
assert(s.padStart(5, "+") === "++foo");
assert(s.padStart(5, 1) === "11foo");
assert(s.padStart(10, null) === "nullnulfoo");
assert(s.padStart(10, "bar") === "barbarbfoo");
assert(s.padStart(10, "123456789") === "1234567foo");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(s.padStart(-1)).toBe("foo");
expect(s.padStart(0)).toBe("foo");
expect(s.padStart(3)).toBe("foo");
expect(s.padStart(5)).toBe(" foo");
expect(s.padStart(10)).toBe(" foo");
expect(s.padStart("5")).toBe(" foo");
expect(s.padStart([[["5"]]])).toBe(" foo");
expect(s.padStart(2, "+")).toBe("foo");
expect(s.padStart(5, "+")).toBe("++foo");
expect(s.padStart(5, 1)).toBe("11foo");
expect(s.padStart(10, null)).toBe("nullnulfoo");
expect(s.padStart(10, "bar")).toBe("barbarbfoo");
expect(s.padStart(10, "123456789")).toBe("1234567foo");
});

View file

@ -1,37 +1,25 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.repeat).toHaveLength(1);
try {
assert(String.prototype.repeat.length === 1);
expect("foo".repeat(0)).toBe("");
expect("foo".repeat(1)).toBe("foo");
expect("foo".repeat(2)).toBe("foofoo");
expect("foo".repeat(3)).toBe("foofoofoo");
expect("foo".repeat(3.1)).toBe("foofoofoo");
expect("foo".repeat(3.5)).toBe("foofoofoo");
expect("foo".repeat(3.9)).toBe("foofoofoo");
expect("foo".repeat(null)).toBe("");
expect("foo".repeat(undefined)).toBe("");
expect("foo".repeat([])).toBe("");
expect("foo".repeat("")).toBe("");
});
try {
test("throws correct range errors", () => {
expect(() => {
"foo".repeat(-1);
assertNotReached();
} catch (e) {
assert(e.name === "RangeError");
assert(e.message === "repeat count must be a positive number");
}
}).toThrowWithMessage(RangeError, "repeat count must be a positive number");
try {
expect(() => {
"foo".repeat(Infinity);
assertNotReached();
} catch (e) {
assert(e.name === "RangeError");
assert(e.message === "repeat count must be a finite number");
}
assert("foo".repeat(0) === "");
assert("foo".repeat(1) === "foo");
assert("foo".repeat(2) === "foofoo");
assert("foo".repeat(3) === "foofoofoo");
assert("foo".repeat(3.1) === "foofoofoo");
assert("foo".repeat(3.5) === "foofoofoo");
assert("foo".repeat(3.9) === "foofoofoo");
assert("foo".repeat(null) === "");
assert("foo".repeat(undefined) === "");
assert("foo".repeat([]) === "");
assert("foo".repeat("") === "");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
}).toThrowWithMessage(RangeError, "repeat count must be a finite number");
});

View file

@ -1,22 +1,18 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.slice).toHaveLength(2);
try {
assert(String.prototype.slice.length === 2);
assert("hello friends".slice() === "hello friends");
assert("hello friends".slice(1) === "ello friends");
assert("hello friends".slice(0, 5) === "hello");
assert("hello friends".slice(13, 6) === "");
assert("hello friends".slice('', 5) === "hello");
assert("hello friends".slice(3, 3) === "");
assert("hello friends".slice(-1, 13) === "s");
assert("hello friends".slice(0, 50) === "hello friends");
assert("hello friends".slice(0, "5") === "hello");
assert("hello friends".slice("6", "13") === "friends");
assert("hello friends".slice(-7) === "friends");
assert("hello friends".slice(1000) === "");
assert("hello friends".slice(-1000) === "hello friends");
expect("hello friends".slice()).toBe("hello friends");
expect("hello friends".slice(1)).toBe("ello friends");
expect("hello friends".slice(0, 5)).toBe("hello");
expect("hello friends".slice(13, 6)).toBe("");
expect("hello friends".slice("", 5)).toBe("hello");
expect("hello friends".slice(3, 3)).toBe("");
expect("hello friends".slice(-1, 13)).toBe("s");
expect("hello friends".slice(0, 50)).toBe("hello friends");
expect("hello friends".slice(0, "5")).toBe("hello");
expect("hello friends".slice("6", "13")).toBe("friends");
expect("hello friends".slice(-7)).toBe("friends");
expect("hello friends".slice(1000)).toBe("");
expect("hello friends".slice(-1000)).toBe("hello friends");
});
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}

View file

@ -1,40 +1,36 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.startsWith).toHaveLength(1);
try {
var s = "foobar";
assert(s.startsWith("f") === true);
assert(s.startsWith("fo") === true);
assert(s.startsWith("foo") === true);
assert(s.startsWith("foob") === true);
assert(s.startsWith("fooba") === true);
assert(s.startsWith("foobar") === true);
assert(s.startsWith("foobar1") === false);
assert(s.startsWith("f", 0) === true);
assert(s.startsWith("fo", 0) === true);
assert(s.startsWith("foo", 0) === true);
assert(s.startsWith("foob", 0) === true);
assert(s.startsWith("fooba", 0) === true);
assert(s.startsWith("foobar", 0) === true);
assert(s.startsWith("foobar1", 0) === false);
assert(s.startsWith("foo", []) === true);
assert(s.startsWith("foo", null) === true);
assert(s.startsWith("foo", undefined) === true);
assert(s.startsWith("foo", false) === true);
assert(s.startsWith("foo", true) === false);
assert(s.startsWith("foo", "foo") === true);
assert(s.startsWith("foo", -1) === true);
assert(s.startsWith("foo", 42) === false);
assert(s.startsWith("bar", 3) === true);
assert(s.startsWith("bar", "3") === true);
assert(s.startsWith("bar1", 3) === false);
assert(s.startsWith() === false);
assert(s.startsWith("") === true);
assert(s.startsWith("", 0) === true);
assert(s.startsWith("", 1) === true);
assert(s.startsWith("", -1) === true);
assert(s.startsWith("", 42) === true);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(s.startsWith("f")).toBeTrue();
expect(s.startsWith("fo")).toBeTrue();
expect(s.startsWith("foo")).toBeTrue();
expect(s.startsWith("foob")).toBeTrue();
expect(s.startsWith("fooba")).toBeTrue();
expect(s.startsWith("foobar")).toBeTrue();
expect(s.startsWith("foobar1")).toBeFalse();
expect(s.startsWith("f", 0)).toBeTrue();
expect(s.startsWith("fo", 0)).toBeTrue();
expect(s.startsWith("foo", 0)).toBeTrue();
expect(s.startsWith("foob", 0)).toBeTrue();
expect(s.startsWith("fooba", 0)).toBeTrue();
expect(s.startsWith("foobar", 0)).toBeTrue();
expect(s.startsWith("foobar1", 0)).toBeFalse();
expect(s.startsWith("foo", [])).toBeTrue();
expect(s.startsWith("foo", null)).toBeTrue();
expect(s.startsWith("foo", undefined)).toBeTrue();
expect(s.startsWith("foo", false)).toBeTrue();
expect(s.startsWith("foo", true)).toBeFalse();
expect(s.startsWith("foo", "foo")).toBeTrue();
expect(s.startsWith("foo", -1)).toBeTrue();
expect(s.startsWith("foo", 42)).toBeFalse();
expect(s.startsWith("bar", 3)).toBeTrue();
expect(s.startsWith("bar", "3")).toBeTrue();
expect(s.startsWith("bar1", 3)).toBeFalse();
expect(s.startsWith()).toBeFalse();
expect(s.startsWith("")).toBeTrue();
expect(s.startsWith("", 0)).toBeTrue();
expect(s.startsWith("", 1)).toBeTrue();
expect(s.startsWith("", -1)).toBeTrue();
expect(s.startsWith("", 42)).toBeTrue();
});

View file

@ -1,19 +1,14 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.substring).toHaveLength(2);
try {
assert(String.prototype.substring.length === 2);
assert("hello friends".substring() === "hello friends");
assert("hello friends".substring(1) === "ello friends");
assert("hello friends".substring(0, 5) === "hello");
assert("hello friends".substring(13, 6) === "friends");
assert("hello friends".substring('', 5) === "hello");
assert("hello friends".substring(3, 3) === "");
assert("hello friends".substring(-1, 13) === "hello friends");
assert("hello friends".substring(0, 50) === "hello friends");
assert("hello friends".substring(0, "5") === "hello");
assert("hello friends".substring("6", "13") === "friends");
console.log("PASS");
} catch (err) {
console.log("FAIL: " + err);
}
expect("hello friends".substring()).toBe("hello friends");
expect("hello friends".substring(1)).toBe("ello friends");
expect("hello friends".substring(0, 5)).toBe("hello");
expect("hello friends".substring(13, 6)).toBe("friends");
expect("hello friends".substring('', 5)).toBe("hello");
expect("hello friends".substring(3, 3)).toBe("");
expect("hello friends".substring(-1, 13)).toBe("hello friends");
expect("hello friends".substring(0, 50)).toBe("hello friends");
expect("hello friends".substring(0, "5")).toBe("hello");
expect("hello friends".substring("6", "13")).toBe("friends");
});

View file

@ -1,15 +1,9 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.toLowerCase).toHaveLength(0);
try {
assert(String.prototype.toLowerCase.length === 0);
expect("foo".toLowerCase()).toBe("foo");
expect("Foo".toLowerCase()).toBe("foo");
expect("FOO".toLowerCase()).toBe("foo");
assert("foo".toLowerCase() === "foo");
assert("Foo".toLowerCase() === "foo");
assert("FOO".toLowerCase() === "foo");
assert(('b' + 'a' + + 'a' + 'a').toLowerCase() === "banana");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(('b' + 'a' + + 'a' + 'a').toLowerCase()).toBe("banana");
});

View file

@ -1,11 +1,6 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.toString).toHaveLength(0)
try {
assert(String.prototype.toString.length === 0)
assert("".toString() === "");
assert("hello friends".toString() === "hello friends");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect("".toString()).toBe("");
expect("hello friends".toString()).toBe("hello friends");
});

View file

@ -1,15 +1,9 @@
load("test-common.js");
test("basic functionality", () => {
expect(String.prototype.toUpperCase).toHaveLength(0);
try {
assert(String.prototype.toUpperCase.length === 0);
expect("foo".toUpperCase()).toBe("FOO");
expect("Foo".toUpperCase()).toBe("FOO");
expect("FOO".toUpperCase()).toBe("FOO");
assert("foo".toUpperCase() === "FOO");
assert("Foo".toUpperCase() === "FOO");
assert("FOO".toUpperCase() === "FOO");
assert(('b' + 'a' + + 'n' + 'a').toUpperCase() === "BANANA");
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(('b' + 'a' + + 'n' + 'a').toUpperCase()).toBe("BANANA");
});

View file

@ -1,56 +1,58 @@
load("test-common.js");
test("trim", () => {
expect(String.prototype.trim).toHaveLength(0);
try {
assert(String.prototype.trim.length === 0);
assert(String.prototype.trimStart.length === 0);
assert(String.prototype.trimEnd.length === 0);
assert(" hello friends ".trim() === "hello friends");
assert("hello friends ".trim() === "hello friends");
assert(" hello friends".trim() === "hello friends");
assert(" hello friends".trimStart() === "hello friends");
assert("hello friends ".trimEnd() === "hello friends");
assert(" hello friends".trimEnd() === " hello friends");
assert("hello friends ".trimStart() === "hello friends ");
assert(" hello friends ".trimEnd() === " hello friends");
assert(" hello friends ".trimStart() === "hello friends ");
expect(" hello friends ".trim()).toBe("hello friends");
expect("hello friends ".trim()).toBe("hello friends");
expect(" hello friends".trim()).toBe("hello friends");
assert("\thello friends".trimStart() === "hello friends");
assert("hello friends\t".trimStart() === "hello friends\t");
assert("\thello friends\t".trimStart() === "hello friends\t");
assert("\rhello friends".trimStart() === "hello friends");
assert("hello friends\r".trimStart() === "hello friends\r");
assert("\rhello friends\r".trimStart() === "hello friends\r");
expect("\thello friends\t".trim()).toBe("hello friends");
expect("\thello friends".trim()).toBe("hello friends");
expect("hello friends\t".trim()).toBe("hello friends");
assert("hello friends\t".trimEnd() === "hello friends");
assert("\thello friends".trimEnd() === "\thello friends");
assert("\thello friends\t".trimEnd() === "\thello friends");
assert("hello friends\r".trimEnd() === "hello friends");
assert("\rhello friends".trimEnd() === "\rhello friends");
assert("\rhello friends\r".trimEnd() === "\rhello friends");
assert("hello friends\n".trimEnd() === "hello friends");
assert("\r\nhello friends".trimEnd() === "\r\nhello friends");
assert("\rhello friends\r\n".trimEnd() === "\rhello friends");
expect("\rhello friends\r".trim()).toBe("hello friends");
expect("\rhello friends".trim()).toBe("hello friends");
expect("hello friends\r".trim()).toBe("hello friends");
assert("\thello friends\t".trim() === "hello friends");
assert("\thello friends".trim() === "hello friends");
assert("hello friends\t".trim() === "hello friends");
assert("\rhello friends\r".trim() === "hello friends");
assert("\rhello friends".trim() === "hello friends");
assert("hello friends\r".trim() === "hello friends");
assert("\rhello friends\n".trim() === "hello friends");
assert("\r\thello friends".trim() === "hello friends");
assert("hello friends\r\n".trim() === "hello friends");
assert(" \thello friends\r\n".trim() === "hello friends");
assert("\n\t\thello friends\r\n".trim() === "hello friends");
assert("\n\t\thello friends\t\t".trim() === "hello friends");
expect("\rhello friends\n".trim()).toBe("hello friends");
expect("\r\thello friends".trim()).toBe("hello friends");
expect("hello friends\r\n".trim()).toBe("hello friends");
expect(" \thello friends\r\n".trim()).toBe("hello friends");
expect("\n\t\thello friends\r\n".trim()).toBe("hello friends");
expect("\n\t\thello friends\t\t".trim()).toBe("hello friends");
});
test("trimStart", () => {
expect(String.prototype.trimStart).toHaveLength(0);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
expect(" hello friends".trimStart()).toBe("hello friends");
expect("hello friends ".trimStart()).toBe("hello friends ");
expect(" hello friends ".trimStart()).toBe("hello friends ");
expect("\thello friends".trimStart()).toBe("hello friends");
expect("hello friends\t".trimStart()).toBe("hello friends\t");
expect("\thello friends\t".trimStart()).toBe("hello friends\t");
expect("\rhello friends".trimStart()).toBe("hello friends");
expect("hello friends\r".trimStart()).toBe("hello friends\r");
expect("\rhello friends\r".trimStart()).toBe("hello friends\r");
});
test("trimEnd", () => {
expect(String.prototype.trimEnd).toHaveLength(0);
expect("hello friends ".trimEnd()).toBe("hello friends");
expect(" hello friends".trimEnd()).toBe(" hello friends");
expect(" hello friends ".trimEnd()).toBe(" hello friends");
expect("hello friends\t".trimEnd()).toBe("hello friends");
expect("\thello friends".trimEnd()).toBe("\thello friends");
expect("\thello friends\t".trimEnd()).toBe("\thello friends");
expect("hello friends\r".trimEnd()).toBe("hello friends");
expect("\rhello friends".trimEnd()).toBe("\rhello friends");
expect("\rhello friends\r".trimEnd()).toBe("\rhello friends");
expect("hello friends\n".trimEnd()).toBe("hello friends");
expect("\r\nhello friends".trimEnd()).toBe("\r\nhello friends");
expect("\rhello friends\r\n".trimEnd()).toBe("\rhello friends");
});

View file

@ -0,0 +1,12 @@
test("basic functionality", () => {
expect(String.prototype.valueOf).toHaveLength(0);
expect(String()).toBe("");
expect(new String().valueOf()).toBe("");
expect(String("foo")).toBe("foo");
expect(new String("foo").valueOf()).toBe("foo");
expect(String(123)).toBe("123");
expect(new String(123).valueOf()).toBe("123");
expect(String(123)).toBe("123");
expect(new String(123).valueOf()).toBe("123");
});

Some files were not shown because too many files have changed in this diff Show more