@@ -34,9 +34,8 @@ if (.runThisTest) {
3434#define foo_h 1
3535// class to set/get double
3636class foo {
37- private:
38- double x;
3937 public:
38+ double x;
4039 double get_x() {return x;}
4140 void set_x(double _x) {x = _x; return;}
4241 foo(double _x) {set_x(_x);}
@@ -54,10 +53,11 @@ class foo {
5453 # # check that result of exposeClass compiles and runs properly
5554 exposeClass(class = " fooR" ,
5655 constructors = list (" double" ),
57- fields = character () ,
56+ fields = " x " ,
5857 methods = c(" get_x" , " set_x" ),
5958 header = ' #include "foo.h"' ,
6059 CppClass = " foo" ,
60+ rename = c(y = " x" , get_y = " get_x" , set_y = " set_x" ),
6161 file = file.path(src_path , " fooModule.cpp" ),
6262 Rfile = file.path(R_path , " fooClass.R" ))
6363 compileAttributes(pkg_path )
@@ -86,11 +86,17 @@ class foo {
8686 checkTrue( exists(" bar" , envir = env , inherits = FALSE ),
8787 " module object successfully instantiated" )
8888 gs <- replicate(n = 10 , {
89- x <- rnorm(1 )
90- bar $ set_x(x )
91- bar $ get_x() - x
89+ y <- rnorm(1 )
90+ bar $ set_y(y )
91+ bar $ get_y() - y
92+ })
93+ checkTrue( all(gs == 0 ), " renamed methods function as expected" )
94+ gs <- replicate(n = 10 , {
95+ y <- rnorm(1 )
96+ bar $ set_y(y )
97+ bar $ y - y
9298 })
93- checkTrue( all(gs == 0 ), " object methods function as expected" )
99+ checkTrue( all(gs == 0 ), " renamed direct field functions as expected" )
94100
95101 }
96102
0 commit comments