From f2d25a0da2a6dc626e5342d13659ee7b423612c0 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 4 May 2024 16:14:26 -0500 Subject: [PATCH] Add test case. --- test/suite-boot.janet | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/suite-boot.janet b/test/suite-boot.janet index 89fb0076..f3b5ee6f 100644 --- a/test/suite-boot.janet +++ b/test/suite-boot.janet @@ -976,4 +976,16 @@ (assert (= () '() (macex '())) "macex ()") (assert (= '[] (macex '[])) "macex []") +# Knuth man or boy test +(var a nil) +(defn man-or-boy [x] (a x |1 |-1 |-1 |1 |0)) +(varfn a [k x1 x2 x3 x4 x5] + (var k k) + (defn b [] (-- k) (a k b x1 x2 x3 x4)) + (if (<= k 0) + (+ (x4) (x5)) + (b))) +(assert (= -2 (man-or-boy 2))) +(assert (= -67 (man-or-boy 10))) + (end-suite)