Skip to content

Commit

Permalink
Fix formatting of output messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nomennescio committed Oct 30, 2023
1 parent cefb082 commit 264f618
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 64 deletions.
8 changes: 4 additions & 4 deletions test/test-custom.4th
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

s" custom messages" describe#{

:noname ." Just passed" cr ; ^passed. !
:noname ." Just failed" cr ; ^different. !
:noname ." Just passed" ; ^passed. !
:noname ." Just failed" ; ^different. !

s" short strings" it#{
<{ s" Hello World!" s# -> s" Hello World!" s# }>
Expand All @@ -17,8 +17,8 @@ s" custom messages" describe#{
2variable actual$
2variable expected$

:noname ." Got '" actual$ 2@ type ." ' as expected" cr ; ^passed. !
:noname ." Expected '" expected$ 2@ type ." ', got '" actual$ 2@ type ." '" cr ; ^different. !
:noname ." Got '" actual$ 2@ type ." ' as expected" ; ^passed. !
:noname ." Expected '" expected$ 2@ type ." ', got '" actual$ 2@ type ." '" ; ^different. !

: &actual 2dup actual$ 2! ;
: &expected 2dup expected$ 2! ;
Expand Down
25 changes: 10 additions & 15 deletions test/test-mixed.expected
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,40 @@

<PASSED::>Test Passed

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

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

<FAILED::>Wrong number of cell results, expected 2 , got 3
<FAILED::>Wrong number of cell results, expected 2 , got 3

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

<FAILED::>Wrong number of cell results, expected 2 , got 3
<FAILED::>Wrong number of cell results, expected 2 , got 3

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

<FAILED::>Wrong number of cell results, expected 3 , got 4
<FAILED::>Wrong number of cell results, expected 3 , got 4

<FAILED::>Wrong number of float results, expected 3 , got 4

<FAILED::>Wrong number of cell results, expected 3 , got 4
<FAILED::>Wrong number of cell results, expected 3 , got 4

<FAILED::>Wrong number of float results, expected 3 , got 4

<FAILED::>Wrong number of cell 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 <:LF:>Wrong number of float results, expected 1 , got 2

<FAILED::>Wrong number of cell 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 <:LF:>Wrong number of float results, expected 1 , got 2

<FAILED::>Wrong number of cell 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 <:LF:>Wrong number of float results, expected 1 , got 2

<FAILED::>Expected 2 , got 1

<FAILED::>Expected 1. , got 2.

<FAILED::>Expected 2 , got 1
<:LF:>Expected 1. , got 2.
<FAILED::>Expected 2 , got 1 <:LF:>Expected 1. , got 2.

<FAILED::>Expected 4 5 6 , got 1 2 3

<FAILED::>Expected 1. 2. 3. , got 4. 5. 6.

<FAILED::>Expected 4 5 6 , got 1 2 3
<:LF:>Expected 1. 2. 3. , got 4. 5. 6.
<FAILED::>Expected 4 5 6 , got 1 2 3 <:LF:>Expected 1. 2. 3. , got 4. 5. 6.
17 changes: 7 additions & 10 deletions test/test-overflow-storage.expected
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@

<PASSED::>Test Passed

<FAILED::>Too many cell results to test
<FAILED::>Too many cell results to test

<FAILED::>Too many float results to test

<FAILED::>Too many cell results to test
<:LF:>Too many float results to test
<FAILED::>Too many cell results to test<:LF:>Too many float results to test

<FAILED::>Too many cell results to test
<FAILED::>Too many cell results to test

<FAILED::>Too many float results to test

<FAILED::>Too many cell results to test
<:LF:>Too many float results to test
<FAILED::>Too many cell results to test<:LF:>Too many float results to test

<FAILED::>Too many cell results to test
<FAILED::>Too many cell results to test

<FAILED::>Too many float results to test

<FAILED::>Too many expected cell results to test
<FAILED::>Too many expected cell results to test

<FAILED::>Too many expected float results to test

<FAILED::>Too many expected cell results to test
<:LF:>Too many expected float results to test
<FAILED::>Too many expected cell results to test<:LF:>Too many expected float results to test
16 changes: 8 additions & 8 deletions test/test-stack-mismatch.expected
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@

<IT::>single test

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

<COMPLETEDIN::>0.023 ms
<COMPLETEDIN::>0.015 ms

<IT::>double test

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

<PASSED::>Test Passed

<COMPLETEDIN::>0.016 ms
<COMPLETEDIN::>0.013 ms

<IT::>double fail test

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

<FAILED::>Wrong number of cell results, expected 3 , got 1
<FAILED::>Wrong number of cell results, expected 3 , got 1

<COMPLETEDIN::>0.018 ms
<COMPLETEDIN::>0.014 ms

<COMPLETEDIN::>0.078 ms
<COMPLETEDIN::>0.058 ms
34 changes: 17 additions & 17 deletions test/test-stack-underflow.expected
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ float stack unbalanced

<PASSED::>Test Passed

<COMPLETEDIN::>0.010 ms
<COMPLETEDIN::>0.012 ms

<COMPLETEDIN::>0.016 ms
<COMPLETEDIN::>0.018 ms
cell stack balanced
float stack balanced

<DESCRIBE::>simple underflow

<IT::>single test

<FAILED::>Wrong number of cell results, expected 1 , got a 1 cell stack underflow
<FAILED::>Wrong number of cell results, expected 1 , got a 1 cell stack underflow

<COMPLETEDIN::>0.008 ms

Expand All @@ -31,55 +31,55 @@ float stack balanced

<IT::>single test

<FAILED::>Wrong number of cell results, expected 1 , got a 1 cell stack underflow
<FAILED::>Wrong number of cell results, expected 1 , got a 1 cell stack underflow

<COMPLETEDIN::>0.008 ms

<IT::>double test

<FAILED::>Wrong number of cell results, expected 1 , got a 1 cell stack underflow
<FAILED::>Wrong number of cell results, expected 1 , got a 1 cell stack underflow

<FAILED::>Wrong number of cell results, expected 1 , got a 2 cell stack underflow
<FAILED::>Wrong number of cell results, expected 1 , got a 2 cell stack underflow

<COMPLETEDIN::>1698095971439.486 ms
<COMPLETEDIN::>1698623934121.134 ms

<IT::>double test

<FAILED::>Wrong number of cell results, expected 2 , got a 1 cell stack underflow
<FAILED::>Wrong number of cell results, expected 2 , got a 1 cell stack underflow

<FAILED::>Wrong number of cell results, expected 2 , got a 2 cell stack underflow
<FAILED::>Wrong number of cell results, expected 2 , got a 2 cell stack underflow

<COMPLETEDIN::>1698095971439.504 ms
<COMPLETEDIN::>1698623934121.154 ms

<IT::>double test

<FAILED::>Wrong number of cell results, expected 2 , got a 1 cell stack underflow
<FAILED::>Wrong number of cell results, expected 2 , got a 1 cell stack underflow

<FAILED::>Wrong number of cell results, expected 1 , got a 2 cell stack underflow
<FAILED::>Wrong number of cell results, expected 1 , got a 2 cell stack underflow

<COMPLETEDIN::>1698095971439.522 ms
<COMPLETEDIN::>1698623934121.172 ms

<IT::>float test

<FAILED::>Wrong number of float results, expected 1 , got a 1 float stack underflow

<COMPLETEDIN::>0.008 ms
<COMPLETEDIN::>0.009 ms

<IT::>double float test

<FAILED::>Wrong number of float results, expected 1 , got a 1 float stack underflow

<FAILED::>Wrong number of float results, expected 1 , got a 2 float stack underflow

<COMPLETEDIN::>0.022 ms
<COMPLETEDIN::>0.014 ms

<IT::>double float test

<FAILED::>Wrong number of float results, expected 2 , got a 1 float stack underflow

<FAILED::>Wrong number of float results, expected 2 , got a 2 float stack underflow

<COMPLETEDIN::>0.015 ms
<COMPLETEDIN::>0.016 ms

<IT::>double float test

Expand All @@ -89,6 +89,6 @@ float stack balanced

<COMPLETEDIN::>0.015 ms

<COMPLETEDIN::>0.142 ms
<COMPLETEDIN::>0.138 ms
cell stack balanced
float stack balanced
2 changes: 1 addition & 1 deletion test/test-too-little-arguments.expected
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

<FAILED::>Wrong number of cell results, expected 2 , got 1
<FAILED::>Wrong number of cell results, expected 2 , got 1
2 changes: 1 addition & 1 deletion test/test-too-many-arguments.expected
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

<FAILED::>Wrong number of cell results, expected 1 , got 2
<FAILED::>Wrong number of cell results, expected 1 , got 2
16 changes: 8 additions & 8 deletions testest.4th
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ F<>: f<>

\ default reporting

: passed. ." Test Passed" cr ;
: (different.) { e[] a[] '@ '. } e[] []> a[] [0] { n s c e* a* } n if ?lf# ." Expected " e[] '@ '. []. ." , got " a[] '@ '. []. cr lf ++ then ;
: passed. ." Test Passed" ;
: (different.) { e[] a[] '@ '. } e[] []> a[] [0] { n s c e* a* } n if ?lf# ." Expected " e[] '@ '. []. ." , got " a[] '@ '. []. lf ++ then ;
: different. expecteds[] actuals[] ['] @ ['] . (different.) ;
: fdifferent. expecteds.f[] actuals.f[] ['] f@ ['] f. (different.) ;
: (#results.) { e[] a[] s* s# } e[] []> a[] []> { #e es ec e* #a as ac a* }
#a ac > if ?lf# ." Too many " s* s# type ." results to test" cr lf ++ exit then
#e ec > if ?lf# ." Too many expected " s* s# type ." results to test" cr lf ++ exit then
#a ac > if ?lf# ." Too many " s* s# type ." results to test" lf ++ exit then
#e ec > if ?lf# ." Too many expected " s* s# type ." results to test" lf ++ exit then
#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 ++
." , got " #a dup 0< if negate ." a " . s* s# type ." stack underflow" else . then lf ++
else drop then ;
: #results. expecteds[] actuals[] s" cell" (#results.) ;
: #results. expecteds[] actuals[] s" cell " (#results.) ;
: #fresults. expecteds.f[] actuals.f[] s" float" (#results.) ;

\ custom reporting
Expand All @@ -96,8 +96,8 @@ variable ^#fresults. ' #fresults. ^#fresults. !
#results expecteds[] tuck ! #fresults expecteds.f[] tuck ! store-stacks reset-stacks
0 0 0 expecteds[] actuals[] ['] compare-result compare-results { #p #f #r } \ compare cells
#p 0 0 expecteds.f[] actuals.f[] ['] fcompare-result compare-results { #pt #ff #rf } \ compare floats
#r #rf + #f #ff + + if failed# #r ^#results. ?@^ #rf ^#fresults. ?@^ #f ^different. ?@^ #ff ^fdifferent. ?@^
else #pt 2 = if passed# ^passed. @ ^ then then reset-stacks ;
#r #rf + #f #ff + + if failed# #r ^#results. ?@^ #rf ^#fresults. ?@^ #f ^different. ?@^ #ff ^fdifferent. ?@^ cr
else #pt 2 = if passed# ^passed. @ ^ cr then then reset-stacks ;

\ testest utility words

Expand Down

0 comments on commit 264f618

Please sign in to comment.