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

View File

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