From aa8fe8afa9a1a50e8cf11bf544792b32ab4b2afc Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:10:23 +0200 Subject: [PATCH] use released version of lzstring --- DESCRIPTION | 2 - tests/testthat/test-tag_examplesShinylive.R | 57 +++++++++++++++++++-- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index da872d3..8b9d8d2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/tests/testthat/test-tag_examplesShinylive.R b/tests/testthat/test-tag_examplesShinylive.R index 32a17cf..ae3b116 100644 --- a/tests/testthat/test-tag_examplesShinylive.R +++ b/tests/testthat/test-tag_examplesShinylive.R @@ -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 #' @@ -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]]) @@ -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" ) }) @@ -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") + ) +})