diff options
-rw-r--r-- | tests/core/test_inlinejs3.in | 26 | ||||
-rw-r--r-- | tests/core/test_inlinejs3.out | 12 | ||||
-rw-r--r-- | tests/test_core.py | 30 |
3 files changed, 41 insertions, 27 deletions
diff --git a/tests/core/test_inlinejs3.in b/tests/core/test_inlinejs3.in new file mode 100644 index 00000000..e7d9b1e8 --- /dev/null +++ b/tests/core/test_inlinejs3.in @@ -0,0 +1,26 @@ + + #include <stdio.h> + #include <emscripten.h> + + int main(int argc, char **argv) { + EM_ASM(Module.print('hello dere1')); + EM_ASM( + Module.print('hello dere2'); + ); + for (int i = 0; i < 3; i++) { + EM_ASM( + Module.print('hello dere3'); + Module.print('hello dere' + 4); + ); + } + int sum = 0; + for (int i = 0; i < argc*3; i++) { + sum += EM_ASM_INT({ + Module.print('i: ' + [$0, ($1).toFixed(2)]); + return $0*2; + }, i, double(i)/12); + } + printf("sum: %d\n", sum); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_inlinejs3.out b/tests/core/test_inlinejs3.out new file mode 100644 index 00000000..c293e80b --- /dev/null +++ b/tests/core/test_inlinejs3.out @@ -0,0 +1,12 @@ +hello dere1 +hello dere2 +hello dere3 +hello dere4 +hello dere3 +hello dere4 +hello dere3 +hello dere4 +i: 0,0.00 +i: 1,0.08 +i: 2,0.17 +sum: 6 diff --git a/tests/test_core.py b/tests/test_core.py index 9aa64347..adbe1826 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1902,34 +1902,10 @@ def process(filename): self.do_run_from_file(src, output) def test_inlinejs3(self): - src = r''' - #include <stdio.h> - #include <emscripten.h> - - int main(int argc, char **argv) { - EM_ASM(Module.print('hello dere1')); - EM_ASM( - Module.print('hello dere2'); - ); - for (int i = 0; i < 3; i++) { - EM_ASM( - Module.print('hello dere3'); - Module.print('hello dere' + 4); - ); - } - int sum = 0; - for (int i = 0; i < argc*3; i++) { - sum += EM_ASM_INT({ - Module.print('i: ' + [$0, ($1).toFixed(2)]); - return $0*2; - }, i, double(i)/12); - } - printf("sum: %d\n", sum); - return 0; - } - ''' + test_path = path_from_root('tests', 'core', 'test_inlinejs3') + src, output = (test_path + s for s in ('.in', '.out')) - self.do_run(src, 'hello dere1\nhello dere2\nhello dere3\nhello dere4\nhello dere3\nhello dere4\nhello dere3\nhello dere4\ni: 0,0.00\ni: 1,0.08\ni: 2,0.17\nsum: 6\n') + self.do_run_from_file(src, output) def test_memorygrowth(self): if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays') |