PRL-PRG / genthat

A record-replay framework for the R programming language
14 stars 8 forks source link

Tracing keeps wrong return value #120

Open fikovnik opened 6 years ago

fikovnik commented 6 years ago

test-140.zip

ibrary(testthat)

.Random.seed <<- .ext.seed

test_that("parseJSON", {
    txt <- "[true,false,null]"
    bigint_as_char <- FALSE
    expect_equal(jsonlite:::parseJSON(txt = txt, bigint_as_char = bigint_as_char), list(TRUE, FALSE, NA))
})

The problem with this test that for the given txt jsonlite:::parseJSON returns list(TRUE, FALSE, NULL). There is somewhere a conversion between NULL and NA. This is one of the feature of jsonlite, but I do not see where.

The same is here:

test-2.zip

library(testthat)

.Random.seed <<- .ext.seed

test_that("parseJSON", {
    txt <- "[1,2,\"NA\",\"NaN\",\"Inf\",\"-Inf\",3.14]"
    bigint_as_char <- FALSE
    expect_equal(jsonlite:::parseJSON(txt = txt, bigint_as_char = bigint_as_char), list(1L, 2L, NA, NaN, Inf, -Inf, 3.14))
})

In this case it returns:

str(jsonlite:::parseJSON(txt = txt, bigint_as_char = F))
List of 7
 $ : int 1
 $ : int 2
 $ : chr "NA"
 $ : chr "NaN"
 $ : chr "Inf"
 $ : chr "-Inf"
 $ : num 3.14