mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibJS: Use the native assert() implementation now avaiable in 'js -t'
Switch the LibJS test suite to use the native assert implementation surfaced inside the js repl when it's launched in test mode.
This commit is contained in:
parent
4233c8662b
commit
bc40908d32
Notes:
sideshowbarker
2024-07-19 07:54:00 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/bc40908d329 Pull-request: https://github.com/SerenityOS/serenity/pull/1648
60 changed files with 2 additions and 119 deletions
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Array.length === 1);
|
||||
assert(Array.prototype.length === 0);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var a = [1, 2, 3];
|
||||
var value = a.pop();
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var a = [1, 2, 3];
|
||||
var value = a.shift();
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var last = 0;
|
||||
for (var i = 0; i < 100; ++i) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getDate()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getDay()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getFullYear()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getHours()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getMilliseconds()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getMinutes()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getMonth()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getSeconds()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var d = new Date();
|
||||
assert(!isNaN(d.getTime()));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var e;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Error().toString() === "Error");
|
||||
assert(Error(undefined).toString() === "Error");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Function.length === 1);
|
||||
assert(Function.prototype.length === 0);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
function Foo(arg) {
|
||||
this.foo = arg;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
function Foo(arg) {
|
||||
this.foo = arg;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert((function() {}).toString() === "function () {\n ???\n}");
|
||||
assert((function(foo) {}).toString() === "function (foo) {\n ???\n}");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Infinity + "" === "Infinity");
|
||||
assert(-Infinity + "" === "-Infinity");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
// FIXME: The parser seems to have issues with decimals,
|
||||
// so we multiply everything and compare with whole numbers.
|
||||
// I.e. 1233 < X * 1000 < 1235 instead of 1.233 < X < 1.235
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Math.abs('-1') === 1);
|
||||
assert(Math.abs(-2) === 2);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Math.ceil(0.95) === 1);
|
||||
assert(Math.ceil(4) === 4);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Math.max.length === 2);
|
||||
assert(Math.max(1) === 1);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Math.sqrt(9) === 3);
|
||||
console.log("PASS");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Math.trunc(13.37) === 13);
|
||||
assert(Math.trunc(42.84) === 42);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var nan = undefined + 1;
|
||||
assert(nan + "" == "NaN");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var names = Object.getOwnPropertyNames([1, 2, 3]);
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var o1 = new Object();
|
||||
var o2 = {};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var o = {};
|
||||
o.foo = 1;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var o = new Object();
|
||||
Object.prototype.foo = 123;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(typeof Object.prototype.toString() === "string");
|
||||
console.log("PASS");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var s = "foobar"
|
||||
assert(typeof s === "string");
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var s = "hello friends"
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var s = "foobar";
|
||||
assert(s.startsWith("f") === true);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var a = [1, 2, 3];
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
try {
|
||||
let getNumber = () => 42;
|
||||
assert(getNumber() === 42);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert((0 | 0) === 0);
|
||||
assert((0 | 1) === 1);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var j = 0;
|
||||
for (var i = 0; i < 9; ++i) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var number = 0;
|
||||
do {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) console.log("FAIL"); }
|
||||
|
||||
try {
|
||||
i < 3;
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var a = [];
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var number = 0;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
try {
|
||||
var b = true;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
function foo() { }
|
||||
assert(foo.length === 0);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
function foo(a, b) { return a + b; }
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(typeof this === "object");
|
||||
assert(this === global);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
function Foo() {
|
||||
this.x = 123;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert((true && true) === true);
|
||||
assert((false && false) === false);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
let foo = 1;
|
||||
false && (foo = 2);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(10 % 3 === 1);
|
||||
assert(10.5 % 2.5 === 0.5);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var o = {};
|
||||
o.a = 1;
|
||||
|
|
|
@ -14,7 +14,7 @@ fail_count=0
|
|||
count=0
|
||||
|
||||
for f in *.js; do
|
||||
result=`$js_program $f`
|
||||
result=`$js_program -t $f`
|
||||
if [ "$result" = "PASS" ]; then
|
||||
let pass_count++
|
||||
echo -ne "( \033[32;1mPass\033[0m ) "
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var i = 0;
|
||||
var three;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var x = 1;
|
||||
|
||||
assert(x === 1 ? true : false);
|
||||
assert(x ? x : 0);
|
||||
assert((x ? x : 0) === x);
|
||||
assert(1 < 2 ? (true) : (false));
|
||||
|
||||
var o = {};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) console.log("FAIL"); }
|
||||
|
||||
try {
|
||||
throw 1;
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(+false === 0);
|
||||
assert(-false === 0);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(typeof "foo" === "string");
|
||||
assert(!(typeof "foo" !== "string"));
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var a = 1, b = 2, c = a + b;
|
||||
assert(a === 1);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
function foo(a) {
|
||||
return a;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue