summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-02-10 16:18:11 +0100
committerCharlie Gordon <github@chqrlie.org>2024-02-10 16:19:17 +0100
commit37bd4ae62db064984a5956ab534920dfa21e3c5d (patch)
tree3bfd1df7e0e68e53771fab0fca9e17a1ef7b8156 /tests
parent6f480abbc8b2abe91fcc0fa58aa07c367e1dcb36 (diff)
downloadquickjs-37bd4ae62db064984a5956ab534920dfa21e3c5d.tar.gz
quickjs-37bd4ae62db064984a5956ab534920dfa21e3c5d.zip
Strip trailing spaces
Diffstat (limited to 'tests')
-rw-r--r--tests/bjson.c6
-rw-r--r--tests/microbench.js8
-rw-r--r--tests/test262.patch4
-rw-r--r--tests/test_bignum.js20
-rw-r--r--tests/test_bjson.js6
-rw-r--r--tests/test_builtin.js24
-rw-r--r--tests/test_closure.js4
-rw-r--r--tests/test_language.js32
-rw-r--r--tests/test_loop.js2
-rw-r--r--tests/test_op_overloading.js4
-rw-r--r--tests/test_qjscalc.js8
-rw-r--r--tests/test_std.js38
-rw-r--r--tests/test_worker_module.js4
13 files changed, 80 insertions, 80 deletions
diff --git a/tests/bjson.c b/tests/bjson.c
index 8e52741..78b1375 100644
--- a/tests/bjson.c
+++ b/tests/bjson.c
@@ -1,6 +1,6 @@
/*
* QuickJS: binary JSON module (test only)
- *
+ *
* Copyright (c) 2017-2019 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -32,7 +32,7 @@ static JSValue js_bjson_read(JSContext *ctx, JSValueConst this_val,
JSValue obj;
size_t size;
int flags;
-
+
if (JS_ToIndex(ctx, &pos, argv[1]))
return JS_EXCEPTION;
if (JS_ToIndex(ctx, &len, argv[2]))
@@ -56,7 +56,7 @@ static JSValue js_bjson_write(JSContext *ctx, JSValueConst this_val,
uint8_t *buf;
JSValue array;
int flags;
-
+
flags = 0;
if (JS_ToBool(ctx, argv[1]))
flags |= JS_WRITE_OBJ_REFERENCE;
diff --git a/tests/microbench.js b/tests/microbench.js
index c1b57bb..3002c0c 100644
--- a/tests/microbench.js
+++ b/tests/microbench.js
@@ -61,7 +61,7 @@ function toPrec(n, prec) {
s = s.substring(0, i) + "." + s.substring(i);
return s;
}
-
+
var ref_data;
var log_data;
@@ -987,7 +987,7 @@ function main(argc, argv, g)
];
var tests = [];
var i, j, n, f, name;
-
+
if (typeof BigInt == "function") {
/* BigInt test */
test_list.push(bigint64_arith);
@@ -997,7 +997,7 @@ function main(argc, argv, g)
/* BigFloat test */
test_list.push(float256_arith);
}
-
+
for (i = 1; i < argc;) {
name = argv[i++];
if (name == "-a") {
@@ -1047,7 +1047,7 @@ function main(argc, argv, g)
log_line("total", "", total[2], total[3], total_score * 100 / total_scale);
else
log_line("total", "", total[2]);
-
+
if (tests == test_list)
save_result("microbench-new.txt", log_data);
}
diff --git a/tests/test262.patch b/tests/test262.patch
index 6576bdc..a46fa30 100644
--- a/tests/test262.patch
+++ b/tests/test262.patch
@@ -28,7 +28,7 @@ index be7039fda0..7b38abf8df 100644
@@ -6,24 +6,27 @@ description: |
defines: [buildString, testPropertyEscapes, matchValidator]
---*/
-
+
+if ($262 && typeof $262.codePointRange === "function") {
+ /* use C function to build the codePointRange (much faster with
+ slow JS engines) */
@@ -67,5 +67,5 @@ index be7039fda0..7b38abf8df 100644
- return result;
+ return result;
}
-
+
function testPropertyEscapes(regex, string, expression) {
diff --git a/tests/test_bignum.js b/tests/test_bignum.js
index f4f72a0..51aa5b2 100644
--- a/tests/test_bignum.js
+++ b/tests/test_bignum.js
@@ -94,7 +94,7 @@ function test_bigint1()
r = 1n << 31n;
assert(r, 2147483648n, "1 << 31n === 2147483648n");
-
+
r = 1n << 32n;
assert(r, 4294967296n, "1 << 32n === 4294967296n");
}
@@ -150,7 +150,7 @@ function test_bigint_ext()
function test_bigfloat()
{
var e, a, b, sqrt2;
-
+
assert(typeof 1n === "bigint");
assert(typeof 1l === "bigfloat");
assert(1 == 1.0l);
@@ -164,7 +164,7 @@ function test_bigfloat()
test_less(2.1, 3l);
test_eq(Math.sqrt(9), 3l);
-
+
test_less(2n, 3l);
test_eq(3n, 3l);
@@ -174,7 +174,7 @@ function test_bigfloat()
assert(a === BigFloat.parseFloat("0x1.6a09e667f3bcc908b2fb1366ea957d3e", 0, e));
assert(e.inexact === true);
assert(BigFloat.fpRound(a) == 0x1.6a09e667f3bcc908b2fb1366ea95l);
-
+
b = BigFloatEnv.setPrec(BigFloat.sqrt.bind(null, 2), 128);
assert(a === b);
@@ -188,7 +188,7 @@ function test_bigfloat()
assert(BigFloat.exp(0.2l) === 1.2214027581601698339210719946396742l);
assert(BigFloat.log(3l) === 1.0986122886681096913952452369225256l);
assert(BigFloat.pow(2.1l, 1.6l) === 3.277561666451861947162828744873745l);
-
+
assert(BigFloat.sin(-1l) === -0.841470984807896506652502321630299l);
assert(BigFloat.cos(1l) === 0.5403023058681397174009366074429766l);
assert(BigFloat.tan(0.1l) === 0.10033467208545054505808004578111154l);
@@ -241,16 +241,16 @@ function test_bigdecimal()
assert(1m !== 2m);
test_less(1m, 2m);
test_eq(2m, 2m);
-
+
test_less(1, 2m);
test_eq(2, 2m);
test_less(1.1, 2m);
test_eq(Math.sqrt(4), 2m);
-
+
test_less(2n, 3m);
test_eq(3n, 3m);
-
+
assert(BigDecimal("1234.1") === 1234.1m);
assert(BigDecimal(" 1234.1") === 1234.1m);
assert(BigDecimal(" 1234.1 ") === 1234.1m);
@@ -272,7 +272,7 @@ function test_bigdecimal()
assert(1234.5m ** 3m === 1881365963.625m);
assertThrows(RangeError, () => { 2m ** 3.1m } );
assertThrows(RangeError, () => { 2m ** -3m } );
-
+
assert(BigDecimal.sqrt(2m,
{ roundingMode: "half-even",
maximumSignificantDigits: 4 }) === 1.414m);
@@ -282,7 +282,7 @@ function test_bigdecimal()
assert(BigDecimal.sqrt(0.002m,
{ roundingMode: "half-even",
maximumFractionDigits: 3 }) === 0.045m);
-
+
assert(BigDecimal.round(3.14159m,
{ roundingMode: "half-even",
maximumFractionDigits: 3 }) === 3.142m);
diff --git a/tests/test_bjson.js b/tests/test_bjson.js
index fcbb8e6..f15ef91 100644
--- a/tests/test_bjson.js
+++ b/tests/test_bjson.js
@@ -34,7 +34,7 @@ function toHex(a)
function isArrayLike(a)
{
- return Array.isArray(a) ||
+ return Array.isArray(a) ||
(a instanceof Uint8ClampedArray) ||
(a instanceof Uint8Array) ||
(a instanceof Uint16Array) ||
@@ -147,7 +147,7 @@ function bjson_test_reference()
function bjson_test_all()
{
var obj;
-
+
bjson_test({x:1, y:2, if:3});
bjson_test([1, 2, 3]);
bjson_test([1.0, "aa", true, false, undefined, null, NaN, -Infinity, -0.0]);
@@ -174,7 +174,7 @@ function bjson_test_all()
bjson_test(new Int32Array([123123, 222111, -32222]));
bjson_test(new Float64Array([123123, 222111.5]));
-
+
/* tested with a circular reference */
obj = {};
obj.x = obj;
diff --git a/tests/test_builtin.js b/tests/test_builtin.js
index e256066..a9b2264 100644
--- a/tests/test_builtin.js
+++ b/tests/test_builtin.js
@@ -57,7 +57,7 @@ function test_function()
}
var r, g;
-
+
r = my_func.call(null, 1, 2);
assert(r, 3, "call");
@@ -70,10 +70,10 @@ function test_function()
assert_throws(TypeError, (function() {
Reflect.apply((function () { return 1; }), null, undefined);
}));
-
+
r = new Function("a", "b", "return a + b;");
assert(r(2,3), 5, "function");
-
+
g = f.bind(1, 2);
assert(g.length, 1);
assert(g.name, "bound f");
@@ -103,7 +103,7 @@ function test()
assert(a.z, 4, "get");
a.z = 5;
assert(a.z_val, 5, "set");
-
+
a = { get z() { return 4; }, set z(val) { this.z_val = val; } };
assert(a.z, 4, "get");
a.z = 5;
@@ -207,7 +207,7 @@ function test_string()
assert(a.charAt(1), "b");
assert(a.charAt(-1), "");
assert(a.charAt(3), "");
-
+
a = "abcd";
assert(a.substring(1, 3), "bc", "substring");
a = String.fromCharCode(0x20ac);
@@ -216,7 +216,7 @@ function test_string()
assert(a, "\u20ac", "unicode");
assert(a, "\u{20ac}", "unicode");
assert("a", "\x61", "unicode");
-
+
a = "\u{10ffff}";
assert(a.length, 2, "unicode");
assert(a, "\u{dbff}\u{dfff}", "unicode");
@@ -379,7 +379,7 @@ function test_eval()
assert(eval("if (0) 2; else 3;"), 3);
assert(f.call(1, "this"), 1);
-
+
a = 2;
assert(eval("a"), 2);
@@ -424,7 +424,7 @@ function test_typed_array()
a[2] = 0.5;
a[3] = 1233.5;
assert(a.toString(), "0,2,0,255");
-
+
buffer = new ArrayBuffer(16);
assert(buffer.byteLength, 16);
a = new Uint32Array(buffer, 12, 1);
@@ -436,7 +436,7 @@ function test_typed_array()
a = new Float32Array(buffer, 8, 1);
a[0] = 1;
-
+
a = new Uint8Array(buffer);
str = a.toString();
@@ -525,7 +525,7 @@ function test_regexp()
a = /(\.(?!com|org)|\/)/.exec("ah.com");
assert(a, null);
-
+
a = /(?=(a+))/.exec("baaabac");
assert(a.index === 1 && a[0] === "" && a[1] === "aaa");
@@ -602,7 +602,7 @@ function test_map()
}
i = 0;
- a.forEach(function (v, o) {
+ a.forEach(function (v, o) {
assert(o, tab[i++][0]);
assert(a.has(o));
assert(a.delete(o));
@@ -625,7 +625,7 @@ function test_weak_map()
a.set(o, v);
}
o = null;
-
+
n2 = n >> 1;
for(i = 0; i < n2; i++) {
a.delete(tab[i][0]);
diff --git a/tests/test_closure.js b/tests/test_closure.js
index aa1d17e..f5d4160 100644
--- a/tests/test_closure.js
+++ b/tests/test_closure.js
@@ -54,7 +54,7 @@ function test_closure1()
function f2()
{
var val = 1;
-
+
function set(a) {
val = a;
}
@@ -63,7 +63,7 @@ function test_closure1()
}
return { "set": set, "get": get };
}
-
+
var obj = f2();
obj.set(10);
var r;
diff --git a/tests/test_language.js b/tests/test_language.js
index 137f1d3..75f5cdc 100644
--- a/tests/test_language.js
+++ b/tests/test_language.js
@@ -68,10 +68,10 @@ function test_op1()
r = 1 << 31;
assert(r, -2147483648, "1 << 31 === -2147483648");
-
+
r = 1 << 32;
assert(r, 1, "1 << 32 === 1");
-
+
r = (1 << 31) < 0;
assert(r, true, "(1 << 31) < 0 === true");
@@ -113,7 +113,7 @@ function test_cvt()
assert(("12345" | 0) === 12345);
assert(("0x12345" | 0) === 0x12345);
assert(((4294967296 * 3 - 4) | 0) === -4);
-
+
assert(("12345" >>> 0) === 12345);
assert(("0x12345" >>> 0) === 0x12345);
assert((NaN >>> 0) === 0);
@@ -141,7 +141,7 @@ function test_eq()
function test_inc_dec()
{
var a, r;
-
+
a = 1;
r = a++;
assert(r === 1 && a === 2, true, "++");
@@ -169,19 +169,19 @@ function test_inc_dec()
a = [true];
a[0]++;
assert(a[0], 2, "++");
-
+
a = {x:true};
r = a.x++;
assert(r === 1 && a.x === 2, true, "++");
-
+
a = {x:true};
r = a.x--;
assert(r === 1 && a.x === 0, true, "--");
-
+
a = [true];
r = a[0]++;
assert(r === 1 && a[0] === 2, true, "++");
-
+
a = [true];
r = a[0]--;
assert(r === 1 && a[0] === 0, true, "--");
@@ -213,7 +213,7 @@ function test_op2()
assert((typeof Object), "function", "typeof");
assert((typeof null), "object", "typeof");
assert((typeof unknown_var), "undefined", "typeof");
-
+
a = {x: 1, if: 2, async: 3};
assert(a.if === 2);
assert(a.async === 3);
@@ -226,7 +226,7 @@ function test_delete()
a = {x: 1, y: 1};
assert((delete a.x), true, "delete");
assert(("x" in a), false, "delete");
-
+
/* the following are not tested by test262 */
assert(delete "abc"[100], true);
@@ -311,7 +311,7 @@ function test_class()
o = new C();
assert(o.f() === 1);
assert(o.x === 10);
-
+
assert(D.F() === -1);
assert(D.G() === -2);
assert(D.H() === -1);
@@ -374,7 +374,7 @@ function test_regexp_skip()
var a, b;
[a, b = /abc\(/] = [1];
assert(a === 1);
-
+
[a, b =/abc\(/] = [2];
assert(a === 2);
}
@@ -419,7 +419,7 @@ function test_argument_scope()
{
var f;
var c = "global";
-
+
f = function(a = eval("var arguments")) {};
assert_throws(SyntaxError, f);
@@ -490,7 +490,7 @@ function test_function_expr_name()
/* non strict mode test : assignment to the function name silently
fails */
-
+
f = function myfunc() {
myfunc = 1;
return myfunc;
@@ -511,7 +511,7 @@ function test_function_expr_name()
return myfunc;
};
assert(f(), f);
-
+
/* strict mode test : assignment to the function name raises a
TypeError exception */
@@ -581,7 +581,7 @@ function test_optional_chaining()
assert(delete z?.b["c"], true);
assert(delete a?.b["c"], true);
assert(JSON.stringify(a), '{"b":{}}');
-
+
a = {
b() { return this._b; },
_b: { c: 42 }
diff --git a/tests/test_loop.js b/tests/test_loop.js
index 084d658..d387cad 100644
--- a/tests/test_loop.js
+++ b/tests/test_loop.js
@@ -356,7 +356,7 @@ function test_try_catch7()
function test_try_catch8()
{
var i, s;
-
+
s = "";
for(var i in {x:1, y:2}) {
try {
diff --git a/tests/test_op_overloading.js b/tests/test_op_overloading.js
index d08a85e..269abb2 100644
--- a/tests/test_op_overloading.js
+++ b/tests/test_op_overloading.js
@@ -35,7 +35,7 @@ function test_operators_create() {
return "Vec2(" + this.x + "," + this.y + ")";
}
}
-
+
Vec2.prototype[Symbol.operatorSet] = Operators.create(
{
"+"(p1, p2) {
@@ -172,7 +172,7 @@ function test_operators()
return "Vec2(" + this.x + "," + this.y + ")";
}
}
-
+
var a = new Vec2(1, 2);
var b = new Vec2(3, 4);
var r;
diff --git a/tests/test_qjscalc.js b/tests/test_qjscalc.js
index 1483466..e97dd31 100644
--- a/tests/test_qjscalc.js
+++ b/tests/test_qjscalc.js
@@ -60,10 +60,10 @@ function test_integer()
r = 1 << 31;
assert(r, 2147483648, "1 << 31 === 2147483648");
-
+
r = 1 << 32;
assert(r, 4294967296, "1 << 32 === 4294967296");
-
+
r = (1 << 31) < 0;
assert(r, false, "(1 << 31) < 0 === false");
@@ -115,7 +115,7 @@ function test_fraction()
function test_mod()
{
var a, b, p;
-
+
a = Mod(3, 101);
b = Mod(-1, 101);
assert((a + b) == Mod(2, 101));
@@ -131,7 +131,7 @@ function test_polynomial()
var a, b, q, r, t, i;
a = (1 + X) ^ 4;
assert(a == X^4+4*X^3+6*X^2+4*X+1);
-
+
r = (1 + X);
q = (1+X+X^2);
b = (1 - X^2);
diff --git a/tests/test_std.js b/tests/test_std.js
index 6fb94c2..562c96c 100644
--- a/tests/test_std.js
+++ b/tests/test_std.js
@@ -46,7 +46,7 @@ function test_file1()
f.seek(0, std.SEEK_SET);
str1 = f.readAsString();
assert(str1 === str);
-
+
f.seek(0, std.SEEK_END);
size = f.tell();
assert(size === str.length);
@@ -81,7 +81,7 @@ function test_file2()
function test_getline()
{
var f, line, line_count, lines, i;
-
+
lines = ["hello world", "line 1", "line 2" ];
f = std.tmpfile();
for(i = 0; i < lines.length; i++) {
@@ -103,7 +103,7 @@ function test_getline()
f.close();
}
-
+
function test_popen()
{
var str, f, fname = "tmp_file.txt";
@@ -115,7 +115,7 @@ function test_popen()
/* test loadFile */
assert(std.loadFile(fname), content);
-
+
/* execute the 'cat' shell command */
f = std.popen("cat " + fname, "r");
str = f.readAsString();
@@ -150,17 +150,17 @@ function test_os()
fname = "tmp_file.txt";
fpath = fdir + "/" + fname;
link_path = fdir + "/test_link";
-
+
os.remove(link_path);
os.remove(fpath);
os.remove(fdir);
err = os.mkdir(fdir, 0o755);
assert(err === 0);
-
+
fd = os.open(fpath, os.O_RDWR | os.O_CREAT | os.O_TRUNC);
assert(fd >= 0);
-
+
buf = new Uint8Array(10);
for(i = 0; i < buf.length; i++)
buf[i] = i;
@@ -169,16 +169,16 @@ function test_os()
assert(os.seek(fd, 0, std.SEEK_SET) === 0);
buf2 = new Uint8Array(buf.length);
assert(os.read(fd, buf2.buffer, 0, buf2.length) === buf2.length);
-
+
for(i = 0; i < buf.length; i++)
assert(buf[i] == buf2[i]);
-
+
if (typeof BigInt !== "undefined") {
assert(os.seek(fd, BigInt(6), std.SEEK_SET), BigInt(6));
assert(os.read(fd, buf2.buffer, 0, 1) === 1);
assert(buf[6] == buf2[0]);
}
-
+
assert(os.close(fd) === 0);
[files, err] = os.readdir(fdir);
@@ -189,7 +189,7 @@ function test_os()
err = os.utimes(fpath, fdate, fdate);
assert(err, 0);
-
+
[st, err] = os.stat(fpath);
assert(err, 0);
assert(st.mode & os.S_IFMT, os.S_IFREG);
@@ -197,7 +197,7 @@ function test_os()
err = os.symlink(fname, link_path);
assert(err === 0);
-
+
[st, err] = os.lstat(link_path);
assert(err, 0);
assert(st.mode & os.S_IFMT, os.S_IFLNK);
@@ -205,7 +205,7 @@ function test_os()
[buf, err] = os.readlink(link_path);
assert(err, 0);
assert(buf, fname);
-
+
assert(os.remove(link_path) === 0);
[buf, err] = os.getcwd();
@@ -215,7 +215,7 @@ function test_os()
assert(err, 0);
assert(buf, buf2);
-
+
assert(os.remove(fpath) === 0);
fd = os.open(fpath, os.O_RDONLY);
@@ -233,7 +233,7 @@ function test_os_exec()
ret = os.exec(["/bin/sh", "-c", "exit 1"], { usePath: false });
assert(ret, 1);
-
+
fds = os.pipe();
pid = os.exec(["sh", "-c", "echo $FOO"], {
stdout: fds[1],
@@ -277,16 +277,16 @@ function test_async_gc()
{
(async function run () {
let obj = {}
-
+
let done = () => {
obj
std.gc();
}
-
+
Promise.resolve().then(done)
-
+
const p = new Promise(() => {})
-
+
await p
})();
}
diff --git a/tests/test_worker_module.js b/tests/test_worker_module.js
index f19600a..bad1a6b 100644
--- a/tests/test_worker_module.js
+++ b/tests/test_worker_module.js
@@ -22,10 +22,10 @@ function handle_msg(e) {
function worker_main() {
var i;
-
+
parent.onmessage = handle_msg;
for(i = 0; i < 10; i++) {
- parent.postMessage({ type: "num", num: i });
+ parent.postMessage({ type: "num", num: i });
}
}