diff options
-rwxr-xr-x | auto_update_tests.py | 9 | ||||
-rwxr-xr-x | check.py | 4 | ||||
-rw-r--r-- | test/address.2asm.js | 43 |
3 files changed, 54 insertions, 2 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py index 67f71b69b..ea624a689 100755 --- a/auto_update_tests.py +++ b/auto_update_tests.py @@ -49,6 +49,15 @@ for wasm in ['min.wast', 'hello_world.wast', 'unit.wast', 'emcc_O2_hello_world.w expected_file = os.path.join('test', asm) open(expected_file, 'w').write(actual) +for wasm in ['address.wast']:#os.listdir(os.path.join('test', 'spec')): + if wasm.endswith('.wast'): + print '..', wasm + asm = wasm.replace('.wast', '.2asm.js') + actual, err = subprocess.Popen([os.path.join('bin', 'wasm2asm'), os.path.join('test', 'spec', wasm)], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + assert err == '', 'bad err:' + err + expected_file = os.path.join('test', asm) + open(expected_file, 'w').write(actual) + for t in sorted(os.listdir(os.path.join('test', 'passes'))): if t.endswith('.wast'): print '..', t @@ -199,10 +199,10 @@ for t in experimental_tests: print '\n[ checking wasm2asm testcases... ]\n' -for wasm in tests: +for wasm in tests + [os.path.join('spec', name) for name in ['address.wast']]:#spec_tests: if wasm.endswith('.wast'): print '..', wasm - asm = wasm.replace('.wast', '.2asm.js') + asm = os.path.basename(wasm).replace('.wast', '.2asm.js') actual, err = subprocess.Popen([os.path.join('bin', 'wasm2asm'), os.path.join('test', wasm)], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() assert err == '', 'bad err:' + err diff --git a/test/address.2asm.js b/test/address.2asm.js new file mode 100644 index 000000000..7c0e95e09 --- /dev/null +++ b/test/address.2asm.js @@ -0,0 +1,43 @@ +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 print = env.print; + function good(i) { + i = i | 0; + var wasm2asm_i32$0 = 0; + print(HEAPU8[i >> 0] | 0 | 0); + print(HEAPU8[(i + 1 | 0) >> 0] | 0 | 0); + print(HEAPU8[(i + 2 | 0) >> 0] | 0 | 0); + print(HEAPU8[(i + 25 | 0) >> 0] | 0 | 0); + print(HEAPU16[i >> 1] | 0 | 0); + print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0) << 8) | 0); + print(HEAPU16[(i + 2 | 0) >> 1] | 0 | 0); + print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 25 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 26 | 0) >> 0] | 0 | 0) << 8) | 0); + print(HEAPU32[i >> 2] | 0 | 0); + print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 3 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 4 | 0) >> 0] | 0 | 0) << 24) | 0); + print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 3 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 4 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 5 | 0) >> 0] | 0 | 0) << 24) | 0); + print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 25 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 26 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 27 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 28 | 0) >> 0] | 0 | 0) << 24) | 0); + } + + function bad2(i) { + i = i | 0; + HEAPU32[(i + 4294967295 | 0) >> 2] | 0 + } + + return { + good: good, + bad2: bad2 + }; +} + |