[Rcpp-commits] r2984 - in pkg/Rcpp/inst/unitTests/testRcppModule: . R src tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 11 10:26:47 CEST 2011
Author: romain
Date: 2011-04-11 10:26:47 +0200 (Mon, 11 Apr 2011)
New Revision: 2984
Added:
pkg/Rcpp/inst/unitTests/testRcppModule/R/zzz.R
Modified:
pkg/Rcpp/inst/unitTests/testRcppModule/NAMESPACE
pkg/Rcpp/inst/unitTests/testRcppModule/R/Modules.R
pkg/Rcpp/inst/unitTests/testRcppModule/src/rcpp_module.cpp
pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp
pkg/Rcpp/inst/unitTests/testRcppModule/tests/modules.R
Log:
surprised this even worked before
Modified: pkg/Rcpp/inst/unitTests/testRcppModule/NAMESPACE
===================================================================
--- pkg/Rcpp/inst/unitTests/testRcppModule/NAMESPACE 2011-04-09 21:34:42 UTC (rev 2983)
+++ pkg/Rcpp/inst/unitTests/testRcppModule/NAMESPACE 2011-04-11 08:26:47 UTC (rev 2984)
@@ -1,3 +1,4 @@
useDynLib(testRcppModule)
exportPattern("^[[:alpha:]]+")
-importClassesFrom( Rcpp, "C++Object", "C++Class", "Module" )
+import(Rcpp)
+
Modified: pkg/Rcpp/inst/unitTests/testRcppModule/R/Modules.R
===================================================================
--- pkg/Rcpp/inst/unitTests/testRcppModule/R/Modules.R 2011-04-09 21:34:42 UTC (rev 2983)
+++ pkg/Rcpp/inst/unitTests/testRcppModule/R/Modules.R 2011-04-11 08:26:47 UTC (rev 2984)
@@ -1,6 +1 @@
-## create modules (their pointers will be initialized when first used)
-yada <- Module("yada")
-stdVector <- Module("stdVector")
-NumEx <- Module("NumEx")
-
Added: pkg/Rcpp/inst/unitTests/testRcppModule/R/zzz.R
===================================================================
--- pkg/Rcpp/inst/unitTests/testRcppModule/R/zzz.R (rev 0)
+++ pkg/Rcpp/inst/unitTests/testRcppModule/R/zzz.R 2011-04-11 08:26:47 UTC (rev 2984)
@@ -0,0 +1,8 @@
+NAMESPACE <- environment()
+
+.onLoad <- function(libname, pkgname){
+ populate( Module("yada"), NAMESPACE )
+ populate( Module("stdVector"), NAMESPACE )
+ populate( Module("NumEx"), NAMESPACE )
+}
+
Modified: pkg/Rcpp/inst/unitTests/testRcppModule/src/rcpp_module.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/testRcppModule/src/rcpp_module.cpp 2011-04-09 21:34:42 UTC (rev 2983)
+++ pkg/Rcpp/inst/unitTests/testRcppModule/src/rcpp_module.cpp 2011-04-11 08:26:47 UTC (rev 2984)
@@ -1,10 +1,5 @@
#include <Rcpp.h>
-/* removed as it upsets windows */
-// std::string hello() {
-// throw std::range_error( "boom" ) ;
-// }
-
int bar( int x){
return x*2 ;
}
@@ -40,7 +35,6 @@
RCPP_MODULE(yada){
using namespace Rcpp ;
- // function( "hello" , &hello ) ;
function( "bar" , &bar ) ;
function( "foo" , &foo ) ;
function( "bla" , &bla ) ;
Modified: pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp 2011-04-09 21:34:42 UTC (rev 2983)
+++ pkg/Rcpp/inst/unitTests/testRcppModule/src/stdVector.cpp 2011-04-11 08:26:47 UTC (rev 2984)
@@ -28,7 +28,7 @@
class_<vec>( "vec")
// exposing the default constructor
- .default_constructor()
+ .constructor()
// exposing member functions
.method( "size", &vec::size)
Modified: pkg/Rcpp/inst/unitTests/testRcppModule/tests/modules.R
===================================================================
--- pkg/Rcpp/inst/unitTests/testRcppModule/tests/modules.R 2011-04-09 21:34:42 UTC (rev 2983)
+++ pkg/Rcpp/inst/unitTests/testRcppModule/tests/modules.R 2011-04-11 08:26:47 UTC (rev 2984)
@@ -1,28 +1,21 @@
library(testRcppModule)
-vClass <- stdVector$vec
-vec <- new(vClass)
+v <- new(vec)
data <- 1:10
-vec$assign(data)
-vec[[3]] <- vec[[3]] + 1
+v$assign(data)
+v[[3]] <- v[[3]] + 1
data[[4]] <- data[[4]] +1
-stopifnot(identical(all.equal(vec$as.vector(), data), TRUE))
+stopifnot(identical(all.equal(v$as.vector(), data), TRUE))
## a few function calls
-stopifnot(all.equal(yada$bar(2), 4))
+stopifnot(all.equal(bar(2), 4))
+stopifnot(all.equal(foo(2,3), 6))
-e <- tryCatch(yada$hello(), error = function(x)x)
-
-stopifnot(is(e, "error"), all.equal(e$message, "boom"))
-
-stopifnot(all.equal(yada$foo(2,3), 6))
-
## properties (at one stage this seqfaulted, so beware)
-nc = NumEx$Num
-nn <- new(nc)
+nn <- new(Num)
nn$x <- pi
stopifnot(all.equal(nn$x, pi))
More information about the Rcpp-commits
mailing list