with_mock(
all.equal = function(x, y, ...) TRUE,
expect_equal(2 * 3, 4),
.env = "base"
)
with_mock(
`base::identical` = function(x, y, ...) TRUE,
`base::all.equal` = function(x, y, ...) TRUE,
expect_equal(x <- 3 * 3, 6),
expect_identical(x + 4, 9)
)
throws_error()(expect_equal(3, 5))
throws_error()(expect_identical(3, 5))
Run the code above in your browser using DataLab