This PR is to fix 2 libcxx test cases, test cases assumed 'a' > 'A' which is not case in z/OS platform on ebcdic mode, modified test cases to compare between upper letters or lower letters, or digits so ordering will be true for all platform.
Details
- Reviewers
hubert.reinterpretcast uweigand zibi muiez abhina.sree fanbo-meng • Quuxplusone - Group Reviewers
Restricted Project - Commits
- rG4f5ebfdcd6c9: [SystemZ][z/OS][libcxx]: fix libcxx test cases failed on ebcdic mode on z/OS
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp | ||
---|---|---|
25–27 | I think I'd prefer to see char lo = std::min('a', 'A'); char hi = std::max('a', 'A'); assert(std::char_traits<char>::lt(lo, hi)); With just your new tests, a case-insensitive comparison would pass the tests, and I think the intent of these tests is specifically to make sure a case-insensitive comparison won't pass. | |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp | ||
28 | Please use the same set of test inputs here as in the char test above. (Yeah, the old code also failed at this; but we can be better. :)) | |
35 | Btw, offhand I suspect a lot of (libc++ and otherwise) code won't work on non-ASCII platforms; would it perhaps make more engineering sense to look into build-system ways to make these tests run in ASCII mode? For example, maybe the test runner should be setting LC_ALL in the environment, or something like that. |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp | ||
---|---|---|
25–27 | I think the assertion Nancy has is essentially the same as the three liner you are proposing. To catch the case-insensitive comparison we should add: assert(std::char_traits<char>::lt('A','a') == !std::char_traits<char>::lt('a','A')); | |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp | ||
35 | It is important to run tests for the non-ASCII flavour of libc++ as well as the ASCII flavour. The good news is check-cxx works for both flavours. It is only a few tests like this one that has a built in assumption about the ordering of the subgroups (eg. lower case letters) within the character encoding that are failing. You are correct, the char{8,16,32}_t tests would pass because they use Unicode literals. The encoding for these are defined to have the ASCII encoding for the single character literals. |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp | ||
---|---|---|
25–27 | As Sean suggested. I can add assert(std::char_traits<char>::lt('A','a') == !std::char_traits<char>::lt('a','A')); | |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp | ||
28 | I can use same tests for both except one is char another is wchar_t |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp | ||
---|---|---|
25–27 | I guess that's acceptable, although I would still prefer a version that explicitly tests that lt returns the intended answer. assert(std::char_traits<char>::lt('A', 'a') == ('A' < 'a')); assert(std::char_traits<char>::lt('a', 'A') == ('a' < 'A')); assert(std::char_traits<char>::lt(' ', 'A') == (' ' < 'A')); assert(std::char_traits<char>::lt('A', '~') == ('A' < '~')); Then you can keep all the test cases from the left-hand side — you just have to add the appropriate == ('x' < 'y') for each of them. (Your new strictly-alphanumeric test cases are good additions; but I did think it was a pity to lose the ones testing punctuation, and this way we get to keep them.) | |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp | ||
28 | Yes, of course. |
- added assert(std::char_traits<char>::lt('A','a') == !std::char_traits<char>::lt('a','A')); for case insensitive test.
- make content of 2 test cases same except one testing char type another one testing wchar_t
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp | ||
---|---|---|
25–27 | sure I can use this pattern. Thanks |
Especially if the !s are removed, LGTM at this point.
I'm taking the liberty of marking it accepted for libc++ too, since I think it's fine to land. (If @ldionne overrules this, listen to him.)
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp | ||
---|---|---|
23 | At this point I recommend removing the ! from both sides. Ditto throughout. |
libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp | ||
---|---|---|
23 | sure I will remove "!" |
I'm fine with this change because of this:
@SeanP said:
It is only a few tests like this one that has a built in assumption about the ordering of the subgroups (eg. lower case letters) within the character encoding that are failing.
Otherwise, I think it would have been useful to have a discussion about how to handle those gracefully without introducing a lot of complexity into the test suite. If that's just a few changes, I think it's not worth wasting time over that and we should just find a simple way to fix the tests on a case by case basis.
At this point I recommend removing the ! from both sides. Ditto throughout.