aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-06 21:48:42 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:35:50 +0200
commit535b51e4e6f1f6c4fac05828ecde8f4444a01c51 (patch)
tree81c0ca9e5b7041b7b62e885bea498104444391ee
parent3dcf74e687a4cf376d7cfdc6452a745b47687c4d (diff)
Use do_run_from_file() for test_floatvars
-rw-r--r--tests/core/test_floatvars.in29
-rw-r--r--tests/core/test_floatvars.out3
-rw-r--r--tests/test_core.py32
3 files changed, 35 insertions, 29 deletions
diff --git a/tests/core/test_floatvars.in b/tests/core/test_floatvars.in
new file mode 100644
index 00000000..f63da19c
--- /dev/null
+++ b/tests/core/test_floatvars.in
@@ -0,0 +1,29 @@
+
+ #include <stdio.h>
+
+ // headers test, see issue #1013
+ #include<cfloat>
+ #include<cmath>
+
+ int main(int argc, char **argv)
+ {
+ float x = 1.234, y = 3.5, q = 0.00000001;
+ y *= 3;
+ int z = x < y;
+ printf("*%d,%d,%.1f,%d,%.4f,%.2f*\n", z, int(y), y, (int)x, x, q);
+
+ printf("%.2f, %.2f, %.2f, %.2f\n", fmin(0.5, 3.3), fmin(NAN, 3.3), fmax(0.5, 3.3), fmax(NAN, 3.3));
+
+ printf("small: %.10f\n", argc * 0.000001);
+
+ /*
+ // Rounding behavior
+ float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
+ double ds[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
+ for (int i = 0; i < 6; i++)
+ printf("*int(%.2f)=%d,%d*\n", fs[i], int(fs[i]), int(ds[i]));
+ */
+
+ return 0;
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_floatvars.out b/tests/core/test_floatvars.out
new file mode 100644
index 00000000..57635092
--- /dev/null
+++ b/tests/core/test_floatvars.out
@@ -0,0 +1,3 @@
+*1,10,10.5,1,1.2340,0.00*
+0.50, 3.30, 3.30, 3.30
+small: 0.0000010000
diff --git a/tests/test_core.py b/tests/test_core.py
index 59ad79d8..2a056cf2 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -761,36 +761,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_floatvars(self):
- src = '''
- #include <stdio.h>
-
- // headers test, see issue #1013
- #include<cfloat>
- #include<cmath>
-
- int main(int argc, char **argv)
- {
- float x = 1.234, y = 3.5, q = 0.00000001;
- y *= 3;
- int z = x < y;
- printf("*%d,%d,%.1f,%d,%.4f,%.2f*\\n", z, int(y), y, (int)x, x, q);
-
- printf("%.2f, %.2f, %.2f, %.2f\\n", fmin(0.5, 3.3), fmin(NAN, 3.3), fmax(0.5, 3.3), fmax(NAN, 3.3));
-
- printf("small: %.10f\\n", argc * 0.000001);
-
- /*
- // Rounding behavior
- float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
- double ds[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
- for (int i = 0; i < 6; i++)
- printf("*int(%.2f)=%d,%d*\\n", fs[i], int(fs[i]), int(ds[i]));
- */
+ test_path = path_from_root('tests', 'core', 'test_floatvars')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '*1,10,10.5,1,1.2340,0.00*\n0.50, 3.30, 3.30, 3.30\nsmall: 0.0000010000\n')
+ self.do_run_from_file(src, output)
def test_fast_math(self):
if self.emcc_args is None: return self.skip('requires emcc')