summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-08-07 11:18:18 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-08-07 11:18:18 +0200
commitb95d1790243c09901fa5175a9ec29fcdce0998a1 (patch)
tree5e5c02810b6fa2fbe04a78ed7751d1146c59cdbf /data
parent5ba737fbc8edac0eb5ed750d92a5b3158fb2a32e (diff)
...
Diffstat (limited to 'data')
-rw-r--r--data/examples/monster_battle/battle.fate2
-rw-r--r--data/tests/conditionals.fate222
-rw-r--r--data/tests/include/data_types.fate70
-rw-r--r--data/tests/operators.fate154
4 files changed, 447 insertions, 1 deletions
diff --git a/data/examples/monster_battle/battle.fate b/data/examples/monster_battle/battle.fate
index cfdce39..9674b95 100644
--- a/data/examples/monster_battle/battle.fate
+++ b/data/examples/monster_battle/battle.fate
@@ -1,5 +1,5 @@
(fate_version 1)
(define_sequence start_battle
- nothing yet
+ (end)
)
diff --git a/data/tests/conditionals.fate b/data/tests/conditionals.fate
new file mode 100644
index 0000000..02730c6
--- /dev/null
+++ b/data/tests/conditionals.fate
@@ -0,0 +1,222 @@
+(fate_version 1)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; COMPUTATIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;; COMPUTATION IF-ELSE
+(assert (ifelse (true) (true) (false)) FAILED: computation if-else A)
+(assert (ifelse (false) (false) (true)) FAILED: computation if-else B)
+(assert (ifelse (false) (false) (ifelse (true) (true) (false))) FAILED: computation if-else C)
+
+;; COMPUTATION COND
+(assert
+ (cond
+ ((true) (true))
+ )
+ FAILED: computation cond A
+)
+(assert
+ (cond
+ ((false) (false))
+ ((true) (true))
+ )
+ FAILED: computation cond D
+)
+(assert
+ (cond
+ ((false) (false))
+ ((true) (true))
+ ((true) (false))
+ )
+ FAILED: computation cond E
+)
+(assert
+ (cond
+ ((false) (false))
+ ((true)
+ (cond
+ ((false) (false))
+ ((true) (true))
+ ((true) (false))
+ )
+ )
+ ((true) (false))
+ )
+ FAILED: computation cond D
+)
+
+;; COMPUTATION SWITCH
+;; TODO: re-enable. Currently not implemented in Wyrd compiler
+;;(assert
+;; (switch 3
+;; (0 (false))
+;; (1 (false))
+;; (3 (true))
+;; (2 (false))
+;; (false)
+;; )
+;; FAILED: computation switch A
+;;)
+;;(assert
+;; (switch 3
+;; (0 (false))
+;; (1 (false))
+;; (2 (false))
+;; (true)
+;; )
+;; FAILED: computation switch B
+;;)
+;;(assert
+;; (switch 3
+;; (0 (false))
+;; (1 (false))
+;; (2 (false))
+;; (switch 2
+;; (0 (false))
+;; (1 (false))
+;; (2 (true))
+;; (false)
+;; )
+;; )
+;; FAILED: computation switch C
+;;)
+;;(assert
+;; (switch 3
+;; (0 (false))
+;; (1 (false))
+;; (2
+;; (switch 1
+;; (0 (false))
+;; (2 (false))
+;; (1 (true))
+;; (false)
+;; )
+;; )
+;; (false)
+;; )
+;; FAILED: computation switch D
+;;)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;; INSTRUCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(declare_variable boolean test_var)
+(set test_var (true))
+
+(assert (var test_var) FAILED: setting test_var)
+
+;; INSTRUCTION IF
+(if (false)
+ (assert (false) FAILED: instruction if A)
+)
+
+(set test_var (false))
+(if (true)
+ (set test_var (true))
+)
+(assert (var test_var) FAILED: instruction if B)
+
+(if (false)
+ (if (false)
+ (assert (false) FAILED: instruction if C)
+ )
+)
+(if (true)
+ (if (false)
+ (assert (false) FAILED: instruction if D)
+ )
+)
+(if (false)
+ (if (true)
+ (assert (false) FAILED: instruction if E)
+ )
+)
+
+(set test_var (false))
+(if (true)
+ (if (true)
+ (set test_var (true))
+ )
+)
+(assert (var test_var) FAILED: instruction if F)
+
+;; INSTRUCTION IF-ELSE
+(set test_var (false))
+(ifelse (false)
+ (assert (false) FAILED: instruction ifelse A)
+ (set test_var (true))
+)
+(assert (var test_var) FAILED: instruction ifelse B)
+
+(set test_var (false))
+(ifelse (true)
+ (set test_var (true))
+ (assert (false) FAILED: instruction ifelse C)
+)
+(assert (var test_var) FAILED: instruction ifelse D)
+
+(set test_var (false))
+(ifelse (true)
+ (ifelse (false)
+ (assert (false) FAILED: instruction ifelse E)
+ (set test_var (true))
+ )
+ (assert (false) FAILED: instruction ifelse F)
+)
+(assert (var test_var) FAILED: instruction ifelse G)
+
+;; INSTRUCTION COND
+(set test_var (false))
+(cond
+ ((false) (assert (false) FAILED: instruction cond A))
+ ((true) (set test_var (true)))
+)
+(assert (var test_var) FAILED: instruction cond B)
+
+(set test_var (false))
+(cond
+ ((true) (set test_var (true)))
+ ((false) (assert (false) FAILED: instruction cond B))
+)
+(assert (var test_var) FAILED: instruction cond C)
+
+(set test_var (false))
+(cond
+ ((true) (set test_var (true)))
+ ((true) (assert (false) FAILED: instruction cond D))
+ ((false) (assert (false) FAILED: instruction cond E))
+)
+(assert (var test_var) FAILED: instruction cond F)
+
+;; INSTRUCTION SWITCH
+(set test_var (false))
+(switch 3
+ (0 (assert (false) FAILED: instruction switch B))
+ (1 (assert (false) FAILED: instruction switch C))
+ (set test_var (true))
+)
+(assert (var test_var) FAILED: instruction switch D)
+
+(set test_var (false))
+(switch 3
+ (0 (assert (false) FAILED: instruction switch E))
+ (1 (assert (false) FAILED: instruction switch F))
+ (3 (set test_var (true)))
+ (2 (assert (false) FAILED: instruction switch G))
+ (assert (false) FAILED: instruction switch H)
+)
+(assert (var test_var) FAILED: instruction switch I)
+
+(set test_var (false))
+(switch 3
+ (0 (assert (false) FAILED: instruction switch J))
+ (1 (assert (false) FAILED: instruction switch K))
+ (3 (set test_var (true)))
+ (3 (assert (false) FAILED: instruction switch L))
+ (2 (assert (false) FAILED: instruction switch M))
+ (assert (false) FAILED: instruction switch N)
+)
+(assert (var test_var) FAILED: instruction switch O)
+
+(end)
diff --git a/data/tests/include/data_types.fate b/data/tests/include/data_types.fate
new file mode 100644
index 0000000..3205b69
--- /dev/null
+++ b/data/tests/include/data_types.fate
@@ -0,0 +1,70 @@
+(fate_version 1)
+
+(typedef boolean sub_boolean)
+(typedef boolean alt_boolean)
+(typedef sub_boolean sub_sub_boolean)
+(typedef sub_boolean alt_sub_boolean)
+
+(typedef int sub_int)
+(typedef int alt_int)
+(typedef sub_int sub_sub_int)
+(typedef sub_int alt_sub_int)
+
+(typedef float sub_float)
+(typedef float alt_float)
+(typedef sub_float sub_sub_float)
+(typedef sub_float alt_sub_float)
+
+(typedef string sub_string)
+(typedef string alt_string)
+(typedef sub_string sub_sub_string)
+(typedef sub_string alt_sub_string)
+
+(define_list_type boolean list_boolean)
+(define_list_type sub_boolean list_sub_boolean)
+(define_set_type boolean set_boolean)
+(define_set_type sub_boolean set_sub_boolean)
+(define_ref_type boolean ref_boolean)
+(define_ref_type sub_boolean ref_sub_boolean)
+
+(define_list_type int list_int)
+(define_list_type sub_int list_sub_int)
+(define_set_type int set_int)
+(define_set_type sub_int set_sub_int)
+(define_ref_type int ref_int)
+(define_ref_type sub_int ref_sub_int)
+
+(define_list_type float list_float)
+(define_list_type sub_float list_sub_float)
+(define_set_type float set_float)
+(define_set_type sub_float set_sub_float)
+(define_ref_type float ref_float)
+(define_ref_type sub_float ref_sub_float)
+
+(define_list_type string list_int)
+(define_list_type sub_string list_sub_int)
+(define_set_type string set_int)
+(define_set_type sub_string set_sub_int)
+(define_ref_type string ref_int)
+(define_ref_type sub_string ref_sub_int)
+
+(define_dict_type simple_dict
+ (boolean boolean)
+ (int int)
+ (float float)
+ (string string)
+)
+
+(define_ref_type simple_dict simple_dict_ptr)
+(define_list_type simple_dict_ptr simple_dict_ptr_list)
+(define_set_type simple_dict_ptr simple_dict_ptr_set)
+
+(define_dict_type two_dict
+ (simple_dict dict_a)
+ (simple_dict dict_b)
+ (simple_dict_ptr dict_ptr)
+)
+
+(define_ref_type two_dict two_dict_ptr)
+(define_list_type two_dict_ptr two_dict_ptr_list)
+(define_set_type two_dict_ptr two_dict_ptr_set)
diff --git a/data/tests/operators.fate b/data/tests/operators.fate
new file mode 100644
index 0000000..6598297
--- /dev/null
+++ b/data/tests/operators.fate
@@ -0,0 +1,154 @@
+(fate_version 1)
+
+;; EQUALITY
+(assert (= 1 1) FAILED: int equality)
+(assert (= 1.0 1.0) FAILED: float equality)
+(assert (= test test) FAILED: string equality)
+(assert (= (true) (true)) FAILED: boolean equality)
+
+(assert (= (= 1 2) (false)) FAILED: int inequality)
+(assert (= (= 1.0 2.0) (false)) FAILED: float inequality)
+(assert (= (= one two) (false)) FAILED: string inequality)
+(assert (= (= (true) (false)) (false)) FAILED: boolean inequality)
+
+(assert (= 1 1 1 1 1) FAILED: int n>2 equality)
+(assert (= 1.0 1.0 1.0 1.0 1.0) FAILED: float n>2 equality)
+(assert (= test test test test test) FAILED: string n>2 equality)
+(assert (= (true) (true) (true) (true)) FAILED: boolean n>2 equality)
+
+
+;; ADDITION
+(assert (= (+ 1 1) 2) FAILED: int addition)
+(assert (= (+ 1 1 1 1) 4) FAILED: int n>2 addition)
+(assert (= (+ 1.5 1.5) 3.0) FAILED: float addition)
+(assert (= (+ 1.5 1.0 1.5 1.0) 5.0) FAILED: float n>2 addition)
+
+;; SUBTRACTION
+(assert (= (- 1 1) 0) FAILED: int subtraction)
+(assert (= (- 1 1 1 1) -2) FAILED: int n>2 subtraction)
+(assert (= (- 1.5 1.5) 0.0) FAILED: float subtraction)
+(assert (= (- 1.5 1.0 1.5 1.0) -2.0) FAILED: float n>2 subtraction)
+
+;; MULTIPLICATION
+(assert (= (* 1 3) 3) FAILED: int multiplication)
+(assert (= (* 1 1 3 2) 6) FAILED: int n>2 multiplication)
+(assert (= (* 1.5 2.0) 3.0) FAILED: float multiplication)
+(assert (= (* 1.5 1.0 3.0 1.0) 4.5) FAILED: float n>2 multiplication)
+
+;; DIVISION
+(assert (= (/ 3 3) 1) FAILED: int division)
+(assert (= (/ 4 3) 1) FAILED: int integer division)
+(assert (= (/ 3.0 3.0) 1.0) FAILED: float division A)
+(assert (= (/ 3.0 2.0) 1.5) FAILED: float division B)
+
+;; MODULO
+(assert (= (% 3 3) 0) FAILED: modulo A)
+(assert (= (% 2 3) 2) FAILED: modulo B)
+(assert (= (% 4 3) 1) FAILED: modulo C)
+(assert (= (% 9 3) 0) FAILED: modulo D)
+(assert (= (% 10 3) 1) FAILED: modulo E)
+
+;; MIN
+(assert (= (min 1 3) 1) FAILED: int min)
+(assert (= (min 1 0 -3 9) -3) FAILED: int n>2 min)
+(assert (= (min 1.5 2.0) 1.5) FAILED: float min)
+(assert (= (min 1.5 1.0 3.0 -1.0) -1.0) FAILED: float n>2 min)
+
+;; MAX
+(assert (= (max 3 1) 3) FAILED: int max)
+(assert (= (max 1 0 -3 9) 9) FAILED: int n>2 max)
+(assert (= (max 1.5 2.0) 2.0) FAILED: float max)
+(assert (= (max 1.5 1.0 3.0 -1.0) 3.0) FAILED: float n>2 max)
+
+;; CLAMP
+(assert (= (clamp 1 3 2) 2) FAILED: int clamp A)
+(assert (= (clamp 1 3 4) 3) FAILED: int clamp B)
+(assert (= (clamp 1 3 -1) 1) FAILED: int clamp C)
+(assert (= (clamp 1 3 1) 1) FAILED: int clamp D)
+(assert (= (clamp 1 3 3) 3) FAILED: int clamp E)
+(assert (= (clamp 1.5 3.0 1.7) 1.7) FAILED: float clamp A)
+(assert (= (clamp 1.5 3.0 4.7) 3.0) FAILED: float clamp B)
+(assert (= (clamp 1.5 3.0 -1.7) 1.5) FAILED: float clamp C)
+(assert (= (clamp 1.5 3.0 1.5) 1.5) FAILED: float clamp D)
+(assert (= (clamp 1.5 3.0 3.0) 3.0) FAILED: float clamp E)
+
+;; ABS
+(assert (= (abs 1) 1) FAILED: int abs A)
+(assert (= (abs -1) 1) FAILED: int abs B)
+(assert (= (abs -99) 99) FAILED: int abs C)
+(assert (= (abs 0) 0) FAILED: int abs D)
+(assert (= (abs 1.5) 1.5) FAILED: float abs A)
+(assert (= (abs -1.5) 1.5) FAILED: float abs B)
+(assert (= (abs -99.5) 99.5) FAILED: float abs C)
+(assert (= (abs 0.5) 0.5) FAILED: float abs D)
+
+;; AND
+(assert (= (and (true) (true)) (true)) FAILED: and A)
+(assert (= (and (true) (false)) (false)) FAILED: and B)
+(assert (= (and (false) (true)) (false)) FAILED: and C)
+(assert (= (and (false) (false)) (false)) FAILED: and D)
+(assert (= (and (true) (true) (true) (true) (true)) (true)) FAILED: and E)
+(assert (= (and (false) (false) (false) (false) (false)) (false)) FAILED: and F)
+(assert (= (and (true) (true) (false) (true) (true)) (false)) FAILED: and G)
+
+;; OR
+(assert (= (or (true) (true)) (true)) FAILED: or A)
+(assert (= (or (true) (false)) (true)) FAILED: or B)
+(assert (= (or (false) (true)) (true)) FAILED: or C)
+(assert (= (or (false) (false)) (false)) FAILED: or D)
+(assert (= (or (true) (true) (true) (true) (true)) (true)) FAILED: or E)
+(assert (= (and (false) (false) (false) (false) (false)) (false)) FAILED: or F)
+(assert (= (or (true) (true) (false) (true) (true)) (true)) FAILED: or G)
+
+;; NOT
+(assert (= (not (true)) (false)) FAILED: not A)
+(assert (= (not (false)) (true)) FAILED: not B)
+
+;; IMPLIES
+(assert (= (implies (true) (true)) (true)) FAILED: implies A)
+(assert (= (implies (true) (false)) (false)) FAILED: implies B)
+(assert (= (implies (false) (true)) (true)) FAILED: implies C)
+(assert (= (implies (false) (false)) (true)) FAILED: implies D)
+
+;; ONE IN
+(assert (= (one_in (true) (true)) (false)) FAILED: one_in A)
+(assert (= (one_in (true) (false)) (true)) FAILED: one_in B)
+(assert (= (one_in (false) (true)) (true)) FAILED: one_in C)
+(assert (= (one_in (false) (false)) (false)) FAILED: one_in D)
+(assert (= (one_in (false) (false) (false) (false)) (false)) FAILED: one_in E)
+(assert (= (one_in (false) (true) (false) (false)) (true)) FAILED: one_in F)
+(assert (= (one_in (false) (true) (false) (true)) (false)) FAILED: one_in F)
+
+;; LESS/LOWER THAN
+(assert (= (< 1 3) (true)) FAILED: int LOWER/LESS THAN)
+(assert (= (< 1 0) (false)) FAILED: int LOWER/LESS THAN)
+(assert (= (< 1 1) (false)) FAILED: int LOWER/LESS THAN)
+(assert (= (< 1.5 2.0) (true)) FAILED: float LOWER/LESS THAN)
+(assert (= (< 1.5 1.0) (false)) FAILED: float LOWER/LESS THAN)
+(assert (= (< 1.5 1.5) (false)) FAILED: float LOWER/LESS THAN)
+
+;; LESS/LOWER EQUAL THAN
+(assert (= (=< 1 3) (true)) FAILED: int LOWER/LESS EQUAL THAN)
+(assert (= (=< 1 0) (false)) FAILED: int LOWER/LESS EQUAL THAN)
+(assert (= (=< 1 1) (true)) FAILED: int LOWER/LESS EQUAL THAN)
+(assert (= (=< 1.5 2.0) (true)) FAILED: float LOWER/LESS EQUAL THAN)
+(assert (= (=< 1.5 1.0) (false)) FAILED: float LOWER/LESS EQUAL THAN)
+(assert (= (=< 1.5 1.5) (true)) FAILED: float LOWER/LESS EQUAL THAN)
+
+;; GREATER THAN
+(assert (= (> 1 3) (false)) FAILED: int GREATER THAN)
+(assert (= (> 1 0) (true)) FAILED: int GREATER THAN)
+(assert (= (> 1 1) (false)) FAILED: int GREATER THAN)
+(assert (= (> 1.5 2.0) (false)) FAILED: float GREATER THAN)
+(assert (= (> 1.5 1.0) (true)) FAILED: float GREATER THAN)
+(assert (= (> 1.5 1.5) (false)) FAILED: float GREATER THAN)
+
+;; GREATER EQUAL THAN
+(assert (= (>= 1 3) (false)) FAILED: int GREATER EQUAL THAN)
+(assert (= (>= 1 0) (true)) FAILED: int GREATER EQUAL THAN)
+(assert (= (>= 1 1) (true)) FAILED: int GREATER EQUAL THAN)
+(assert (= (>= 1.5 2.0) (false)) FAILED: float GREATER EQUAL THAN)
+(assert (= (>= 1.5 1.0) (true)) FAILED: float GREATER EQUAL THAN)
+(assert (= (>= 1.5 1.5) (true)) FAILED: float GREATER EQUAL THAN)
+
+(end)