aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-18 18:18:37 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-06-18 18:18:37 -0700
commitf144ebdbd829a9223e50d7858d7ba79e43030875 (patch)
treecdcbf2dbc6737639ec09bc2a13cd1cc619f37faf /tests
parenta15b0d50618241a345d13ae4d939bfc53178a01d (diff)
add wip inlinejs2 test
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 7575d651..72c9afd1 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -4036,6 +4036,39 @@ def process(filename):
self.do_run(src, 'Inline JS is very cool\n3.64')
+ def zzztest_inlinejs2(self):
+ if Settings.ASM_JS: return self.skip('asm does not support random code, TODO: something that works in asm')
+ src = r'''
+ #include <stdio.h>
+
+ double get() {
+ double ret = 0;
+ __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable
+ return ret;
+ }
+
+ int mix(int x, int y) {
+ int ret;
+ asm("Math.pow(2, %0+%1+1)" : "=r"(ret) : "r"(x), "r"(y)); // read and write
+ return ret;
+ }
+
+ void mult() {
+ asm("var $_$1 = Math.abs(-100); $_$1 *= 2;"); // multiline
+ asm __volatile__("Module.print($_$1); Module.print('\n')");
+ }
+
+ int main(int argc, char **argv) {
+ asm("Module.print('Inline JS is very cool')");
+ printf("%.2f\n", get());
+ printf("%d\n", mix(argc, argc/2));
+ mult();
+ return 0;
+ }
+ '''
+
+ self.do_run(src, 'Inline JS is very cool\n3.64\nwaka\nzakai\n')
+
def test_memorygrowth(self):
if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays')
if Settings.ASM_JS: return self.skip('asm does not support memory growth yet')