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

Values in flex/transformations unit test seem wrong #133

Open
travisdowns opened this issue Oct 16, 2021 · 0 comments
Open

Values in flex/transformations unit test seem wrong #133

travisdowns opened this issue Oct 16, 2021 · 0 comments

Comments

@travisdowns
Copy link

travisdowns commented Oct 16, 2021

One of the tests in transformations.d has code like this:

        assert(iv.ltx.approxEqual(-8.75651e-27));
        assert(iv.lt1x.approxEqual(-1.02451e-24));
        assert(iv.lt2x.approxEqual(-1.18581e-22));

Note that all the expected values are negative and small.

However, when I actually print out these values immediately before the test, they are all positive (but otherwise the same):

iv.ltx  8.756510893e-27
iv.lt1x 1.024511801e-24
iv.lt2x 1.185806751e-22

How is it that the test is passing when the expected values have the wrong sign? Well, these values are all very small and appoxEqual with default arguments will accept any two values whose absolute difference is less than 1e5, so any two small value will always succeed regardless of their values.

Perhaps something like feqrel should be used instead: the values agree to at least 19 mantissa bits based on that function (if the sign is fixed), or just a purely "relative" test rather than dual relative + absolute tests like approxEqual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant