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

[BigInteger] Parse test with trailing spaces fails on some cultures #14545

Closed
Maxwe11 opened this issue May 6, 2015 · 13 comments · Fixed by dotnet/corefx#15587
Closed

[BigInteger] Parse test with trailing spaces fails on some cultures #14545

Maxwe11 opened this issue May 6, 2015 · 13 comments · Fixed by dotnet/corefx#15587
Labels
area-System.Numerics good first issue Issue should be easy to implement, good for first-time contributors test-bug Problem in test source code (most likely)
Milestone

Comments

@Maxwe11
Copy link
Contributor

Maxwe11 commented May 6, 2015

System.Numerics.Tests.parseTest.RunParseToStringTests [FAIL]
    Assert.Throws() Failure
    Expected: typeof(System.FormatException)
    Actual:   (No exception was thrown)
    Stack Trace:
       m:\Workspace\github\corefx\src\System.Runtime.Numerics\tests\BigInteger\parse.cs(408,0): at System.Numerics.Tests.parseTest.VerifyParseToString(String num1, NumberStyles ns, Boolean failureNotExpected, String expected)
       m:\Workspace\github\corefx\src\System.Runtime.Numerics\tests\BigInteger\parse.cs(380,0): at System.Numerics.Tests.parseTest.VerifyParseToString(String num1, NumberStyles ns, Boolean failureNotExpected)
       m:\Workspace\github\corefx\src\System.Runtime.Numerics\tests\BigInteger\parse.cs(247,0): at System.Numerics.Tests.parseTest.VerifyNumberStyles(NumberStyles ns, Random random)
       m:\Workspace\github\corefx\src\System.Runtime.Numerics\tests\BigInteger\parse.cs(33,0): at System.Numerics.Tests.parseTest.RunParseToStringTests()
Finished:    System.Runtime.Numerics.Tests
=== TEST EXECUTION SUMMARY ===
System.Runtime.Numerics.Tests  Total: 2, Errors: 0, Failed: 1, Skipped: 0, Time: 20,751s

Repro steps:

  1. Start->Run (WinKey + R) -> intl.cpl
  2. Change format (no need to change locale) to Ukrainian (Ukraine)
  3. build /p:WithCategories=OuterLoop

Possible solution: dotnet/corefx#1592 (comment)

Maxwe11 referenced this issue in Maxwe11/corefx May 6, 2015
This fixes a bunch of tests which fail due to decimal separator is not a dot (#1491).
But test method still disabled due to #1642
Maxwe11 referenced this issue in Maxwe11/corefx May 6, 2015
This fixes a bunch of tests which fail due to decimal separator is not a dot (#1491).
But test method still disabled due to #1642
@Maxwe11 Maxwe11 changed the title [BigInteger] Test on trailing spaces fails on some cultures [BigInteger] Parse test with trailing spaces fails on some cultures May 6, 2015
@mellinoe mellinoe removed their assignment Sep 26, 2016
@AlexGhiondea
Copy link
Contributor

Looks like we know what needs to happen here. It is a simple fix that would be a great place to start looking at the CoreFx code.

@ghost
Copy link

ghost commented Jan 26, 2017

I'm looking for an opportunity to get started contributing to .NET Core. Would it be possible to get this issue assigned to me?

@mellinoe
Copy link
Contributor

I'm looking for an opportunity to get started contributing to .NET Core. Would it be possible to get this issue assigned to me?

Sure!

I'll try to give you an updated set of instructions to use to repro this. Since this was filed so long ago (almost 2 years), we're not even sure if it still repros. Chances are it still does, though, because none of us run the tests in a Ukrainian environment as far as I know.

Steps:

  • Clone repo
  • Run build.cmd
    Run build-tests.cmd -- /p:Outerloop=true

If you then want to repro the individual test project that is failing, you can run

msbuild src\System.Runtime.Numerics\tests\System.Runtime.Numerics.Tests.csproj /t:RebuildAndTest /p:Outerloop=true

@mellinoe
Copy link
Contributor

@karelz I think we need to add @dennisdietrich to the "Contributors" group before I can assign him any issues. How do we do that, again?

@karelz
Copy link
Member

karelz commented Jan 26, 2017

Invitation sent (you need super-powers in dotnet org to make it happen).
@dennisdietrich please ping me here, when you accept and I will assign it to you.

@karelz karelz self-assigned this Jan 26, 2017
@ghost
Copy link

ghost commented Jan 26, 2017

Thanks @karelz! Done.

@mellinoe mellinoe assigned ghost and unassigned karelz Jan 26, 2017
@ghost
Copy link

ghost commented Jan 27, 2017

@mellinoe, quick question (I'm sure this is documented somewhere but I can't find it): What about line endings? Should they be Windows or UNIX-style/what value is preferred for core.autocrlf?

@mellinoe
Copy link
Contributor

what value is preferred for core.autocrlf

True, I believe. TBH I've never actively thought of this; we use the default as far as I know.

@ghost
Copy link

ghost commented Jan 27, 2017

@mellinoe, the good news (I guess) is that I can repro the issue. Unfortunately, so far I'm unable to build System.Runtime.Numerics.sln in VS (trying to get help on Gitter).

@ghost
Copy link

ghost commented Jan 28, 2017

Still stuck trying to build/debug corefx in VS so it's difficult to do a root cause analysis. However, since I can reproduce on the command line I've looked at the stack trace and so far this looks like a legitimate product bug to me (though it is labeled 'test bug'). First of all, the test passes for invariant, en-US, de-DE, and hi-IN. Second, it chokes on trailing 0x20 characters for uk-UA which is just a regular space.

Edit: Checked CultureInfo.NumberFormat for uk-UA but that just seems to confirm my result so far. It is using whitespace characters in a few places but those are 0xA0 and not 0x20.

@ghost
Copy link

ghost commented Jan 28, 2017

N/m. Found this method in FormatProvider.Number so I guess this is by-design and it's interpreting the trailing 0x20 as a trailing group separator. Preparing a PR on the basis of this assumption.

private static unsafe char* MatchChars(char* p, char* str)
{
    Debug.Assert(p != null && str != null);

    if (*str == '\0')
    {
        return null;
    }

    // We only hurt the failure case
    // This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 as a
    // space character we use 0x20 space character instead to mean the same.
    while (*p == *str || (*str == '\u00a0' && *p == '\u0020'))
    {
        p++;
        str++;
        if (*str == '\0') return p;
    }
    return null;
}

@karelz
Copy link
Member

karelz commented Jan 28, 2017

Still stuck trying to build/debug corefx in VS

Can you provide some details? Maybe @weshaggard @mellinoe can help ...

@ghost
Copy link

ghost commented Jan 28, 2017

Already discussing this with Eric on Gitter (seemed like the better place for figuring this out). Thanks!

danmoseley referenced this issue in dotnet/corefx Jan 31, 2017
* Fixed BigInteger test failure for uk-UA

BigInteger string parsing test was faulty for cultures that use 0xA0
as the group separator. The fixed test does not expect an exception
anymore if:
 - The trailing whitespace is 0x20 characters only AND
 - Grouping is allowed (NumberStyles.AllowThousands) AND
 - Currency symbol is allowed and currency group separator is 0xA0 OR
   Currency symbol is not allowed and number group separator is 0xA0

Fix #1642

* Additional inline code documentation

Added comment to FailureNotExpectedForTrailingWhite(NumberStyles, bool)
in System.Numerics.Tests.parseTest explaining the need for/function of
that method.

Fix #1642
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.0.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Numerics good first issue Issue should be easy to implement, good for first-time contributors test-bug Problem in test source code (most likely)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants