-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add exercise: luhn #177
Add exercise: luhn #177
Conversation
run jq -r -f luhn.jq << 'END_INPUT' | ||
{ | ||
"value": "1" | ||
} | ||
END_INPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather have
run jq -r -f luhn.jq << 'END_INPUT' | |
{ | |
"value": "1" | |
} | |
END_INPUT | |
run jq -r -f luhn.jq '"1"' |
but I did not spot a way to accomplish this through generate_tests.json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wrote generate_tests to grab the canonical-data "input" verbatim. Have a look at the generate_tests.json
file, if you would prefer to simplify the bats file and omit this exercise from the test generator.
And jq -r -f luhn.jq '"1"'
would give an error
jq: error: Could not open file "1": No such file or directory
You'd want one of
run jq -r -f luhn.jq <<< '"1"'
# or pass into jq as a variable
run jq -r -f luhn.jq --arg input 1
run jq -r -f luhn.jq << 'END_INPUT' | ||
{ | ||
"value": "1" | ||
} | ||
END_INPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wrote generate_tests to grab the canonical-data "input" verbatim. Have a look at the generate_tests.json
file, if you would prefer to simplify the bats file and omit this exercise from the test generator.
And jq -r -f luhn.jq '"1"'
would give an error
jq: error: Could not open file "1": No such file or directory
You'd want one of
run jq -r -f luhn.jq <<< '"1"'
# or pass into jq as a variable
run jq -r -f luhn.jq --arg input 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
I'd put the try
into the function, but I can do that in my own solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try
inside of parse_digit
? I'm not seeing how that could work out correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll just have to wait and see :)
This can come out of Draft status for merging, yes? |
I'm aiming to look at the tests' formatting tomorrow, and then undraft. |
Thank you @MatthijsBlom! |
Add the Luhn exercise for Slimline September.