Skip to content

Commit

Permalink
print invisibly returns the object (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimrothstein authored Jan 21, 2025
1 parent 7f162fc commit 3832ddb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

* `ui_add` and `srv_add` no longer exist as adding new filters is a part of `ui_active` and `srv_active`.

### Miscellaneous

* `print.teal_slice()` and `print.teal_slices()` now return object invisibly.

# teal.slice 0.5.1

### Bug fixes
Expand Down
1 change: 1 addition & 0 deletions R/teal_slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ format.teal_slice <- function(x, show_all = FALSE, trim_lines = TRUE, ...) {
#'
print.teal_slice <- function(x, ...) {
cat(format(x, ...))
invisible(x)
}


Expand Down
1 change: 1 addition & 0 deletions R/teal_slices.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ format.teal_slices <- function(x, show_all = FALSE, trim_lines = TRUE, ...) {
#'
print.teal_slices <- function(x, ...) {
cat(format(x, ...), "\n")
invisible(x)
}


Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-teal_slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,8 @@ testthat::test_that(
testthat::expect_type(shiny::isolate(tss[[1]]$choices), "character")
}
)

testthat::test_that("print.teal_slice returns argument", {
fs <- teal_slice("data", "var")
testthat::expect_identical(print(fs), fs)
})
7 changes: 7 additions & 0 deletions tests/testthat/test-teal_slices.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,10 @@ testthat::test_that("format.teal_slices prints count_type attribute if not empty
ffs <- format(fs, show_all = TRUE)
testthat::expect_true(!grepl("count_type", ffs))
})

testthat::test_that("print.teal_slices returns argument", {
fs1 <- teal_slice("data", "var1")
fs2 <- teal_slice("data", "var2")
fs <- teal_slices(fs1, fs2)
testthat::expect_identical(print(fs), fs)
})

0 comments on commit 3832ddb

Please sign in to comment.