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

23: Breaks up nearest tests to not be singular test #43

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

khurd21
Copy link
Contributor

@khurd21 khurd21 commented Jul 5, 2024

Tests modified:

  • floor_test.cpp
  • trunc_test.cpp

Both adopts parameterized tests. These help reduce the expect calls and code duplication, also making it easier to add additional test cases in the future. NaN tests are still inside of the original TEST function.

Since the tests seemed to be directly comparing the function under test with the standard library equivalent, adjusted the std::signbit and std::isnan comparisons to directly compare equality in the NaN tests.

I also made sure to run the clang-format on the files that were modified.

@khurd21 khurd21 requested a review from Rinzii as a code owner July 5, 2024 05:55
@khurd21
Copy link
Contributor Author

khurd21 commented Jul 5, 2024

I saw this project and thought it was very well documented and heavily tested! I wanted to use this PR as an introduction and to see if changes like this for the tests are okay! I saw your card #23 . If these changes look okay, I would love to look into the other ones and format them similarly.

@Rinzii
Copy link
Owner

Rinzii commented Jul 7, 2024

Hello! Firstly, thank you for taking the time to create a PR for ccmath!

Overall, these changes are perfectly acceptable the only request I would have is that somewhere in the test we perform a static_assert to ensure the functions are being evaluated at compile time, but overall these changes seem pretty good!

@Rinzii Rinzii added the enhancement New feature or request label Jul 7, 2024
@Rinzii Rinzii linked an issue Jul 7, 2024 that may be closed by this pull request
Copy link
Owner

@Rinzii Rinzii left a comment

Choose a reason for hiding this comment

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

All that is required at the moment would be to add a static_assert to both of these test cases to ensure our functions work at compile time. Besides lgtm!

@khurd21 khurd21 force-pushed the 23-break-up-tests-nearest branch from fba76e5 to 11ef23d Compare July 9, 2024 00:28
@khurd21
Copy link
Contributor Author

khurd21 commented Jul 10, 2024

I tried giving this a good tackle and think I stumbled upon an issue. I noticed when I added the tests for compile time assertions, theccm::truncl yieled an error for the ninja-clang build only. The error is here:

https://github.com/Rinzii/ccmath/actions/runs/9848897543/job/27191697093#step:5:82

It seems like there is an improper type being passed into __builtin_bit_cast based on the message. I was unable to replicate this locally. I attempted to use the ninja-clang configuration preset but I was unable to get a successful build yet.

In the most recent push, I commented out the internals of the test with the constexpr ccm::truncl and it seems there is no issue with any of the other functions in the nearest folder.

What are you thoughts on this?

@khurd21 khurd21 force-pushed the 23-break-up-tests-nearest branch from 11ef23d to 8a42dd0 Compare July 10, 2024 06:59
@Rinzii
Copy link
Owner

Rinzii commented Jul 13, 2024

I tried giving this a good tackle and think I stumbled upon an issue. I noticed when I added the tests for compile time assertions, theccm::truncl yieled an error for the ninja-clang build only. The error is here:

https://github.com/Rinzii/ccmath/actions/runs/9848897543/job/27191697093#step:5:82

It seems like there is an improper type being passed into __builtin_bit_cast based on the message. I was unable to replicate this locally. I attempted to use the ninja-clang configuration preset but I was unable to get a successful build yet.

In the most recent push, I commented out the internals of the test with the constexpr ccm::truncl and it seems there is no issue with any of the other functions in the nearest folder.

What are you thoughts on this?

Sorry I‘ve been having a lot of IRL stuff going on recently and have not had much time to look at my GitHub. Is this issue still persisting?

@khurd21
Copy link
Contributor Author

khurd21 commented Jul 15, 2024

I tried giving this a good tackle and think I stumbled upon an issue. I noticed when I added the tests for compile time assertions, theccm::truncl yieled an error for the ninja-clang build only. The error is here:
https://github.com/Rinzii/ccmath/actions/runs/9848897543/job/27191697093#step:5:82
It seems like there is an improper type being passed into __builtin_bit_cast based on the message. I was unable to replicate this locally. I attempted to use the ninja-clang configuration preset but I was unable to get a successful build yet.
In the most recent push, I commented out the internals of the test with the constexpr ccm::truncl and it seems there is no issue with any of the other functions in the nearest folder.
What are you thoughts on this?

Sorry I‘ve been having a lot of IRL stuff going on recently and have not had much time to look at my GitHub. Is this issue still persisting?

No problem. Yes, the issue still is persisting. I have been trying to build using clang on Ubuntu locally, however I was getting other build errors before this one. In the current commit, I have commented out the compile time test I added for ccm::truncl. It seems that truncl is the only function out of the nearest tests that does not work at compile time for Linux Ninja Clang build.

If this sounds like an okay plan, I leave commented out compile time test here and have a card to address this properly in the future?

@Rinzii
Copy link
Owner

Rinzii commented Jul 15, 2024

I tried giving this a good tackle and think I stumbled upon an issue. I noticed when I added the tests for compile time assertions, theccm::truncl yieled an error for the ninja-clang build only. The error is here:
https://github.com/Rinzii/ccmath/actions/runs/9848897543/job/27191697093#step:5:82
It seems like there is an improper type being passed into __builtin_bit_cast based on the message. I was unable to replicate this locally. I attempted to use the ninja-clang configuration preset but I was unable to get a successful build yet.
In the most recent push, I commented out the internals of the test with the constexpr ccm::truncl and it seems there is no issue with any of the other functions in the nearest folder.
What are you thoughts on this?

Sorry I‘ve been having a lot of IRL stuff going on recently and have not had much time to look at my GitHub. Is this issue still persisting?

No problem. Yes, the issue still is persisting. I have been trying to build using clang on Ubuntu locally, however I was getting other build errors before this one. In the current commit, I have commented out the compile time test I added for ccm::truncl. It seems that truncl is the only function out of the nearest tests that does not work at compile time for Linux Ninja Clang build.

If this sounds like an okay plan, I leave commented out compile time test here and have a card to address this properly in the future?

Hmmm I’ll investigate this issue myself locally in a few days. I’ll see if I can identify what the problem may be. :)

@Rinzii
Copy link
Owner

Rinzii commented Jul 26, 2024

Ok, after looking into this it appears the issue is because of specific implementation details of how __builtin_bit_cast works on clang vs GCC. This issue is appearing due to __builtin_bit_cast inability to determine the value of long double since it will always be 16 bytes, but can be represented as either 80 or 128 bits. GCC appears to just let it fly but clang does not and errors out. There is no real simple way to solve this issue, so for simplicity I'd just get rid of this test with a macro if we are on clang and testing truncl specifically.

@khurd21 khurd21 force-pushed the 23-break-up-tests-nearest branch from 8a42dd0 to e02a166 Compare July 28, 2024 19:08
Tests modified:
- floor_test.cpp
- trunc_test.cpp

Both adopts parameterized tests. These help reduce the expect calls and
code duplication, also making it easier to add additional test cases in
the future. NaN tests are still inside of the original TEST function.

Since the tests seemed to be directly comparing the function under test
with the standard library equivalent, adjusted the `std::signbit` and
`std::isnan` comparisons to directly compare equality in the NaN tests.
@khurd21 khurd21 force-pushed the 23-break-up-tests-nearest branch from e02a166 to 823605a Compare July 28, 2024 19:27
@khurd21
Copy link
Contributor Author

khurd21 commented Jul 28, 2024

Ok, after looking into this it appears the issue is because of specific implementation details of how __builtin_bit_cast works on clang vs GCC. This issue is appearing due to __builtin_bit_cast inability to determine the value of long double since it will always be 16 bytes, but can be represented as either 80 or 128 bits. GCC appears to just let it fly but clang does not and errors out. There is no real simple way to solve this issue, so for simplicity I'd just get rid of this test with a macro if we are on clang and testing truncl specifically.

Sounds good! I updated the code. I added a macro to the cpp file here: https://github.com/Rinzii/ccmath/pull/43/files#diff-0ad15176bfaf60d1dd519b442c7412c099c1d2425808bd30e4823cf9ddd4722bR17

Since clang linux was the only one failing, I made sure to check the compiler was clang and the os was linux. I then undefined it at the end of the source file to try and reduce the scope of the macro to be just that test file.

Copy link
Owner

@Rinzii Rinzii left a comment

Choose a reason for hiding this comment

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

lgtm!

@Rinzii Rinzii merged commit dc72e75 into Rinzii:dev Jul 31, 2024
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants