Skip to content

Commit

Permalink
Update tests (#250)
Browse files Browse the repository at this point in the history
* Update largest-series-product tests

* Add run-length-encoding tests.toml

* Add missing test for allergies

* Update anagram tests

* Update phone-number tests

* Update exercises/practice/allergies/allergies.vader

Co-authored-by: Victor Goff <[email protected]>

* Remove unclear test

* Update exercises/practice/allergies/allergies.vader

Co-authored-by: Victor Goff <[email protected]>

* Update exercises/practice/allergies/allergies.vader

Co-authored-by: Victor Goff <[email protected]>

---------

Co-authored-by: Victor Goff <[email protected]>
  • Loading branch information
BNAndras and kotp authored Jan 4, 2024
1 parent ec0284c commit 761f926
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 22 deletions.
3 changes: 3 additions & 0 deletions exercises/practice/allergies/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,6 @@ description = "list when: -> everything"

[12ce86de-b347-42a0-ab7c-2e0570f0c65b]
description = "list when: -> no allergen score parts"

[93c2df3e-4f55-4fed-8116-7513092819cd]
description = "list when: -> no allergen score parts without highest valid score"
4 changes: 4 additions & 0 deletions exercises/practice/allergies/allergies.vader
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ Execute (ignore non allergen score parts):
let expected = ['eggs', 'shellfish', 'strawberries', 'tomatoes', 'chocolate', 'pollen', 'cats']
AssertEqual expected, List(input)

Execute (no allergen score parts without highest valid score):
let input = 257
let expected = ['eggs']
AssertEqual expected, List(input)
24 changes: 24 additions & 0 deletions exercises/practice/anagram/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,36 @@ description = "detects anagrams using case-insensitive possible matches"

[7cc195ad-e3c7-44ee-9fd2-d3c344806a2c]
description = "does not detect an anagram if the original word is repeated"
include = false

[630abb71-a94e-4715-8395-179ec1df9f91]
description = "does not detect an anagram if the original word is repeated"
reimplements = "7cc195ad-e3c7-44ee-9fd2-d3c344806a2c"
include = false

[9878a1c9-d6ea-4235-ae51-3ea2befd6842]
description = "anagrams must use all letters exactly once"

[85757361-4535-45fd-ac0e-3810d40debc1]
description = "words are not anagrams of themselves (case-insensitive)"
include = false

[68934ed0-010b-4ef9-857a-20c9012d1ebf]
description = "words are not anagrams of themselves"
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"

[589384f3-4c8a-4e7d-9edc-51c3e5f0c90e]
description = "words are not anagrams of themselves even if letter case is partially different"
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"

[ba53e423-7e02-41ee-9ae2-71f91e6d18e6]
description = "words are not anagrams of themselves even if letter case is completely different"
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"

[a0705568-628c-4b55-9798-82e4acde51ca]
description = "words other than themselves can be anagrams"
include = false

[33d3f67e-fbb9-49d3-a90e-0beb00861da7]
description = "words other than themselves can be anagrams"
reimplements = "a0705568-628c-4b55-9798-82e4acde51ca"
44 changes: 29 additions & 15 deletions exercises/practice/anagram/anagram.vader
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
"
" Version: 1.4.0
"

Execute (no matches):
let candidates = ['hello', 'world', 'zombies', 'pants']
let subject = "diaper"
let expected = []
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (detects two anagrams):
let candidates = ['stream', 'pigeon', 'maters']
let subject = "master"
let expected = ['stream', 'maters']
let candidates = ['lemons', 'cherry', 'melons']
let subject = "solemn"
let expected = ['lemons', 'melons']
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (does not detect anagram subsets):
Expand All @@ -32,6 +28,12 @@ Execute (detects three anagrams):
let expected = ['gallery', 'regally', 'largely']
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (detects multiple anagrams with different case):
let candidates = ['Eons', 'ONES']
let subject = "nose"
let expected = ['Eons', 'ONES']
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (does not detect non-anagrams with identical checksum):
let candidates = ['last']
let subject = "mass"
Expand All @@ -56,20 +58,32 @@ Execute (detects anagrams using case-insensitive possible matches):
let expected = ['Carthorse']
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (does not detect a anagram if the original word is repeated):
let candidates = ['go Go GO']
let subject = "go"
let expected = []
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (anagrams must use all letters exactly once):
let candidates = ['patter']
let subject = "tapper"
let expected = []
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (words are not anagrams of themselves (case-insensitive)):
let candidates = ['BANANA', 'Banana', 'banana']
Execute (words are not anagrams of themselves):
let candidates = ['BANANA']
let subject = "BANANA"
let expected = []
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (words are not anagrams of themselves even if letter case is partially different):
let candidates = ['Banana']
let subject = "BANANA"
let expected = []
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (words are not anagrams of themselves even if letter case is completely different):
let candidates = ['banana']
let subject = "BANANA"
let expected = []
AssertEqual expected, FindAnagrams(candidates, subject)

Execute (words other than themselves can be anagrams):
let candidates = ['LISTEN', 'Silent']
let subject = "LISTEN"
let expected = ['Silent']
AssertEqual expected, FindAnagrams(candidates, subject)
5 changes: 4 additions & 1 deletion exercises/practice/largest-series-product/.meta/example.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ function! LargestProduct(digits, span) abort

for i in range(len(a:digits) - a:span + 1)
let tmp = s:product(a:digits[i : i + a:span - 1])
if tmp == -1
return -1
endif
if tmp > max
let max = tmp
endif
Expand All @@ -22,7 +25,7 @@ function! s:product(digits) abort

for digit in split(a:digits[1:], '\zs')
if digit !~? '\d'
throw 'invalid input'
return -1
endif
let prod = prod * digit
endfor
Expand Down
5 changes: 5 additions & 0 deletions exercises/practice/largest-series-product/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ description = "rejects invalid character in digits"

[5fe3c0e5-a945-49f2-b584-f0814b4dd1ef]
description = "rejects negative span"
include = false

[c859f34a-9bfe-4897-9c2f-6d7f8598e7f0]
description = "rejects negative span"
reimplements = "5fe3c0e5-a945-49f2-b584-f0814b4dd1ef"
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ Execute (rejects empty string and nonzero span):
AssertEqual expected, LargestProduct(input, span)

Execute (rejects invalid character in digits):
AssertThrows call LargestProduct('1234a5', 2)
AssertEqual 'invalid input', g:vader_exception
let input = "1234a5"
let span = 2
let expected = -1
AssertEqual expected, LargestProduct(input, span)

Execute (rejects negative span):
let input = "12345"
Expand Down
24 changes: 24 additions & 0 deletions exercises/practice/phone-number/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ description = "cleans numbers with multiple spaces"

[598d8432-0659-4019-a78b-1c6a73691d21]
description = "invalid when 9 digits"
include = false

[2de74156-f646-42b5-8638-0ef1d8b58bc2]
description = "invalid when 9 digits"
reimplements = "598d8432-0659-4019-a78b-1c6a73691d21"
include = false

[57061c72-07b5-431f-9766-d97da7c4399d]
description = "invalid when 11 digits does not start with a 1"
Expand All @@ -32,12 +38,30 @@ description = "valid when 11 digits and starting with 1 even with punctuation"

[c6a5f007-895a-4fc5-90bc-a7e70f9b5cad]
description = "invalid when more than 11 digits"
include = false

[4a1509b7-8953-4eec-981b-c483358ff531]
description = "invalid when more than 11 digits"
reimplements = "c6a5f007-895a-4fc5-90bc-a7e70f9b5cad"
include = false

[63f38f37-53f6-4a5f-bd86-e9b404f10a60]
description = "invalid with letters"
include = false

[eb8a1fc0-64e5-46d3-b0c6-33184208e28a]
description = "invalid with letters"
reimplements = "63f38f37-53f6-4a5f-bd86-e9b404f10a60"
include = false

[4bd97d90-52fd-45d3-b0db-06ab95b1244e]
description = "invalid with punctuations"
include = false

[065f6363-8394-4759-b080-e6c8c351dd1f]
description = "invalid with punctuations"
reimplements = "4bd97d90-52fd-45d3-b0db-06ab95b1244e"
include = false

[d77d07f8-873c-4b17-8978-5f66139bf7d7]
description = "invalid if area code starts with 0"
Expand Down
4 changes: 0 additions & 4 deletions exercises/practice/phone-number/phone_number.vader
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"
" Common test data version: 1.2.0
"

Execute (cleans the number):
AssertEqual '2234567890', ToNANP('(223) 456-7890')

Expand Down
49 changes: 49 additions & 0 deletions exercises/practice/run-length-encoding/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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.

[ad53b61b-6ffc-422f-81a6-61f7df92a231]
description = "run-length encode a string -> empty string"

[52012823-b7e6-4277-893c-5b96d42f82de]
description = "run-length encode a string -> single characters only are encoded without count"

[b7868492-7e3a-415f-8da3-d88f51f80409]
description = "run-length encode a string -> string with no single characters"

[859b822b-6e9f-44d6-9c46-6091ee6ae358]
description = "run-length encode a string -> single characters mixed with repeated characters"

[1b34de62-e152-47be-bc88-469746df63b3]
description = "run-length encode a string -> multiple whitespace mixed in string"

[abf176e2-3fbd-40ad-bb2f-2dd6d4df721a]
description = "run-length encode a string -> lowercase characters"

[7ec5c390-f03c-4acf-ac29-5f65861cdeb5]
description = "run-length decode a string -> empty string"

[ad23f455-1ac2-4b0e-87d0-b85b10696098]
description = "run-length decode a string -> single characters only"

[21e37583-5a20-4a0e-826c-3dee2c375f54]
description = "run-length decode a string -> string with no single characters"

[1389ad09-c3a8-4813-9324-99363fba429c]
description = "run-length decode a string -> single characters with repeated characters"

[3f8e3c51-6aca-4670-b86c-a213bf4706b0]
description = "run-length decode a string -> multiple whitespace mixed in string"

[29f721de-9aad-435f-ba37-7662df4fb551]
description = "run-length decode a string -> lowercase string"

[2a762efd-8695-4e04-b0d6-9736899fbc16]
description = "encode and then decode -> encode followed by decode gives original string"

0 comments on commit 761f926

Please sign in to comment.