Learn R Programming

testthatmulti (version 0.2.0)

ttm_expect_true: Test that multi: expect true

Description

See `testthat::expect_true` for details.

Usage

ttm_expect_true(object, info = NULL, label = NULL, verbose = 0)

Value

Test result

Arguments

object

Object to test.

info

Passed to `testthat::expect_true()`.

label

Passed to `testthat::expect_true()`.

verbose

Amount of info that should be printed.

Examples

Run this code
set.seed(0)

# 1 attempt, all pass
ttm(1, {
  ttm_expect_true(TRUE)
  ttm_expect_true(1 == 1)
  ttm_expect_true(all(1:5 == 1:5))
})

# Fails first 10 times, then passes
ttm(100, {
  x <- runif(1)
  print(x)
  ttm_expect_true(x < 0.1)
})

# Will always fail regardless of number of attempts
try({
  ttm(3, {
    ttm_expect_true(1 == 2)
  })
})

Run the code above in your browser using DataLab