Skip to content

Consider trivia when testing code fixes and refactorings#21439

Merged
CyrusNajmabadi merged 4 commits intodotnet:masterfrom
sharwell:consider-trivia
Aug 11, 2017
Merged

Consider trivia when testing code fixes and refactorings#21439
CyrusNajmabadi merged 4 commits intodotnet:masterfrom
sharwell:consider-trivia

Conversation

@sharwell
Copy link
Contributor

@sharwell sharwell commented Aug 11, 2017

  • Change ignoreTrivia to default to false
  • Fix tests so the expected test results accurately reflect reality, including trivia

Reviewers: The main item to verify is that this pull request only changes expected test outputs. Test inputs should remain the same. One (seemingly unavoidable) exception is indicated with a ⚠️ comment.

📝 The changes to expected test results reveal a large number of bugs. These will be identified in comments in this PR, and bugs filed so they can be fixed later.

@sharwell sharwell added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Aug 11, 2017
Copy link
Contributor Author

Choose a reason for hiding this comment

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

💭 It seems like the previous version was correct here, but I'm not certain enough to call it a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➡️ #21453

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 ignoreTrivia is totally ignored here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➡️ #21454

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💭 This formatting seems sub-optimal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 This directive disappeared.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➡️ #21455

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 This directive disappeared.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dim c = TryCast(obj, c1(Of V, U))
Return c IsNot Nothing AndAlso EqualityComparer(Of V).Default.Equals(x, c.x)
Return c IsNot Nothing AndAlso
EqualityComparer(Of V).Default.Equals(x, c.x)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 This formatting is not consistent with the smart indent implementation. The second line should be indented 4 spaces, not 7.

sub M()
for each (v in x)
{|Warning:dim i = CInt(0)|}
{|Warning:dim i = CInt(0)|}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 Incorrect indentation

if true
dim x as integer = 5
dim x as integer
= 5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 Should not have split the line.

End Namespace|]",
"Imports System, System.Collections.Generic
Module Program
"Imports System, System.Collections.Generic Module Program
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 Module should still appear on the next line.

End Class
End Namespace|]",
"Imports A
"Imports A _
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🐛 Should omit _.

Copy link
Member

Choose a reason for hiding this comment

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

Curious, do you use some tool to update assertions based on the actual output?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I manually reviewed each case. 😦

Copy link
Member

Choose a reason for hiding this comment

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

Currently my bottleneck is the test-runner - tried a couple of other tools. It's really inconvenient to use command-line or wpf xunit runner. I'm wondering if either of those are what you're using for local testing.

Copy link
Contributor Author

@sharwell sharwell Aug 11, 2017

Choose a reason for hiding this comment

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

I used the WPF runner. I made a note from this work regarding some additional potential areas for improvement.

Copy link
Member

Choose a reason for hiding this comment

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

That's great! I'm looking forward to it. Thanks.


Case "File"
Return String.Join(vbCrLf, lines)
Return testSource.NormalizedValue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

⚠️ This causes some test inputs to change (addition of blank lines at the beginning and/or end of the input), but I didn't see a clean way to separate the two.

@sharwell sharwell removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Aug 11, 2017
@sharwell sharwell requested a review from a team August 11, 2017 14:18
@CyrusNajmabadi
Copy link
Contributor

Change ignoreTrivia to default to false

Any need to have the option at all now? I think it ahs served its purpose. It was originally used because of too much churn in the formatter, but now that that has stabilized, i would be fine with it going away.

@sharwell
Copy link
Contributor Author

sharwell commented Aug 11, 2017

Any need to have the option at all now? I think it ahs served its purpose. It was originally used because of too much churn in the formatter, but now that that has stabilized, i would be fine with it going away.

@CyrusNajmabadi The PR is unmanageable with that change merged with this one. The next step is removing over 1000 places where it's explicitly specified to be false (now the default). Then we can look at removing it.

@alrz
Copy link
Member

alrz commented Aug 11, 2017

Then we can look at removing it.

It is very useful when you're just verifying the behavior without worrying about trivia. After that it should be required to be false (or absent with default=false) before merge.

@CyrusNajmabadi
Copy link
Contributor

It is very useful when you're just verifying the behavior without worrying about trivia. After that it should be required to be false

Seems reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants