Skip to content

Commit 1e84c07

Browse files
authored
[house] Add a Jinja test template (#844)
This changes the expecations for the output layout. This brings the exercise in line with the problem spec and breaks all existing solutions.
1 parent 0278c73 commit 1e84c07

3 files changed

Lines changed: 72 additions & 221 deletions

File tree

exercises/practice/house/.meta/example.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ main() {
3333

3434
verse() {
3535
local -i n=$1
36-
printf "This is the %s\n" "${items[n]}"
36+
printf "This is the %s" "${items[n]}"
3737
for ((; n>0; n--)); do
38-
printf "that %s the %s\n" "${that[n]}" "${items[n-1]}"
38+
printf " that %s the %s" "${that[n]}" "${items[n-1]}"
3939
done
4040
}
4141

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{ header }}
2+
{% for idx, case in cases %}
3+
@test "{{ case["description"] }}" {
4+
{% if idx == 0 %}# {% endif %}[[ $BATS_RUN_SKIPPED == "true" ]] || skip
5+
expected=$(cat <<END
6+
{{ case["expected"] | join("\n") }}
7+
END
8+
)
9+
run bash {{ solution }} {{ case["input"]["startVerse"] }} {{ case["input"]["endVerse"] }}
10+
assert_success
11+
assert_output "$expected"
12+
}
13+
{% endfor %}
14+
15+
{%- for start, end in [(0, 12), (1, -1), (14, 12), (1, 13)] %}
16+
@test "invalid verse {{ loop.index }}" {
17+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
18+
run bash {{ solution }} {{ start }} {{ end }}
19+
assert_failure
20+
assert_output --partial "invalid"
21+
}
22+
{% endfor %}

0 commit comments

Comments
 (0)