File tree Expand file tree Collapse file tree 4 files changed +37
-13
lines changed
testRcppInterfaceExporter/src Expand file tree Collapse file tree 4 files changed +37
-13
lines changed Original file line number Diff line number Diff line change 77 functions are still caught and dealt with properly by the client
88 package.
99
10+ * inst/unitTests/runit.interface.R: Test both Rcpp_eval() and
11+ Rcpp_fast_eval().
12+
10132018-06-01 Lionel Henry <lionel@rstudio.com>
1114
1215 * inst/unitTests/runit.interface.R: New tests for interfaces and unwind.
Original file line number Diff line number Diff line change 77
88// ' @export
99// [[Rcpp::export]]
10- SEXP test_cpp_interface (SEXP x) {
10+ SEXP test_cpp_interface (SEXP x, bool fast = false ) {
1111 unwound_t stack_obj (" cpp_interface_upstream" );
12- return Rcpp::Rcpp_fast_eval (x, R_GlobalEnv);
12+ if (fast) {
13+ return Rcpp::Rcpp_fast_eval (x, R_GlobalEnv);
14+ } else {
15+ return Rcpp::Rcpp_eval (x, R_GlobalEnv);
16+ }
1317}
Original file line number Diff line number Diff line change 88
99// ' @export
1010// [[Rcpp::export]]
11- SEXP use_cpp_interface (SEXP x) {
11+ SEXP use_cpp_interface (SEXP x, bool fast = false ) {
1212 unwound_t stack_obj (" cpp_interface_downstream" );
13- Rcpp::RObject out = testRcppInterfaceExporter::test_cpp_interface (x);
13+ Rcpp::RObject out = testRcppInterfaceExporter::test_cpp_interface (x, fast );
1414 Rcpp::Rcout << " Wrapping up" << std::endl;
1515 return out;
1616}
Original file line number Diff line number Diff line change 11
2+ reset <- function () {
3+ testRcppInterfaceUser :: reset_flags()
4+ testRcppInterfaceExporter :: reset_flags()
5+ }
6+
7+
28# This tests errors converted to exceptions by Rcpp_eval()
39x <- tryCatch(
410 error = identity ,
511 testRcppInterfaceUser :: use_cpp_interface(quote(stop(" jump!" )))
612)
713
8- stopifnot(grepl(" jump!" , x $ message ))
14+ stopifnot(
15+ grepl(" jump!" , x $ message ),
16+ testRcppInterfaceUser :: peek_flag(" cpp_interface_downstream" ),
17+ testRcppInterfaceExporter :: peek_flag(" cpp_interface_upstream" )
18+ )
919
10- if (getRversion() > = " 3.5.0" ) {
11- stopifnot(
12- testRcppInterfaceUser :: peek_flag(" cpp_interface_downstream" ),
13- testRcppInterfaceExporter :: peek_flag(" cpp_interface_upstream" )
14- )
15- }
20+
21+ reset()
22+
23+ # This tests errors converted to resumable longjumps by Rcpp_fast_eval()
24+ x <- tryCatch(
25+ error = identity ,
26+ testRcppInterfaceUser :: use_cpp_interface(quote(stop(" jump!" )), fast = TRUE )
27+ )
28+
29+ stopifnot(
30+ grepl(" jump!" , x $ message ),
31+ testRcppInterfaceUser :: peek_flag(" cpp_interface_downstream" ),
32+ testRcppInterfaceExporter :: peek_flag(" cpp_interface_upstream" )
33+ )
1634
1735
18- testRcppInterfaceUser :: reset_flags()
19- testRcppInterfaceExporter :: reset_flags()
36+ reset()
2037
2138# This tests longjumps not caught by Rcpp_eval()
2239x <- withRestarts(
You can’t perform that action at this time.
0 commit comments