Skip to content

Values in flex/transformations unit test seem wrong #133

@travisdowns

Description

@travisdowns

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions