summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-23 13:11:42 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-12-23 13:11:42 -0800
commit6f573309b3ee704eff76068297511934ca13009f (patch)
tree78a2bb4dec1d954877536d143e9abf2446a3b9d1
parent781ac0929c76862c9988867a731b4699b459f5fd (diff)
downloadbinaryen-6f573309b3ee704eff76068297511934ca13009f.tar.gz
binaryen-6f573309b3ee704eff76068297511934ca13009f.tar.bz2
binaryen-6f573309b3ee704eff76068297511934ca13009f.zip
add wasm-backend globals testcase
-rwxr-xr-xcheck.py2
-rw-r--r--test/wasm_backend/globals.cpp21
-rw-r--r--test/wasm_backend/globals.txt5
3 files changed, 27 insertions, 1 deletions
diff --git a/check.py b/check.py
index 07ff9b072..97fe1b886 100755
--- a/check.py
+++ b/check.py
@@ -307,7 +307,7 @@ if has_emcc:
print '\n[ checking emcc WASM_BACKEND testcases... ]\n'
- for c in ['hello_world.cpp', 'hello_num.cpp']:
+ for c in ['hello_world.cpp', 'hello_num.cpp', 'globals.cpp']:
print '..', c
base = c.replace('.cpp', '').replace('.c', '')
expected = open(os.path.join('test', 'wasm_backend', base + '.txt')).read()
diff --git a/test/wasm_backend/globals.cpp b/test/wasm_backend/globals.cpp
new file mode 100644
index 000000000..9a2f1bcc8
--- /dev/null
+++ b/test/wasm_backend/globals.cpp
@@ -0,0 +1,21 @@
+#include <emscripten.h>
+
+char c = 10;
+short s = 20;
+int i = 55;
+
+void print(int v) {
+ int *x = (int*)8;
+ *x = v;
+ EM_ASM({
+ Module.print("print: " + HEAP32[8>>2]);
+ });
+}
+
+int main() {
+ print(1);
+ print(c);
+ print(s);
+ print(i);
+}
+
diff --git a/test/wasm_backend/globals.txt b/test/wasm_backend/globals.txt
new file mode 100644
index 000000000..56248691d
--- /dev/null
+++ b/test/wasm_backend/globals.txt
@@ -0,0 +1,5 @@
+print: 1
+print: 10
+print: 20
+print: 55
+