diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-17 10:20:45 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-17 10:20:45 -0800 |
commit | a4e9c38c371360b3cc652f1fcd11974d0476b54a (patch) | |
tree | 64c386bc57cbc117a371b173666d4ded9defcde9 /tests/test_core.py | |
parent | dddebe080f0792b1df14c1dbb596961f108cc3b5 (diff) |
EM_ASM_INT and EM_ASM_DOUBLE, which allow input and output values from EM_ASM; fixes #1819
Diffstat (limited to 'tests/test_core.py')
-rw-r--r-- | tests/test_core.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index d7b6cf53..67e316e4 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3970,7 +3970,7 @@ def process(filename): #include <stdio.h> #include <emscripten.h> - int main() { + int main(int argc, char **argv) { EM_ASM(Module.print('hello dere1')); EM_ASM( Module.print('hello dere2'); @@ -3981,11 +3981,19 @@ def process(filename): 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; } ''' - self.do_run(src, 'hello dere1\nhello dere2\nhello dere3\nhello dere4\nhello dere3\nhello dere4\nhello dere3\nhello dere4\n') + 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') def test_memorygrowth(self): if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays') |