From 119d7a663f707ee2c74d56947c32f730a2d66b58 Mon Sep 17 00:00:00 2001 From: Vasilis Kalintiris Date: Fri, 6 Dec 2013 21:20:11 +0200 Subject: [PATCH] Use do_run_from_file() for test_float32_precise --- tests/core/test_float32_precise.in | 21 +++++++++++++++++++++ tests/core/test_float32_precise.out | 2 ++ tests/test_core.py | 24 +++--------------------- 3 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 tests/core/test_float32_precise.in create mode 100644 tests/core/test_float32_precise.out diff --git a/tests/core/test_float32_precise.in b/tests/core/test_float32_precise.in new file mode 100644 index 000000000..231b4289b --- /dev/null +++ b/tests/core/test_float32_precise.in @@ -0,0 +1,21 @@ + + #include + + 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 000000000..f5eeb5058 --- /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 43a91a41b..3d454286f 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 + 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'''