diff --git a/R/pb.R b/R/pb.R index 92f07d2..c971f49 100644 --- a/R/pb.R +++ b/R/pb.R @@ -4,7 +4,7 @@ #' Makes the object spawn a progress bar in response to indexing with `[[` #' operator. Intended to be used with most iterators in R, e.g.: #' [base::lapply()] and some of its cousins, [base::Reduce()], -#' [parallel::mclapply()], [purrr::map()], [foreach::foreach()]... +#' [plyr::llply()], [purrr::map()], [foreach::foreach()]... #' #' @param object `ANY`\cr #' An iterable that should spawn a progress bar. diff --git a/man/pb.Rd b/man/pb.Rd index 4f71e85..cc52f4a 100644 --- a/man/pb.Rd +++ b/man/pb.Rd @@ -28,7 +28,7 @@ progress bar display in response to indexing. Makes the object spawn a progress bar in response to indexing with \code{[[} operator. Intended to be used with most iterators in R, e.g.: \code{\link[base:lapply]{base::lapply()}} and some of its cousins, \code{\link[base:funprog]{base::Reduce()}}, -\code{\link[parallel:mcdummies]{parallel::mclapply()}}, \code{\link[purrr:map]{purrr::map()}}, \code{\link[foreach:foreach]{foreach::foreach()}}... +\code{\link[plyr:llply]{plyr::llply()}}, \code{\link[purrr:map]{purrr::map()}}, \code{\link[foreach:foreach]{foreach::foreach()}}... } \examples{ result <- lapply(pb(6:20), gmp::factorize) diff --git a/tests/testthat/test-pb-methods.R b/tests/testthat/test-pb-methods.R new file mode 100644 index 0000000..2e40918 --- /dev/null +++ b/tests/testthat/test-pb-methods.R @@ -0,0 +1,16 @@ +test_that("no progress bar call is being made when using str()", { + x <- pb(seq(10)) + pre_val <- aurrera:::.PROGRESS_BAR$getVal() + suppress_output(str(x)) + expect_equal( + aurrera:::.PROGRESS_BAR$getVal(), + pre_val + ) +}) + +test_that("`aurrera_iter` class is preserved when using c()", { + x <- pb(seq(10)) + expect_vector(c(x, 17:20), + ptype = pb(1L), + size = 14) +}) diff --git a/tests/testthat/test-pb.R b/tests/testthat/test-pb.R index 7b39031..b7873b3 100644 --- a/tests/testthat/test-pb.R +++ b/tests/testthat/test-pb.R @@ -44,13 +44,18 @@ test_that("purrr::map_chr() returns correct value", { # PARALLEL::MCLAPPLY ---------------------------------------------------------- test_that("pb() prints progress bar inside parallel::mclapply()", { expect_equal( - capture_output(parallel::mclapply(pb(x), identity), width = width), + capture_output( + parallel::mclapply(pb(x), identity, mc.preschedule = FALSE), + width = width + ), bar ) }) test_that("parallel::mclapply() returns correct value", { - suppress_output(ret <- parallel::mclapply(pb(x), identity)) + suppress_output( + ret <- parallel::mclapply(pb(x), identity, mc.preschedule = FALSE) + ) expect_equal(ret, x) })