From d837fa057d067ffa409e6c6d8e6adc5d74f6946e Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Sat, 5 Dec 2026 08:34:45 -0500 Subject: [PATCH] Address vehicle-purchase review findings Test that the price calculation multiplies before dividing, silence a ShellCheck warning in the tests, fix a code fence language in the conditionals concept, and drop advice about [ and test, which the exercise does not cover. Co-Authored-By: Claude Sonnet 5.5 --- concepts/conditionals/about.md | 2 +- concepts/conditionals/introduction.md | 2 +- exercises/concept/vehicle-purchase/.docs/hints.md | 3 +-- exercises/concept/vehicle-purchase/.docs/introduction.md | 2 +- exercises/concept/vehicle-purchase/vehicle_purchase.bats | 9 +++++++++ exercises/concept/vehicle-purchase/vehicle_purchase.sh | 1 - 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/concepts/conditionals/about.md b/concepts/conditionals/about.md index 98b1bdce..3f3d64ab 100644 --- a/concepts/conditionals/about.md +++ b/concepts/conditionals/about.md @@ -75,7 +75,7 @@ You still need to recognize `[` and `test`, because you will see them in other s There is no special syntax around the CONDITIONAL_COMMANDS. You may be used to seeing if statements that look like this: -```if +```bash if [ "$password" = "secure" ]; then echo "Welcome!" fi diff --git a/concepts/conditionals/introduction.md b/concepts/conditionals/introduction.md index 4e415de5..77bd1898 100644 --- a/concepts/conditionals/introduction.md +++ b/concepts/conditionals/introduction.md @@ -75,7 +75,7 @@ You still need to recognize `[` and `test`, because you will see them in other s There is no special syntax around the CONDITIONAL_COMMANDS. You may be used to seeing if statements that look like this: -```if +```bash if [ "$password" = "secure" ]; then echo "Welcome!" fi diff --git a/exercises/concept/vehicle-purchase/.docs/hints.md b/exercises/concept/vehicle-purchase/.docs/hints.md index 8ba3449f..b076324d 100644 --- a/exercises/concept/vehicle-purchase/.docs/hints.md +++ b/exercises/concept/vehicle-purchase/.docs/hints.md @@ -2,8 +2,7 @@ ## General -- Quote your variable expansions in conditional expressions when you use `[` or `test`. - Inside `[[ ... ]]`, variables are not split or glob-expanded, but quoting the right-hand side of `==` makes it match literally. +- Inside `[[ ... ]]`, variables are not split or glob-expanded, but quoting the right-hand side of `==` makes it match literally. - Read about [conditional constructs][conditional-constructs] in the bash manual, or the track's conditionals concept page. ## 1. Determine if you will need a license diff --git a/exercises/concept/vehicle-purchase/.docs/introduction.md b/exercises/concept/vehicle-purchase/.docs/introduction.md index 8af69471..6ed7b2dc 100644 --- a/exercises/concept/vehicle-purchase/.docs/introduction.md +++ b/exercises/concept/vehicle-purchase/.docs/introduction.md @@ -77,7 +77,7 @@ You still need to recognize `[` and `test`, because you will see them in other s There is no special syntax around the CONDITIONAL_COMMANDS. You may be used to seeing if statements that look like this: -```if +```bash if [ "$password" = "secure" ]; then echo "Welcome!" fi diff --git a/exercises/concept/vehicle-purchase/vehicle_purchase.bats b/exercises/concept/vehicle-purchase/vehicle_purchase.bats index ef3c41f3..a110c578 100644 --- a/exercises/concept/vehicle-purchase/vehicle_purchase.bats +++ b/exercises/concept/vehicle-purchase/vehicle_purchase.bats @@ -1,5 +1,6 @@ #!/usr/bin/env bats load bats-extra +declare lines # bats test_tags=task:1 test_car_needs_a_license() { # @test @@ -145,6 +146,14 @@ test_price_for_an_old_vehicle_other_price() { # @test assert_line --index 2 'Estimated price: 12500' } +# bats test_tags=task:3 +test_price_multiplies_before_dividing() { # @test + run bash vehicle_purchase.sh car 'Ford Pinto' 'Bugatti Veyron' 999 5 + + assert_success + assert_line --index 2 'Estimated price: 699' +} + # bats test_tags=task:3 test_prints_exactly_three_lines() { # @test run bash vehicle_purchase.sh car 'Ford Pinto' 'Bugatti Veyron' 1000 5 diff --git a/exercises/concept/vehicle-purchase/vehicle_purchase.sh b/exercises/concept/vehicle-purchase/vehicle_purchase.sh index d5170002..f23df839 100644 --- a/exercises/concept/vehicle-purchase/vehicle_purchase.sh +++ b/exercises/concept/vehicle-purchase/vehicle_purchase.sh @@ -11,7 +11,6 @@ # # Add your code below each task comment. # Each task builds on the previous tasks, so keep the earlier output unchanged. -# Quote your variable expansions when you use `[` or `test`. # Task 1: print whether a license is needed for this kind of vehicle.