diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-06 21:20:11 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:50 +0200 |
commit | 119d7a663f707ee2c74d56947c32f730a2d66b58 (patch) | |
tree | 4de077af7f89665150604a473fd0902af77b72df /tests | |
parent | 70a3dae19cc998ea315ccfa120515d1790aeeed6 (diff) |
Use do_run_from_file() for test_float32_precise
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_float32_precise.in | 21 | ||||
-rw-r--r-- | tests/core/test_float32_precise.out | 2 | ||||
-rw-r--r-- | tests/test_core.py | 24 |
3 files changed, 26 insertions, 21 deletions
diff --git a/tests/core/test_float32_precise.in b/tests/core/test_float32_precise.in new file mode 100644 index 00000000..231b4289 --- /dev/null +++ b/tests/core/test_float32_precise.in @@ -0,0 +1,21 @@ + + #include <stdio.h> + + int main(int argc, char **argv) { + float x = 1.23456789123456789; + float y = 5.20456089123406709; + while (argc > 10 || argc % 19 == 15) { + // confuse optimizer + x /= y; + y = 2*y - 1; + argc--; + } + x = x - y; + y = 3*y - x/2; + x = x*y; + y += 0.000000000123123123123; + x -= y/7.654; + printf("\n%.20f, %.20f\n", x, y); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_float32_precise.out b/tests/core/test_float32_precise.out new file mode 100644 index 00000000..f5eeb505 --- /dev/null +++ b/tests/core/test_float32_precise.out @@ -0,0 +1,2 @@ + +-72.16590881347656250000, 17.59867858886718750000 diff --git a/tests/test_core.py b/tests/test_core.py index 43a91a41..3d454286 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -461,28 +461,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_float32_precise(self): Settings.PRECISE_F32 = 1 - src = r''' - #include <stdio.h> + test_path = path_from_root('tests', 'core', 'test_float32_precise') + src, output = (test_path + s for s in ('.in', '.out')) - int main(int argc, char **argv) { - float x = 1.23456789123456789; - float y = 5.20456089123406709; - while (argc > 10 || argc % 19 == 15) { - // confuse optimizer - x /= y; - y = 2*y - 1; - argc--; - } - x = x - y; - y = 3*y - x/2; - x = x*y; - y += 0.000000000123123123123; - x -= y/7.654; - printf("\n%.20f, %.20f\n", x, y); - return 0; - } - ''' - self.do_run(src, '\n-72.16590881347656250000, 17.59867858886718750000\n') + self.do_run_from_file(src, output) def test_negative_zero(self): src = r''' |