Skip to content

Commit

Permalink
Resolve #45
Browse files Browse the repository at this point in the history
  • Loading branch information
wahani committed Aug 25, 2023
1 parent 3bd410e commit ed2c130
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/export.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ exportExtractElement <- function(where) {
name <- if (name == "") element else name
# we need to make sure that special names, e.g. %*%, ==.foo and names with
# whitespaces are parsed correctly
regexp <- "^%.*%$|^[[:alnum:][:space:]]+$|^[[:punct:]]{2,}.*$"
regexp <- "^%.*%$|^[[:alnum:][:space:]]+$|^[[:punct:]]{2,}.*$|^[[:punct:]]$"
element <- if (grepl(regexp, element)) paste0("`", element, "`") else element # Exclude Linting
object <- tryCatch(
eval(parse(text = element), where, baseenv()),
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-export.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ test_that("Exports of special names #37", {
testthat::expect_true(m$`%add%`(1, 2) == 3)
})

test_that("Exports of special names #45", {
m <- module({
"[" <- `[`
})
testthat::expect_true(is.primitive(m$"["))

})

test_that("Exports of names with whitespace #39", {
m <- module({
"my fun" <- function(x) x # Exclude Linting
Expand Down

0 comments on commit ed2c130

Please sign in to comment.