diff --git a/exercises/acronym/.meta/version b/exercises/acronym/.meta/version index bd8bf882..943f9cbc 100644 --- a/exercises/acronym/.meta/version +++ b/exercises/acronym/.meta/version @@ -1 +1 @@ -1.7.0 +1.7.1 diff --git a/exercises/acronym/acronym_test.sh b/exercises/acronym/acronym_test.sh index 388d39f6..d2dd2370 100644 --- a/exercises/acronym/acronym_test.sh +++ b/exercises/acronym/acronym_test.sh @@ -62,3 +62,10 @@ [[ "$status" -eq 0 ]] [[ "$output" == "TRNT" ]] } + +@test "contains shell globbing character" { + [[ $BATS_RUN_SKIPPED == true ]] || skip + run bash acronym.sh "Two * Words" + [[ "$status" -eq 0 ]] + [[ "$output" == "TW" ]] +} diff --git a/exercises/acronym/example.sh b/exercises/acronym/example.sh index f8013b30..2ff87558 100644 --- a/exercises/acronym/example.sh +++ b/exercises/acronym/example.sh @@ -5,9 +5,8 @@ if [ "$#" -ne 1 ]; then exit 1 fi -phrase=$(echo "$1" | tr '-' ' ') -set -f -- junk $phrase -shift +phrase=$(echo "$1" | tr -s '*-' ' ') +set -f -- $phrase shopt -s extglob for word; do diff --git a/exercises/pig-latin/.meta/version b/exercises/pig-latin/.meta/version index 26aaba0e..6085e946 100644 --- a/exercises/pig-latin/.meta/version +++ b/exercises/pig-latin/.meta/version @@ -1 +1 @@ -1.2.0 +1.2.1 diff --git a/exercises/pig-latin/example.sh b/exercises/pig-latin/example.sh index 6ed28e15..04e2ff18 100644 --- a/exercises/pig-latin/example.sh +++ b/exercises/pig-latin/example.sh @@ -19,4 +19,4 @@ translate() { fi } -main "$@" \ No newline at end of file +main "$@" diff --git a/exercises/pig-latin/pig_latin_test.sh b/exercises/pig-latin/pig_latin_test.sh index e64bf4b0..4e5d9640 100644 --- a/exercises/pig-latin/pig_latin_test.sh +++ b/exercises/pig-latin/pig_latin_test.sh @@ -157,3 +157,11 @@ [[ $status -eq 0 ]] [[ $output == "ickquay astfay unray" ]] } + +# danger this way lies +@test "shell globbing" { + [[ $BATS_RUN_SKIPPED == true ]] || skip + run bash pig_latin.sh "pig*" + [[ $status -eq 0 ]] + [[ $output == "ig*pay" ]] +} diff --git a/exercises/proverb/.meta/version b/exercises/proverb/.meta/version index 9084fa2f..524cb552 100644 --- a/exercises/proverb/.meta/version +++ b/exercises/proverb/.meta/version @@ -1 +1 @@ -1.1.0 +1.1.1 diff --git a/exercises/proverb/proverb_test.sh b/exercises/proverb/proverb_test.sh index df12f997..1a47807a 100644 --- a/exercises/proverb/proverb_test.sh +++ b/exercises/proverb/proverb_test.sh @@ -75,3 +75,27 @@ END [[ $status -eq 0 ]] [[ $output == "$expected" ]] } + +@test "items with whitespace" { + [[ $BATS_RUN_SKIPPED == true ]] || skip + expected=$(cat <&2 + echo "invalid color: $1" >&2 return 1 fi } +# silently ignore extra colors result="" -for color; do +for color in "$1" "$2"; do if code=$(code "$color"); then result+="$code" else diff --git a/exercises/resistor-color-duo/resistor_color_duo_test.sh b/exercises/resistor-color-duo/resistor_color_duo_test.sh index 1f8823aa..86d7d81d 100644 --- a/exercises/resistor-color-duo/resistor_color_duo_test.sh +++ b/exercises/resistor-color-duo/resistor_color_duo_test.sh @@ -32,5 +32,12 @@ [[ $BATS_RUN_SKIPPED == true ]] || skip run bash resistor_color_duo.sh foo [[ $status -eq 1 ]] - [[ $output == "invalid color" ]] + [[ $output == *"invalid color"* ]] +} + +@test "ignore too many colors" { + [[ $BATS_RUN_SKIPPED == true ]] || skip + run bash resistor_color_duo.sh green brown orange + [[ $status -eq 0 ]] + [[ $output == "51" ]] } diff --git a/exercises/word-count/.meta/version b/exercises/word-count/.meta/version index 88c5fb89..347f5833 100644 --- a/exercises/word-count/.meta/version +++ b/exercises/word-count/.meta/version @@ -1 +1 @@ -1.4.0 +1.4.1 diff --git a/exercises/word-count/example.sh b/exercises/word-count/example.sh index 941d1b64..f7e19d26 100755 --- a/exercises/word-count/example.sh +++ b/exercises/word-count/example.sh @@ -1,6 +1,6 @@ #!/bin/bash -init_var=$(echo -e "$1" | tr -d '!@$%^&:.') +init_var=$(echo -e "$1" | tr -d '*!@$%^&:.') preprocessed_var=$(echo "${init_var//[$'\n,']/ }" | tr '[:upper:]' '[:lower:]') read -r -a words <<< "$preprocessed_var" diff --git a/exercises/word-count/word_count_test.sh b/exercises/word-count/word_count_test.sh index 5c6c9a1a..0ec0a049 100644 --- a/exercises/word-count/word_count_test.sh +++ b/exercises/word-count/word_count_test.sh @@ -139,3 +139,12 @@ [[ $(wc -l <<< "$output") -eq 3 ]] } +@test "contains shell globbing character" { + [[ $BATS_RUN_SKIPPED == true ]] || skip + run bash word_count.sh "two * words" + [[ $status -eq 0 ]] + echo "$output" | grep -qFx "two: 1" + echo "$output" | grep -qFx "words: 1" + [[ $(wc -l <<< "$output") -eq 2 ]] +} +