From 6636624b1289c0d1a4c778b8709afb18efe87a94 Mon Sep 17 00:00:00 2001 From: nomennescio Date: Sun, 22 Oct 2023 18:33:43 +0200 Subject: [PATCH] Handle linefeeds in multi-line messages --- test/test-mixed.expected | 6 +++--- testest.4th | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/test/test-mixed.expected b/test/test-mixed.expected index b603634..2d694e8 100644 --- a/test/test-mixed.expected +++ b/test/test-mixed.expected @@ -30,10 +30,10 @@ Wrong number of float results, expected 3 , got 4 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 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 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 diff --git a/testest.4th b/testest.4th index 0656b4b..d599253 100644 --- a/testest.4th +++ b/testest.4th @@ -8,14 +8,16 @@ decimal : it#{ ( c-addr len -- ) cr ." " type cr utime ; : }# ( -- ) utime cr ." " 2swap d- #ms type ." ms" cr ; -: failed# ( -- ) cr ." " ; -: passed# ( -- ) cr ." " ; - ' execute alias ^ : @^ ( addr -- ) @ ^ ; : ++ ( addr -- ) 1 swap +! ; : 0! ( addr -- ) 0 swap ! ; +: failed# ( -- ) cr ." " ; +: passed# ( -- ) cr ." " ; +variable lf lf 0! +: ?lf# ( -- ) lf @ if ." <:LF:>" then lf 0! ; + \ data stack variable start-depth variable #actuals create actuals[] 32 cells allot @@ -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$) ; @@ -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