Minilisp.pm/t/and_or.t

25 lines
629 B
Perl
Raw Normal View History

2021-04-09 00:01:27 +02:00
(plan 7)
(let ((a 'ok))
(and nil (set a 'fail))
(expect "and - 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)))
2021-04-08 23:52:03 +02:00
(expect "and - returns nil if no operands supplied"
(null (and)))
(let ((a 'ok))
(or t (set a 'fail))
(expect "or - short circuit" (equal a 'ok)))
(expect "or - returns last value if all operands evaluate to false"
(equal (or nil 'ok) 'ok))
(expect "or - returns nil if no operands supplied"
(null (or)))