summaryrefslogtreecommitdiff
path: root/test.fs
diff options
context:
space:
mode:
authorkitty <nepeta@canaglie.net>2026-04-22 01:27:02 +1000
committerkitty <nepeta@canaglie.net>2026-04-22 01:27:02 +1000
commit6975cd610ac3a32050e337b04d3f8c3f492cd28b (patch)
tree9da84e46c25aff2c870883286ddc0fa3272de3d0 /test.fs
parent0c46b326b3079ce2acd21817dae7c0bbe0b8d617 (diff)
case stuff
one of the tests is broken. i'm not entirely sure what the issue is yet
Diffstat (limited to 'test.fs')
-rw-r--r--test.fs61
1 files changed, 47 insertions, 14 deletions
diff --git a/test.fs b/test.fs
index 7eb09f0..aea5f5f 100644
--- a/test.fs
+++ b/test.fs
@@ -374,6 +374,36 @@ t{ -1 gi1 -> 123 }t
t{ <false> melse -> 2 4 }t
t{ <true> melse -> 1 3 5 }t
+: CS1 case 1 of 111 endof
+ 2 of 222 endof
+ 3 of 333 endof
+ >r 999 r>
+ endcase
+;
+t{ 1 CS1 -> 111 }t
+t{ 2 CS1 -> 222 }t
+t{ 3 CS1 -> 333 }t
+t{ 4 CS1 -> 999 }t
+: CS2 >r case
+ -1 of case r@ 1 of 100 endof
+ 2 of 200 endof
+ >r -300 r>
+ endcase
+ endof
+ -2 of case r@ 1 of -99 endof
+ >r -199 r>
+ endcase
+ endof
+ >r 299 r>
+ endcase r> drop ;
+
+t{ -1 1 CS2 -> 100 }t
+t{ -1 2 CS2 -> 200 }t
+t{ -1 3 CS2 -> -300 }t
+t{ -2 1 CS2 -> -99 }t
+t{ -2 2 CS2 -> -199 }t
+t{ 0 2 CS2 -> 299 }t
+
t{ : gi3 begin dup 5 < while dup 1+ repeat ; -> }t
t{ 0 gi3 -> 0 1 2 3 4 5 }t
t{ 4 gi3 -> 4 5 }t
@@ -400,20 +430,23 @@ t{ :noname ( N -- 0, 1, .., N )
t{ 0 RN1 execute -> 0 }t
t{ 4 RN1 execute -> 0 1 2 3 4 }t
-\ :noname ( N -- N1 )
-\ 1- dup
-\ case 0 of exit endof
-\ 1 of 11 swap recurse endof
-\ 2 of 22 swap recurse endof
-\ 3 of 33 swap recurse endof
-\ drop abs recurse exit
-\ endcase
-\ ; constant RN2
-\
-\ t{ 1 RN2 execute -> 0 }t
-\ t{ 2 RN2 execute -> 11 0 }t
-\ t{ 4 RN2 execute -> 33 22 11 0 }t
-\ t{ 25 RN2 execute -> 33 22 11 0 }t
+\ todo broken
+\ i think the case is splunging up the recurse
+\ i dont know why, because recurse takes no arguments
+:noname ( N -- N1 )
+ 1- dup
+ case 0 of exit endof
+ 1 of 11 swap recurse endof
+ 2 of 22 swap recurse endof
+ 3 of 33 swap recurse endof
+ drop abs recurse exit
+ endcase
+; constant RN2
+
+t{ 1 RN2 execute -> 0 }t
+t{ 2 RN2 execute -> 11 0 }t
+t{ 4 RN2 execute -> 33 22 11 0 }t
+t{ 25 RN2 execute -> 33 22 11 0 }t
hex
t{ : gd1 do i loop ; -> }t