Skip to content

Commit

Permalink
Work around visible bindings notes in R CMD check
Browse files Browse the repository at this point in the history
Closes #40
  • Loading branch information
lionel- committed Oct 30, 2024
1 parent 942d7d9 commit f69a822
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# coro (development version)

* Generators and async functions assigned in namespaces no
longer produce R CMD check notes about visible bindings (#40).

# coro 1.0.5

* Async functions created by `coro::async()` now return their
Expand Down
4 changes: 4 additions & 0 deletions R/generator.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ generator0 <- function(fn, type = "generator") {
`_private`$caller_env <- base::parent.frame()

base::local(envir = `_private`, {
generator_env <- environment()$generator_env
caller_env <- environment()$caller_env
exits <- NULL

info <- machine_info(type, env = caller_env)

# Generate the state machine lazily at runtime
Expand Down
1 change: 1 addition & 0 deletions man/coro-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/testthat/test-async.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,13 @@ test_that("async function returns invisibly (#46)", {
})
expect_invisible(fn())
})

test_that("async functions do not cause CMD check notes (#40)", {
skip_on_cran()
expect_silent(
invisible(compiler::cmpfun(
async(function() NULL),
options = list(suppressAll = FALSE)
))
)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-generator.R
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,13 @@ test_that("stepping into generators returns visibly (#46)", {
expect_visible(abc())
expect_visible(abc())
})

test_that("generators do not cause CMD check notes (#40)", {
skip_on_cran()
expect_silent(
invisible(compiler::cmpfun(
generator(function() NULL),
options = list(suppressAll = FALSE)
))
)
})

0 comments on commit f69a822

Please sign in to comment.