From 1f0ed57f87160a0de18eea07e8bb753d589ab6e3 Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Wed, 12 Oct 2022 11:26:04 -0400 Subject: [PATCH] configlet sync poker --- exercises/practice/poker/.meta/tests.toml | 17 +++++++++- exercises/practice/poker/poker.bats | 41 +++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/exercises/practice/poker/.meta/tests.toml b/exercises/practice/poker/.meta/tests.toml index 27a1fad2..76ac892d 100644 --- a/exercises/practice/poker/.meta/tests.toml +++ b/exercises/practice/poker/.meta/tests.toml @@ -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" @@ -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" diff --git a/exercises/practice/poker/poker.bats b/exercises/practice/poker/poker.bats index 7e5e173f..3fb3f8fd 100644 --- a/exercises/practice/poker/poker.bats +++ b/exercises/practice/poker/poker.bats @@ -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" @@ -237,6 +246,30 @@ 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" @@ -244,3 +277,11 @@ load bats-extra 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" +}