Closed averissimo closed 5 days ago
Both in the code and the data type. See reproducible code below
library(teal.code) testthat::test_that("within preserves integer definition in code", { q <- within(qenv(), a <- 1L) testthat::expect_identical(get_code(q), "a <- 1L") }) #> ── Failure: within preserves integer definition in code ──────────────────────── #> get_code(q) not identical to "a <- 1L". #> 1/1 mismatches #> x[1]: "a <- 1" #> y[1]: "a <- 1L" #> Error: #> ! Test failed testthat::describe("within preserves variable data type with", { testthat::test_that("integer shorthand", { q <- within(qenv(), an_integer_shorthand <- 1L) testthat::expect_type(q[["an_integer_shorthand"]], "integer") }) testthat::test_that("integer", { q <- within(qenv(), an_integer <- integer(1L)) testthat::expect_type(q[["an_integer"]], "integer") }) testthat::test_that("complex", { q <- within(qenv(), a_complex <- 1 + 3i) testthat::expect_type(q[["a_complex"]], "complex") }) testthat::test_that("double", { q <- within(qenv(), a_double <- 1.0) testthat::expect_type(q[["a_double"]], "double") }) testthat::test_that("raw", { q <- within(qenv(), a_raw <- as.raw(0xa3)) testthat::expect_type(q[["a_raw"]], "raw") }) testthat::test_that("logical", { q <- within(qenv(), a_logical <- TRUE) testthat::expect_type(q[["a_logical"]], "logical") }) testthat::test_that("logical shorthand", { q <- within(qenv(), a_logical_shorthand <- T) testthat::expect_type(q[["a_logical_shorthand"]], "logical") }) }) #> ── Failure: integer shorthand ────────────────────────────────────────────────── #> q[["an_integer_shorthand"]] has type 'double', not 'integer'. #> Error: #> ! Test failed
Created on 2024-10-30 with reprex v2.1.1
No response
What happened?
Both in the code and the data type. See reproducible code below
Created on 2024-10-30 with reprex v2.1.1
sessionInfo()
No response
Relevant log output
No response
Code of Conduct
Contribution Guidelines
Security Policy