diff --git a/exercises/practice/bob/.meta/tests.toml b/exercises/practice/bob/.meta/tests.toml index 5299e289..c6a46496 100644 --- a/exercises/practice/bob/.meta/tests.toml +++ b/exercises/practice/bob/.meta/tests.toml @@ -9,17 +9,20 @@ # As user-added comments (using the # character) will be removed when this file # is regenerated, comments can be added via a `comment` key. -[e162fead-606f-437a-a166-d051915cea8e] -description = "stating something" +[8a2e771d-d6f1-4e3f-b6c6-b41495556e37] +description = "asking a question" [73a966dc-8017-47d6-bb32-cf07d1a5fcd9] description = "shouting" -[d6c98afd-df35-4806-b55e-2c457c3ab748] -description = "shouting gibberish" +[a5193c61-4a92-4f68-93e2-f554eb385ec6] +description = "forceful question" -[8a2e771d-d6f1-4e3f-b6c6-b41495556e37] -description = "asking a question" +[bc39f7c6-f543-41be-9a43-fd1c2f753fc0] +description = "silence" + +[e162fead-606f-437a-a166-d051915cea8e] +description = "stating something" [81080c62-4e4d-4066-b30a-48d8d76920d9] description = "asking a numeric question" @@ -27,23 +30,34 @@ description = "asking a numeric question" [2a02716d-685b-4e2e-a804-2adaf281c01e] description = "asking gibberish" -[c02f9179-ab16-4aa7-a8dc-940145c385f7] -description = "talking forcefully" +[bb0011c5-cd52-4a5b-8bfb-a87b6283b0e2] +description = "question with no letters" -[153c0e25-9bb5-4ec5-966e-598463658bcd] -description = "using acronyms in regular speech" +[9bfc677d-ea3a-45f2-be44-35bc8fa3753e] +description = "non-letters with question" -[a5193c61-4a92-4f68-93e2-f554eb385ec6] -description = "forceful question" +[8608c508-f7de-4b17-985b-811878b3cf45] +description = "prattling on" -[a20e0c54-2224-4dde-8b10-bd2cdd4f61bc] -description = "shouting numbers" +[05b304d6-f83b-46e7-81e0-4cd3ca647900] +description = "ending with whitespace" -[f7bc4b92-bdff-421e-a238-ae97f230ccac] -description = "no letters" +[66953780-165b-4e7e-8ce3-4bcb80b6385a] +description = "multiple line question" +include = false -[bb0011c5-cd52-4a5b-8bfb-a87b6283b0e2] -description = "question with no letters" +[2c7278ac-f955-4eb4-bf8f-e33eb4116a15] +description = "multiple line question" +reimplements = "66953780-165b-4e7e-8ce3-4bcb80b6385a" + +[d6c98afd-df35-4806-b55e-2c457c3ab748] +description = "shouting gibberish" + +[3c954328-86fb-4c71-8961-e18d6a5e2517] +description = "shouting a statement containing a question mark" + +[a20e0c54-2224-4dde-8b10-bd2cdd4f61bc] +description = "shouting numbers" [496143c8-1c31-4c01-8a08-88427af85c66] description = "shouting with special characters" @@ -51,40 +65,29 @@ description = "shouting with special characters" [e6793c1c-43bd-4b8d-bc11-499aea73925f] description = "shouting with no exclamation mark" -[aa8097cc-c548-4951-8856-14a404dd236a] -description = "statement containing question mark" - -[9bfc677d-ea3a-45f2-be44-35bc8fa3753e] -description = "non-letters with question" - -[8608c508-f7de-4b17-985b-811878b3cf45] -description = "prattling on" - -[bc39f7c6-f543-41be-9a43-fd1c2f753fc0] -description = "silence" - [d6c47565-372b-4b09-b1dd-c40552b8378b] description = "prolonged silence" [4428f28d-4100-4d85-a902-e5a78cb0ecd3] description = "alternate silence" -[66953780-165b-4e7e-8ce3-4bcb80b6385a] -description = "multiple line question" -include = false +[72bd5ad3-9b2f-4931-a988-dce1f5771de2] +description = "other whitespace" -[5371ef75-d9ea-4103-bcfa-2da973ddec1b] -description = "starting with whitespace" +[c02f9179-ab16-4aa7-a8dc-940145c385f7] +description = "talking forcefully" -[05b304d6-f83b-46e7-81e0-4cd3ca647900] -description = "ending with whitespace" +[153c0e25-9bb5-4ec5-966e-598463658bcd] +description = "using acronyms in regular speech" -[72bd5ad3-9b2f-4931-a988-dce1f5771de2] -description = "other whitespace" +[f7bc4b92-bdff-421e-a238-ae97f230ccac] +description = "no letters" + +[aa8097cc-c548-4951-8856-14a404dd236a] +description = "statement containing question mark" + +[5371ef75-d9ea-4103-bcfa-2da973ddec1b] +description = "starting with whitespace" [12983553-8601-46a8-92fa-fcaa3bc4a2a0] description = "non-question ending with whitespace" - -[2c7278ac-f955-4eb4-bf8f-e33eb4116a15] -description = "multiple line question" -reimplements = "66953780-165b-4e7e-8ce3-4bcb80b6385a" diff --git a/exercises/practice/bob/BobResponse.tests.ps1 b/exercises/practice/bob/BobResponse.tests.ps1 index f0a962e8..93996587 100644 --- a/exercises/practice/bob/BobResponse.tests.ps1 +++ b/exercises/practice/bob/BobResponse.tests.ps1 @@ -4,20 +4,24 @@ BeforeAll { Describe "Test Get-BobResponse" { - It "stating something" { - Get-BobResponse -HeyBob "Tom-ay-to, tom-aaaah-to." | Should -BeExactly "Whatever." + It "asking a question" { + Get-BobResponse -HeyBob "Does this cryogenic chamber make me look fat?" | Should -BeExactly "Sure." } It "shouting" { Get-BobResponse -HeyBob "WATCH OUT!" | Should -BeExactly "Whoa, chill out!" } - It "shouting gibberish" { - Get-BobResponse -HeyBob "FCECDFCAAB" | Should -BeExactly "Whoa, chill out!" + It "forceful question" { + Get-BobResponse -HeyBob "WHAT'S GOING ON?" | Should -BeExactly "Calm down, I know what I'm doing!" } - It "asking a question" { - Get-BobResponse -HeyBob "Does this cryogenic chamber make me look fat?" | Should -BeExactly "Sure." + It "silence" { + Get-BobResponse -HeyBob "" | Should -BeExactly "Fine. Be that way!" + } + + It "stating something" { + Get-BobResponse -HeyBob "Tom-ay-to, tom-aaaah-to." | Should -BeExactly "Whatever." } It "asking a numeric question" { @@ -28,78 +32,78 @@ Describe "Test Get-BobResponse" { Get-BobResponse -HeyBob "fffbbcbeab?" | Should -BeExactly "Sure." } - It "talking forcefully" { - Get-BobResponse -HeyBob "Let's go make out behind the gym!" | Should -BeExactly "Whatever." + It "question with no letters" { + Get-BobResponse -HeyBob "4?" | Should -BeExactly "Sure." } - It "using acronyms in regular speech" { - Get-BobResponse -HeyBob "It's OK if you don't want to go to the DMV." | Should -BeExactly "Whatever." + It "non-letters with question" { + Get-BobResponse -HeyBob ":) ?" | Should -BeExactly "Sure." } - It "forceful question" { - Get-BobResponse -HeyBob "WHAT THE HELL WERE YOU THINKING?" | Should -BeExactly "Calm down, I know what I'm doing!" + It "prattling on" { + Get-BobResponse -HeyBob "Wait! Hang on. Are you going to be OK?" | Should -BeExactly "Sure." } - It "shouting numbers" { - Get-BobResponse -HeyBob "1, 2, 3 GO!" | Should -BeExactly "Whoa, chill out!" + It "ending with whitespace" { + Get-BobResponse -HeyBob "Okay if like my spacebar quite a bit? " | Should -BeExactly "Sure." } - It "no letters" { - Get-BobResponse -HeyBob "1, 2, 3" | Should -BeExactly "Whatever." + It "multiple line question" { + Get-BobResponse -HeyBob "`nDoes this cryogenic chamber make`n me look fat?" | Should -BeExactly "Sure." } - It "question with no letters" { - Get-BobResponse -HeyBob "4?" | Should -BeExactly "Sure." + It "shouting gibberish" { + Get-BobResponse -HeyBob "FCECDFCAAB" | Should -BeExactly "Whoa, chill out!" + } + + It "shouting a statement containing a question mark" { + Get-BobResponse -HeyBob "DO LIONS EAT PEOPLE? AHHHHH." | Should -BeExactly "Whoa, chill out!" } + It "shouting numbers" { + Get-BobResponse -HeyBob "1, 2, 3 GO!" | Should -BeExactly "Whoa, chill out!" + } + It "shouting with special characters" { Get-BobResponse -HeyBob "ZOMG THE %^*@#`$(*^ ZOMBIES ARE COMING!!11!!1!" | Should -BeExactly "Whoa, chill out!" } It "shouting with no exclamation mark" { - Get-BobResponse -HeyBob "I HATE YOU" | Should -BeExactly "Whoa, chill out!" + Get-BobResponse -HeyBob "I HATE THE DENTIST" | Should -BeExactly "Whoa, chill out!" } - It "statement containing question mark" { - Get-BobResponse -HeyBob "Ending with ? means a question." | Should -BeExactly "Whatever." + It "prolonged silence" { + Get-BobResponse -HeyBob " " | Should -BeExactly "Fine. Be that way!" } - It "non-letters with question" { - Get-BobResponse -HeyBob ":) ?" | Should -BeExactly "Sure." + It "alternate silence" { + Get-BobResponse -HeyBob "`t`t`t`t`t`t`t`t`t`t`t" | Should -BeExactly "Fine. Be that way!" } - It "prattling on" { - Get-BobResponse -HeyBob "Wait! Hang on. Are you going to be OK?" | Should -BeExactly "Sure." + It "other whitespace" { + Get-BobResponse -HeyBob "`n`r `t" | Should -BeExactly "Fine. Be that way!" } - It "silence" { - Get-BobResponse -HeyBob "" | Should -BeExactly "Fine. Be that way!" + It "talking forcefully" { + Get-BobResponse -HeyBob "Hi there!" | Should -BeExactly "Whatever." } - It "prolonged silence" { - Get-BobResponse -HeyBob " " | Should -BeExactly "Fine. Be that way!" + It "using acronyms in regular speech" { + Get-BobResponse -HeyBob "It's OK if you don't want to go work for NASA." | Should -BeExactly "Whatever." } - It "alternate silence" { - Get-BobResponse -HeyBob "`t`t`t`t`t`t`t`t`t`t`t" | Should -BeExactly "Fine. Be that way!" + It "no letters" { + Get-BobResponse -HeyBob "1, 2, 3" | Should -BeExactly "Whatever." } - It "multiple line question" { - Get-BobResponse -HeyBob "`nDoes this cryogenic chamber make`n me look fat?" | Should -BeExactly "Sure." + It "statement containing question mark" { + Get-BobResponse -HeyBob "Ending with ? means a question." | Should -BeExactly "Whatever." } It "starting with whitespace" { Get-BobResponse -HeyBob " hmmmmmmm..." | Should -BeExactly "Whatever." } - It "ending with whitespace" { - Get-BobResponse -HeyBob "Okay if like my spacebar quite a bit? " | Should -BeExactly "Sure." - } - - It "other whitespace" { - Get-BobResponse -HeyBob "`n`r `t" | Should -BeExactly "Fine. Be that way!" - } - It "non-question ending with whitespace" { Get-BobResponse -HeyBob "This is a statement ending with whitespace " | Should -BeExactly "Whatever." } diff --git a/exercises/practice/connect/.meta/tests.toml b/exercises/practice/connect/.meta/tests.toml index 6ada8773..951b87e5 100644 --- a/exercises/practice/connect/.meta/tests.toml +++ b/exercises/practice/connect/.meta/tests.toml @@ -30,6 +30,12 @@ description = "nobody wins crossing adjacent angles" [cd61c143-92f6-4a8d-84d9-cb2b359e226b] description = "X wins crossing from left to right" +[495e33ed-30a9-4012-b46e-d7c4d5fe13c3] +description = "X wins with left-hand dead end fork" + +[ab167ab0-4a98-4d0f-a1c0-e1cddddc3d58] +description = "X wins with right-hand dead end fork" + [73d1eda6-16ab-4460-9904-b5f5dd401d0b] description = "O wins crossing from top to bottom" diff --git a/exercises/practice/connect/Connect.tests.ps1 b/exercises/practice/connect/Connect.tests.ps1 index 3954ca64..24877a64 100644 --- a/exercises/practice/connect/Connect.tests.ps1 +++ b/exercises/practice/connect/Connect.tests.ps1 @@ -78,6 +78,32 @@ Describe "Connect test cases" { $got | Should -BeExactly $want } + It "X wins with left-hand dead end fork" { + $board = @( + ". . X .", + " X X . .", + " . X X X", + " O O O O" + ) + $got = [Connect]::new($board).GetWinner() + $want = [Winner]::X + + $got | Should -BeExactly $want + } + + It "X wins with right-hand dead end fork" { + $board = @( + ". . X X", + " X X . .", + " . X X .", + " O O O O" + ) + $got = [Connect]::new($board).GetWinner() + $want = [Winner]::X + + $got | Should -BeExactly $want + } + It "X wins crossing from left to right" { $board = @( ". O . .", diff --git a/exercises/practice/flower-field/.meta/tests.toml b/exercises/practice/flower-field/.meta/tests.toml index c2b24fda..965ba8fd 100644 --- a/exercises/practice/flower-field/.meta/tests.toml +++ b/exercises/practice/flower-field/.meta/tests.toml @@ -44,3 +44,6 @@ description = "cross" [dd9d4ca8-9e68-4f78-a677-a2a70fd7a7b8] description = "large garden" + +[6e4ac13a-3e43-4728-a2e3-3551d4b1a996] +description = "multiple adjacent flowers" diff --git a/exercises/practice/flower-field/FlowerField.tests.ps1 b/exercises/practice/flower-field/FlowerField.tests.ps1 index 4dc9a1e9..499a01dc 100644 --- a/exercises/practice/flower-field/FlowerField.tests.ps1 +++ b/exercises/practice/flower-field/FlowerField.tests.ps1 @@ -168,6 +168,17 @@ Describe "Flower Field test cases" { $got | Should -BeExactly $want } + It "multiple adjacent flowers" { + $got = Get-Annotate -Garden @( + " ** " + ) + $want = @( + "1**1" + ) + + $got | Should -BeExactly $want + } + It "annotate 9" { $got = Get-Annotate -Garden @( " ", diff --git a/exercises/practice/isbn-verifier/.meta/tests.toml b/exercises/practice/isbn-verifier/.meta/tests.toml index 6d5a8459..17e18d47 100644 --- a/exercises/practice/isbn-verifier/.meta/tests.toml +++ b/exercises/practice/isbn-verifier/.meta/tests.toml @@ -30,6 +30,12 @@ description = "invalid character in isbn is not treated as zero" [28025280-2c39-4092-9719-f3234b89c627] description = "X is only valid as a check digit" +[8005b57f-f194-44ee-88d2-a77ac4142591] +description = "only one check digit is allowed" + +[fdb14c99-4cf8-43c5-b06d-eb1638eff343] +description = "X is not substituted by the value 10" + [f6294e61-7e79-46b3-977b-f48789a4945b] description = "valid isbn without separating dashes" diff --git a/exercises/practice/isbn-verifier/IsbnVerifier.tests.ps1 b/exercises/practice/isbn-verifier/IsbnVerifier.tests.ps1 index fbf15e51..d4bc65fa 100644 --- a/exercises/practice/isbn-verifier/IsbnVerifier.tests.ps1 +++ b/exercises/practice/isbn-verifier/IsbnVerifier.tests.ps1 @@ -45,6 +45,18 @@ Describe "IsbnVerifierTests" { $got | Should -BeFalse } + It "only one check digit is allowed" { + $got = Test-Isbn -Isbn "3-598-21508-96" + + $got | Should -BeFalse + } + + It "X is not substituted by the value 10" { + $got = Test-Isbn -Isbn "3-598-2X507-5" + + $got | Should -BeFalse + } + It "valid isbn without separating dashes" { $got = Test-Isbn -Isbn "3598215088" diff --git a/exercises/practice/line-up/.meta/tests.toml b/exercises/practice/line-up/.meta/tests.toml index 36fdf1d0..dd66fc15 100644 --- a/exercises/practice/line-up/.meta/tests.toml +++ b/exercises/practice/line-up/.meta/tests.toml @@ -51,9 +51,24 @@ description = "format non-exceptional ordinal numeral 13" [2bdcebc5-c029-4874-b6cc-e9bec80d603a] description = "format exceptional ordinal numeral 21" +[a98e2e22-ab41-4557-a7c2-efedc19c16da] +description = "format exceptional ordinal numeral 22 ending in nd even though it is a multiple of 11" + +[ab45d2fb-e0ee-4016-b605-76917584db0a] +description = "format exceptional ordinal numeral 33 ending in rd even though it is a multiple of 11" + +[c9243603-9f17-45b3-9a41-db9ebdbf08e1] +description = "format exceptional ordinal numeral 52 ending in nd even though it is a multiple of 13" + [74ee2317-0295-49d2-baf0-d56bcefa14e3] description = "format exceptional ordinal numeral 62" +[3f6c408c-4331-42b6-bb6c-3ad0823e568a] +description = "format non-exceptional ordinal numeral 72 ending in nd even though it is a multiple of 12" + +[8db52cd9-9689-413f-a812-6c36fcfd0d07] +description = "format exceptional ordinal numeral 91 ending in st even though it is a multiple of 13" + [b37c332d-7f68-40e3-8503-e43cbd67a0c4] description = "format exceptional ordinal numeral 100" @@ -65,3 +80,6 @@ description = "format non-exceptional ordinal numeral 112" [06b62efe-199e-4ce7-970d-4bf73945713f] description = "format exceptional ordinal numeral 123" + +[6792c54e-59a7-4faf-839a-c4bb61014229] +description = "format large number 972 ending in nd even though it is a multiple of 12" diff --git a/exercises/practice/line-up/LineUp.tests.ps1 b/exercises/practice/line-up/LineUp.tests.ps1 index 02485274..c0fd44d6 100644 --- a/exercises/practice/line-up/LineUp.tests.ps1 +++ b/exercises/practice/line-up/LineUp.tests.ps1 @@ -101,6 +101,27 @@ Describe "LineUp test cases" { $got | Should -BeExactly $expect } + It "format exceptional ordinal numeral 22" { + $got = Get-LineUp -Name "Ingrid" -Number 22 + $expect = "Ingrid, you are the 22nd customer we serve today. Thank you!" + + $got | Should -BeExactly $expect + } + + It "format exceptional ordinal numeral 33 ending in rd even though it is a multiple of 112" { + $got = Get-LineUp -Name "Mario" -Number 33 + $expect = "Mario, you are the 33rd customer we serve today. Thank you!" + + $got | Should -BeExactly $expect + } + + It "format exceptional ordinal numeral 52 ending in nd even though it is a multiple of 13" { + $got = Get-LineUp -Name "Quentin" -Number 52 + $expect = "Quentin, you are the 52nd customer we serve today. Thank you!" + + $got | Should -BeExactly $expect + } + It "format exceptional ordinal numeral 62" { $got = Get-LineUp -Name "Nayra" -Number 62 $expect = "Nayra, you are the 62nd customer we serve today. Thank you!" @@ -108,6 +129,20 @@ Describe "LineUp test cases" { $got | Should -BeExactly $expect } + It "format non-exceptional ordinal numeral 72 ending in nd even though it is a multiple of 12" { + $got = Get-LineUp -Name "Ugo" -Number 72 + $expect = "Ugo, you are the 72nd customer we serve today. Thank you!" + + $got | Should -BeExactly $expect + } + + It "format exceptional ordinal numeral 91 ending in st even though it is a multiple of 13" { + $got = Get-LineUp -Name "Boris" -Number 91 + $expect = "Boris, you are the 91st customer we serve today. Thank you!" + + $got | Should -BeExactly $expect + } + It "format exceptional ordinal numeral 100" { $got = Get-LineUp -Name "John" -Number 100 $expect = "John, you are the 100th customer we serve today. Thank you!" @@ -135,4 +170,11 @@ Describe "LineUp test cases" { $got | Should -BeExactly $expect } + + It "format large number 972 ending in nd even though it is a multiple of 12" { + $got = Get-LineUp -Name "Elias" -Number 972 + $expect = "Elias, you are the 972nd customer we serve today. Thank you!" + + $got | Should -BeExactly $expect + } } diff --git a/exercises/practice/perfect-numbers/.meta/tests.toml b/exercises/practice/perfect-numbers/.meta/tests.toml index ec288891..81d48408 100644 --- a/exercises/practice/perfect-numbers/.meta/tests.toml +++ b/exercises/practice/perfect-numbers/.meta/tests.toml @@ -27,6 +27,9 @@ description = "Abundant numbers -> Medium abundant number is classified correctl [ec7792e6-8786-449c-b005-ce6dd89a772b] description = "Abundant numbers -> Large abundant number is classified correctly" +[05f15b93-849c-45e9-9c7d-1ea131ef7d10] +description = "Abundant numbers -> Perfect square abundant number is classified correctly" + [e610fdc7-2b6e-43c3-a51c-b70fb37413ba] description = "Deficient numbers -> Smallest prime deficient number is classified correctly" diff --git a/exercises/practice/perfect-numbers/PerfectNumbers.tests.ps1 b/exercises/practice/perfect-numbers/PerfectNumbers.tests.ps1 index fb3ec078..7f72e444 100644 --- a/exercises/practice/perfect-numbers/PerfectNumbers.tests.ps1 +++ b/exercises/practice/perfect-numbers/PerfectNumbers.tests.ps1 @@ -39,6 +39,13 @@ Describe "Test Invoke-PerfectNumbers.ps1" { $got | Should -BeExactly $want } + It "Perfect square abundant number is classified correctly" { + $got = Invoke-PerfectNumbers -Number 196 + $want = "abundant" + + $got | Should -BeExactly $want + } + It "Large abundant number is classified correctly" { $got = Invoke-PerfectNumbers -Number 33550335 $want = "abundant" diff --git a/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml b/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml index 8fc25e21..5f574b2a 100644 --- a/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml +++ b/exercises/practice/state-of-tic-tac-toe/.meta/tests.toml @@ -99,3 +99,9 @@ reimplements = "b1dc8b13-46c4-47db-a96d-aa90eedc4e8d" [4801cda2-f5b7-4c36-8317-3cdd167ac22c] description = "Invalid boards -> Invalid board: players kept playing after a win" + +[5a84757a-fc86-4328-aec9-a5759e6ed35d] +description = "Invalid boards -> Invalid board: O kept playing after X wins" + +[cf25543d-583a-4656-b9ab-f82dc00a4a02] +description = "Invalid boards -> Invalid board: X kept playing after O wins" diff --git a/exercises/practice/state-of-tic-tac-toe/StateOfTicTacToe.tests.ps1 b/exercises/practice/state-of-tic-tac-toe/StateOfTicTacToe.tests.ps1 index 66948acc..842f82e5 100644 --- a/exercises/practice/state-of-tic-tac-toe/StateOfTicTacToe.tests.ps1 +++ b/exercises/practice/state-of-tic-tac-toe/StateOfTicTacToe.tests.ps1 @@ -271,5 +271,21 @@ Describe "StateOfTicTacToe test cases" { {Get-StateOfTicTacToe -Board $grid} | Should -Throw "*Impossible board: game should have ended after the game was won*" } + + It "Invalid board: O kept playing after X wins" { + $grid = @("OO ", + "XXX", + " O ") + + {Get-StateOfTicTacToe -Board $grid} | Should -Throw "*Impossible board: game should have ended after the game was won*" + } + + It "Invalid board: X kept playing after O wins" { + $grid = @( "XX ", + "OOO", + " XX") + + {Get-StateOfTicTacToe -Board $grid} | Should -Throw "*Impossible board: game should have ended after the game was won*" + } } } diff --git a/exercises/practice/swift-scheduling/.meta/tests.toml b/exercises/practice/swift-scheduling/.meta/tests.toml index 7cc3e415..f2475c9e 100644 --- a/exercises/practice/swift-scheduling/.meta/tests.toml +++ b/exercises/practice/swift-scheduling/.meta/tests.toml @@ -56,3 +56,6 @@ description = "Q4 in the second quarter translates to the last workday of the fo [c920886c-44ad-4d34-a156-dc4176186581] description = "Q3 in the fourth quarter translates to the last workday of the third quarter of next year" + +[7c8f1616-be62-417e-bbd5-a60fa743eccc] +description = "Q2 starting in the last month of the second quarter translates to the last workday of the second quarter of this year" diff --git a/exercises/practice/swift-scheduling/SwiftScheduling.tests.ps1 b/exercises/practice/swift-scheduling/SwiftScheduling.tests.ps1 index 4d693938..b40d41ea 100644 --- a/exercises/practice/swift-scheduling/SwiftScheduling.tests.ps1 +++ b/exercises/practice/swift-scheduling/SwiftScheduling.tests.ps1 @@ -146,4 +146,13 @@ Describe "SwiftScheduling test cases" { $got | Should -BeExactly $want } + + It "Q2 starting in the last month of the second quarter translates to the last workday of the second quarter of this year" { + $start = [Datetime]::New(2019, 6, 15, 9, 50, 0) + + $got = Invoke-SwiftScheduling -MeetingStart $start -Description "Q2" + $want = [Datetime]::New(2019, 6, 28, 8, 0, 0) + + $got | Should -BeExactly $want + } } diff --git a/exercises/practice/tree-building/.meta/TreeBuilding.example.ps1 b/exercises/practice/tree-building/.meta/TreeBuilding.example.ps1 index cd85914c..286f9e41 100644 --- a/exercises/practice/tree-building/.meta/TreeBuilding.example.ps1 +++ b/exercises/practice/tree-building/.meta/TreeBuilding.example.ps1 @@ -54,6 +54,9 @@ Function Build-Tree() { | Sort-Object RecordId | ForEach-Object {$nodes = @{}} { $_.Validate($upperBound) + if ($nodes.ContainsKey(($_.RecordId))) { + Throw "Record id is invalid or out of order." + } $nodes[$_.RecordId] = [Node]::new($_) } diff --git a/exercises/practice/tree-building/.meta/tests.toml b/exercises/practice/tree-building/.meta/tests.toml new file mode 100644 index 00000000..fcdc1d50 --- /dev/null +++ b/exercises/practice/tree-building/.meta/tests.toml @@ -0,0 +1,58 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[761790a3-4c27-461a-b4e9-8bce8ccee5a1] +description = "empty list" + +[dcc89dc3-eb39-4f26-a3cd-964e607c95ff] +description = "single record" + +[dcdb80f0-e5da-43e1-8b8d-6f307be89c0e] +description = "three records in order" + +[2ff5b8f8-d95e-401e-9359-233919488d22] +description = "three records in reverse order" + +[de798d3b-8905-4446-a114-a0dd2476d945] +description = "more than two children" + +[13dd9b3c-6137-415f-b6fe-5044c1dfbc50] +description = "binary tree" + +[5cfd29dc-166b-47da-84ca-1c60b5ae5941] +description = "unbalanced tree" + +[a05ddb5d-2d11-4948-88d3-b5f18a44ddce] +description = "one root node and has parent" + +[9ed09df2-8fd6-4e37-aa37-e7753c057a1a] +description = "root node has parent" + +[8755a2c4-2c6b-4396-b155-b5bf4b6bc280] +description = "no root node" + +[c6ef8f9a-4045-4949-a1e1-e0ae804e4af4] +description = "duplicate node" + +[7a7b77a6-3447-4905-b79c-d22bfe43f408] +description = "duplicate root" + +[c6f51bd7-3608-4390-b446-dfd1bcbf3ddc] +description = "non-continuous" + +[1f3d1b50-4494-4b22-b88a-68f32f7d321d] +description = "cycle directly" + +[ac568b50-3f9b-4cb4-b602-e0eb13de4269] +description = "cycle indirectly" + +[cf954b21-3cef-420c-8e72-d19547505e1f] +description = "higher id parent of lower id" diff --git a/exercises/practice/tree-building/TreeBuilding.tests.ps1 b/exercises/practice/tree-building/TreeBuilding.tests.ps1 index 293a0930..26927238 100644 --- a/exercises/practice/tree-building/TreeBuilding.tests.ps1 +++ b/exercises/practice/tree-building/TreeBuilding.tests.ps1 @@ -23,14 +23,14 @@ BeforeAll { Describe "TreeBuilding test cases" { Context "Valid records input" { - It "empty list input" { + It "empty list" { $records = @() $tree = Build-Tree -Records $records $tree | Should -BeNullOrEmpty } - It "one Node" { + It "single record" { $records = @( [Record]::new(0, 0) ) @@ -39,7 +39,7 @@ Describe "TreeBuilding test cases" { NodeIsLeaf -Node $tree -NodeID 0 } - It "three Nodes in order" { + It "three records in order" { $records = @( [Record]::new(0, 0) [Record]::new(1, 0) @@ -52,7 +52,7 @@ Describe "TreeBuilding test cases" { NodeIsLeaf -Node $tree.Children[1] -NodeID 2 } - It "three Nodes in reverse order" { + It "three records in reverse order" { $records = @( [Record]::new(2, 0) [Record]::new(1, 0) @@ -101,7 +101,7 @@ Describe "TreeBuilding test cases" { NodeIsLeaf -Node $tree.Children[1].Children[1] -NodeID 6 } - It "unbalanced treed" { + It "unbalanced tree" { $records = @( [Record]::new(5, 2) [Record]::new(2, 0) @@ -124,6 +124,14 @@ Describe "TreeBuilding test cases" { } Context "Invalid records input" { + It "one root node and has parent" { + $records = @( + [Record]::new(0, 1) + ) + + {Build-Tree -Records $records} | Should -Throw "*Node record id should be greater than parent id.*" + } + It "root Node has parent" { $records = @( [Record]::new(0, 1) @@ -141,6 +149,25 @@ Describe "TreeBuilding test cases" { {Build-Tree -Records $records} | Should -Throw "*Record id is invalid or out of order.*" } + + It "duplicate node" { + $records = @( + [Record]::new(0, 0) + [Record]::new(1, 0) + [Record]::new(1, 0) + ) + + {Build-Tree -Records $records} | Should -Throw "*Record id is invalid or out of order.*" + } + + It "duplicate root" { + $records = @( + [Record]::new(0, 0) + [Record]::new(0, 0) + ) + + {Build-Tree -Records $records} | Should -Throw "*Record id is invalid or out of order.*" + } It "non continuous" { $records = @(