From 3d916922e1073a627fe2484fe579c8730b6e45a7 Mon Sep 17 00:00:00 2001 From: Bruce Axtens Date: Wed, 13 Sep 2023 11:12:22 +0800 Subject: [PATCH] add test_map_eq to test-words. missing in word-count (#94) --- exercises/practice/acronym/test-words.8th | 14 +++ .../practice/affine-cipher/test-words.8th | 14 +++ .../practice/armstrong-numbers/test-words.8th | 14 +++ .../practice/atbash-cipher/test-words.8th | 14 +++ exercises/practice/bob/test-words.8th | 14 +++ .../collatz-conjecture/test-words.8th | 14 +++ exercises/practice/darts/test-words.8th | 14 +++ exercises/practice/gigasecond/test-words.8th | 14 +++ exercises/practice/hamming/test-words.8th | 14 +++ exercises/practice/hello-world/test-words.8th | 14 +++ exercises/practice/isogram/test-words.8th | 14 +++ exercises/practice/leap/test-words.8th | 14 +++ exercises/practice/luhn/test-words.8th | 14 +++ exercises/practice/pangram/test-words.8th | 14 +++ exercises/practice/raindrops/test-words.8th | 14 +++ .../practice/resistor-color/test-words.8th | 14 +++ .../practice/reverse-string/test-words.8th | 14 +++ .../practice/roman-numerals/test-words.8th | 14 +++ exercises/practice/series/test-words.8th | 14 +++ exercises/practice/test-words.8th | 100 ------------------ exercises/practice/triangle/test-words.8th | 14 +++ exercises/practice/trinary/test-words.8th | 14 +++ exercises/practice/two-fer/test-words.8th | 14 +++ exercises/practice/word-count/test-words.8th | 14 +++ exercises/practice/yacht/test-words.8th | 14 +++ 25 files changed, 336 insertions(+), 100 deletions(-) delete mode 100644 exercises/practice/test-words.8th diff --git a/exercises/practice/acronym/test-words.8th b/exercises/practice/acronym/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/acronym/test-words.8th +++ b/exercises/practice/acronym/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/affine-cipher/test-words.8th b/exercises/practice/affine-cipher/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/affine-cipher/test-words.8th +++ b/exercises/practice/affine-cipher/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/armstrong-numbers/test-words.8th b/exercises/practice/armstrong-numbers/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/armstrong-numbers/test-words.8th +++ b/exercises/practice/armstrong-numbers/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/atbash-cipher/test-words.8th b/exercises/practice/atbash-cipher/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/atbash-cipher/test-words.8th +++ b/exercises/practice/atbash-cipher/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/bob/test-words.8th b/exercises/practice/bob/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/bob/test-words.8th +++ b/exercises/practice/bob/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/collatz-conjecture/test-words.8th b/exercises/practice/collatz-conjecture/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/collatz-conjecture/test-words.8th +++ b/exercises/practice/collatz-conjecture/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/darts/test-words.8th b/exercises/practice/darts/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/darts/test-words.8th +++ b/exercises/practice/darts/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/gigasecond/test-words.8th b/exercises/practice/gigasecond/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/gigasecond/test-words.8th +++ b/exercises/practice/gigasecond/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/hamming/test-words.8th b/exercises/practice/hamming/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/hamming/test-words.8th +++ b/exercises/practice/hamming/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/hello-world/test-words.8th b/exercises/practice/hello-world/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/hello-world/test-words.8th +++ b/exercises/practice/hello-world/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/isogram/test-words.8th b/exercises/practice/isogram/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/isogram/test-words.8th +++ b/exercises/practice/isogram/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/leap/test-words.8th b/exercises/practice/leap/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/leap/test-words.8th +++ b/exercises/practice/leap/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/luhn/test-words.8th b/exercises/practice/luhn/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/luhn/test-words.8th +++ b/exercises/practice/luhn/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/pangram/test-words.8th b/exercises/practice/pangram/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/pangram/test-words.8th +++ b/exercises/practice/pangram/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/raindrops/test-words.8th b/exercises/practice/raindrops/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/raindrops/test-words.8th +++ b/exercises/practice/raindrops/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/resistor-color/test-words.8th b/exercises/practice/resistor-color/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/resistor-color/test-words.8th +++ b/exercises/practice/resistor-color/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/reverse-string/test-words.8th b/exercises/practice/reverse-string/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/reverse-string/test-words.8th +++ b/exercises/practice/reverse-string/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/roman-numerals/test-words.8th b/exercises/practice/roman-numerals/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/roman-numerals/test-words.8th +++ b/exercises/practice/roman-numerals/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/series/test-words.8th b/exercises/practice/series/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/series/test-words.8th +++ b/exercises/practice/series/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/test-words.8th b/exercises/practice/test-words.8th deleted file mode 100644 index 79c96a53..00000000 --- a/exercises/practice/test-words.8th +++ /dev/null @@ -1,100 +0,0 @@ -needs console/loaded - --1 var, test-count - -: tests \ n -- - test-count ! -; - -: decr-test-count \ -- - test-count @ n:1- test-count ! -; - -: isword? \ x -- x f - dup >kind ns:w n:= -; - -: test_eq \ s x w -- | s w x -- - decr-test-count - isword? !if swap then - w:exec - n:= if - con:green con:onBlack . space " ... OK" . con:white con:onBlack cr - else - con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr - then -; - -: test_eqs \ s x w -- | s w x -- - decr-test-count - isword? !if swap then - w:exec - s:= if - con:green con:onBlack . space " ... OK" . con:white con:onBlack cr - else - con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr - then -; - -: test_true \ s w -- - decr-test-count - w:exec - if - con:green con:onBlack . space " ... OK" . con:white con:onBlack cr - else - con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr - then -; - -: test_false \ s w -- - decr-test-count - w:exec - !if - con:green con:onBlack . space " ... OK" . con:white con:onBlack cr - else - con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr - then -; - -: test_null \ s w -- - decr-test-count - w:exec - null? if - drop con:green con:onBlack . space " ... OK" . con:white con:onBlack cr - else - drop con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr - then -; - -\ compare arrays by testing elements with string equality -: test_eqa \ s x w -- | s w x -- - decr-test-count - isword? !if swap then - w:exec - ' s:= a:= nip nip if - con:green con:onBlack . space " ... OK" . con:white con:onBlack cr - else - con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr - then -; - -: test_map_neq \ m m -- - decr-test-count - isword? !if swap then - w:exec - ' n:= m:= !if - 2drop - con:green con:onBlack . space " ... OK" . con:white con:onBlack cr - else - 2drop - con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr - then -; - -( test-count @ 0 n:= - !if - con:red con:onBlack - "... FAIL - not all tests completed" . - con:white con:onBlack - cr - then ) onexit diff --git a/exercises/practice/triangle/test-words.8th b/exercises/practice/triangle/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/triangle/test-words.8th +++ b/exercises/practice/triangle/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/trinary/test-words.8th b/exercises/practice/trinary/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/trinary/test-words.8th +++ b/exercises/practice/trinary/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/two-fer/test-words.8th b/exercises/practice/two-fer/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/two-fer/test-words.8th +++ b/exercises/practice/two-fer/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/word-count/test-words.8th b/exercises/practice/word-count/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/word-count/test-words.8th +++ b/exercises/practice/word-count/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then diff --git a/exercises/practice/yacht/test-words.8th b/exercises/practice/yacht/test-words.8th index 79c96a53..24dec902 100644 --- a/exercises/practice/yacht/test-words.8th +++ b/exercises/practice/yacht/test-words.8th @@ -78,6 +78,20 @@ needs console/loaded then ; + +: test_map_eq \ m m -- + decr-test-count + isword? !if swap then + w:exec + ' n:= m:= if + 2drop + con:green con:onBlack . space " ... OK" . con:white con:onBlack cr + else + 2drop + con:red con:onBlack . space " ... FAIL" . con:white con:onBlack cr + then +; + : test_map_neq \ m m -- decr-test-count isword? !if swap then