Skip to content

Commit be480f1

Browse files
committed
test: problem with integer (1L) shorthand in within
1 parent e00fd92 commit be480f1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/testthat/test-qenv_within.R

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,35 @@ testthat::test_that("within run on qenv.error returns the qenv.error as is", {
114114

115115
testthat::expect_identical(qe, qee)
116116
})
117+
118+
testthat::test_that("within preserves integer definition in code", {
119+
q <- within(qenv(), a <- 1L)
120+
testthat::expect_identical(get_code(q), "a <- 1L")
121+
})
122+
123+
testthat::describe("within preserves R primitives shorthands with", {
124+
testthat::test_that("integer", {
125+
q <- within(qenv(), an_integer <- 1L)
126+
testthat::expect_type(q[["an_integer"]], "integer")
127+
})
128+
129+
testthat::test_that("complex", {
130+
q <- within(qenv(), a_complex <- 1 + 3i)
131+
testthat::expect_type(q[["a_complex"]], "complex")
132+
})
133+
134+
testthat::test_that("double", {
135+
q <- within(qenv(), a_double <- 1.0)
136+
testthat::expect_type(q[["a_double"]], "double")
137+
})
138+
139+
testthat::test_that("logical", {
140+
q <- within(qenv(), a_logical <- TRUE)
141+
testthat::expect_type(q[["a_logical"]], "logical")
142+
})
143+
144+
testthat::test_that("logical shorthand", {
145+
q <- within(qenv(), a_logical_shorthand <- T)
146+
testthat::expect_type(q[["a_logical_shorthand"]], "logical")
147+
})
148+
})

0 commit comments

Comments
 (0)