From 0b92419a57fc6a27b2701a688cf7ac3b1707241f Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Sat, 7 Nov 2020 20:05:25 +0100 Subject: More unit tests, fixes equals operator. --- data/unit-testing/count.fate | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 data/unit-testing/count.fate (limited to 'data/unit-testing/count.fate') diff --git a/data/unit-testing/count.fate b/data/unit-testing/count.fate new file mode 100644 index 0000000..99fed3d --- /dev/null +++ b/data/unit-testing/count.fate @@ -0,0 +1,78 @@ +(fate_version 1) + +(global string test_name) + +(set test_name ( COUNT )) + +(assert (= (count 10 (range 0 60 1)) 1) + [FAILED] (var test_name) Failed to find 10 in range 0 60 1. +) + +(global (list int) li) + +(add_all! (range 0 10 1) li) +(add_all! (range 0 10 1) li) +(add_all! (range 0 10 1) li) +(add_all! (range 0 10 1) li) + +(assert (= (count 10 li) 4) + [FAILED] (var test_name) Failed to find 10 four times in li. +) + +(global (set int) si) + +(add_all! (range 0 10 1) si) +(add_all! (range 0 10 1) si) +(add_all! (range 0 10 1) si) +(add_all! (range 0 10 1) si) + +(assert (= (count 10 si) 1) + [FAILED] (var test_name) Failed to find 10 exactly once in si. +) + +(global (list string) ls) + +(add! test0 ls) +(add! test1 ls) +(add! test2 ls) +(add! test3 ls) + +(assert (= (count test0 ls) 1) + [FAILED] (var test_name) Failed to find test0 exactly once in ls. +) + +(add! test0 ls) +(add! test1 ls) +(add! test2 ls) +(add! test3 ls) +(add! test0 ls) +(add! test1 ls) +(add! test2 ls) +(add! test3 ls) +(add! test0 ls) +(add! test1 ls) +(add! test2 ls) +(add! test3 ls) + +(assert (= (count test0 ls) 4) + [FAILED] (var test_name) Failed to find test0 four times in ls. +) + +(global (list bool) lb) +(local int i) + +(for (set i 0) (=< i 10) (set i (+ i 1)) + (add! (= (mod i 2) 0) lb) +) + +(assert (= (count (true) lb) 6) + [FAILED] (var test_name) Failed to find six even numbers. +) + +(assert (= (count (false) lb) 5) + [FAILED] (var test_name) Failed to find four odd numbers. +) + +[COMPLETED] (var test_name) + +(end) -- cgit v1.2.3-70-g09d2