From 35f2ab4525bb7d6d16186d28d860cc5c15ea2d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:37:12 +0100 Subject: [PATCH] adds some missing prefixes and bumps testthat --- DESCRIPTION | 2 +- tests/testthat/test-string_ops.R | 2 +- tests/testthat/test-substitute_names.R | 36 +++++++++++++------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ddf1b4cf80..9c315a2b0f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/tests/testthat/test-string_ops.R b/tests/testthat/test-string_ops.R index e738e1c541..786abb6fe9 100644 --- a/tests/testthat/test-string_ops.R +++ b/tests/testthat/test-string_ops.R @@ -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_)), diff --git a/tests/testthat/test-substitute_names.R b/tests/testthat/test-substitute_names.R index 279ac6b254..929edca066 100644 --- a/tests/testthat/test-substitute_names.R +++ b/tests/testthat/test-substitute_names.R @@ -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) })