| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-11-07 20:05:25 +0100 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-11-07 20:05:25 +0100 |
| commit | 0b92419a57fc6a27b2701a688cf7ac3b1707241f (patch) | |
| tree | b401d9f84358e5e25232a8902a081d0f8e282e9e /data/unit-testing | |
| parent | 659c4440918e2e1c68cf388e9d9c7eb3e83eb4d7 (diff) | |
More unit tests, fixes equals operator.
Diffstat (limited to 'data/unit-testing')
| -rw-r--r-- | data/unit-testing/count.fate | 78 | ||||
| -rw-r--r-- | data/unit-testing/field_access.fate | 90 |
2 files changed, 168 insertions, 0 deletions
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) diff --git a/data/unit-testing/field_access.fate b/data/unit-testing/field_access.fate new file mode 100644 index 0000000..eba657a --- /dev/null +++ b/data/unit-testing/field_access.fate @@ -0,0 +1,90 @@ +(fate_version 1) + +(global string test_name) + +(set test_name ( FIELD ACCESS )) + +(declare_structure test_struct_type0 + (int i) + (int j) + (int k) + ((list int) li) +) + +(declare_structure test_struct_type1 + (int i) + (test_struct_type0 ts0) + ((list test_struct_type0) lts) +) + +(declare_structure test_struct_type2 + (int i) + (test_struct_type0 ts0) + (test_struct_type1 ts1) +) + +(local test_struct_type0 ts0_0) +(local test_struct_type0 ts0_1) +(local test_struct_type1 ts1_0) +(local test_struct_type1 ts1_1) +(local test_struct_type2 ts2_0) + + +(set_fields! ts0_0 + (i 42) + (j 69) + (k 420) + (li (range 0 10 1)) +) + +(set_fields! ts0_1 + (i 42) + (j 69) + (k 420) + (k 42) + (j 69) + (i 420) + (li (range 11 20 1)) +) + +(set_fields! ts1_0 + (i 1337) + (ts0 (var ts0_0)) + (lts (add (var ts0_1) (add (var ts0_0) (default (list test_struct_type0))))) +) + +(set_fields! ts1_1 + (i 1337) + (ts0 (var ts0_1)) + (lts (add (var ts0_0) (add (var ts0_1) (default (list test_struct_type0))))) +) + +(set ts2_0 + (set_fields (default test_struct_type2) + (i -1337) + (ts0 (var ts0_0)) + (ts1 (var ts1_1)) + ) +) + +(assert + (= (get_field ts0_0 i) (var ts0_0.i) (get_field ts0_1 k) (var ts0_1.k) 42) + [FAILED] (var test_name) Test 0. + (newline) + ts0_0.i = (var ts0_0.i) + (newline) + ts0_1.k = (var ts0_1.k) +) + +(assert + (= (get_field ts0_1 i) (var ts0_1.i) (get_field ts0_0 k) (var ts0_0.k) 420) + [FAILED] (var test_name) Test 1. + (newline) + ts0_0.k = (var ts0_0.k) + (newline) + ts0_1.i = (var ts0_1.i) +) + +[COMPLETED] (var test_name) + +(end) |


