aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/core/test_isnan.in17
-rw-r--r--tests/core/test_isnan.out9
-rw-r--r--tests/test_core.py29
3 files changed, 29 insertions, 26 deletions
diff --git a/tests/core/test_isnan.in b/tests/core/test_isnan.in
new file mode 100644
index 00000000..d5ca7a6e
--- /dev/null
+++ b/tests/core/test_isnan.in
@@ -0,0 +1,17 @@
+
+ #include <stdio.h>
+
+ int IsNaN(double x){
+ int rc; /* The value return */
+ volatile double y = x;
+ volatile double z = y;
+ rc = (y!=z);
+ return rc;
+ }
+
+ int main() {
+ double tests[] = { 1.0, 3.333, 1.0/0.0, 0.0/0.0, -1.0/0.0, -0, 0, -123123123, 12.0E200 };
+ for (int i = 0; i < sizeof(tests)/sizeof(double); i++)
+ printf("%d - %f - %d\n", i, tests[i], IsNaN(tests[i]));
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_isnan.out b/tests/core/test_isnan.out
new file mode 100644
index 00000000..b7e33f0e
--- /dev/null
+++ b/tests/core/test_isnan.out
@@ -0,0 +1,9 @@
+0 - 1.000000 - 0
+1 - 3.333000 - 0
+2 - inf - 0
+3 - nan - 1
+4 - -inf - 0
+5 - 0.000000 - 0
+6 - 0.000000 - 0
+7 - -123123123.000000 - 0
+8 - 1.2e+201 - 0
diff --git a/tests/test_core.py b/tests/test_core.py
index 19e9e188..548b5452 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -788,33 +788,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_isnan(self):
- src = r'''
- #include <stdio.h>
-
- int IsNaN(double x){
- int rc; /* The value return */
- volatile double y = x;
- volatile double z = y;
- rc = (y!=z);
- return rc;
- }
+ test_path = path_from_root('tests', 'core', 'test_isnan')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- double tests[] = { 1.0, 3.333, 1.0/0.0, 0.0/0.0, -1.0/0.0, -0, 0, -123123123, 12.0E200 };
- for (int i = 0; i < sizeof(tests)/sizeof(double); i++)
- printf("%d - %f - %d\n", i, tests[i], IsNaN(tests[i]));
- }
- '''
- self.do_run(src, '''0 - 1.000000 - 0
-1 - 3.333000 - 0
-2 - inf - 0
-3 - nan - 1
-4 - -inf - 0
-5 - 0.000000 - 0
-6 - 0.000000 - 0
-7 - -123123123.000000 - 0
-8 - 1.2e+201 - 0
-''')
+ self.do_run_from_file(src, output)
def test_globaldoubles(self):
src = r'''