summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/calls.cpp21
-rw-r--r--test/calls.emcc1
-rw-r--r--test/calls.post.js16
-rw-r--r--test/calls.txt12
4 files changed, 50 insertions, 0 deletions
diff --git a/test/calls.cpp b/test/calls.cpp
new file mode 100644
index 000000000..b73dff3f4
--- /dev/null
+++ b/test/calls.cpp
@@ -0,0 +1,21 @@
+#include <cmath>
+#include <algorithm>
+#include <emscripten.h>
+
+extern "C" {
+
+int inner(int x) {
+ return x*x + 2;
+}
+
+int EMSCRIPTEN_KEEPALIVE simple(int x) {
+ return inner(x);
+}
+
+int EMSCRIPTEN_KEEPALIVE fibo(int x) {
+ if (x == 0 || x == 1) return 1;
+ return fibo(x-1) + fibo(x-2);
+}
+
+}
+
diff --git a/test/calls.emcc b/test/calls.emcc
new file mode 100644
index 000000000..40c421eee
--- /dev/null
+++ b/test/calls.emcc
@@ -0,0 +1 @@
+["-s", "ASSERTIONS=0"]
diff --git a/test/calls.post.js b/test/calls.post.js
new file mode 100644
index 000000000..f2b422ed2
--- /dev/null
+++ b/test/calls.post.js
@@ -0,0 +1,16 @@
+
+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');
+
diff --git a/test/calls.txt b/test/calls.txt
new file mode 100644
index 000000000..7d1b8ee47
--- /dev/null
+++ b/test/calls.txt
@@ -0,0 +1,12 @@
+simple
+ 1 ==> 3
+ 2 ==> 6
+ 3 ==> 11
+ 4 ==> 18
+ 7 ==> 51
+fibo
+ 1 ==> 1
+ 2 ==> 2
+ 3 ==> 3
+ 4 ==> 5
+ 7 ==> 21