-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Simplify canonical data types #430
Conversation
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. |
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.
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)) | |||
{ |
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.
@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:)
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.
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!
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.
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.
@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);"; |
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.
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> |
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.
Minor: For consistency with other places in the code this should all be on one line
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.
Agreed
Great work, @ErikSchierboom 🎉 |
This PR is quite a big refactoring of the canonical data type handling. It contains lots of things: some use of
dynamic
, theConstructorInput
andInput
properties referring to theProperties
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 thealphametics
andword-count
exercises, which deal with dictionary conversions.