tests/testthat/test-i_recycle.R

test_that("Indefinite i_recycle of integer sequence", {
  it <- i_recycle(1:3)

  expect_equal(nextOr(it, NA), 1)
  expect_equal(nextOr(it, NA), 2)
  expect_equal(nextOr(it, NA), 3)

  expect_equal(nextOr(it, NA), 1)
  expect_equal(nextOr(it, NA), 2)
  expect_equal(nextOr(it, NA), 3)

  expect_equal(nextOr(it, NA), 1)
})

test_that("i_recycle repeats integer fixed number of times", {
  it <- i_recycle(1:3, times=2)

  expect_equal(nextOr(it, NA), 1)
  expect_equal(nextOr(it, NA), 2)
  expect_equal(nextOr(it, NA), 3)

  expect_equal(nextOr(it, NA), 1)
  expect_equal(nextOr(it, NA), 2)
  expect_equal(nextOr(it, NA), 3)

  expect_equal(nextOr(it, NA), NA)
})

Try the iterors package in your browser

Any scripts or data that you put into this service are public.

iterors documentation built on May 31, 2023, 5:36 p.m.