Skip to content

expect_snapshot_value() with style = "deparse" throws error due to : #1678

Open
@kjytay

Description

@kjytay

reprex:

f <- function() {
  3:5
}

test_that("test", {
  expect_snapshot_value(f(), style = "deparse")
})

Saved the above in a test file in a package. Running the test with testthat::test_file() throws the following error:

── Error (test-temp.R:6:3): test ───────────────────────────────────────────────
Error in `3:5`: could not find function ":"
Backtrace:
  1. testthat::expect_snapshot_value(f(), style = "deparse")
       at test-temp.R:6:2
  2. testthat:::expect_snapshot_helper(...)
  3. snapshotter$take_snapshot(...)
  9. testthat (local) load(value_enc)
 10. testthat:::reparse(x)
 11. base::eval(parse(text = x), env)
 12. base::eval(parse(text = x), env)

[ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]

This error seems similar in spirit to #1342 and #1294.

Session info:

R version 4.2.0 (2022-04-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.5.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] testthat_3.1.4

loaded via a namespace (and not attached):
 [1] compiler_4.2.0  magrittr_2.0.3  R6_2.5.1        rprojroot_2.0.3 cli_3.3.0       tools_4.2.0     withr_2.5.0     glue_1.6.2     
 [9] rstudioapi_0.13 waldo_0.4.0     crayon_1.5.1    desc_1.4.1      pkgload_1.3.0   brio_1.1.3      rlang_1.0.4    

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorsnapshot 📷

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions