Skip to content

Commit

Permalink
test withAutoprint() behavior too
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Dec 4, 2024
1 parent 843f00a commit 5a7882d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
11 changes: 10 additions & 1 deletion tests/autoprint.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,14 @@ class(dt) <- c("foo", "data.table", "data.frame")
print.foo <- function(x, ...) {
NextMethod("print")
}

dt[, y := 1] # no

# withAutoprint() testing (since R3.4.0)
if (!exists("withAutoprint", baseenv())) {
q("no")
}
if (TRUE) withAutoprint({
DT # yes
DT[1L, 1L] # yes
DT[2L, a := 10L] # no
})
23 changes: 21 additions & 2 deletions tests/autoprint.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,28 @@ NULL
> print.foo <- function(x, ...) {
+ NextMethod("print")
+ }
>
> dt[, y := 1] # no
>
> # withAutoprint() testing (since R3.4.0)
> if (!exists("withAutoprint", baseenv())) {
+ q("no")
+ }
> if (TRUE) withAutoprint({
+ DT # yes
+ DT[1L, 1L] # yes
+ DT[2L, a := 10L] # no
+ })
> DT
a
<int>
1: 10
2: 10
> DT[1L, 1L]
a
<int>
1: 10
> DT[2L, `:=`(a, 10L)]
>
> proc.time()
user system elapsed
0.209 0.053 0.288
0.182 0.056 0.246

0 comments on commit 5a7882d

Please sign in to comment.