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

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


Author: romain
Date: 2010-07-07 14:08:13 +0200 (Wed, 07 Jul 2010)
New Revision: 1802

Removed:
   pkg/Rcpp/inst/unitTests/runit.Vector.create.R
Modified:
   pkg/Rcpp/inst/unitTests/runit.CharacterVector.R
   pkg/Rcpp/inst/unitTests/runit.GenericVector.R
   pkg/Rcpp/inst/unitTests/runit.IntegerVector.R
Log:
moving tests from runit.Vector.create in relevant fast files

Modified: pkg/Rcpp/inst/unitTests/runit.CharacterVector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.CharacterVector.R	2010-07-07 12:06:59 UTC (rev 1801)
+++ pkg/Rcpp/inst/unitTests/runit.CharacterVector.R	2010-07-07 12:08:13 UTC (rev 1802)
@@ -157,7 +157,20 @@
                    signature(x = "character"),
                    'CharacterVector y(x) ;
 	            CharacterVector::iterator it = std::find( y.begin(), y.end(), "foo" ) ;
-	            return wrap( std::distance( y.begin(), it )); ')
+	            return wrap( std::distance( y.begin(), it )); '
+	            
+	            ), "create_" = list( 
+	            	signature(), 
+	            	'
+						List output(2); 
+						output[0] = CharacterVector::create( "foo", "bar" ) ;
+						output[1] = CharacterVector::create( 
+							_["foo"] = "bar", 
+							_["bar"] = "foo"
+							) ;
+						return output ;
+					'
+	            )
 
                    )
 
@@ -293,4 +306,10 @@
     fun <- .rcpp.CharacterVector$find_
     checkEquals( fun( c("bar", "foo", "bob") ), 1L, msg = "support for std::find in CharacterVector" )
 }
+    
+test.CharacterVector.create <- function(){
+	fun <- .rcpp.CharacterVector$create_
+    checkEquals( fun(), list( c( "foo", "bar" ), c(foo = "bar", bar = "foo" ) ), 
+	 	msg = "CharacterVector::create" )
+}
 

Modified: pkg/Rcpp/inst/unitTests/runit.GenericVector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.GenericVector.R	2010-07-07 12:06:59 UTC (rev 1801)
+++ pkg/Rcpp/inst/unitTests/runit.GenericVector.R	2010-07-07 12:08:13 UTC (rev 1802)
@@ -119,10 +119,21 @@
                     list["foo"] = 10 ;
                     list["bar" ] = "foobar" ;
                     return list ;
-                   ')
+                   '), 
+              "create_" = list( 
+              	signature(), 
+              	'
+					List output(2); 
+					output[0] = List::create( 10, "foo" ) ;
+					output[1] = List::create( 
+						_["foo"] = 10, 
+						_["bar"] = true ) ;
+					return output ;
+				'
+              )
+              
+        )
 
-                  )
-
         g <- list("initializer_list"=list(
                   signature(),
                   'SEXP x0 = PROTECT( Rf_ScalarInteger( 0 ) ) ;
@@ -269,4 +280,9 @@
     checkEquals( fun(), list( foo = 10, bar = "foobar" ), msg = "List implicit push back" )
 }
 
+test.List.create <- function(){
+	fun <- .rcpp.List$create_
+    checkEquals( fun(), list( list( 10L, "foo" ), list(foo = 10L, bar =  TRUE ) ), 
+		msg = "List::create" )
+}
 

Modified: pkg/Rcpp/inst/unitTests/runit.IntegerVector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.IntegerVector.R	2010-07-07 12:06:59 UTC (rev 1801)
+++ pkg/Rcpp/inst/unitTests/runit.IntegerVector.R	2010-07-07 12:08:13 UTC (rev 1802)
@@ -145,7 +145,19 @@
 
                   ,"create_zero"=list(
                    signature(),
-                   'return IntegerVector::create();')
+                   'return IntegerVector::create();'
+                  ), 
+                  "create_" = list( 
+                  signature(), 
+                  '
+					List output(2); 
+					output[0] = IntegerVector::create( 10, 20 ) ;
+					output[1] = IntegerVector::create( 
+						_["foo"] = 20, 
+						_["bar"] = 30 ) ;
+					return output ;
+					' 
+                  )
 
                   )
 
@@ -327,4 +339,10 @@
     checkEquals( fun(), integer(0), msg = "IntegerVector::create()" )
 }
 
+test.IntegerVector.create <- function(){
+    fun <- .rcpp.IntegerVector$create_
+	checkEquals( fun(), list( c( 10L, 20L) , c(foo = 20L, bar = 30L) ), 
+		msg = "IntegerVector::create" )
+}
 
+

Deleted: pkg/Rcpp/inst/unitTests/runit.Vector.create.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Vector.create.R	2010-07-07 12:06:59 UTC (rev 1801)
+++ pkg/Rcpp/inst/unitTests/runit.Vector.create.R	2010-07-07 12:08:13 UTC (rev 1802)
@@ -1,63 +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/>.
-
-test.IntegerVector.create <- function(){
-	fx <- cppfunction(signature(), '
-	List output(2); 
-	output[0] = IntegerVector::create( 10, 20 ) ;
-	output[1] = IntegerVector::create( 
-		_["foo"] = 20, 
-		_["bar"] = 30 ) ;
-	return output ;
-	' )
-	
-	checkEquals( fx(), list( c( 10L, 20L) , c(foo = 20L, bar = 30L) ), 
-		msg = "IntegerVector::create" )
-}
-
-test.List.create <- function(){
-	fx <- cppfunction(signature(), '
-	List output(2); 
-	output[0] = List::create( 10, "foo" ) ;
-	output[1] = List::create( 
-		_["foo"] = 10, 
-		_["bar"] = true ) ;
-	return output ;
-	' )
-	
-	checkEquals( fx(), list( list( 10L, "foo" ), list(foo = 10L, bar =  TRUE ) ), 
-		msg = "List::create" )
-}
-
-test.CharacterVector.create <- function(){
-	fx <- cppfunction(signature(), '
-	List output(2); 
-	output[0] = CharacterVector::create( "foo", "bar" ) ;
-	output[1] = CharacterVector::create( 
-		_["foo"] = "bar", 
-		_["bar"] = "foo"
-		) ;
-	return output ;
-	')
-	
-	checkEquals( fx(), list( c( "foo", "bar" ), c(foo = "bar", bar = "foo" ) ), 
-	 	msg = "CharacterVector::create" )
-	
-}
-



More information about the Rcpp-commits mailing list