Skip to content

Commit 54931eb

Browse files
committed
test for cyclic dependency
1 parent 1012319 commit 54931eb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/testthat/test-qenv_get_code.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@ testthat::describe("get_code for specific names", {
290290
)
291291
}
292292
)
293+
testthat::it("prevents cyclic dependencies when function (c) is on left side of assignment and right side of the oprations", {
294+
code <- c(
295+
"object_list <- list(x = iris, y = iris)",
296+
"object_list_2 <- list(x = mtcars, y = mtcars)",
297+
"object_list_2[c('x')] <- c('string')",
298+
"object_list[c('x')] <- c('string')"
299+
)
300+
q <- eval_code(qenv(), code = code)
301+
result <- get_code(q, names = "object_list")
302+
testthat::expect_identical(result, paste(code[c(1, 4)], collapse = "\n"))
303+
})
304+
293305
})
294306

295307

0 commit comments

Comments
 (0)