22decimal
33s" test/ttester.fs" included
44
5- : #ms ( dmicroseconds -- len c-addr ) <# # # # [char] . hold #s #> ;
5+ : #ms ( dmicroseconds -- c-addr len ) <# # # # [char] . hold #s #> ;
66
7- : describe#{ ( len c-addr -- ) cr ." <DESCRIBE::>" type cr utime ;
8- : it#{ ( len c-addr -- ) cr ." <IT::>" type cr utime ;
7+ : describe#{ ( c-addr len -- ) cr ." <DESCRIBE::>" type cr utime ;
8+ : it#{ ( c-addr len -- ) cr ." <IT::>" type cr utime ;
99: }# ( -- ) utime cr ." <COMPLETEDIN::>" 2swap d- #ms type ." ms" cr ;
1010
1111: failed# ( -- ) cr ." <FAILED::>" ;
@@ -26,13 +26,20 @@ variable ^different
2626 RESULTS @ 0 +do ACTUAL-RESULTS i cells + @ . loop
2727 cr ;
2828: nresults$ ." Wrong number of results, expected " depth START-DEPTH @ - .
29- ." , got " ACTUAL-DEPTH @ START-DEPTH @ - . cr ;
29+ ." , got " ACTUAL-DEPTH @ START-DEPTH @ - dup 0< if negate ." a " . ." cell stack underflow" else . then cr ;
3030
3131' passed$ ^passed !
3232' nresults$ ^nresults !
3333' different$ ^different !
3434
3535: <{ T{ ;
36+ : -> depth dup ACTUAL-DEPTH !
37+ START-DEPTH @ >= if
38+ depth START-DEPTH @ - 0 +do ACTUAL-RESULTS i cells + ! loop
39+ else
40+ START-DEPTH @ depth - -1 +do 0 loop
41+ then
42+ F-> ;
3643: }>
3744 depth ACTUAL-DEPTH @ = if
3845 depth START-DEPTH @ > if
@@ -56,4 +63,4 @@ variable ^different
56633037000493 constant #m \ prime number < sqrt (2^63-1)
576453 constant #p \ prime number
5865: c# { hash pow c -- hash' pow' } c pow * hash + #m mod pow #p * #m mod ; \ polynomial rolling hash function, single char
59- : s# { c-addr u -- hash } 0 1 c-addr u 0 +do { s } s c@ c# s char+ loop 2drop ; \ string hash
66+ : s# { c-addr len -- hash } 0 1 c-addr len 0 +do { s } s c@ c# s char+ loop 2drop ; \ string hash
0 commit comments