| 1 |
foo <- function() { |
| 2 |
capture <- function() { |
| 3 |
list( |
| 4 |
calls = sys.calls(), |
| 5 |
parents = sys.parents() |
| 6 |
) |
| 7 |
} |
| 8 |
|
| 9 |
capture_1 <- function() { |
| 10 |
capture() |
| 11 |
} |
| 12 |
|
| 13 |
capture_2 <- function() { |
| 14 |
capture_1() |
| 15 |
} |
| 16 |
|
| 17 |
do.call( |
| 18 |
identity, |
| 19 |
list( |
| 20 |
identity(capture_2()) |
| 21 |
) |
| 22 |
) |
| 23 |
} |
| 24 |
res <- foo() |
| 25 |
res$calls <- tail(res$calls, 6) |
| 26 |
res$parents <- tail(res$parents - (length(res$parents) - 6), 6) |
| 27 |
|
| 28 |
describe("stack pruning", { |
| 29 |
it("passes basic example", { |
| 30 |
expect_equal(pruneStackTrace(res$parents), c(T, F, F, T, T, T)) |
| 31 |
expect_equal(lapply(list(res$parents), pruneStackTrace), list(c(T, F, F, T, T, T))) |
| 32 |
}) |
| 33 |
}) |