Skip to content

Commit

Permalink
configlet sync poker
Browse files Browse the repository at this point in the history
  • Loading branch information
glennj authored and kotp committed Oct 12, 2022
1 parent a99647d commit 1f0ed57
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
17 changes: 16 additions & 1 deletion exercises/practice/poker/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ description = "aces can end a straight (10 J Q K A)"
[76856b0d-35cd-49ce-a492-fe5db53abc02]
description = "aces can start a straight (A 2 3 4 5)"

[e214b7df-dcba-45d3-a2e5-342d8c46c286]
description = "aces cannot be in the middle of a straight (Q K A 2 3)"

[6980c612-bbff-4914-b17a-b044e4e69ea1]
description = "both hands with a straight, tie goes to highest ranked card"

Expand Down Expand Up @@ -96,5 +99,17 @@ description = "with multiple decks, both hands with identical four of a kind, ti
[923bd910-dc7b-4f7d-a330-8b42ec10a3ac]
description = "straight flush beats four of a kind"

[d9629e22-c943-460b-a951-2134d1b43346]
description = "aces can end a straight flush (10 J Q K A)"

[05d5ede9-64a5-4678-b8ae-cf4c595dc824]
description = "aces can start a straight flush (A 2 3 4 5)"

[ad655466-6d04-49e8-a50c-0043c3ac18ff]
description = "aces cannot be in the middle of a straight flush (Q K A 2 3)"

[d0927f70-5aec-43db-aed8-1cbd1b6ee9ad]
description = "both hands have straight flush, tie goes to highest-ranked card"
description = "both hands have a straight flush, tie goes to highest-ranked card"

[be620e09-0397-497b-ac37-d1d7a4464cfc]
description = "even though an ace is usually high, a 5-high straight flush is the lowest-scoring straight flush"
41 changes: 41 additions & 0 deletions exercises/practice/poker/poker.bats
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ load bats-extra
assert_equal "${#lines[@]}" "1"
}

@test "aces cannot be in the middle of a straight (Q K A 2 3)" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash poker.sh "2C 3D 7H 5H 2S" "QS KH AC 2D 3S"
assert_success
assert_line "2C 3D 7H 5H 2S"
assert_equal "${#lines[@]}" "1"
}


@test "both hands with a straight, tie goes to highest ranked card" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash poker.sh "4S 6C 7S 8D 5H" "5S 7H 8S 9D 6H"
Expand Down Expand Up @@ -237,10 +246,42 @@ load bats-extra
assert_equal "${#lines[@]}" "1"
}

@test "aces can end a straight flush (10 J Q K A)" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash poker.sh "KC AH AS AD AC" "10C JC QC KC AC"
assert_success
assert_line "10C JC QC KC AC"
assert_equal "${#lines[@]}" "1"
}

@test "aces can start a straight flush (A 2 3 4 5)" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash poker.sh "KS AH AS AD AC" "4H AH 3H 2H 5H"
assert_success
assert_line "4H AH 3H 2H 5H"
assert_equal "${#lines[@]}" "1"
}

@test "aces cannot be in the middle of a straight flush (Q K A 2 3)" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash poker.sh "2C AC QC 10C KC" "QH KH AH 2H 3H"
assert_success
assert_line "2C AC QC 10C KC"
assert_equal "${#lines[@]}" "1"
}

@test "both hands have straight flush, tie goes to highest-ranked card" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash poker.sh "4H 6H 7H 8H 5H" "5S 7S 8S 9S 6S"
assert_success
assert_line "5S 7S 8S 9S 6S"
assert_equal "${#lines[@]}" "1"
}

@test "even though an ace is usually high, a 5-high straight flush is the lowest-scoring straight flush" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash poker.sh "2H 3H 4H 5H 6H" "4D AD 3D 2D 5D"
assert_success
assert_line "2H 3H 4H 5H 6H"
assert_equal "${#lines[@]}" "1"
}

0 comments on commit 1f0ed57

Please sign in to comment.