lots of tests!

This commit is contained in:
~d6 2021-12-26 00:47:13 -05:00
parent fba5b57eaf
commit b2bf87ae68
2 changed files with 22 additions and 6 deletions

View File

@ -74,6 +74,8 @@ RTN
;buf LDA LIT '^ EQU ;test-xor32 JCN2
;buf LDA LIT '~ EQU ;test-complement32 JCN2
;buf LDA LIT 'N EQU ;test-negate32 JCN2
;buf LDA LIT '= EQU ;test-eq32 JCN2
;buf LDA LIT '! EQU ;test-ne32 JCN2
LIT '? EMIT NEWLINE RESET-POS BRK
( format: ". xxxxxxxx" )
@ -115,6 +117,20 @@ RTN
@test-complement32 ;complement32 UNARY-32-TEST
@test-negate32 ;negate32 UNARY-32-TEST
@test-eq32
( format: "= xxxxxxxx yyyyyyyy" )
;buf #0002 ADD2 ;read-long JSR2
;buf #000b ADD2 ;read-long JSR2
;eq32 JSR2 ;emit-byte JSR2
NEWLINE RESET-POS BRK
@test-ne32
( format: "= xxxxxxxx yyyyyyyy" )
;buf #0002 ADD2 ;read-long JSR2
;buf #000b ADD2 ;read-long JSR2
;ne32 JSR2 ;emit-byte JSR2
NEWLINE RESET-POS BRK
@bitcount8 ( x^ -> n^ )
#00 SWP ( n x )
&loop
@ -149,9 +165,8 @@ RTN
RTN
@eq32 ( xhi* xlo* yhi* ylo* -> bool^ )
ROT2 EQU2 ,&maybe JCN
POP4 #00 RTN
&maybe EQU2
ROT2 EQU2 #00 TOR2
EQU2 SWP POP AND
RTN
@eq-zero32 ( x** -> bool^ )
@ -159,9 +174,8 @@ RTN
RTN
@ne32 ( xhi* xlo* yhi* ylo* -> bool^ )
ROT2 EQU2 ,&maybe JCN
POP4 #01 RTN
&maybe NEQ2
ROT2 NEQ2 #00 TOR2
NEQ2 SWP POP ORA
RTN
@ne-zero32 ( x** -> bool^ )

View File

@ -71,6 +71,8 @@ def main():
test(p, runs, b'^', [('x', u32), ('y', u32)], u32, lambda x, y: x ^ y)
test(p, runs, b'~', [('x', u32)], u32, lambda x: ~x)
test(p, runs, b'N', [('x', u32)], u32, lambda x: -x)
test(p, runs, b'=', [('x', u32), ('y', u32)], u8, lambda x, y: int(x == y))
test(p, runs, b'!', [('x', u32), ('y', u32)], u8, lambda x, y: int(x != y))
p.stdin.close()
p.stdout.close()