Minilisp.pm/t/and_or.t

14 lines
377 B
Perl
Raw Normal View History

(let ((a 'ok))
(and nil (set a 'fail))
(expect "and - Short circuit" (equal a 'ok)))
;; (let ((a 'ok))
;; (or t (set a 'fail))
;; (expect "or - short circuit" (equal a 'ok)))
(expect "and - returns last value if all operands evaluate to true"
(equal (and t 'ok) 'ok))
(expect "and - returns nil if any operand evaluates to false"
(null (and nil t)))