flan/test/programs/ffi-bool.flan

25 lines
665 B
Plaintext

;;;; A bool from C that is not 0 or 1 reads as its low bit on both backends:
;;;; abs(3) is 3, which is true, and equal to abs(1).
(declare two [n i32] bool "abs")
(defstruct Flag [on bool])
(defn main [] i32
(let [a (two 3)
b (two 1)
c (two 0)
f (Flag {.on a})
v [a b]]
(print (= a b)) (print " ")
(print (!= a b)) (print " ")
(print (= a true)) (print " ")
(print (= (.on f) b)) (print " ")
(print (= (at v 0) (at v 1))) (print " ")
(print (match a true "T" false "F")) (print " ")
(print (if a "t" "f")) (print " ")
(print (not a)) (print " ")
(print (= c false))
(println "")
0))