[Rcpp-commits] r3157 - in pkg/Rcpp: . inst inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 28 19:21:33 CEST 2011


Author: edd
Date: 2011-07-28 19:21:32 +0200 (Thu, 28 Jul 2011)
New Revision: 3157

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/NEWS
   pkg/Rcpp/inst/unitTests/runit.Function.R
Log:
new unit test for accessing a non-exported function via namespace env.


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-07-28 16:01:20 UTC (rev 3156)
+++ pkg/Rcpp/ChangeLog	2011-07-28 17:21:32 UTC (rev 3157)
@@ -1,3 +1,8 @@
+2011-07-28  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/unitTests/runit.Function.R: new unit test for accessing a
+	non-exported function from a namespace
+
 2011-07-26  Dirk Eddelbuettel  <edd at debian.org>
 
         * DESCRIPTION: Release 0.9.6

Modified: pkg/Rcpp/inst/NEWS
===================================================================
--- pkg/Rcpp/inst/NEWS	2011-07-28 16:01:20 UTC (rev 3156)
+++ pkg/Rcpp/inst/NEWS	2011-07-28 17:21:32 UTC (rev 3157)
@@ -1,3 +1,7 @@
+0.9.7   2011-xx-yy
+
+    o   New unit test for accessing a non-exported function from a namespace
+
 0.9.6   2011-07-26
 
     o   Added helper traits to facilitate implementation of the RcppEigen

Modified: pkg/Rcpp/inst/unitTests/runit.Function.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Function.R	2011-07-28 16:01:20 UTC (rev 3156)
+++ pkg/Rcpp/inst/unitTests/runit.Function.R	2011-07-28 17:21:32 UTC (rev 3157)
@@ -1,7 +1,7 @@
 #!/usr/bin/r -t
 # -*- mode: R; tab-width: 4 -*-
 #
-# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+# Copyright (C) 2010 - 2011  Dirk Eddelbuettel and Romain Francois
 #
 # This file is part of Rcpp.
 #
@@ -67,8 +67,16 @@
 						) ;
 					return output ;
 				'
+        	),
+        	"function_namespace_env" = list(
+        		signature(),
+        		'
+                Environment ns = Environment::namespace_env( "stats" ) ;
+                Function fun = ns[".asSparse"] ;  // accesses a non-exported function
+                return fun;
+				'
         	)
-        )    
+        )
 }
 
 cxxargs <- function(){
@@ -80,9 +88,9 @@
     tests <- ".rcpp.Function"
     if( ! exists( tests, globalenv() )) {
         ## definition of all the functions at once
-        fun <- Rcpp:::compile_unit_tests( 
-            definitions(), 
-            cxxargs = cxxargs() 
+        fun <- Rcpp:::compile_unit_tests(
+            definitions(),
+            cxxargs = cxxargs()
         )
         assign( tests, fun, globalenv() )
     }
@@ -134,3 +142,11 @@
 		msg = "binary_call(Function)" )
 }
 
+test.Function.namespace.env <- function() {
+    funx <- .rcpp.Function$function_namespace_env
+    exportedfunc <- funx()
+    mat <- matrix(1:9, 3)
+    res <- exportedfunc(mat)
+    expected <- stats:::.asSparse(mat)
+	checkEquals( res, expected, msg = "namespace_env(Function)" )
+}



More information about the Rcpp-commits mailing list