Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating tests for largest-series-product #2592

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"contributors": [
"ankorGH",
"jagdish-15",
"ovidiu141",
"petertseng",
"rchavarria",
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/largest-series-product/.meta/proof.ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ export const largestProduct = (digits, seriesLength) => {
return 1;
}
if (seriesLength > digits.length) {
throw new Error('Span must be smaller than string length');
throw new Error('span must be smaller than string length');
}
if (seriesLength < 0) {
throw new Error('Span must be greater than zero');
throw new Error('span must not be negative');
}

if (!/^[0-9]+$/g.test(digits)) {
throw new Error('Digits input must only contain digits');
throw new Error('digits input must only contain digits');
}

let result = 0;
Expand Down
18 changes: 15 additions & 3 deletions exercises/practice/largest-series-product/.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.

[7c82f8b7-e347-48ee-8a22-f672323324d4]
description = "finds the largest product if span equals length"
Expand Down Expand Up @@ -48,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 @@ -42,25 +42,25 @@ describe('Largest Series Product', () => {

xtest('rejects span longer than string length', () => {
expect(() => largestProduct('123', 4)).toThrow(
new Error('Span must be smaller than string length'),
new Error('span must be smaller than string length'),
);
});

xtest('rejects empty string and nonzero span', () => {
expect(() => largestProduct('', 1)).toThrow(
new Error('Span must be smaller than string length'),
new Error('span must be smaller than string length'),
);
});

xtest('rejects invalid character in digits', () => {
expect(() => largestProduct('1234a5', 2)).toThrow(
new Error('Digits input must only contain digits'),
new Error('digits input must only contain digits'),
);
});

xtest('rejects negative span', () => {
expect(() => largestProduct('12345', -1)).toThrow(
new Error('Span must be greater than zero'),
new Error('span must not be negative'),
);
});
});