Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

>NUMBER #11

Open
drom opened this issue Nov 29, 2015 · 1 comment
Open

>NUMBER #11

drom opened this issue Nov 29, 2015 · 1 comment
Labels
Milestone

Comments

@drom
Copy link
Member

drom commented Nov 29, 2015

\ >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 #>
   0 0 2SWAP >NUMBER SWAP DROP      \ RETURN LENGTH ONLY
   R> BASE ! ;
T{ 0 0 2 GN1 -> 0 0 0 }T
T{ MAX-UINT 0 2 GN1 -> MAX-UINT 0 0 }T
T{ MAX-UINT DUP 2 GN1 -> MAX-UINT DUP 0 }T
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

Errors:

Error: in line: 886 T{ 0 0 GN' 0' >NUMBER -> 0 0 GN-CONSUMED }T  expected [ 0, 0, 147, 1 ] to deeply equal [ 0, 0, 148, 0 ].
Error: in line: 887 T{ 0 0 GN' 1' >NUMBER -> 1 0 GN-CONSUMED }T  expected [ 0, 0, 147, 1 ] to deeply equal [ 1, 0, 148, 0 ].
Error: in line: 888 T{ 1 0 GN' 1' >NUMBER -> BASE @ 1+ 0 GN-CONSUMED }T  expected [ 1, 0, 147, 1 ] to deeply equal [ 17, 0, 148, 0 ].
.
.
.
Error: in line: 896 T{ 0 0 GN' 2' 10 >NUMBER-BASED -> 2 0 GN-CONSUMED }T  expected [ 0, 0, 147, 1 ] to deeply equal [ 2, 0, 148, 0 ].
.
Error: in line: 898 T{ 0 0 GN' F' 10 >NUMBER-BASED -> F 0 GN-CONSUMED }T  expected [ 0, 0, 147, 1 ] to deeply equal [ 15, 0, 148, 0 ].
.
Error: in line: 900 T{ 0 0 GN' G' MAX-BASE >NUMBER-BASED -> 10 0 GN-CONSUMED }T  expected [ 0, 0, 147, 1 ] to deeply equal [ 16, 0, 148, 0 ].
Error: in line: 901 T{ 0 0 GN' Z' MAX-BASE >NUMBER-BASED -> 23 0 GN-CONSUMED }T  expected [ 0, 0, 147, 1 ] to deeply equal [ 35, 0, 148, 0 ].
Error: in line: 908 T{ 0 0 2 GN1 -> 0 0 0 }T  expected [ 0, 0, 1 ] to deeply equal [ 0, 0, 0 ].
Error: in line: 909 T{ MAX-UINT 0 2 GN1 -> MAX-UINT 0 0 }T  expected [ 0, 0, 32 ] to deeply equal [ -1, 0, 0 ].
Error: in line: 910 T{ MAX-UINT DUP 2 GN1 -> MAX-UINT DUP 0 }T  expected [ 0, 0, 64 ] to deeply equal [ -1, -1, 0 ].
Error: in line: 911 T{ 0 0 MAX-BASE GN1 -> 0 0 0 }T  expected [ 0, 0, 1 ] to deeply equal [ 0, 0, 0 ].
Error: in line: 912 T{ MAX-UINT 0 MAX-BASE GN1 -> MAX-UINT 0 0 }T  expected [ 0, 0, 7 ] to deeply equal [ -1, 0, 0 ].
Error: in line: 913 T{ MAX-UINT DUP MAX-BASE GN1 -> MAX-UINT DUP 0 }T  expected [ 0, 0, 13 ] to deeply equal [ -1, -1, 0 ].
@drom drom added the bug label Nov 29, 2015
@drom drom added this to the v1 milestone Nov 29, 2015
@drom
Copy link
Member Author

drom commented Nov 29, 2015

Some words from ANS94

image


image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant