Skip to content
Merged
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
32 changes: 32 additions & 0 deletions exercises/practice/wordy/.meta/template.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{ header }}
{% for idx, case in cases %}
@test "{{ case["description"] }}" {
{% if idx == 0 %}# {% endif %}[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash {{ solution }} "{{ case["input"]["question"] }}"
{%- if case["expect_error"] %}
assert_failure
assert_output "{{ case["expect_error_msg"] }}"
{%- else %}
assert_success
assert_output "{{ case["expected"] }}"
{%- endif %}
}
{% endfor %}

# Track specific tests

@test "strict left to right, ignores typical order of operations" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash {{ solution }} "What is 2 plus 3 multiplied by 4?"
assert_success
[[ $output != "14" ]]
assert_output "20"
}

@test "reject problem with no operands" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash {{ solution }} "What is plus?"
assert_failure
assert_output "syntax error"
}

38 changes: 22 additions & 16 deletions exercises/practice/wordy/wordy.bats
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env bats
load bats-extra

# generated on 2026-06-29T06:08:31+00:00
# local version: 2.0.0.0

@test "just a number" {
#[[ $BATS_RUN_SKIPPED == "true" ]] || skip
# [[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 5?"
assert_success
assert_output "5"
Expand Down Expand Up @@ -134,14 +137,6 @@ load bats-extra
assert_output "2"
}

@test "strict left to right, ignores typical order of operations" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 2 plus 3 multiplied by 4?"
assert_success
[[ $output != "14" ]]
assert_output "20"
}

@test "unknown operation" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 52 cubed?"
Expand All @@ -156,13 +151,6 @@ load bats-extra
assert_output "unknown operation"
}

@test "reject problem with no operands" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is plus?"
assert_failure
assert_output "syntax error"
}

@test "reject problem missing an operand" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 1 plus?"
Expand Down Expand Up @@ -204,3 +192,21 @@ load bats-extra
assert_failure
assert_output "syntax error"
}


# Track specific tests

@test "strict left to right, ignores typical order of operations" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 2 plus 3 multiplied by 4?"
assert_success
[[ $output != "14" ]]
assert_output "20"
}

@test "reject problem with no operands" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is plus?"
assert_failure
assert_output "syntax error"
}