-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert eventReactive() to function() (#55)
* Add logiv for eventReactive and simplify * Add test * Add new functions to select right expression for evaluation * Use new return_inner_expression() in update_expressions() * Add importFrom methods formalArgs * Create test-return-inner-expression.R * Add methods to desc
- Loading branch information
Showing
6 changed files
with
130 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ Imports: | |
glue, | ||
knitr, | ||
magrittr, | ||
methods, | ||
pander, | ||
purrr, | ||
readr, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
test_that("return argument pulls returns right piece of code", { | ||
x <- expression(y <- eventReactive(input$button, {print(input$n)})) | ||
code_as_call <- as.call(x)[[1]] | ||
|
||
all_args <- full_argument_names(code_as_call[[3]]) | ||
|
||
expect_equal( | ||
object = all_args, | ||
expected = c("", "eventExpr", "valueExpr") | ||
) | ||
|
||
get_event <- return_inner_expression(code_as_call[[3]], "eventExpr") | ||
get_value <- return_inner_expression(code_as_call[[3]], "valueExpr") | ||
|
||
expect_equal( | ||
object = as.call(get_event), | ||
expected = as.call(quote(input$button)) | ||
) | ||
|
||
expect_equal( | ||
object = as.character(get_value)[[2]], | ||
expected = "print(input$n)" | ||
) | ||
}) | ||
|
||
|
||
|
||
test_that("full_argument_names works", { | ||
all_args <- c("", "pattern", "replacement", "x") | ||
|
||
expect_equal( | ||
object = full_argument_names(parse(text = "gsub(' ', '_', 'a b c')")[[1]]), | ||
expected = all_args | ||
) | ||
|
||
expect_equal( | ||
object = full_argument_names(expression(gsub(x = "a b c", " ", "_"))[[1]]), | ||
expected = all_args[c(1,4,2,3)] | ||
) | ||
|
||
expect_equal( | ||
object = full_argument_names(expression(gsub(x = "a b c", pat = " ", rep = "_"))[[1]]), | ||
expected = all_args[c(1,4,2,3)] | ||
) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters