| 1 | context('utils') |
| 2 | |
| 3 | library(evaluate) |
| 4 | |
| 5 | test_that('skip_repeated works', { |
| 6 | stack <- c('foo()', 'f()', 'f()', 'f()', 'f()', 'bar()') |
| 7 | expect_equal(skip_repeated(stack), c('foo()', 'f()', ellip_h, 'f()', 'bar()')) |
| 8 | }) |
| 9 | |
| 10 | test_that('skip_repeated does not skip three or less consecutive items', { |
| 11 | stack <- c('foo()', 'f()', 'f()', 'f()', 'bar()') |
| 12 | expect_equal(skip_repeated(stack), stack) |
| 13 | }) |
| 14 | |
| 15 | test_that('skip_repeated works on tracebacks', { |
| 16 | err <- try_capture_stack(quote({ |
| 17 | f <- function(x) stop(x) |
| 18 | f(1) |
| 19 | }), new.env()) |
| 20 | skipped_stack <- skip_repeated(err$calls) |
| 21 | expect_is(skipped_stack[[1]], 'call') |
| 22 | }) |