Skip to content

test() doesn't distinguish plain NA_real_, NaN #7853

Description

@MichaelChirico
# no error
data.table:::test(1, NA_real_, NaN)
# but it's not totally NA-NaN-unaware
data.table:::test(1, list(NA_real_), list(NaN))
# Test 1 ran without errors but failed check that x equals y:
# > x = list(NA_real_) 
# First 1 of 1 (type 'list'): 
# [[1]]
# [1] NA

# > y = list(NaN) 
# First 1 of 1 (type 'list'): 
# [[1]]
# [1] NaN

Activity

  1. MichaelChirico commented on Jul 31, 2026

    @MichaelChirico
    MemberAuthor

    @jangorecki continuing discussion (#7864 (comment)) here.

    Further context is #7856, #7854.

    Maybe the right solution is instead to make list(NA_real_) vs. list(NaN) resolve to TRUE as it does in other contexts? But IIRC that was intentional for some tests in froll context where the goal was to be more "correct" about NA vs. NaN. WDYT?

  2. jangorecki commented on Aug 1, 2026

    @jangorecki
    Member

    I think we are correct but that behavior is not portable across different platforms. IMO we should not worry about that aspect as long as R core suggests to ignore it.

  3. MichaelChirico commented on Aug 4, 2026

    @MichaelChirico
    MemberAuthor

    Is there a simple behavioral test we could use to skip on platforms where we think the behavior is wrong/worse than ours? I'm still hung up on the inconsistent behavior:

    test(0,      NA,       NaN)  # pass
    test(0, list(NA), list(NaN)) # fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions