Such dependence on the magnitude of the target value may lead to false positives in our case, so it's probably a good idea to write an expect_ variant or any other solution that always uses absolute tolerances, such as setting scale = 1 to end up in all.equal.
Testthat's
expect_equal
can work with a tolerance, but whether this tolerance is absolute or relative actually depends on the version (waldo:::num_equal
in 3e,testthat:::compare.numeric
in 2e), possibly its size compared to the target value, or the specific path taken bytestthat:::compare.numeric
andall.equal
.Such dependence on the magnitude of the target value may lead to false positives in our case, so it's probably a good idea to write an
expect_
variant or any other solution that always uses absolute tolerances, such as settingscale = 1
to end up inall.equal
.