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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 25 01:30:24 CEST 2010


Author: jmc
Date: 2010-09-25 01:30:23 +0200 (Sat, 25 Sep 2010)
New Revision: 2166

Modified:
   pkg/Rcpp/inst/unitTests/runit.modref.R
Log:
setup as unit test

Modified: pkg/Rcpp/inst/unitTests/runit.modref.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.modref.R	2010-09-24 19:40:08 UTC (rev 2165)
+++ pkg/Rcpp/inst/unitTests/runit.modref.R	2010-09-24 23:30:23 UTC (rev 2166)
@@ -1,9 +1,26 @@
-    require( Rcpp )
-    if(!require( inline ))
-     q("no")
+#!/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/>.
 
-	inc  <- '
 
+test.modRef <- function() {
+    inc  <- '
+
 	class World {
 	public:
 	    World() : foo(1), msg("hello") {}
@@ -36,25 +53,27 @@
 	}
 
 	'
-	fx <- inline::cxxfunction( signature(), "" , include = inc, plugin = "Rcpp" )
+    fx <- inline::cxxfunction( signature(), "" , include = inc, plugin = "Rcpp" )
 
-	mod <- Module( "yada", getDynLib(fx) )
+    mod <- Module( "yada", getDynLib(fx) )
 
     World <- mod$World
 
-ww = new(World)
-wg = World$new()
+    ww = new(World)
+    wg = World$new()
 
-stopifnot(all.equal(ww$greet(), wg$greet()))
-wgg <- wg$greet()
+    checkEquals(ww$greet(), wg$greet())
+    wgg <- wg$greet()
 
-ww$set("Other")
+    ww$set("Other")
 
-## test independence of ww, wg
-stopifnot(all.equal(ww$greet(), "Other"),
-          all.equal(wg$greet(), wgg))
+    ## test independence of ww, wg
+    checkEquals(ww$greet(), "Other")
+    checkEquals(wg$greet(), wgg)
 
-World$methods(
-     twice = function() paste(greet(), greet()))
+    World$methods(
+                  twice = function() paste(greet(), greet()))
 
-stopifnot(all.equal(ww$twice(), paste(ww$greet(), ww$greet())))
+    checkEquals(ww$twice(), paste(ww$greet(), ww$greet()))
+
+}



More information about the Rcpp-commits mailing list