diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 12:52:20 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:56 +0200 |
commit | 72672fc7b0fd2917b0df4e45e65c6576438c813d (patch) | |
tree | 03df90cbd9ad381d127ac3e946978e2e5425fdf6 | |
parent | 3f2932b3449f040179aa131a136b513b3a39f9b6 (diff) |
Use do_run_from_file() for test_inlinejs
-rw-r--r-- | tests/core/test_inlinejs.in | 26 | ||||
-rw-r--r-- | tests/core/test_inlinejs.out | 2 | ||||
-rw-r--r-- | tests/test_core.py | 28 |
3 files changed, 31 insertions, 25 deletions
diff --git a/tests/core/test_inlinejs.in b/tests/core/test_inlinejs.in new file mode 100644 index 00000000..0359b707 --- /dev/null +++ b/tests/core/test_inlinejs.in @@ -0,0 +1,26 @@ + + #include <stdio.h> + + double get() { + double ret = 0; + __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable + asm("#comment1"); + asm volatile("#comment2"); + asm volatile("#comment3\n" + "#comment4\n"); + return ret; + } + + int main() { + asm("Module.print('Inline JS is very cool')"); + printf("%.2f\n", get()); + + // Test that passing multiple input and output variables works. + int src1 = 1, src2 = 2, src3 = 3; + int dst1 = 0, dst2 = 0, dst3 = 0; + // TODO asm("Module.print(%3); Module.print(%4); Module.print(%5); %0 = %3; %1 = %4; %2 = %5;" : "=r"(dst1),"=r"(dst2),"=r"(dst3): "r"(src1),"r"(src2),"r"(src3)); + // TODO printf("%d\n%d\n%d\n", dst1, dst2, dst3); + + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_inlinejs.out b/tests/core/test_inlinejs.out new file mode 100644 index 00000000..1838ef2e --- /dev/null +++ b/tests/core/test_inlinejs.out @@ -0,0 +1,2 @@ +Inline JS is very cool +3.64 diff --git a/tests/test_core.py b/tests/test_core.py index c8b4e7e2..0d70f50d 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1883,34 +1883,12 @@ def process(filename): def test_inlinejs(self): if not self.is_le32(): return self.skip('le32 needed for inline js') - src = r''' - #include <stdio.h> - - double get() { - double ret = 0; - __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable - asm("#comment1"); - asm volatile("#comment2"); - asm volatile("#comment3\n" - "#comment4\n"); - return ret; - } - - int main() { - asm("Module.print('Inline JS is very cool')"); - printf("%.2f\n", get()); - // Test that passing multiple input and output variables works. - int src1 = 1, src2 = 2, src3 = 3; - int dst1 = 0, dst2 = 0, dst3 = 0; - // TODO asm("Module.print(%3); Module.print(%4); Module.print(%5); %0 = %3; %1 = %4; %2 = %5;" : "=r"(dst1),"=r"(dst2),"=r"(dst3): "r"(src1),"r"(src2),"r"(src3)); - // TODO printf("%d\n%d\n%d\n", dst1, dst2, dst3); + test_path = path_from_root('tests', 'core', 'test_inlinejs') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' + self.do_run_from_file(src, output) - self.do_run(src, 'Inline JS is very cool\n3.64\n') # TODO 1\n2\n3\n1\n2\n3\n') if self.emcc_args == []: # opts will eliminate the comments out = open('src.cpp.o.js').read() for i in range(1, 5): assert ('comment%d' % i) in out |