summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 11:53:28 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:54 +0200
commit2be08eb3a196ad79e66309d0632a659ea052cf17 (patch)
tree1c7ddb1f308bda47a8aaa449441d93817a49722f /tests
parentb647d9d786873add910bb2477a0f0f8f40abd9e0 (diff)
Use do_run_from_file() for test_mathfuncptr
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_mathfuncptr.in13
-rw-r--r--tests/core/test_mathfuncptr.out1
-rw-r--r--tests/test_core.py16
3 files changed, 17 insertions, 13 deletions
diff --git a/tests/core/test_mathfuncptr.in b/tests/core/test_mathfuncptr.in
new file mode 100644
index 00000000..96e78401
--- /dev/null
+++ b/tests/core/test_mathfuncptr.in
@@ -0,0 +1,13 @@
+
+ #include <math.h>
+ #include <stdio.h>
+
+ int
+ main(int argc, char **argv) {
+ float (*fn)(float) = argc != 12 ? &sqrtf : &fabsf;
+ float (*fn2)(float) = argc != 13 ? &fabsf : &sqrtf;
+ float (*fn3)(float) = argc != 14 ? &erff : &fabsf;
+ printf("fn2(-5) = %d, fn(10) = %.2f, erf(10) = %.2f\n", (int)fn2(-5), fn(10), fn3(10));
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_mathfuncptr.out b/tests/core/test_mathfuncptr.out
new file mode 100644
index 00000000..166cc3da
--- /dev/null
+++ b/tests/core/test_mathfuncptr.out
@@ -0,0 +1 @@
+fn2(-5) = 5, fn(10) = 3.16, erf(10) = 1.00 \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index e155d053..6e4ef726 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1526,20 +1526,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
self.do_run_from_file(src, output)
def test_mathfuncptr(self):
- src = '''
- #include <math.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_mathfuncptr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int
- main(int argc, char **argv) {
- float (*fn)(float) = argc != 12 ? &sqrtf : &fabsf;
- float (*fn2)(float) = argc != 13 ? &fabsf : &sqrtf;
- float (*fn3)(float) = argc != 14 ? &erff : &fabsf;
- printf("fn2(-5) = %d, fn(10) = %.2f, erf(10) = %.2f\\n", (int)fn2(-5), fn(10), fn3(10));
- return 0;
- }
- '''
- self.do_run(src, 'fn2(-5) = 5, fn(10) = 3.16, erf(10) = 1.00')
+ self.do_run_from_file(src, output)
def test_funcptrfunc(self):
src = r'''