Skip to content

Commit 140ed13

Browse files
committed
Merge branch '211_subset@main' of https://github.com/insightsengineering/teal.code into 211_subset@main
2 parents 6c5d5ab + bc95670 commit 140ed13

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

R/qenv-class.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ setClass(
3030
setMethod(
3131
"initialize",
3232
"qenv",
33-
function(.Object, # nolint: object_name.
34-
.xData, # nolint: object_name.
35-
...) {
33+
function(.Object, .xData, code = list(), ...) { # nolint: object_name.
3634
new_xdata <- if (rlang::is_missing(.xData)) {
3735
new.env(parent = parent.env(.GlobalEnv))
3836
} else {
@@ -45,8 +43,9 @@ setMethod(
4543
# most 1 unnamed formal argument of class `environment`.
4644
# See methods::findMethods("initialize")$.environment
4745
methods::callNextMethod(
48-
# Mandatory use of `xData` to build a correct [email protected]
49-
.Object, new_xdata, ...
46+
.Object,
47+
new_xdata, # Mandatory use of unnamed environment arg
48+
code = code, ...
5049
)
5150
}
5251
)

R/utils.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ lang2calls <- function(x) {
5757
#' Obtain warnings or messages from code slot
5858
#'
5959
#' @param object (`qenv`)
60-
#' @param what (``
60+
#' @param what (`"warning"` or `"message"`)
61+
#' @return `character(1)` containing combined message or `NULL` when no warnings/messages
62+
#' @keywords internal
6163
get_warn_message_util <- function(object, what) {
6264
checkmate::matchArg(what, choices = c("warning", "message"))
6365
messages <- lapply(object@code, "attr", what)

man/get_warn_message_util.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-qenv_eval_code.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ testthat::test_that("comments from the same line are associated with it's call",
150150
)
151151
})
152152

153-
testthat::test_that("alone comments at the end of the source are considered as a separate call", {
153+
testthat::test_that("alone comments at the end of the source are considered as continuation of the last call", {
154154
# todo: should be associated to the last call or be separted?
155-
code <- c("x <- 5", "y <- 10", "# comment")
155+
code <- c("x <- 5\ny <- 10\n# comment")
156156
q <- eval_code(eval_code(qenv(), code[1]), code[2])
157157
testthat::expect_identical(
158-
unlist(q@code)[3],
159-
"# comment"
158+
unlist(q@code)[2],
159+
"y <- 10\n# comment"
160160
)
161161
})
162162

0 commit comments

Comments
 (0)