summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/test/wasm2js.py8
-rw-r--r--test/calls.post.js23
-rw-r--r--test/control_flow.post.js26
-rw-r--r--test/float_ops.post.js89
-rw-r--r--test/int_ops.post.js53
-rw-r--r--test/mem.post.js53
-rw-r--r--test/wasm2asm.asserts.js118
-rw-r--r--test/wasm2asm.traps.js146
-rw-r--r--test/wasm2js/wasm2js.asserts.js (renamed from test/wasm2js.asserts.js)0
-rw-r--r--test/wasm2js/wasm2js.traps.js (renamed from test/wasm2js.traps.js)0
10 files changed, 4 insertions, 512 deletions
diff --git a/scripts/test/wasm2js.py b/scripts/test/wasm2js.py
index 374e93297..6463fa3a8 100644
--- a/scripts/test/wasm2js.py
+++ b/scripts/test/wasm2js.py
@@ -127,8 +127,8 @@ def test_asserts_output():
asserts = os.path.basename(wasm).replace('.wast.asserts', '.asserts.js')
traps = os.path.basename(wasm).replace('.wast.asserts', '.traps.js')
- asserts_expected_file = os.path.join(shared.options.binaryen_test, asserts)
- traps_expected_file = os.path.join(shared.options.binaryen_test, traps)
+ asserts_expected_file = os.path.join(shared.options.binaryen_test, 'wasm2js', asserts)
+ traps_expected_file = os.path.join(shared.options.binaryen_test, 'wasm2js', traps)
wasm = os.path.join(shared.get_test_dir('wasm2js'), wasm)
cmd = shared.WASM2JS + [wasm, '--allow-asserts', '-all',
@@ -203,8 +203,8 @@ def update_wasm2js_tests():
asserts = os.path.basename(wasm).replace('.wast.asserts', '.asserts.js')
traps = os.path.basename(wasm).replace('.wast.asserts', '.traps.js')
- asserts_expected_file = os.path.join(shared.options.binaryen_test, asserts)
- traps_expected_file = os.path.join(shared.options.binaryen_test, traps)
+ asserts_expected_file = os.path.join(shared.options.binaryen_test, 'wasm2js', asserts)
+ traps_expected_file = os.path.join(shared.options.binaryen_test, 'wasm2js', traps)
cmd = shared.WASM2JS + [os.path.join(shared.get_test_dir('wasm2js'), wasm), '--allow-asserts', '-all', '--disable-exception-handling']
out = support.run_command(cmd)
diff --git a/test/calls.post.js b/test/calls.post.js
deleted file mode 100644
index bec4d498b..000000000
--- a/test/calls.post.js
+++ /dev/null
@@ -1,23 +0,0 @@
-
-function test(name) {
- Module.print(name);
- function doTest(x) {
- Module.print(' ' + [x] + ' ==> ' + Module['_' + name](x));
- }
- doTest(1);
- doTest(2);
- doTest(3);
- doTest(4);
- doTest(7);
-}
-
-test('simple');
-test('fibo');
-
-Module.print('run_script');
-Module.print(Module['_run_script']());
-
-Module.print('too many/few arguments');
-Module.print(Module['_simple']());
-Module.print(Module['_simple'](10, 20));
-
diff --git a/test/control_flow.post.js b/test/control_flow.post.js
deleted file mode 100644
index 823580e7b..000000000
--- a/test/control_flow.post.js
+++ /dev/null
@@ -1,26 +0,0 @@
-
-function test(name) {
- Module.print(name);
- function doTest(x) {
- Module.print(' ' + [x] + ' ==> ' + Module['_check_' + name](x));
- }
- doTest(1);
- doTest(2);
- doTest(3);
- doTest(4);
- doTest(11);
- doTest(90);
-}
-
-test('if');
-test('loop');
-test('loop_break');
-test('loop_continue');
-test('do_loop');
-test('do_once');
-test('while_forever');
-test('switch');
-test('switch_nodefault');
-test('switch_rdefault');
-test('switch_fallthrough');
-
diff --git a/test/float_ops.post.js b/test/float_ops.post.js
deleted file mode 100644
index c08ba19e5..000000000
--- a/test/float_ops.post.js
+++ /dev/null
@@ -1,89 +0,0 @@
-
-// unary
-function testUnary(name) {
- Module.print(name);
- function doTest(x) {
- Module.print(' ' + [x] + ' ==> ' + Module['_' + name](x));
- }
- doTest(0);
- doTest(1);
- doTest(-1);
- doTest(0.5);
- doTest(-0.5);
- doTest(1.4);
- doTest(-1.4);
- doTest(1.6);
- doTest(-1.6);
- doTest(5.1);
- doTest(5.3);
- doTest(5.7);
- doTest(5.9);
- doTest(-1 | 0);
- doTest((-1 | 0) + 1);
- doTest((-1 | 0) - 1);
- doTest((-1 >>> 0) + 1);
- doTest((-1 >>> 0) - 1);
- doTest((-1 | 0) + 2);
- doTest((-1 | 0) - 2);
- doTest((-1 >>> 0) + 2);
- doTest((-1 >>> 0) - 2);
-}
-testUnary('dfloor');
-
-// binary
-function testBinary(name) {
- Module.print(name);
- function doTest(x, y) {
- Module.print(' ' + [x, y] + ' ==> ' + Module['_' + name](x, y));
- }
- doTest(0, 0);
- doTest(0, 1);
- doTest(1, 0);
- doTest(1, 1);
- doTest(5, 6);
- doTest(6, 5);
- doTest(101, -12);
- doTest(-12, 101);
- doTest(-1, 5);
- doTest(5, -1);
- doTest(-1, -1);
- doTest(0.12, 0.12);
- doTest(0.812, 1);
- doTest(1.821, 0);
- doTest(1, 1.212);
- doTest(5.543, 6);
- doTest(6, 5.121);
- doTest(101.001, -12);
- doTest(-12.001, 101);
- doTest(-1, 5.123);
- doTest(5, -1.123);
- doTest(-1, -1.123);
-}
-testBinary('dadd');
-testBinary('dsub');
-testBinary('dmul');
-testBinary('ddiv');
-//testBinary('dcopysign'); // TODO this uses tempDoublePtr, a global, which is not yet functional
-testBinary('dmin');
-testBinary('dmax');
-
-// comparisons
-testBinary('deq');
-testBinary('dne');
-testBinary('dlt');
-testBinary('dle');
-testBinary('dgt');
-testBinary('dge');
-
-// conversions
-testUnary('int_to_double');
-testUnary('uint_to_double');
-testUnary('double_to_int');
-testUnary('double_to_uint');
-testUnary('int_to_float');
-testUnary('uint_to_float');
-testUnary('float_to_int');
-testUnary('float_to_uint');
-
-Module.print('done.');
-
diff --git a/test/int_ops.post.js b/test/int_ops.post.js
deleted file mode 100644
index f1f84c31b..000000000
--- a/test/int_ops.post.js
+++ /dev/null
@@ -1,53 +0,0 @@
-
-// unary
-Module.print('clz');
-Module.print(Module._clz(1));
-Module.print(Module._clz(-1));
-Module.print(Module._clz(8));
-
-// binary
-function testBinary(name, noSecondZero, noSecondBig) {
- Module.print(name);
- function doTest(x, y) {
- Module.print(' ' + [x, y] + ' ==> ' + Module['_' + name](x, y));
- }
- if (!noSecondZero) doTest(0, 0);
- doTest(0, 1);
- if (!noSecondZero) doTest(1, 0);
- doTest(1, 1);
- doTest(5, 6);
- doTest(6, 5);
- if (!noSecondBig) doTest(101, -12);
- if (!noSecondBig) doTest(-12, 101);
- doTest(-1, 5);
- if (!noSecondBig) doTest(5, -1);
- if (!noSecondBig) doTest(-1, -1);
-}
-testBinary('add');
-testBinary('sub');
-testBinary('mul');
-testBinary('sdiv', true);
-testBinary('udiv', true);
-testBinary('srem', true);
-testBinary('urem', true);
-testBinary('and');
-testBinary('or');
-testBinary('xor');
-testBinary('shl', false, true);
-testBinary('sshr', false, true);
-testBinary('ushr', false, true);
-
-// comparisons
-testBinary('eq');
-testBinary('ne');
-testBinary('lts');
-testBinary('ltu');
-testBinary('les');
-testBinary('leu');
-testBinary('gts');
-testBinary('gtu');
-testBinary('ges');
-testBinary('geu');
-
-Module.print('done.');
-
diff --git a/test/mem.post.js b/test/mem.post.js
deleted file mode 100644
index 4dcfb7a83..000000000
--- a/test/mem.post.js
+++ /dev/null
@@ -1,53 +0,0 @@
-
-function test(name) {
- Module.print(name);
- function doTest(x) {
- // write to 0, as 0-8 is normally unused anyhow
- Module['_store' + name](0, x);
- Module.print(' ' + [x] + ' ==> ' + Module['_load' + name](0));
- }
- doTest(0);
- doTest(1);
- doTest(-1);
- doTest(0.5);
- doTest(-0.5);
- doTest(1.4);
- doTest(-1.4);
- doTest(1.6);
- doTest(-1.6);
- doTest(5.1);
- doTest(5.3);
- doTest(5.7);
- doTest(5.9);
- doTest(1 << 10);
- doTest(1 << 20);
- doTest(-1 | 0);
- doTest((-1 | 0) + 1);
- doTest((-1 | 0) - 1);
- doTest(-1 >>> 0);
- doTest((-1 >>> 0) + 1);
- doTest((-1 >>> 0) - 1);
-
- Module.print(' pre ==> ' + Module['_load' + name](0));
- HEAPU8[0] = 10;
- HEAPU8[1] = 20;
- HEAPU8[2] = 30;
- HEAPU8[3] = 40;
- HEAPU8[4] = 50;
- HEAPU8[5] = 99;
- HEAPU8[6] = 125;
- HEAPU8[7] = 250;
- Module.print(' post ==> ' + Module['_load' + name](0));
-}
-
-test('i8');
-test('i16');
-test('i32');
-test('u8');
-test('u16');
-test('u32');
-test('f32');
-test('f64');
-
-Module.print('stack: ' + (Module['_get_stack']() > 8));
-
diff --git a/test/wasm2asm.asserts.js b/test/wasm2asm.asserts.js
deleted file mode 100644
index 71515c4c3..000000000
--- a/test/wasm2asm.asserts.js
+++ /dev/null
@@ -1,118 +0,0 @@
-function asmFunc(global, env, buffer) {
- "use asm";
- var HEAP8 = new global.Int8Array(buffer);
- var HEAP16 = new global.Int16Array(buffer);
- var HEAP32 = new global.Int32Array(buffer);
- var HEAPU8 = new global.Uint8Array(buffer);
- var HEAPU16 = new global.Uint16Array(buffer);
- var HEAPU32 = new global.Uint32Array(buffer);
- var HEAPF32 = new global.Float32Array(buffer);
- var HEAPF64 = new global.Float64Array(buffer);
- var Math_imul = global.Math.imul;
- var Math_fround = global.Math.fround;
- var Math_abs = global.Math.abs;
- var Math_clz32 = global.Math.clz32;
- var Math_min = global.Math.min;
- var Math_max = global.Math.max;
- var Math_floor = global.Math.floor;
- var Math_ceil = global.Math.ceil;
- var Math_sqrt = global.Math.sqrt;
- var abort = env.abort;
- var i64toi32_i32$HIGH_BITS = 0;
- function $0() {
-
- }
-
- function $1(x, y) {
- x = x | 0;
- y = y | 0;
- return x + y | 0 | 0;
- }
-
- function $2(x, y) {
- x = x | 0;
- y = y | 0;
- return (x | 0) / (y | 0) | 0 | 0;
- }
-
- function __wasm_fetch_high_bits() {
- return i64toi32_i32$HIGH_BITS | 0;
- }
-
- return {
- empty: $0,
- add: $1,
- div_s: $2,
- __wasm_fetch_high_bits: __wasm_fetch_high_bits
- };
-}
-
-
- var __array_buffer = new ArrayBuffer(65536)
- var HEAP32 = new Int32Array(__array_buffer);
- var HEAPF32 = new Float32Array(__array_buffer);
- var HEAPF64 = new Float64Array(__array_buffer);
- ;
-
- function f32Equal(a, b) {
- var i = new Int32Array(1);
- var f = new Float32Array(i.buffer);
- f[0] = a;
- var ai = f[0];
- f[0] = b;
- var bi = f[0];
-
- return (isNaN(a) && isNaN(b)) || a == b;
- }
-
- function f64Equal(a, b) {
- var i = new Int32Array(2);
- var f = new Float64Array(i.buffer);
- f[0] = a;
- var ai1 = i[0];
- var ai2 = i[1];
- f[0] = b;
- var bi1 = i[0];
- var bi2 = i[1];
-
- return (isNaN(a) && isNaN(b)) || (ai1 == bi1 && ai2 == bi2);
- }
- ;
-var asmModule = asmFunc({
- Math: Math,
- Int8Array: Int8Array,
- Int16Array: Int16Array,
- Int32Array: Int32Array,
- Uint8Array: Uint8Array,
- Uint16Array: Uint16Array,
- Uint32Array: Uint32Array,
- Float32Array: Float32Array,
- Float64Array: Float64Array,
- Infinity: Infinity,
- NaN: NaN
-}, {
- abort: function abort() {
- unreachable();
- console_log();
- }
- ,
- print: function print() {}
-}, __array_buffer);
-
- function i64Equal(actual_lo, actual_hi, expected_lo, expected_hi) {
- return actual_lo == (expected_lo | 0) && actual_hi == (expected_hi | 0);
- }
- ;
-function check1() {
- var wasm2asm_i32$0 = 0;
- asmModule.empty();
- wasm2asm_i32$0 = 1;
- return wasm2asm_i32$0 | 0;
-}
-
-if (!check1()) fail1();
-function check2() {
- return (asmModule.add(1 | 0, 1 | 0) | 0 | 0) == (2 | 0) | 0;
-}
-
-if (!check2()) fail2();
diff --git a/test/wasm2asm.traps.js b/test/wasm2asm.traps.js
deleted file mode 100644
index c2a7219bc..000000000
--- a/test/wasm2asm.traps.js
+++ /dev/null
@@ -1,146 +0,0 @@
-function asmFunc(global, env, buffer) {
- "use asm";
- var HEAP8 = new global.Int8Array(buffer);
- var HEAP16 = new global.Int16Array(buffer);
- var HEAP32 = new global.Int32Array(buffer);
- var HEAPU8 = new global.Uint8Array(buffer);
- var HEAPU16 = new global.Uint16Array(buffer);
- var HEAPU32 = new global.Uint32Array(buffer);
- var HEAPF32 = new global.Float32Array(buffer);
- var HEAPF64 = new global.Float64Array(buffer);
- var Math_imul = global.Math.imul;
- var Math_fround = global.Math.fround;
- var Math_abs = global.Math.abs;
- var Math_clz32 = global.Math.clz32;
- var Math_min = global.Math.min;
- var Math_max = global.Math.max;
- var Math_floor = global.Math.floor;
- var Math_ceil = global.Math.ceil;
- var Math_sqrt = global.Math.sqrt;
- var abort = env.abort;
- var i64toi32_i32$HIGH_BITS = 0;
- function $0() {
-
- }
-
- function $1(x, y) {
- x = x | 0;
- y = y | 0;
- return x + y | 0 | 0;
- }
-
- function $2(x, y) {
- x = x | 0;
- y = y | 0;
- return (x | 0) / (y | 0) | 0 | 0;
- }
-
- function __wasm_fetch_high_bits() {
- return i64toi32_i32$HIGH_BITS | 0;
- }
-
- return {
- empty: $0,
- add: $1,
- div_s: $2,
- __wasm_fetch_high_bits: __wasm_fetch_high_bits
- };
-}
-
-
- var __array_buffer = new ArrayBuffer(65536)
- var HEAP32 = new Int32Array(__array_buffer);
- var HEAPF32 = new Float32Array(__array_buffer);
- var HEAPF64 = new Float64Array(__array_buffer);
- ;
-
- function f32Equal(a, b) {
- var i = new Int32Array(1);
- var f = new Float32Array(i.buffer);
- f[0] = a;
- var ai = f[0];
- f[0] = b;
- var bi = f[0];
-
- return (isNaN(a) && isNaN(b)) || a == b;
- }
-
- function f64Equal(a, b) {
- var i = new Int32Array(2);
- var f = new Float64Array(i.buffer);
- f[0] = a;
- var ai1 = i[0];
- var ai2 = i[1];
- f[0] = b;
- var bi1 = i[0];
- var bi2 = i[1];
-
- return (isNaN(a) && isNaN(b)) || (ai1 == bi1 && ai2 == bi2);
- }
- ;
-var asmModule = asmFunc({
- Math: Math,
- Int8Array: Int8Array,
- Int16Array: Int16Array,
- Int32Array: Int32Array,
- Uint8Array: Uint8Array,
- Uint16Array: Uint16Array,
- Uint32Array: Uint32Array,
- Float32Array: Float32Array,
- Float64Array: Float64Array,
- Infinity: Infinity,
- NaN: NaN
-}, {
- abort: function abort() {
- unreachable();
- console_log();
- }
- ,
- print: function print() {}
-}, __array_buffer);
-
- function i64Equal(actual_lo, actual_hi, expected_lo, expected_hi) {
- return actual_lo == (expected_lo | 0) && actual_hi == (expected_hi | 0);
- }
- ;
-function check1() {
- var wasm2asm_i32$0 = 0;
- asmModule.empty();
- wasm2asm_i32$0 = 1;
- return wasm2asm_i32$0 | 0;
-}
-
-if (!check1()) fail1();
-function check2() {
- return (asmModule.add(1 | 0, 1 | 0) | 0 | 0) == (2 | 0) | 0;
-}
-
-if (!check2()) fail2();
-function check3() {
- function f() {
- asmModule.div_s(0 | 0, 0 | 0);
- }
-
- try {
- f();
- } catch (e) {
- return e.message.includes("integer divide by zero");
- };
- return 0;
-}
-
-if (!check3()) fail3();
-function check4() {
- function f() {
- asmModule.div_s(2147483648 | 0, 4294967295 | 0);
- }
-
- try {
- f();
- } catch (e) {
- return e.message.includes("integer overflow");
- };
- return 0;
-}
-
-if (!check4()) fail4();
diff --git a/test/wasm2js.asserts.js b/test/wasm2js/wasm2js.asserts.js
index fb6516106..fb6516106 100644
--- a/test/wasm2js.asserts.js
+++ b/test/wasm2js/wasm2js.asserts.js
diff --git a/test/wasm2js.traps.js b/test/wasm2js/wasm2js.traps.js
index 8f87e2423..8f87e2423 100644
--- a/test/wasm2js.traps.js
+++ b/test/wasm2js/wasm2js.traps.js