Skip to content
Draft
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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ Language: en-GB
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
Config/testthat/edition: 3
3 changes: 1 addition & 2 deletions R/text-parsing-fns.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ bracket_sequences <- function (x, open_sym, close_sym, both_sym) {
start_multi_line_quote <- TRUE
} else if (is.na (qstart_1) && !is.na (qend_1)) {
multi_line_quote <- FALSE
}
}

if (!multi_line_quote || (multi_line_quote && start_multi_line_quote)) {

Expand Down Expand Up @@ -419,7 +419,6 @@ parse_expressions <- function (x) {
xfirst <- x [1:(br_open [i] - 1)]
if (br_closed [i] < length (x))
xlast <- x [(br_closed [i] + 1):length (x)]

x <- c (xfirst, xmid, xlast)
}
}
Expand Down
20 changes: 20 additions & 0 deletions autotest.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 4
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: XeLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
8 changes: 8 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(autotest)

Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/_snaps/text-parsing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# parse_expressions with two curly brace pairs

Code
parse_expressions(ex)
Error <simpleError>
missing value where TRUE/FALSE needed

6 changes: 6 additions & 0 deletions tests/testthat/test-text-parsing.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ test_that ("parse_expressions", {
expect_silent (eval (parse (text = res2)))
})

test_that("parse_expressions with two curly brace pairs", {
ex <- c("if (TRUE) {", " message(\"blop\")",
"} else {", " message(\"bla\"", " ))", "}")
expect_snapshot(parse_expressions(ex), error = TRUE)
})

test_that ("strip_if_cond", {
x <- "if(x==1)y<-0"
res <- strip_if_cond (x)
Expand Down