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 7
7
functions are still caught and dealt with properly by the client
8
8
package.
9
9
10
+ * inst/unitTests/runit.interface.R: Test both Rcpp_eval() and
11
+ Rcpp_fast_eval().
12
+
10
13
2018-06-01 Lionel Henry <
[email protected] >
11
14
12
15
* inst/unitTests/runit.interface.R: New tests for interfaces and unwind.
Original file line number Diff line number Diff line change 7
7
8
8
// ' @export
9
9
// [[Rcpp::export]]
10
- SEXP test_cpp_interface (SEXP x) {
10
+ SEXP test_cpp_interface (SEXP x, bool fast = false ) {
11
11
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
+ }
13
17
}
Original file line number Diff line number Diff line change 8
8
9
9
// ' @export
10
10
// [[Rcpp::export]]
11
- SEXP use_cpp_interface (SEXP x) {
11
+ SEXP use_cpp_interface (SEXP x, bool fast = false ) {
12
12
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 );
14
14
Rcpp::Rcout << " Wrapping up" << std::endl;
15
15
return out;
16
16
}
Original file line number Diff line number Diff line change 1
1
2
+ reset <- function () {
3
+ testRcppInterfaceUser :: reset_flags()
4
+ testRcppInterfaceExporter :: reset_flags()
5
+ }
6
+
7
+
2
8
# This tests errors converted to exceptions by Rcpp_eval()
3
9
x <- tryCatch(
4
10
error = identity ,
5
11
testRcppInterfaceUser :: use_cpp_interface(quote(stop(" jump!" )))
6
12
)
7
13
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
+ )
9
19
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
+ )
16
34
17
35
18
- testRcppInterfaceUser :: reset_flags()
19
- testRcppInterfaceExporter :: reset_flags()
36
+ reset()
20
37
21
38
# This tests longjumps not caught by Rcpp_eval()
22
39
x <- withRestarts(
You can’t perform that action at this time.
0 commit comments