Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use released version of lzstring #10

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Suggests:
pkgdown (>= 2.0.0),
testthat (>= 3.1.5),
withr (>= 2.4.3)
Remotes:
lzstring=parmsam/lzstring-r
Config/Needs/verdepcheck: tidyverse/glue, jeroen/jsonlite,
lzstring=parmsam/lzstring-r, r-lib/roxygen2, tidyverse/stringr,
r-lib/pkgdown, r-lib/testthat, r-lib/withr
Expand Down
57 changes: 52 additions & 5 deletions tests/testthat/test-tag_examplesShinylive.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test_that("examplesShinylive tag - multiple occurrences", {
)
})

test_that("examplesShinylive tag - don't use previous example code", {
test_that("examplesShinylive tag - on default use only next example code", {
text <- "
#' This is a title
#'
Expand All @@ -94,10 +94,10 @@ test_that("examplesShinylive tag - don't use previous example code", {
#' @export
#'
#' @examples
#' x <- 'this is excluded'
#' 'this is excluded'
#' @examplesShinylive
#' @examples
#' f(1, 2)
#' 'this is included'
f <- function(x, y) x + y
"
expect_silent(block <- roxygen2::parse_text(text)[[1]])
Expand All @@ -108,11 +108,11 @@ test_that("examplesShinylive tag - don't use previous example code", {
)
expect_identical(
roxygen2::block_get_tag(block, "examplesShinylive")$raw,
"\nf(1, 2)"
"\n'this is included'"
)
expect_identical(
roxygen2::block_get_tag_value(block, "examplesShinylive"),
"https://shinylive.io/r/app/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAHQgDMAKARlwAIAmASjAF8BdIA"
"https://shinylive.io/r/app/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAHQgHJSALASwGcACNziAgGwFcAJnEF0wAXwC6QA"
)
})

Expand Down Expand Up @@ -354,3 +354,50 @@ test_that("format returns Rd parsable to tidy HTML", {
testthat::expect_setequal(tidy_res, character(0))
})
})

test_that("examplesShinylive tag - respect order of tags - before examples", {
text <- "
#' This is a title
#'
#' This is the description.
#'
#' @param x,y A number
#' @export
#' @examplesShinylive
#' @examples
#' f(1, 2)
f <- function(x, y) x + y
"
expect_silent(block <- roxygen2::parse_text(text)[[1]])

block_tag_names <- vapply(block$tags, `[[`, character(1), "tag")

expect_lt(
which(block_tag_names == "examplesShinylive"),
which(block_tag_names == "examples")
)
})

test_that("examplesShinylive tag - respect order of tags - after examples", {
text <- "
#' This is a title
#'
#' This is the description.
#'
#' @param x,y A number
#' @export
#' @examples
#' f(1, 2)
#' @examplesShinylive
#' {{ prev_example }}
f <- function(x, y) x + y
"
expect_silent(block <- roxygen2::parse_text(text)[[1]])

block_tag_names <- vapply(block$tags, `[[`, character(1), "tag")

expect_gt(
which(block_tag_names == "examplesShinylive"),
which(block_tag_names == "examples")
)
})
Loading