set.seed(0)
# 1 attempt, all pass
ttm(1, {
ttm_expect_error(stop('error'))
})
# Fails first ~10 times, then passes
ttm(100, {
ttm_expect_error({
print(1)
if (runif(1) < 0.1) {
stop('give error')
}
})
})
# Will always fail regardless of number of attempts
try({
ttm(3, {
ttm_expect_error(1 == 2)
})
})
Run the code above in your browser using DataLab