usually_return_1 <- function(i) {
if (runif(1) < 0.1) 0 else 1
}
if (FALSE) {
# 10% chance of failure:
expect_equal(usually_return_1(), 1)
# 1% chance of failure:
try_again(1, expect_equal(usually_return_1(), 1))
# 0.1% chance of failure:
try_again(2, expect_equal(usually_return_1(), 1))
}
Run the code above in your browser using DataLab