Skip to content
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

Semantic tokens tests: Use Linq instead #8256

Merged
merged 5 commits into from
Feb 18, 2023

Conversation

ryanbrandenburg
Copy link
Contributor

Summary of the changes

  • As per @phil-allen-msft's suggestion we should pre-filter the list instead of trying funny business with the array. Much cleaner.

@ryanbrandenburg ryanbrandenburg requested a review from a team as a code owner February 10, 2023 18:00
@@ -128,7 +121,7 @@ public async Task VerifyGetClassificationsAsync(IEnumerable<ClassificationSpan>
}
}

Assert.Equal(expectedArray.Length, actualArray.Length - actualOffset);
Assert.Equal(expectedArray.Length, actualArray.Length);
Copy link
Contributor

Choose a reason for hiding this comment

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

This assert is not doing anything any more: If the lengths weren't equal, we would have got index out of range exceptions on line 104/5.

I think this should be moved in front of the loop, just for good measure, and to provide a little more information than an index out of range exception would, should it ever fail.

var actualSemanticClassifications = actualClassifications.Where(a =>
a.ClassificationType.BaseTypes.Any() &&
a.ClassificationType is ILayeredClassificationType layeredClassificationType &&
layeredClassificationType.Layer == ClassificationLayer.Syntactic);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this now change to !=?

@davidwengier
Copy link
Contributor

Definitely much easier to understand that moving two indexes. Which I didn't 😝

Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

This is even easier to understand :)

@davidwengier
Copy link
Contributor

Oh no, I take it back. If expected is longer than actual it will help. My bad.

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.

2 participants