Skip to content

Commit

Permalink
Handle linefeeds in multi-line messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nomennescio committed Oct 22, 2023
1 parent 310a13d commit 6636624
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions test/test-mixed.expected
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<FAILED::>Wrong number of float results, expected 3 , got 4

<FAILED::>Wrong number of cell results, expected 1 , got 2
Wrong number of float results, expected 1 , got 2
<:LF:>Wrong number of float results, expected 1 , got 2

<FAILED::>Wrong number of cell results, expected 1 , got 2
Wrong number of float results, expected 1 , got 2
<:LF:>Wrong number of float results, expected 1 , got 2

<FAILED::>Wrong number of cell results, expected 1 , got 2
Wrong number of float results, expected 1 , got 2
<:LF:>Wrong number of float results, expected 1 , got 2
18 changes: 10 additions & 8 deletions testest.4th
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ decimal
: it#{ ( c-addr len -- ) cr ." <IT::>" type cr utime ;
: }# ( -- ) utime cr ." <COMPLETEDIN::>" 2swap d- #ms type ." ms" cr ;

: failed# ( -- ) cr ." <FAILED::>" ;
: passed# ( -- ) cr ." <PASSED::>" ;

' execute alias ^
: @^ ( addr -- ) @ ^ ;
: ++ ( addr -- ) 1 swap +! ;
: 0! ( addr -- ) 0 swap ! ;

: failed# ( -- ) cr ." <FAILED::>" ;
: passed# ( -- ) cr ." <PASSED::>" ;
variable lf lf 0!
: ?lf# ( -- ) lf @ if ." <:LF:>" then lf 0! ;

\ data stack
variable start-depth
variable #actuals create actuals[] 32 cells allot
Expand All @@ -32,15 +34,15 @@ variable #expecteds.f create expecteds.f[] 32 floats allot
: passed$ ." Test Passed" cr ;

: (different$) { r* e* a* 's '@ '. }
r* @ if ." Expected " 0 r* @ -do e* i 1- 's ^ + '@ ^ '. ^ 1 -loop ." , got " 0 r* @ -do a* i 1- 's ^ + '@ ^ '. ^ 1 -loop cr then ;
r* @ dup if ?lf# ." Expected " 0 r* @ -do e* i 1- 's ^ + '@ ^ '. ^ 1 -loop ." , got " 0 r* @ -do a* i 1- 's ^ + '@ ^ '. ^ 1 -loop cr lf ++ then ;

: different$ #expecteds expecteds[] actuals[] ['] cells ['] @ ['] . (different$) ;
: different.f$ #expecteds.f expecteds.f[] actuals.f[] ['] floats ['] f@ ['] f. (different$) ;

: (#results$) { #e #a s* s# }
#e #a - if
." Wrong number of " s* s# type ." results, expected " #e .
." , got " #a dup 0< if negate ." a " . s* s# type ." stack underflow" else . then cr
#e #a - dup if
?lf# ." Wrong number of " s* s# type ." results, expected " #e .
." , got " #a dup 0< if negate ." a " . s* s# type ." stack underflow" else . then cr lf ++
then ;

: #results$ #expecteds @ #actuals @ s" cell " (#results$) ;
Expand All @@ -52,7 +54,7 @@ variable ^different.f ' different.f$ ^different.f !
variable ^#results ' #results$ ^#results !
variable ^#results.f ' #results.f$ ^#results.f !

: <{ depth start-depth ! fdepth start-fdepth ! ;
: <{ depth start-depth ! fdepth start-fdepth ! lf 0! ;

: store-results { #a s *r '! '0 }
#a 0 >= if
Expand Down

0 comments on commit 6636624

Please sign in to comment.