Skip to content

Simplify canonical data types #430

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 8 commits into from
Sep 9, 2017
Merged

Simplify canonical data types #430

merged 8 commits into from
Sep 9, 2017

Conversation

ErikSchierboom
Copy link
Member

This PR is quite a big refactoring of the canonical data type handling. It contains lots of things: some use of dynamic, the ConstructorInput and Input properties referring to the Properties values instead of being copies, and much more :) With these changes, many exercises could further be simplified. The only exercises I'm not completely happy with are the alphametics and word-count exercises, which deal with dictionary conversions.

@jpreese
Copy link
Contributor

jpreese commented Sep 8, 2017

Oh boy, this is a big one :) Honestly I think my only critique is that I want Convert out of the Exercises/ dir!

Obviously it works and less code is required to generate some of the tests. I don't see anything that here that is a major red flag to me.

Copy link
Contributor

@robkeim robkeim left a comment

Choose a reason for hiding this comment

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

Great work @ErikSchierboom! One minor nit but I'll go ahead and merge as-is.

@@ -20,38 +20,30 @@ protected override void UpdateCanonicalData(CanonicalData canonicalData)
{
// Process expected
if (IsComplexNumber(canonicalDataCase.Expected))
{
Copy link
Contributor

Choose a reason for hiding this comment

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

@ErikSchierboom - between you, @jpreese, and I are style for when to use braces is clearly different... there are PRs where they're being added and removed:)

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha, true. I tend to not bother with these kind of changes since it does boil down to preferences, but sometimes you just cant resist. I love braces!

Copy link
Member Author

Choose a reason for hiding this comment

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

@robkeim @jpreese Yeah, there is some stylistic difference between us ;) Perhaps we should start a discussion at #398.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ErikSchierboom ok sounds good!

@@ -62,55 +54,36 @@ protected override string RenderTestMethodBodyAssert(TestMethodBody testMethodBo

private static string RenderComplexNumberAssert(TestMethodBody testMethodBody)
{
var template = "Assert.Equal({{ ExpectedParameter }}.Real(), {{ TestedValue }}.Real(), 15);\r\nAssert.Equal({{ ExpectedParameter }}.Imaginary(), {{ TestedValue }}.Imaginary(), 15);";
const string template = "Assert.Equal({{ ExpectedParameter }}.Real(), {{ TestedValue }}.Real(), precision: 15);\r\nAssert.Equal({{ ExpectedParameter }}.Imaginary(), {{ TestedValue }}.Imaginary(), precision: 15);";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! This change definitely makes the output feel more natural and not like it was written by a program :)


return TemplateRenderer.RenderInline(template, testMethodBody.AssertTemplateParameters);
}

protected override HashSet<string> AddAdditionalNamespaces()
protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string>
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: For consistency with other places in the code this should all be on one line

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed

@robkeim robkeim merged commit 62522c3 into exercism:master Sep 9, 2017
@robkeim
Copy link
Contributor

robkeim commented Sep 9, 2017

Great work, @ErikSchierboom 🎉

@ErikSchierboom ErikSchierboom deleted the simplify-canonical-data-types branch September 9, 2017 14:08
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