This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Simplify the handling of platform specific NAN formatting in put_long_double
ClosedPublic

Authored by mstorsjo on Jan 26 2022, 4:17 AM.

Details

Summary

Also opt in to testing the hexadecimal float formatting for glibc; glibc does matches the current test references there.

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Jan 26 2022, 4:17 AM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2022, 4:17 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
mstorsjo updated this revision to Diff 407415.Feb 10 2022, 1:13 AM

Rebased on top of current git main, simplifying the already committed fix doing similar things.

mstorsjo retitled this revision from [libcxx] [test] Fix put_long_double on glibc to [libcxx] [test] Simplify the handling of platform specific NAN formatting in put_long_double.Feb 10 2022, 1:14 AM
mstorsjo edited the summary of this revision. (Show Details)
mstorsjo added a reviewer: Mordante.
Mordante added inline comments.Feb 10 2022, 10:00 AM
libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
10916–10917

How do you feel about always using strings like pnan_padding25 + pnan_sign + "nan" and not have pnan and PNAN?

24428

Is this change still needed? The test currently passes CI without this change.

mstorsjo added inline comments.Feb 10 2022, 10:40 AM
libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
10916–10917

That’d work for me too.

24428

It’s not needed, but this is a test that currently only is executed on apple platforms (because it hadn’t passed on FreeBSD). This test does pass on glibc too, so let’s run it there too, for increased test coverage.

mstorsjo updated this revision to Diff 407794.Feb 11 2022, 12:28 AM

Removed the pnan/PNAN strings and kept literal "nan" and "NAN".

If preferred, I could split out the change to opt in to the hexadecimal formatting tests into a separate change.

Mordante accepted this revision as: Mordante.Feb 11 2022, 8:58 AM

LGTM!

Quuxplusone accepted this revision.Feb 14 2022, 8:35 AM

I suggest an alternative approach, but I see no reason to block over that, so might as well accept. Feel free to adopt the IF_GLIBC idea or not, I guess.

libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
10900–10901

This is obscure enough I shouldn't really care, but wouldn't it be easier to understand the test if it was like

assert(ex == IF_GLIBC("+nan", "nan"));
~~~
assert(ex == IF_GLIBC("+nan*********************",
                      "nan**********************"));

and so on? (The IF_GLIBC macro would just be scoped to this one file.)

This revision is now accepted and ready to land.Feb 14 2022, 8:35 AM
mstorsjo added inline comments.Feb 14 2022, 8:47 AM
libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
10900–10901

I think I’d prefer to not go with this approach. I’ll add windows into the mix soon (which does the same as glibc here) so the macro naming would be less straightforward then. And going further, there could (theoretically, at least in some other test) be more than two different variations, which is easier if the conditionals are centralized.

I suggest an alternative approach, but I see no reason to block over that, so might as well accept. Feel free to adopt the IF_GLIBC idea or not, I guess.

I don't mind that approach, but then I prefer a global macro. There are more localization tests disabled due to glibc giving a different result.

I suggest an alternative approach, but I see no reason to block over that, so might as well accept. Feel free to adopt the IF_GLIBC idea or not, I guess.

I don't mind that approach, but then I prefer a global macro. There are more localization tests disabled due to glibc giving a different result.

I think I'll go with my original approach for now. Especially in this test, I think that results in less clunky code. And for other tests, given that there's more than two platforms that may want to expect different results, the exact form of handling it can differ a bit between all tests. (FWIW I have a couple more glibc locale fixes in my queue in various state of finished, and a bunch of more windows locale fixes on top of those too.)

This revision was landed with ongoing or failed builds.Feb 14 2022, 12:21 PM
This revision was automatically updated to reflect the committed changes.