[Rcpp-commits] r1816 - pkg/Rcpp/inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 7 16:14:10 CEST 2010


Author: romain
Date: 2010-07-07 16:14:10 +0200 (Wed, 07 Jul 2010)
New Revision: 1816

Removed:
   pkg/Rcpp/inst/unitTests/runit.sugar.matrix.R
Modified:
   pkg/Rcpp/inst/unitTests/runit.sugar.R
Log:
merge both sugar unit test files

Modified: pkg/Rcpp/inst/unitTests/runit.sugar.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.R	2010-07-07 14:12:19 UTC (rev 1815)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.R	2010-07-07 14:14:10 UTC (rev 1816)
@@ -500,7 +500,24 @@
 				IntegerVector yy = rev( xx * xx );
 				return yy ;
 				'
-				)
+				), 
+			"runit_outer" = list( 
+				signature( x = "numeric", y = "numeric" ), 
+				'
+				NumericVector xx(x) ;
+				NumericVector yy(y);
+				NumericMatrix m = outer( xx, yy, std::plus<double>() ) ;
+				return m ;
+				'		), 
+			"runit_row" = list( 
+				signature( x = "numeric" ), 
+				'
+				NumericMatrix xx(x) ;
+				return List::create( 
+					_["row"] = row( xx ), 
+					_["col"] = col( xx )
+					) ;
+				'	
 			
 			
 		)
@@ -966,3 +983,26 @@
 	checkEquals( fx(1:10), rev( 1:10 * 1:10 ) )
 }
 
+
+
+
+
+
+
+
+
+
+			
+test.sugar.outer <- function( ){
+	fx <- .rcpp.sugar$runit_outer
+	x <- 1:2
+	y <- 1:5
+	checkEquals( fx(x,y) , outer(x,y,"+") )
+}
+
+test.sugar.row <- function( ){
+	fx <- .rcpp.sugar$runit_row
+	m <- matrix( 1:16, nc = 4 )
+	checkEquals( fx(m), list( row = row(m), col = col(m) ) ) 
+}
+

Deleted: pkg/Rcpp/inst/unitTests/runit.sugar.matrix.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.sugar.matrix.R	2010-07-07 14:12:19 UTC (rev 1815)
+++ pkg/Rcpp/inst/unitTests/runit.sugar.matrix.R	2010-07-07 14:14:10 UTC (rev 1816)
@@ -1,65 +0,0 @@
-#!/usr/bin/r -t
-#
-# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
-#
-# This file is part of Rcpp.
-#
-# Rcpp is free software: you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# Rcpp is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
-
-.setUp <- function(){
-	if( ! exists( ".rcpp.sugar.matrix", globalenv() ) ){
-		# definition of all the functions at once
-		
-		sugar.functions <- list( 
-			"runit_outer" = list( 
-				signature( x = "numeric", y = "numeric" ), 
-'
-NumericVector xx(x) ;
-NumericVector yy(y);
-NumericMatrix m = outer( xx, yy, std::plus<double>() ) ;
-return m ;
-'		), 
-			"runit_row" = list( 
-				signature( x = "numeric" ), 
-'
-NumericMatrix xx(x) ;
-return List::create( 
-	_["row"] = row( xx ), 
-	_["col"] = col( xx )
-	) ;
-'
-			) 
-		)
-		
-		signatures <- lapply( sugar.functions, "[[", 1L )
-		bodies <- lapply( sugar.functions, "[[", 2L )
-		fx <- cxxfunction( signatures, bodies, plugin = "Rcpp")
-		getDynLib( fx ) # just forcing loading the dll now
-		assign( ".rcpp.sugar.matrix", fx, globalenv() )			
-	}
-}
-			
-test.sugar.outer <- function( ){
-	fx <- .rcpp.sugar.matrix$runit_outer
-	x <- 1:2
-	y <- 1:5
-	checkEquals( fx(x,y) , outer(x,y,"+") )
-}
-
-test.sugar.row <- function( ){
-	fx <- .rcpp.sugar.matrix$runit_row
-	m <- matrix( 1:16, nc = 4 )
-	checkEquals( fx(m), list( row = row(m), col = col(m) ) ) 
-}
-



More information about the Rcpp-commits mailing list