Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises/practice/house/.meta/example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ main() {

verse() {
local -i n=$1
printf "This is the %s\n" "${items[n]}"
printf "This is the %s" "${items[n]}"
for ((; n>0; n--)); do
printf "that %s the %s\n" "${that[n]}" "${items[n-1]}"
printf " that %s the %s" "${that[n]}" "${items[n-1]}"
done
}

Expand Down
22 changes: 22 additions & 0 deletions exercises/practice/house/.meta/template.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ header }}
{% for idx, case in cases %}
@test "{{ case["description"] }}" {
{% if idx == 0 %}# {% endif %}[[ $BATS_RUN_SKIPPED == "true" ]] || skip
expected=$(cat <<END
{{ case["expected"] | join("\n") }}
END
)
run bash {{ solution }} {{ case["input"]["startVerse"] }} {{ case["input"]["endVerse"] }}
assert_success
assert_output "$expected"
}
{% endfor %}

{%- for start, end in [(0, 12), (1, -1), (14, 12), (1, 13)] %}
@test "invalid verse {{ loop.index }}" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash {{ solution }} {{ start }} {{ end }}
assert_failure
assert_output --partial "invalid"
}
{% endfor %}
Loading