improve math testing

This commit is contained in:
~d6 2022-02-11 00:02:45 -05:00
parent f64806dbd4
commit 1a8e9e4fb6
2 changed files with 12 additions and 21 deletions

View File

@ -3,11 +3,9 @@
( methods for testing math32 and emitting output )
%EMIT { #18 DEO }
%DIGIT { #00 SWP ;digits ADD2 LDA EMIT }
%SPACE { #20 EMIT }
%NEWLINE { #0a EMIT }
%RESET-POS { #0000 ;pos STA2 #00 ;buf STA }
%EMIT-BYTE { DUP #04 SFT DIGIT #0f AND DIGIT }
( devices )
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ]
@ -87,13 +85,13 @@ JMP2r
( format: ". xxxxxxxx" -> "zzzzzzzz" )
@unary-32-test
;buf #0002 ADD2 ;read-long JSR2
ROT2 JSR2 ;emit-long JSR2
ROT2 JSR2 ;emit/long JSR2
NEWLINE RESET-POS BRK
( format: ". xxxxxxxx" -> "zz" )
@unary-32-8-test
;buf #0002 ADD2 ;read-long JSR2
ROT2 JSR2 ;emit-byte JSR2
ROT2 JSR2 ;emit/byte JSR2
NEWLINE RESET-POS BRK
( format: ". xxxxxxxx yyyyyyyy" -> "zzzzzzzz" )
@ -101,7 +99,7 @@ JMP2r
;buf #0002 ADD2 ;read-long JSR2
ROT2
;buf #000b ADD2 ;read-long JSR2
ROT2 JSR2 ;emit-long JSR2
ROT2 JSR2 ;emit/long JSR2
NEWLINE RESET-POS BRK
( format: ". xxxxxxxx yy" -> "zzzzzzzz" )
@ -109,7 +107,7 @@ JMP2r
;buf #0002 ADD2 ;read-long JSR2
ROT2
;buf #000b ADD2 ;read-byte JSR2
TOR JSR2 ;emit-long JSR2
TOR JSR2 ;emit/long JSR2
NEWLINE RESET-POS BRK
( format: ". xxxxxxxx yyyyyyyy" -> "zz" )
@ -117,7 +115,7 @@ JMP2r
;buf #0002 ADD2 ;read-long JSR2
ROT2
;buf #000b ADD2 ;read-long JSR2
ROT2 JSR2 ;emit-byte JSR2
ROT2 JSR2 ;emit/byte JSR2
NEWLINE RESET-POS BRK
( different test executors )
@ -144,17 +142,9 @@ JMP2r
@test-gt32 ;gt32 ;binary-32-32-8-test JMP2
@test-gteq32 ;gteq32 ;binary-32-32-8-test JMP2
@emit-long ( hi* lo* -> )
SWP2
SWP EMIT-BYTE EMIT-BYTE
SWP EMIT-BYTE EMIT-BYTE
JMP2r
@emit-byte ( x^ -> )
EMIT-BYTE
JMP2r
( convenience for less branching when printing hex )
@digits
30 31 32 33 34 35 36 37
38 39 61 62 63 64 65 66
@emit
&long SWP2 ,&short JSR
&short SWP ,&byte JSR
&byte DUP #04 SFT ,&char JSR
&char #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r

View File

@ -86,6 +86,7 @@ def main():
test(p, trials, b'}', [('x', u32), ('y', u32)], u8, lambda x, y: int(x >= y))
p.stdin.close()
p.stdout.close()
p.kill()
if __name__ == "__main__":
main()