diff options
-rw-r--r-- | tests/core/test_inlinejs2.in | 20 | ||||
-rw-r--r-- | tests/core/test_inlinejs2.out | 3 | ||||
-rw-r--r-- | tests/test_core.py | 23 |
3 files changed, 26 insertions, 20 deletions
diff --git a/tests/core/test_inlinejs2.in b/tests/core/test_inlinejs2.in new file mode 100644 index 00000000..7a05fd67 --- /dev/null +++ b/tests/core/test_inlinejs2.in @@ -0,0 +1,20 @@ + + #include <stdio.h> + + 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; Module.print($_$1)"); // multiline + asm __volatile__("Module.print('done')"); + } + + int main(int argc, char **argv) { + printf("%d\n", mix(argc, argc/2)); + mult(); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_inlinejs2.out b/tests/core/test_inlinejs2.out new file mode 100644 index 00000000..68dd9b64 --- /dev/null +++ b/tests/core/test_inlinejs2.out @@ -0,0 +1,3 @@ +4 +200 +done diff --git a/tests/test_core.py b/tests/test_core.py index 0d70f50d..9aa64347 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1895,28 +1895,11 @@ def process(filename): def test_inlinejs2(self): if not self.is_le32(): return self.skip('le32 needed for inline js') - src = r''' - #include <stdio.h> - - 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; Module.print($_$1)"); // multiline - asm __volatile__("Module.print('done')"); - } - int main(int argc, char **argv) { - printf("%d\n", mix(argc, argc/2)); - mult(); - return 0; - } - ''' + test_path = path_from_root('tests', 'core', 'test_inlinejs2') + src, output = (test_path + s for s in ('.in', '.out')) - self.do_run(src, '4\n200\ndone\n') + self.do_run_from_file(src, output) def test_inlinejs3(self): src = r''' |