From 2054983775165f3ae50b241aae71ccb4969eade4 Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 5 Dec 2025 19:12:30 +0100 Subject: test 12-flt --- test/12-flt.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test/all.sh | 8 ++++++++ test/flt.c | 25 ------------------------- test/run.sh | 4 ---- 4 files changed, 61 insertions(+), 29 deletions(-) create mode 100644 test/12-flt.c create mode 100755 test/all.sh delete mode 100644 test/flt.c (limited to 'test') diff --git a/test/12-flt.c b/test/12-flt.c new file mode 100644 index 0000000..295e40f --- /dev/null +++ b/test/12-flt.c @@ -0,0 +1,53 @@ +/* EXPECT: +ok +*/ +typedef unsigned u32; +typedef signed s32; +typedef float f32; +typedef double f64; +typedef unsigned long long u64; +typedef signed long long s64; + +f32 s32_to_f32(s32 x) { return x; } +f32 u32_to_f32(u32 x) { return x; } +f64 s32_to_f64(s32 x) { return x; } +f64 u32_to_f64(u32 x) { return x; } +f32 s64_to_f32(s64 x) { return x; } +f32 u64_to_f32(u64 x) { return x; } +f64 s64_to_f64(s64 x) { return x; } +f64 u64_to_f64(u64 x) { return x; } +s32 f32_to_s32(f32 x) { return x; } +u32 f32_to_u32(f32 x) { return x; } +s32 f64_to_s32(f64 x) { return x; } +u32 f64_to_u32(f64 x) { return x; } +s64 f32_to_s64(f32 x) { return x; } +u64 f32_to_u64(f32 x) { return x; } +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 +#include + +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/flt.c b/test/flt.c deleted file mode 100644 index 04ce3e3..0000000 --- a/test/flt.c +++ /dev/null @@ -1,25 +0,0 @@ -typedef unsigned u32; -typedef signed s32; -typedef float f32; -typedef double f64; -typedef unsigned long long u64; -typedef signed long long s64; - -f32 s32_to_f32(s32 x) { return x; } -f32 u32_to_f32(u32 x) { return x; } -f64 s32_to_f64(s32 x) { return x; } -f64 u32_to_f64(u32 x) { return x; } -f32 s64_to_f32(s64 x) { return x; } -f32 u64_to_f32(u64 x) { return x; } -f64 s64_to_f64(s64 x) { return x; } -f64 u64_to_f64(u64 x) { return x; } -s32 f32_to_s32(f32 x) { return x; } -u32 f32_to_u32(f32 x) { return x; } -s32 f64_to_s32(f64 x) { return x; } -u32 f64_to_u32(f64 x) { return x; } -s64 f32_to_s64(f32 x) { return x; } -u64 f32_to_u64(f32 x) { return x; } -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; } 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 -- cgit v1.2.3