diff options
| author | 2025-12-05 19:12:30 +0100 | |
|---|---|---|
| committer | 2025-12-05 19:12:30 +0100 | |
| commit | 2054983775165f3ae50b241aae71ccb4969eade4 (patch) | |
| tree | c588cc7f640aecff20acbd11656ec36f2ce95ff1 /test | |
| parent | bb3bc012c9349c05299069ec19d6bee4abacfb77 (diff) | |
test 12-flt
Diffstat (limited to 'test')
| -rw-r--r-- | test/12-flt.c (renamed from test/flt.c) | 28 | ||||
| -rwxr-xr-x | test/all.sh | 8 | ||||
| -rwxr-xr-x | test/run.sh | 4 |
3 files changed, 36 insertions, 4 deletions
diff --git a/test/flt.c b/test/12-flt.c index 04ce3e3..295e40f 100644 --- a/test/flt.c +++ b/test/12-flt.c @@ -1,3 +1,6 @@ +/* EXPECT: +ok +*/ typedef unsigned u32; typedef signed s32; typedef float f32; @@ -23,3 +26,28 @@ s64 f64_to_s64(f64 x) { return x; } u64 f64_to_u64(f64 x) { return x; } f32 f64_to_f32(f64 x) { return x; } f64 f32_to_f64(f32 x) { return x; } + +#include <stdio.h> +#include <assert.h> + +double NAN = 0.0; +double _(double x) { return x; } + +int main() { + NAN/=0.0; + assert(_(1.0) < _(2.0)); + assert(_(1.0) >= _(1.0)); + assert(_(1.0) >= _(-1.0)); + assert(_(1.0) != _(2.0)); + assert(_(1.0) - 1.0 == 0.0); + assert(-_(0.0) == 0.0); + assert(!(NAN < 2.0)); + assert(!(NAN > NAN)); + assert(!(NAN >= NAN)); + assert(!(NAN <= NAN)); + assert(!(NAN < NAN)); + assert(!(NAN == NAN)); + assert(NAN != NAN); + assert(NAN != 0.0); + printf("ok\n"); +} diff --git a/test/all.sh b/test/all.sh new file mode 100755 index 0000000..0a138a8 --- /dev/null +++ b/test/all.sh @@ -0,0 +1,8 @@ +#!/bin/env sh + +cd $(dirname "$0") +./run.sh + +echo "--- 'Write a C Compiler' test suite ---" +cd nlsandler-write_a_c_compiler +exec ./test_compiler.sh ../../antcc diff --git a/test/run.sh b/test/run.sh index b4ffd9d..5e0bc0f 100755 --- a/test/run.sh +++ b/test/run.sh @@ -49,7 +49,3 @@ done echo TESTS PASSED: $npass/$ntest printf 'wc log.txt;' wc log.txt - -echo "--- 'Write a C Compiler' test suite ---" -cd nlsandler-write_a_c_compiler -exec ./test_compiler.sh ../../antcc |