@@ -22,11 +22,25 @@ if( ! Rcpp:::capabilities()[["Rcpp modules"]] ) exit_file("Skipping as no Module
22
22
23
23
Rcpp :: sourceCpp(" cpp/Module.cpp" )
24
24
25
+ # checks the presence of "invisible", added when the function returns void
26
+ is_void <- function (call ) {
27
+ if (length(grep(" invisible" , deparse(call ))) == 0 )
28
+ return (FALSE )
29
+ return (TRUE )
30
+ }
31
+
25
32
# test.Module <- function(){
26
33
expect_equal( bar( 2L ), 4L )
27
34
expect_equal( foo( 2L , 10.0 ), 20.0 )
28
35
expect_equal( hello(), " hello" )
29
36
37
+ expect_false(is_void(bar @ .Data ))
38
+ expect_false(is_void(foo @ .Data ))
39
+ expect_false(is_void(hello @ .Data ))
40
+ expect_true(is_void(bla @ .Data ))
41
+ expect_true(is_void(bla1 @ .Data ))
42
+ expect_true(is_void(bla2 @ .Data ))
43
+
30
44
w <- new( ModuleWorld )
31
45
expect_equal( w $ greet(), " hello" )
32
46
w $ set( " hello world" )
@@ -38,13 +52,24 @@ expect_equal( w$greet(), "hello world const ref" )
38
52
w $ clear( )
39
53
expect_equal( w $ greet(), " " )
40
54
55
+ expect_false(is_void(w $ greet ))
56
+ expect_true(is_void(w $ set ))
57
+ expect_true(is_void(w $ set_ref ))
58
+ expect_true(is_void(w $ set_const_ref ))
59
+ expect_true(is_void(w $ clear ))
60
+
41
61
# test.Module.exposed.class <- function(){
42
62
test <- new( ModuleTest , 3.0 )
43
63
expect_equal( Test_get_x_const_ref(test ), 3.0 )
44
64
expect_equal( Test_get_x_const_pointer(test ), 3.0 )
45
65
expect_equal( Test_get_x_ref(test ), 3.0 )
46
66
expect_equal( Test_get_x_pointer(test ), 3.0 )
47
67
68
+ expect_false(is_void(Test_get_x_const_ref @ .Data ))
69
+ expect_false(is_void(Test_get_x_const_pointer @ .Data ))
70
+ expect_false(is_void(Test_get_x_ref @ .Data ))
71
+ expect_false(is_void(Test_get_x_pointer @ .Data ))
72
+
48
73
expect_equal( attr_Test_get_x_const_ref(test ), 3.0 )
49
74
expect_equal( attr_Test_get_x_const_pointer(test ), 3.0 )
50
75
expect_equal( attr_Test_get_x_ref(test ), 3.0 )
0 commit comments