summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 12:10:17 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:55 +0200
commit691d17950f6e5cf9210542447ae05f3952a295c2 (patch)
treee2833cfe9b29502f83bf7386fa798f7a68d0c730
parent3c464bae721f6e2012062ea88852b66c5897409f (diff)
Use do_run_from_file() for test_stack_byval
-rw-r--r--tests/core/test_stack_byval.in25
-rw-r--r--tests/core/test_stack_byval.out1
-rw-r--r--tests/test_core.py30
3 files changed, 30 insertions, 26 deletions
diff --git a/tests/core/test_stack_byval.in b/tests/core/test_stack_byval.in
new file mode 100644
index 00000000..565866ee
--- /dev/null
+++ b/tests/core/test_stack_byval.in
@@ -0,0 +1,25 @@
+
+// We should also not blow up the stack with byval arguments
+ #include<stdio.h>
+ struct vec {
+ int x, y, z;
+ vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
+ static vec add(vec a, vec b) {
+ return vec(a.x+b.x, a.y+b.y, a.z+b.z);
+ }
+ };
+ int main() {
+ int total = 0;
+ for (int i = 0; i < 1000; i++) {
+ for (int j = 0; j < 1000; j++) {
+ vec c(i+i%10, j*2, i%255);
+ vec d(j*2, j%255, i%120);
+ vec f = vec::add(c, d);
+ total += (f.x + f.y + f.z) % 100;
+ total %= 10240;
+ }
+ }
+ printf("sum:%d*\n", total);
+ return 0;
+ }
+
diff --git a/tests/core/test_stack_byval.out b/tests/core/test_stack_byval.out
new file mode 100644
index 00000000..62f1b081
--- /dev/null
+++ b/tests/core/test_stack_byval.out
@@ -0,0 +1 @@
+sum:9780* \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index 4b4ad6b4..5e38034e 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1572,32 +1572,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_stack_byval(self):
if self.emcc_args is None: return # too slow in other modes
- # We should also not blow up the stack with byval arguments
- src = r'''
- #include<stdio.h>
- struct vec {
- int x, y, z;
- vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
- static vec add(vec a, vec b) {
- return vec(a.x+b.x, a.y+b.y, a.z+b.z);
- }
- };
- int main() {
- int total = 0;
- for (int i = 0; i < 1000; i++) {
- for (int j = 0; j < 1000; j++) {
- vec c(i+i%10, j*2, i%255);
- vec d(j*2, j%255, i%120);
- vec f = vec::add(c, d);
- total += (f.x + f.y + f.z) % 100;
- total %= 10240;
- }
- }
- printf("sum:%d*\n", total);
- return 0;
- }
- '''
- self.do_run(src, 'sum:9780*')
+ test_path = path_from_root('tests', 'core', 'test_stack_byval')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_stack_varargs(self):
if self.emcc_args is None: return # too slow in other modes