diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-02-05 20:42:20 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-03-30 22:23:58 -0400 |
commit | e294db833217a26297dcec284b8a13809cb5f832 (patch) | |
tree | e76c6f1435361e890158b6b19ba5da5319cad45f | |
parent | 712237a2f9edbbe4fc541983a7f00b44098b96c4 (diff) | |
download | haskell-e294db833217a26297dcec284b8a13809cb5f832.tar.gz |
testsuite: Port T16514 to C
Previously this test was C++ which made it a bit of a portability
problem.
-rw-r--r-- | testsuite/tests/rts/T16514_c.c | 31 | ||||
-rw-r--r-- | testsuite/tests/rts/T16514_c.cpp | 45 | ||||
-rw-r--r-- | testsuite/tests/rts/all.T | 2 |
3 files changed, 32 insertions, 46 deletions
diff --git a/testsuite/tests/rts/T16514_c.c b/testsuite/tests/rts/T16514_c.c new file mode 100644 index 0000000000..9acb7d7d1f --- /dev/null +++ b/testsuite/tests/rts/T16514_c.c @@ -0,0 +1,31 @@ +#include <stdio.h> + +void fn_hs(); +void fn() { + fn_hs(); +} + +void check(double sqrt2, double sqrt3, double sqrt5, + double sqrt8, double sqrt13, double sqrt21) +{ + printf("%f %f %f %f %f %f\n", sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); + if (sqrt2 != 1.41421 || sqrt3 != 1.73205 || sqrt5 != 2.23607 || + sqrt8 != 2.82843 || sqrt13 != 3.60555 || sqrt21 != 4.58258) { + fprintf(stderr, "xmm registers have been scratched\n"); + } +} + +int test() { + double sqrt2 = 1.41421; + double sqrt3 = 1.73205; + double sqrt5 = 2.23607; + double sqrt8 = 2.82843; + double sqrt13 = 3.60555; + double sqrt21 = 4.58258; + check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); + fn(); + check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); + fn(); + check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); + return 0; +}
\ No newline at end of file diff --git a/testsuite/tests/rts/T16514_c.cpp b/testsuite/tests/rts/T16514_c.cpp deleted file mode 100644 index 1474741ec0..0000000000 --- a/testsuite/tests/rts/T16514_c.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include <iostream> -#include <stdexcept> - -extern "C" { - -void fn_hs(); -void fn() { - fn_hs(); -} - -void check(double sqrt2, double sqrt3, double sqrt5, - double sqrt8, double sqrt13, double sqrt21) { - std::cout << std::fixed << sqrt2 << " " << sqrt3 << " " << sqrt5 << " " - << sqrt8 << " " << sqrt13 << " " << sqrt21 << std::endl; - if (sqrt2 != 1.41421 || sqrt3 != 1.73205 || sqrt5 != 2.23607 || - sqrt8 != 2.82843 || sqrt13 != 3.60555 || sqrt21 != 4.58258) { - throw std::runtime_error("xmm registers have been scratched"); - } -} - -int test() { - try { - double sqrt2 = 1.41421; - double sqrt3 = 1.73205; - double sqrt5 = 2.23607; - double sqrt8 = 2.82843; - double sqrt13 = 3.60555; - double sqrt21 = 4.58258; - check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); - fn(); - check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); - try { - fn(); - } catch (const std::exception &) { - } - check(sqrt2, sqrt3, sqrt5, sqrt8, sqrt13, sqrt21); - } catch (const std::exception &e) { - std::cerr << e.what() << std::endl; - return 1; - } - return 0; -} - -} // extern "C" - diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index e59e4c5204..5290ca07e0 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -479,7 +479,7 @@ test('keep-cafs', # When -fcompact-unwind becomes default, generalize test to all platforms. test('T11829', unless(opsys('darwin'), skip), compile_and_run, ['T11829_c.cpp -lstdc++ -fcompact-unwind']) -test('T16514', unless(opsys('mingw32'), skip), compile_and_run, ['T16514_c.cpp -lstdc++']) +test('T16514', normal, compile_and_run, ['T16514_c.c']) test('test-zeroongc', extra_run_opts('-DZ'), compile_and_run, ['-debug']) test('T13676', |