aboutsummaryrefslogtreecommitdiffstats
path: root/forth/test
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2023-03-14 09:44:08 -0400
committerClyne Sullivan <clyne@bitgloo.com>2023-03-14 09:44:08 -0400
commit74753670d582e4ceeaba383e4ce360eb13004a35 (patch)
tree1606fd3fb26fbda6a4ac796be91df6028e801625 /forth/test
parentc46f531b6bb62d7dd947504a1c731efb5eb57ef5 (diff)
>number
Diffstat (limited to 'forth/test')
-rw-r--r--forth/test/core.fr71
1 files changed, 36 insertions, 35 deletions
diff --git a/forth/test/core.fr b/forth/test/core.fr
index 42fff25..f326432 100644
--- a/forth/test/core.fr
+++ b/forth/test/core.fr
@@ -820,6 +820,7 @@ T{ GS4 123 456
\ \ ------------------------------------------------------------------------
\ TESTING <# # #S #> HOLD SIGN BASE >NUMBER HEX DECIMAL
+." TESTING BASE >NUMBER HEX DEMICAL" CR
\
\ : S= \ ( ADDR1 C1 ADDR2 C2 -- T/F ) COMPARE TWO STRINGS.
\ >R SWAP R@ = IF \ MAKE SURE STRINGS HAVE SAME LENGTH
@@ -845,12 +846,12 @@ T{ GS4 123 456
\
\ : GP4 <# 1 0 #S #> S" 1" S= ;
\ T{ GP4 -> <TRUE> }T
-\
-\ 24 CONSTANT MAX-BASE \ BASE 2 .. 36
-\ : COUNT-BITS
-\ 0 0 INVERT BEGIN DUP WHILE >R 1+ R> 2* REPEAT DROP ;
-\ COUNT-BITS 2* CONSTANT #BITS-UD \ NUMBER OF BITS IN UD
-\
+
+24 CONSTANT MAX-BASE \ BASE 2 .. 36
+: COUNT-BITS
+ 0 0 INVERT BEGIN DUP WHILE >R 1+ R> 2* REPEAT DROP ;
+COUNT-BITS 2* CONSTANT #BITS-UD \ NUMBER OF BITS IN UD
+
\ : GP5
\ BASE @ <TRUE>
\ MAX-BASE 1+ 2 DO \ FOR EACH POSSIBLE BASE
@@ -885,30 +886,30 @@ T{ GS4 123 456
\ R> BASE ! ;
\
\ T{ GP7 -> <TRUE> }T
-\
-\ \ >NUMBER TESTS
-\ CREATE GN-BUF 0 C,
-\ : GN-STRING GN-BUF 1 ;
-\ : GN-CONSUMED GN-BUF CHAR+ 0 ;
-\ : GN' [CHAR] ' WORD CHAR+ C@ GN-BUF C! GN-STRING ;
-\
-\ T{ 0 0 GN' 0' >NUMBER -> 0 0 GN-CONSUMED }T
-\ T{ 0 0 GN' 1' >NUMBER -> 1 0 GN-CONSUMED }T
-\ T{ 1 0 GN' 1' >NUMBER -> BASE @ 1+ 0 GN-CONSUMED }T
-\ T{ 0 0 GN' -' >NUMBER -> 0 0 GN-STRING }T \ SHOULD FAIL TO CONVERT THESE
-\ T{ 0 0 GN' +' >NUMBER -> 0 0 GN-STRING }T
-\ T{ 0 0 GN' .' >NUMBER -> 0 0 GN-STRING }T
-\
-\ : >NUMBER-BASED
-\ BASE @ >R BASE ! >NUMBER R> BASE ! ;
-\
-\ T{ 0 0 GN' 2' 10 >NUMBER-BASED -> 2 0 GN-CONSUMED }T
-\ T{ 0 0 GN' 2' 2 >NUMBER-BASED -> 0 0 GN-STRING }T
-\ T{ 0 0 GN' F' 10 >NUMBER-BASED -> F 0 GN-CONSUMED }T
-\ T{ 0 0 GN' G' 10 >NUMBER-BASED -> 0 0 GN-STRING }T
-\ T{ 0 0 GN' G' MAX-BASE >NUMBER-BASED -> 10 0 GN-CONSUMED }T
-\ T{ 0 0 GN' Z' MAX-BASE >NUMBER-BASED -> 23 0 GN-CONSUMED }T
-\
+
+\ >NUMBER TESTS
+CREATE GN-BUF 0 C,
+: GN-STRING GN-BUF 1 ;
+: GN-CONSUMED GN-BUF CHAR+ 0 ;
+: GN' [CHAR] ' WORD CHAR+ C@ GN-BUF C! GN-STRING ;
+
+T{ 0 0 GN' 0' >NUMBER -> 0 0 GN-CONSUMED }T
+T{ 0 0 GN' 1' >NUMBER -> 1 0 GN-CONSUMED }T
+T{ 1 0 GN' 1' >NUMBER -> BASE @ 1+ 0 GN-CONSUMED }T
+T{ 0 0 GN' -' >NUMBER -> 0 0 GN-STRING }T \ SHOULD FAIL TO CONVERT THESE
+T{ 0 0 GN' +' >NUMBER -> 0 0 GN-STRING }T
+T{ 0 0 GN' .' >NUMBER -> 0 0 GN-STRING }T
+
+: >NUMBER-BASED
+ BASE @ >R BASE ! >NUMBER R> BASE ! ;
+
+T{ 0 0 GN' 2' 10 >NUMBER-BASED -> 2 0 GN-CONSUMED }T
+T{ 0 0 GN' 2' 2 >NUMBER-BASED -> 0 0 GN-STRING }T
+T{ 0 0 GN' F' 10 >NUMBER-BASED -> F 0 GN-CONSUMED }T
+T{ 0 0 GN' G' 10 >NUMBER-BASED -> 0 0 GN-STRING }T
+T{ 0 0 GN' G' MAX-BASE >NUMBER-BASED -> 10 0 GN-CONSUMED }T
+T{ 0 0 GN' Z' MAX-BASE >NUMBER-BASED -> 23 0 GN-CONSUMED }T
+
\ : GN1 \ ( UD BASE -- UD' LEN ) UD SHOULD EQUAL UD' AND LEN SHOULD BE ZERO.
\ BASE @ >R BASE !
\ <# #S #>
@@ -920,11 +921,11 @@ T{ GS4 123 456
\ T{ 0 0 MAX-BASE GN1 -> 0 0 0 }T
\ T{ MAX-UINT 0 MAX-BASE GN1 -> MAX-UINT 0 0 }T
\ T{ MAX-UINT DUP MAX-BASE GN1 -> MAX-UINT DUP 0 }T
-\
-\ : GN2 \ ( -- 16 10 )
-\ BASE @ >R HEX BASE @ DECIMAL BASE @ R> BASE ! ;
-\ T{ GN2 -> 10 A }T
-\
+
+: GN2 \ ( -- 16 10 )
+ BASE @ >R HEX BASE @ DECIMAL BASE @ R> BASE ! ;
+T{ GN2 -> 10 A }T
+
\ ------------------------------------------------------------------------
." TESTING FILL MOVE" CR