Skip to content

Commit

Permalink
adds some missing prefixes and bumps testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Jan 23, 2024
1 parent bffb4fb commit 35f2ab4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Suggests:
lubridate,
nestcolor (>= 0.1.0),
teal.data (>= 0.3.0.9010),
testthat (>= 3.0)
testthat (>= 3.1.5)
VignetteBuilder:
knitr
Config/Needs/website: insightsengineering/nesttemplate
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-string_ops.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test_that("`as_num` as a wide interpretation of input to extract numerics.", {
testthat::test_that("`as_num` as a wide interpretation of input to extract numerics.", {
dta <- list(
character = c("text10,20.5letter30.!", "!-.40$$-50e5[", NA),
factor = factor(c("]+60e-6, 7.7%%8L", "%90sep.100\"1L", NA_character_)),
Expand Down
36 changes: 18 additions & 18 deletions tests/testthat/test-substitute_names.R
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
test_that("substitute_q works as expected", {
testthat::test_that("substitute_q works as expected", {
result <- substitute_q(
qexpr = quote(a <- c + d),
env = list(c = 5, d = 3)
)
expected <- quote(a <- 5 + 3)
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

test_that("substitute_q fails on unquoted call", {
expect_error(substitute_q(c + d, env = list(c = 5, d = 3)))
testthat::test_that("substitute_q fails on unquoted call", {
testthat::expect_error(substitute_q(c + d, env = list(c = 5, d = 3)))
})

test_that("h_subst_lhs_names works as expected", {
testthat::test_that("h_subst_lhs_names works as expected", {
result <- h_subst_lhs_names(
qexpr = quote(c(a = d, b = 3, z = "foo")),
names = list(a = as.name("x"), z = as.name("y"))
)
expected <- quote(c(x = d, b = 3, y = "foo"))
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

test_that("substitute_lhs_names works as expected with nested expressions", {
testthat::test_that("substitute_lhs_names works as expected with nested expressions", {
result <- substitute_lhs_names(
qexpr = quote(anl <- anl %>% mutate(a = factor(a))),
names = list(a = as.name("AEBODSYS"))
)
expected <- quote(anl <- anl %>% mutate(AEBODSYS = factor(a)))
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

test_that("substitute_lhs_names does not lead to infinite recursion", {
testthat::test_that("substitute_lhs_names does not lead to infinite recursion", {
result <- substitute_lhs_names(
qexpr = quote(c(a = d, b = 3, z = "foo")),
names = list(b = as.name("x"), z = as.name("y"))
)
expected <- quote(c(a = d, x = 3, y = "foo"))
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

test_that("substitute_rhs works as expected", {
testthat::test_that("substitute_rhs works as expected", {
result <- substitute_rhs(
qexpr = quote(c(a = d, b = 3, z = "foo")),
env = list(d = as.name("x"), z = as.name("y"))
)
expected <- quote(c(a = x, b = 3, z = "foo"))
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

test_that("substitute_names works as expected", {
testthat::test_that("substitute_names works as expected", {
result <- substitute_names(
expr = c(a = d, b = 3, z = "foo"),
names = list(d = as.name("x"), z = as.name("y"))
)
expected <- quote(c(a = x, b = 3, y = "foo"))
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

test_that("substitute_names can also substitute other expressions if requested", {
testthat::test_that("substitute_names can also substitute other expressions if requested", {
result <- substitute_names(
expr = c(a = d, b = 3, z = doo),
names = list(d = as.name("x"), z = as.name("y")),
others = list(doo = "loo")
)
expected <- quote(c(a = x, b = 3, y = "loo"))
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

test_that("substitute_names works as expected with nested expressions", {
testthat::test_that("substitute_names works as expected with nested expressions", {
result <- substitute_names(
expr = anl <- anl %>% mutate(a = factor(a)),
names = list(a = as.name("AEBODSYS"))
)
expected <- quote(anl <- anl %>% mutate(AEBODSYS = factor(AEBODSYS)))
expect_identical(result, expected)
testthat::expect_identical(result, expected)
})

0 comments on commit 35f2ab4

Please sign in to comment.