Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

BigInteger based random testing of Decimal (part 2) #26338

Merged
merged 1 commit into from
Feb 1, 2018

Conversation

pentp
Copy link

@pentp pentp commented Jan 14, 2018

This is a continuation of #24053 and contains new tests for dotnet/corert#4997

int actual = decimal.ToInt32(d1);
throw new Xunit.Sdk.AssertActualExpectedException(typeof(OverflowException), actual, d1 + " ToInt32");
}
catch (OverflowException) { }
Copy link
Member

Choose a reason for hiding this comment

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

Can this use Assert.Throws instead?

Copy link
Member

Choose a reason for hiding this comment

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

Similar comment for BigInteger_ToOACurrency


In reply to: 162362932 [](ancestors = 162362932)

Copy link
Author

Choose a reason for hiding this comment

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

Assert.Throws loses the context (the input values).

[Fact]
public static void BigInteger_ToInt32()
{
int overflowBudget = 100;
Copy link
Member

Choose a reason for hiding this comment

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

The existing tests all use an overflowBudget of 1000, but these 2 new ones have 100. Why the difference?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand what overflowBudget is trying to achieve. Can you explain?


In reply to: 162363865 [](ancestors = 162363865)

Copy link
Author

Choose a reason for hiding this comment

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

The existing tests do N*N invocations (where N is about 1000), but these new tests run only N invocations so I reduced the max time spent on exception cases also somewhat. Should I remove the overflowBudget entirely from these new tests?

Copy link
Member

Choose a reason for hiding this comment

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

So overflowBudget is just about reducing test execution time? Do these tests take more than a few seconds to run?

My opinion would be if this will only add a couple hundred milliseconds to the testing time, I don't think the added complexity is worth it.

@@ -1455,6 +1455,159 @@ public static void Test()
}
}

[Fact]
public static void BigInteger_Floor()
Copy link
Contributor

Choose a reason for hiding this comment

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

If these were [Theory]s that took pairs of values then the message produced would be clearer as to the failing input if a test failed, making fixing it easier.

Copy link
Author

Choose a reason for hiding this comment

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

This code generates the same AssertActualExpectedException that would be generated when using a [Theory], but it runs a lot faster. GetRandomData produces about N=1000 decimals that are then tested in N * N, N * 29 or N invocations depending on the test.

}

[Fact]
public static void BigInteger_Ceiling()
Copy link
Member

Choose a reason for hiding this comment

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

Any reason these tests are called BigInteger? I guess I would have thought they would be called BigDecimal.

Copy link
Author

Choose a reason for hiding this comment

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

I used the same name for previous BigInteger based tests. I guess they could be called BigDecimal based also, but the BigDecimal type is a private type inside this test class only.

@pentp
Copy link
Author

pentp commented Feb 1, 2018

Can this be merged or should I rename the tests (including the previously added Cmp/Add/Mul/Div tests)?

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

Looks good. I'll merge when it is green. We can rename the tests separately, if necessary.

@eerhardt eerhardt merged commit 64634c7 into dotnet:master Feb 1, 2018
@pentp pentp deleted the DecimalTests2 branch February 2, 2018 17:21
@karelz karelz added this to the 2.1.0 milestone Feb 4, 2018
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Aug 26, 2019
…et#26338)

User may have extra expectations for the privatly owned array pools.
For example there could be an expectation that array never contains negative numbers (since user never puts them there). Uninitialized allocations can break such expectations.

Signed-off-by: dotnet-bot <[email protected]>
stephentoub pushed a commit that referenced this pull request Aug 26, 2019
User may have extra expectations for the privatly owned array pools.
For example there could be an expectation that array never contains negative numbers (since user never puts them there). Uninitialized allocations can break such expectations.

Signed-off-by: dotnet-bot <[email protected]>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Aug 26, 2019
…et#26338) (dotnet#26366)

User may have extra expectations for the privatly owned array pools.
For example there could be an expectation that array never contains negative numbers (since user never puts them there). Uninitialized allocations can break such expectations.

Signed-off-by: dotnet-bot <[email protected]>
stephentoub added a commit that referenced this pull request Aug 26, 2019
…) (#26366)

User may have extra expectations for the privatly owned array pools.
For example there could be an expectation that array never contains negative numbers (since user never puts them there). Uninitialized allocations can break such expectations.

Signed-off-by: dotnet-bot <[email protected]>
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
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.

5 participants