From 3046ab019649e906647ea1ae0b86c1f105a4871e Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Mon, 8 Jul 2024 21:22:11 -0700 Subject: [PATCH] progress --- R/construction_helpers.R | 4 ---- tests/testthat/test-construction_helpers.R | 12 +++++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/R/construction_helpers.R b/R/construction_helpers.R index 5af416a4..3474e6dc 100644 --- a/R/construction_helpers.R +++ b/R/construction_helpers.R @@ -161,10 +161,6 @@ construct_model.survey.design <- function(data, formula, method, method.args = l return(call_args(x_enexpr)) } - if (tryCatch(inherits(x, "list"), error = \(x) FALSE)) { - return(x) - } - cli::cli_abort( c("There was an error processing the {.arg {argname}} argument.", i = "Expecting a simple call. See {.help rlang::is_call_simple} for details." diff --git a/tests/testthat/test-construction_helpers.R b/tests/testthat/test-construction_helpers.R index 16f2da22..faba50ac 100644 --- a/tests/testthat/test-construction_helpers.R +++ b/tests/testthat/test-construction_helpers.R @@ -36,19 +36,21 @@ test_that("construct_model() works", { ) # styler: off + expect_error({ + outside_fun <- function() .as_list_of_exprs(x = !!expr(list())) + outside_fun()}, + NA + ) expect_equal({ outside_fun <- function() { - method.args <- list() - - construct_model.data.frame( + construct_model( mtcars, formula = mpg ~ cyl, method = "lm", - method.args = method.args + method.args = !!expr(list()) ) |> coef() } - outside_fun()}, lm(mpg ~ cyl, mtcars) |> coef() )