Skip to content

all-your-base: add test generator #945

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

Merged
merged 1 commit into from
Dec 17, 2017

Conversation

ferhatelmas
Copy link
Contributor

  • with putting assumption into hints

Copy link
Contributor

@leenipper leenipper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the canonical-data.json forced some test cases to now be errors which were not errors before, at least in the Go track. Oh well. There's not much way around that if we use that data.

I prefer preserving the error return value instead of a null slice. Test data can remain the same with adjustments to the example and the test program. But your choice.

}

if !digitsEqual(c.outputDigits, output) {
output := ConvertToBase(c.inputBase, c.inputDigits, c.outputBase)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping the explicit error return value and collapsing all the errors to a nil slice seems a bit atypical.

@ferhatelmas
Copy link
Contributor Author

ferhatelmas commented Nov 10, 2017

@leenipper Hold on this, there is an ongoing discussion and improvement: be explicit about errors[problem-specifications#1001] and be decisive about zeros[problem-specifications#1001]

@leenipper
Copy link
Contributor

Ok. Let it sit until some consensus.

@ferhatelmas ferhatelmas force-pushed the all-your-base-generator branch from b0e96e5 to 3391d09 Compare December 7, 2017 00:07
@ferhatelmas
Copy link
Contributor Author

@leenipper @tleen updated for review.

Copy link
Contributor

@leenipper leenipper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Only one optional item.

Handle problem cases with following messages:
* input base must be >= 2
* output base must be >= 2
* all digits must satisfy 0 <= d < input base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the test program does expect exact error match,
I'm wondering whether more specific Go wording in hints.md would be helpful. Perhaps:

Handle problem cases by returning an error whose Error() method
returns one of these strings:
"input base must be >= 2"
"output base must be >= 2"
"all digits must satisfy 0 <= d < input base"

Reading the test program would lead to same conclusion. Your choice on this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of hints as a more user-friendly way explaining expectations than using the test cases themselves. Although the test cases end up being the authority.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leenipper done so.

Copy link
Member

@tleen tleen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

 - canonical data assumption are hint file
@ferhatelmas ferhatelmas force-pushed the all-your-base-generator branch from 3391d09 to 44ed5f6 Compare December 17, 2017 01:12
@ferhatelmas ferhatelmas merged commit 8b37963 into exercism:master Dec 17, 2017
@ferhatelmas ferhatelmas deleted the all-your-base-generator branch December 17, 2017 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants