Skip to content

Conversation

@tannergooding
Copy link
Member

@tannergooding tannergooding commented Apr 14, 2022

These apparently didn't get checked in alongside the integer tests like they should've. I've extracted them from #67939 since that is otherwise blocked (hopefully due to something specific to the changes in that PR)

There are no changes from #67939 which has already been reviewed/approved, so you shouldn't feel the need to re-review the files.

@ghost
Copy link

ghost commented Apr 14, 2022

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link

ghost commented Apr 14, 2022

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

These apparently didn't get checked in alongside the integer tests like they should've. I've extracted them from #67939 since that is otherwise blocked (hopefully due to something specific to the changes in that PR)

There are no changes from #67939 which has already been reviewed/approved, so you shouldn't feel the need to re-review the files.

Author: tannergooding
Assignees: tannergooding
Labels:

area-System.Runtime

Milestone: -

Copy link
Contributor

@dakersnar dakersnar left a comment

Choose a reason for hiding this comment

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

Already approved the previous PR, so I'm assuming this is all good.

Copy link
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

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

I strongly prefer the use of [Theory] with [InlineData] or [MemberData] over [Fact] with many asserts to capture the scenarios. With a [Theory], regressions surface N times more failures and the impact is much more obvious than a [Fact] that fails on the first regressed scenario. Are all scenarios broken, a subset, or just one?

With the sheer number of asserts that exist herein though, would we incur overhead from [Theory] with measurable difference in build time? Or is there another reason why you're favoring multi-assert [Fact] tests?

Approved as this recommendation isn't a blocker, but I'd like it to be considered

AssertBitwiseEqual(1.0, NumberHelper<double>.CreateSaturating<nuint>((nuint)0x00000001));
AssertBitwiseEqual(2147483647.0, NumberHelper<double>.CreateSaturating<nuint>((nuint)0x7FFFFFFF));

// https://github.com/dotnet/roslyn/issues/60714
Copy link
Member

Choose a reason for hiding this comment

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

I suggest breaking these commented-out asserts (in both branches) into a new test, and annotating with [ActiveIssue] instead of commenting them out. The new tests would then have names that denote the trait that makes them fail currently.

And this comment is true for each place you have tests commented out.

@tannergooding
Copy link
Member Author

tannergooding commented Apr 15, 2022

I strongly prefer the use of [Theory] with [InlineData] or [MemberData] over [Fact] with many asserts to capture the scenarios.

I'd generally agree. However these are all very basic tests covering the primitives where we are really doing the bare minimum validation that the one line implementation isn't falling over at runtime.

Given the 14 different types and that there needs to be tests covering conversion between the 14 different types to each other, this effectively becomes a combinatorics problem where its much simpler to just copy past the literal code with a simple find/replace for each type. It then also handles the issues around types like Half or special values that cannot be represented in attributes.

-- If we were using nunit, where a lot of the basic support for these kinds of problems are built-in, I likely would've gone a different route.

@tannergooding tannergooding merged commit 300616e into dotnet:main Apr 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators May 15, 2022
@tannergooding tannergooding deleted the generic-math-float-tests branch November 11, 2022 15:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants