[Rcpp-devel] [Rcpp-commits] r333 - in pkg: inst inst/unitTests src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 10 10:03:46 CET 2010


Author: romain
Date: 2010-01-10 10:03:46 +0100 (Sun, 10 Jan 2010)
New Revision: 333

Modified:
   pkg/inst/ChangeLog
   pkg/inst/unitTests/runit.Function.R
   pkg/src/Function.cpp
Log:
added unit test for function throwing exceptions

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-01-09 22:36:05 UTC (rev 332)
+++ pkg/inst/ChangeLog	2010-01-10 09:03:46 UTC (rev 333)
@@ -1,3 +1,10 @@
+2010-01-10  Romain Francois <francoisromain at free.fr>
+
+	* inst/unitTests/runit.Function.R: added unit test for function
+	throwing exceptions
+
+	* src/Function.cpp: grab the condition message and not the call
+
 2010-01-09  Romain Francois <francoisromain at free.fr>
 
 	* src/Rcpp/RObject.h: attr can now be used to get or set the 

Modified: pkg/inst/unitTests/runit.Function.R
===================================================================
--- pkg/inst/unitTests/runit.Function.R	2010-01-09 22:36:05 UTC (rev 332)
+++ pkg/inst/unitTests/runit.Function.R	2010-01-10 09:03:46 UTC (rev 333)
@@ -38,12 +38,13 @@
 
 test.Function.variadic <- function(){
 	if( Rcpp:::canUseCXX0X() ){
-		funx <- cfunction(signature(x="function", y = "numeric"), '
+		funx <- cfunction(signature(x="function", y = "ANY"), '
 		Function sort(x) ;
 		return sort( y, Named("decreasing", true) ) ;
 		', Rcpp=TRUE, verbose=FALSE, includes = "using namespace Rcpp;" )
 		checkEquals( funx( sort, sample(1:20) ), 
 			20:1, msg = "calling function" )
+		checkException( funx(sort, sort), msg = "Function, R error -> exception" )
 	}
 }
 

Modified: pkg/src/Function.cpp
===================================================================
--- pkg/src/Function.cpp	2010-01-09 22:36:05 UTC (rev 332)
+++ pkg/src/Function.cpp	2010-01-10 09:03:46 UTC (rev 333)
@@ -58,7 +58,7 @@
 			message = "unknown error" ;
 		} else{
 			message = as<std::string>( Rf_eval( 
-				Rf_lang2( Rf_install("conditionCall"), err), 
+				Rf_lang2( Rf_install("conditionMessage"), err), 
 				R_GlobalEnv ) );
 		}
 	}

_______________________________________________
Rcpp-commits mailing list
Rcpp-commits at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-commits


More information about the Rcpp-devel mailing list