Skip to content

Commit d4cbbcc

Browse files
committed
add unit tests
1 parent 9cb51ab commit d4cbbcc

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ChangeLog

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
2015-06-25 Kevin Ushey <[email protected]>
1+
2015-06-25 Kevin Ushey <[email protected]>
22

33
* inst/include/Rcpp/api/meat/Rcpp_eval.h: reset error after Rcpp_eval
4+
* inst/unitTests/cpp/Function.cpp: unit tests
5+
* inst/unitTests/runit.Function.R: unit tests
46
* inst/include/Rcpp/Function.h: catch empty error messages
57
* inst/include/Rcpp/api/meat/Rcpp_eval.h: protect call
68

inst/unitTests/cpp/Function.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@ Function function_namespace_env(){
7676
Function fun = ns[".asSparse"] ; // accesses a non-exported function
7777
return fun;
7878
}
79+
80+
// [[Rcpp::export]]
81+
void exec(Function f) { f(); }
82+

inst/unitTests/runit.Function.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ if (.runThisTest) {
8484
checkException(function_cons_ns("sourceCpp", "Rcppp"), msg = "namespace-lookup constructor: fail when ns does not exist")
8585
checkException(function_cons_ns("sourceCppp", "Rcpp"), msg = "namespace-lookup constructor: fail when function not found")
8686
}
87+
88+
test.Function.eval <- function() {
89+
checkException(exec(stop))
90+
# should not throw exception
91+
exec(function() try(silent = TRUE, exec(stop)))
92+
}
8793

8894
# also check function is found in parent env
8995

0 commit comments

Comments
 (0)