From c954f0216f0e61a21ce68916012ea36b266f8d9a Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Mon, 5 Apr 2021 04:07:22 +0200 Subject: [PATCH] when, unless: check for wrongful evaluation when and unless must not evaluate their bodies if the condition does not require it. --- t/unless.t | 4 ++++ t/when.t | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/t/unless.t b/t/unless.t index 524eefb..c931dd9 100644 --- a/t/unless.t +++ b/t/unless.t @@ -3,3 +3,7 @@ (expect "unless - false condition" (equal 'ok (unless nil 'ok))) + +(let ((a 'ok)) + (unless t (set a 'fail)) + (expect "unless - does not evaluate on true" (equal a 'ok))) diff --git a/t/when.t b/t/when.t index 11a3c29..0a24226 100644 --- a/t/when.t +++ b/t/when.t @@ -3,3 +3,7 @@ (expect "when - false condition" (null (when nil 'fail))) + +(let ((a 'ok)) + (when nil (set a 'fail)) + (expect "when - does not evaluate on false" (equal a 'ok)))