Skip to content

Commit

Permalink
if requireNamespace nc
Browse files Browse the repository at this point in the history
  • Loading branch information
tdhock committed Apr 12, 2024
1 parent 1d5a623 commit d09bb8d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: atime
Type: Package
Title: Asymptotic Timing
Version: 2024.2.13
Version: 2024.3.5
Authors@R: c(
person("Toby", "Hocking",
email="[email protected]",
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Changes in version 2024.3.5

- if(requireNamespace("nc")) in tests, thanks CRAN.

Changes in version 2024.2.13

- atime_grid gains new argument symbol.params, and more informative error messages.
Expand Down
63 changes: 32 additions & 31 deletions tests/testthat/test-CRAN.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,37 +173,6 @@ test_that("atime_grid ok when THREADS used", {
expect_equal(length(expr.list), 3)
})

test_that("error for expr.list not list", {
expr.list <- atime::atime_grid(
list(ENGINE=c(
if(requireNamespace("re2"))"RE2",
"PCRE",
if(requireNamespace("stringi"))"ICU")),
nc=nc::capture_first_vec(subject, pattern, engine=ENGINE))
dolist <- function(elist){
atime::atime(
N=1:25,
setup={
rep.collapse <- function(chr)paste(rep(chr, N), collapse="")
subject <- rep.collapse("a")
pattern <- list(maybe=rep.collapse("a?"), rep.collapse("a"))
},
expr.list=elist)
}
atime.list <- dolist(expr.list)
expect_is(atime.list, "atime")
expect_error({
dolist(structure(2, class=c("foo","bar")))
}, "expr.list should be a list of expressions to run for various N, but has classes foo, bar")
})

test_that("only one value in grid is OK", {
expr.list <- atime::atime_grid(
list(ENGINE="PCRE"),
nc=nc::capture_first_vec(subject, pattern, engine=ENGINE))
expect_identical(names(expr.list), "nc ENGINE=PCRE")
})

test_that("atime_grid symbol.params arg OK", {
grid.result <- atime::atime_grid(list(
PERL=TRUE,
Expand Down Expand Up @@ -370,3 +339,35 @@ test_that("atime_versions error when no versions specified", {
}, "need to specify at least one git SHA, in either sha.vec, or ...", fixed=TRUE)
})

if(requireNamespace("nc")){
test_that("only one value in grid is OK", {
expr.list <- atime::atime_grid(
list(ENGINE="PCRE"),
nc=nc::capture_first_vec(subject, pattern, engine=ENGINE))
expect_identical(names(expr.list), "nc ENGINE=PCRE")
})
test_that("error for expr.list not list", {
expr.list <- atime::atime_grid(
list(ENGINE=c(
if(requireNamespace("re2"))"RE2",
"PCRE",
if(requireNamespace("stringi"))"ICU")),
nc=nc::capture_first_vec(subject, pattern, engine=ENGINE))
dolist <- function(elist){
atime::atime(
N=1:25,
setup={
rep.collapse <- function(chr)paste(rep(chr, N), collapse="")
subject <- rep.collapse("a")
pattern <- list(maybe=rep.collapse("a?"), rep.collapse("a"))
},
expr.list=elist)
}
atime.list <- dolist(expr.list)
expect_is(atime.list, "atime")
expect_error({
dolist(structure(2, class=c("foo","bar")))
}, "expr.list should be a list of expressions to run for various N, but has classes foo, bar")
})
}

0 comments on commit d09bb8d

Please sign in to comment.