#60 AssertEquals_REAL does not handle NaN

v1.3.0.0
open
hermsen
None
2022-05-24
2022-03-09
jtebokkel
No

What happened.

rlExpected := 1.0 / 0.0; // results in NaN
AssertEquals_REAL(0.0, rlExpected, 0.0001, 'comparison of a valid REAL and NaN should fail');

What I expected.

A comparison between a float value and NaN should be a fail.
Comparison between NaN, +Inf, -Inf should also be supported. If both Expected and Actual are NaN (etc) it should pass.

What happened instead.

The test passed.

Discussion

  • jtebokkel

    jtebokkel - 2022-03-09

    A note about this.

    It seems that if all the variables in the function I'm testing are 0.0 then the math can return NaN however if only the divisor (rl2) is 0.0 then the controller will throw a divide-by-zero exception.

    FUNCTION ExampleFunction : REAL
    VAR_INPUT
        rl1 : REAL;
        rl2 : REAL;
        rl3 : REAL;
    END_VAR
    
    ExampleFunction := (rl1 / rl2) * rl3;
    

    It is interesting the things you discover as you create more test cases. (Thanks for your work on this library <3 )

     

    Last edit: jtebokkel 2022-03-09
  • hermsen

    hermsen - 2022-03-09
     
  • hermsen

    hermsen - 2022-03-09

    Hi John,

    We are aware that certain details in the framework are sub optimal. However, that said, every tip/hint we get to optimise is one step in the right direction.

    So, since you found this issue, I hope you could also submit a patch which catches the Not A Number status and yields a fail in the assert.

    You can submit your patch in multiple ways. My suggestion would be that you just drop a code here in the Ticket. The reason behind this because I dont know if you hvae the Professional Developer Edition with Git , since we stepped over from SVN to git.

    PS Have you found it in v1200?

     
  • hermsen

    hermsen - 2022-05-24
    • status: open --> wont-fix
     
  • hermsen

    hermsen - 2022-05-24
    • status: wont-fix --> open
     
  • hermsen

    hermsen - 2022-05-24
    • assigned_to: h-hermsen
    • Milestone: v1.1.0.0 --> v1.3.0.0
     

Log in to post a comment.