Skip to content

Commit

Permalink
test trace_lists param for #19
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jun 23, 2023
1 parent 8e1bb3d commit e35d3cc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: typetracer
Title: Trace Function Parameter Types
Version: 0.2.1.006
Version: 0.2.1.007
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265")),
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeRepository": "https://github.com/mpadge/typetracer",
"issueTracker": "https://github.com/mpadge/typetracer/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.2.1.006",
"version": "0.2.1.007",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-trace-fns.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,28 @@ test_that ("untrace call", {

expect_identical (e0, e2)
})

test_that ("trace lists", {

f <- function (x, y, a) {
stopifnot (is.list (a))
stopifnot ("x" %in% names (a))
x * x + y * y + a$x
}

inject_tracer (f, trace_lists = FALSE)
clear_traces ()
val <- f (x = 1:2, y = 3:4 + 0., a = list (x = 4))
x0 <- load_traces ()
uninject_tracer (f)

inject_tracer (f, trace_lists = TRUE)
clear_traces ()
val <- f (x = 1:2, y = 3:4 + 0., a = list (x = 4))
x1 <- load_traces ()
uninject_tracer (f)

expect_true (nrow (x1) > nrow (x0))
expect_false (any (grepl ("\\$", x0$par_name)))
expect_true (any (grepl ("\\$", x1$par_name)))
})

0 comments on commit e35d3cc

Please sign in to comment.