27 lines
668 B
Fennel
27 lines
668 B
Fennel
(import-macros {: def : q : ttype : static} :terra)
|
|
(local t (require :faith))
|
|
|
|
(local tests {})
|
|
|
|
(fn tests.test-primitive-ops []
|
|
(local add (def [x int y int : int]
|
|
(return (+ x y))))
|
|
(t.= (add 1 2) 3))
|
|
|
|
(fn tests.test-even-odd []
|
|
(local even? (def [uint32 : bool]))
|
|
(local odd? (def [n uint32 : bool]
|
|
(if (= n 0)
|
|
(return false)
|
|
(return (even? (- n 1))))))
|
|
(even?:adddefinition (def [n uint32 : bool]
|
|
(if (= n 0)
|
|
(return true)
|
|
(return (odd? (- n 1))))))
|
|
|
|
(t.= (even? 4) true)
|
|
(t.= (even? 5) false)
|
|
(t.= (odd? 4) false)
|
|
(t.= (odd? 5) true))
|
|
|
|
tests |