Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exercises/practice/luhn/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"contributors": [
"ankorGH",
"gabriel376",
"jagdish-15",
"ovidiu141",
"rchavarria",
"ryanplusplus",
Expand Down
25 changes: 22 additions & 3 deletions exercises/practice/luhn/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# 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.

[792a7082-feb7-48c7-b88b-bbfec160865e]
description = "single digit strings can not be valid"
Expand All @@ -26,6 +33,9 @@ description = "invalid credit card"
[20e67fad-2121-43ed-99a8-14b5b856adb9]
description = "invalid long number with an even remainder"

[7e7c9fc1-d994-457c-811e-d390d52fba5e]
description = "invalid long number with a remainder divisible by 5"

[ad2a0c5f-84ed-4e5b-95da-6011d6f4f0aa]
description = "valid number with an even number of digits"

Expand All @@ -50,8 +60,17 @@ description = "more than a single zero is valid"
[ab56fa80-5de8-4735-8a4a-14dae588663e]
description = "input digit 9 is correctly converted to output digit 9"

[b9887ee8-8337-46c5-bc45-3bcab51bc36f]
description = "very long input is valid"

[8a7c0e24-85ea-4154-9cf1-c2db90eabc08]
description = "valid luhn with an odd number of digits and non zero first digit"

[39a06a5a-5bad-4e0f-b215-b042d46209b1]
description = "using ascii value for non-doubled non-digit isn't allowed"

[f94cf191-a62f-4868-bc72-7253114aa157]
description = "using ascii value for doubled non-digit isn't allowed"

[8b72ad26-c8be-49a2-b99c-bcc3bf631b33]
description = "non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed"
16 changes: 16 additions & 0 deletions exercises/practice/luhn/luhn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ describe('Luhn', () => {
expect(valid('1 2345 6789 1234 5678 9012')).toEqual(false);
});

xtest('invalid long number with a remainder divisible by 5', () => {
expect(valid('1 2345 6789 1234 5678 9013')).toEqual(false);
});

xtest('valid number with an even number of digits', () => {
expect(valid('095 245 88')).toEqual(true);
});
Expand Down Expand Up @@ -66,11 +70,23 @@ describe('Luhn', () => {
expect(valid('091')).toEqual(true);
});

xtest('very long input is valid', () => {
expect(valid('9999999999 9999999999 9999999999 9999999999')).toEqual(true);
});

xtest('valid luhn with an odd number of digits and non zero first digit', () => {
expect(valid('109')).toEqual(true);
});

xtest("using ascii value for non-doubled non-digit isn't allowed", () => {
expect(valid('055b 444 285')).toEqual(false);
});

xtest("using ascii value for doubled non-digit isn't allowed", () => {
expect(valid(':9')).toEqual(false);
});

xtest("non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed", () => {
expect(valid('59%59')).toEqual(false);
});
});