summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2019-10-24 08:08:25 -0700
committerGitHub <noreply@github.com>2019-10-24 08:08:25 -0700
commitffefb3ba2cdfca91fd20a8ac99c668f80140760d (patch)
treec9bc8b910dfb2623d3e800f7fdc747565d3d6b05 /test
parent73f141d49a8759993e0a79c3a0e86dd23784378c (diff)
downloadwabt-ffefb3ba2cdfca91fd20a8ac99c668f80140760d.tar.gz
wabt-ffefb3ba2cdfca91fd20a8ac99c668f80140760d.tar.bz2
wabt-ffefb3ba2cdfca91fd20a8ac99c668f80140760d.zip
wasm-decompile: Added initial tests. (#1195)
These are pretty minimal, more will be added as part of feature-PRs.
Diffstat (limited to 'test')
-rw-r--r--test/decompile/basic.txt76
-rw-r--r--test/find_exe.py6
-rwxr-xr-xtest/run-tests.py4
3 files changed, 85 insertions, 1 deletions
diff --git a/test/decompile/basic.txt b/test/decompile/basic.txt
new file mode 100644
index 00000000..7e529fc0
--- /dev/null
+++ b/test/decompile/basic.txt
@@ -0,0 +1,76 @@
+;;; TOOL: run-wasm-decompile
+
+(module
+ (memory 1)
+ (func $f (param i32 i32) (result i32) (local i64 f32 f64)
+ i64.const 8
+ set_local 2
+ f32.const 6.0
+ set_local 3
+ f64.const 7.0
+ tee_local 4
+ f64.const 10.0
+ f64.lt
+ if
+ i32.const 1
+ i32.const 2
+ i32.load offset=3
+ i32.const 5
+ i32.add
+ i32.store offset=4
+ end
+ get_local 0
+ get_local 1
+ i32.add
+ i32.const 9
+ call $f
+ drop
+ loop
+ block
+ i32.const 0
+ if (result i32)
+ i32.const 1
+ else
+ i32.const 2
+ end
+ br_if 0
+ br 1
+ end
+ i32.const 1
+ br_if 0
+ end
+ call $mv
+ i32.eq
+ )
+ (func $mv (param) (result i32 i32)
+ i32.const 1
+ i32.const 2
+ )
+ (export "f" (func $f))
+ (export "mv" (func $mv))
+)
+
+(;; STDOUT ;;;
+
+function f(a:int, b:int):int {
+ var c:long = 8L;
+ var d:float = 6f;
+ var e:double = 7d;
+ if (e < 10d) { 1[4]:int = (2[3]:int + 5) }
+ f(a + b, 9);
+ loop L_b {
+ block B_c {
+ if (if (0) { 1 } else { 2 }) break B_c;
+ continue L_b;
+ }
+ if (1) continue L_b;
+ }
+ push_all(mv());
+ return pop() == pop();
+}
+
+function mv():(int, int) {
+ return 1, 2
+}
+
+;;; STDOUT ;;)
diff --git a/test/find_exe.py b/test/find_exe.py
index 80ea407d..d989879e 100644
--- a/test/find_exe.py
+++ b/test/find_exe.py
@@ -26,7 +26,7 @@ REPO_ROOT_DIR = os.path.dirname(SCRIPT_DIR)
EXECUTABLES = [
'wat2wasm', 'wast2json', 'wasm2wat', 'wasm-objdump', 'wasm-interp',
'wasm-opcodecnt', 'wat-desugar', 'spectest-interp', 'wasm-validate',
- 'wasm2c', 'wasm-strip'
+ 'wasm2c', 'wasm-strip', 'wasm-decompile'
]
GEN_WASM_PY = os.path.join(SCRIPT_DIR, 'gen-wasm.py')
@@ -110,3 +110,7 @@ def GetWasm2CExecutable(override=None):
def GetWasmStripExecutable(override=None):
return FindExecutable('wasm-strip', override)
+
+
+def GetWasmDecompileExecutable(override=None):
+ return FindExecutable('wasm-decompile', override)
diff --git a/test/run-tests.py b/test/run-tests.py
index 021391c1..5b0291fd 100755
--- a/test/run-tests.py
+++ b/test/run-tests.py
@@ -138,6 +138,10 @@ TOOLS = {
'%(out_dir)s',
]),
('VERBOSE-ARGS', ['--print-cmd', '-v']),
+ ],
+ 'run-wasm-decompile': [
+ ('RUN', '%(wat2wasm)s --enable-multi-value %(in_file)s -o %(temp_file)s.wasm'),
+ ('RUN', '%(wasm-decompile)s --enable-multi-value %(temp_file)s.wasm'),
]
}