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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jul 7 17:48:29 CEST 2010


Author: edd
Date: 2010-07-07 17:48:29 +0200 (Wed, 07 Jul 2010)
New Revision: 1826

Removed:
   pkg/Rcpp/inst/unitTests/runit.RcppDatetime.R
Modified:
   pkg/Rcpp/inst/unitTests/runit.RcppDate.R
Log:
moved RcppDatetime into RcppDate and converted to faster 'one compile' style


Modified: pkg/Rcpp/inst/unitTests/runit.RcppDate.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.RcppDate.R	2010-07-07 15:36:51 UTC (rev 1825)
+++ pkg/Rcpp/inst/unitTests/runit.RcppDate.R	2010-07-07 15:48:29 UTC (rev 1826)
@@ -28,10 +28,10 @@
                            rs.add("day",   dt.getDay());
                            rs.add("year",  dt.getYear());
                            rs.add("julian",dt.getJulian());
-                           return rs.getReturnList();'),
+                           return rs.getReturnList();')
 
-                          "operators"=list(
-                          signature(),
+                          ,"operators"=list(
+                           signature(),
                           'RcppDate d1 = RcppDate(12,31,1999);
                            RcppDate d2 = d1 + 1;
                            RcppResultSet rs;
@@ -41,13 +41,47 @@
                            rs.add("equal",   d2 == d1);
                            rs.add("ge",      d2 >= d1);
                            rs.add("le",      d2 <= d1);
-                           return rs.getReturnList();'),
+                           return rs.getReturnList();')
 
-                          "wrap"=list(
-                          signature(),
+                          ,"wrap"=list(
+                           signature(),
                           'RcppDate dt = RcppDate(12,31,1999);
                            return wrap(dt);')
 
+                          ,"RcppDatetime_functions"=list(
+                           signature(x="numeric"),
+                           'RcppDatetime dt = RcppDatetime(x);
+		            RcppResultSet rs;
+		            rs.add("year",     dt.getYear());
+		            rs.add("month",    dt.getMonth());
+		            rs.add("day",      dt.getDay());
+		            rs.add("wday",     dt.getWeekday());
+		            rs.add("hour",     dt.getHour());
+		            rs.add("minute",   dt.getMinute());
+		            rs.add("second",   dt.getSecond());
+		            rs.add("microsec", dt.getMicroSec());
+		            return rs.getReturnList();')
+
+                          ,"RcppDatetime_operators"=list(
+                           signature(x="numeric"),
+                           'RcppDatetime d1 = RcppDatetime(946774923.123456);
+		            //RcppDatetime d1 = RcppDatetime(1152338523.456789);
+						// as.POSIXct("2006-07-08 01:02:03.456789")
+		            RcppDatetime d2 = d1 + 60*60;
+		            RcppResultSet rs;
+        	            rs.add("diff",    d2 - d1);
+	                    rs.add("bigger",  d2 > d1);
+	                    rs.add("smaller", d2 < d1);
+	                    rs.add("equal",   d2 == d1);
+	                    rs.add("ge",      d2 >= d1);
+	                    rs.add("le",      d2 <= d1);
+	            	    return rs.getReturnList();')
+
+                           ,"RcppDatetime_wrap"=list(
+                            signature(),
+                            'RcppDatetime dt = RcppDatetime(981162123.123456);
+	    		     return wrap(dt);')
+
                           )
 
         signatures <- lapply(functions, "[[", 1L)
@@ -65,7 +99,8 @@
 
 test.RcppDate.operators <- function() {
     fun <- .rcpp.RcppDate$operators
-    checkEquals(fun(), list(diff=1, bigger=TRUE, smaller=FALSE, equal=FALSE, ge=TRUE, le=FALSE), msg = "RcppDate.operators")
+    checkEquals(fun(), list(diff=1, bigger=TRUE, smaller=FALSE, equal=FALSE, ge=TRUE, le=FALSE),
+                msg = "RcppDate.operators")
 }
 
 test.RcppDate.wrap <- function() {
@@ -73,3 +108,22 @@
     checkEquals(fun(), as.Date("1999-12-31"), msg = "RcppDate.wrap")
 }
 
+test.RcppDatetime.get.functions <- function() {
+    fun <- .rcpp.RcppDate$RcppDatetime_functions
+    checkEquals(fun(as.numeric(as.POSIXct("2001-02-03 01:02:03.123456"))),
+                list(year=2001, month=2, day=3, wday=6, hour=1, minute=2, second=3, microsec=123456),
+                msg = "RcppDate.get.functions")
+}
+
+test.RcppDatetime.operators <- function() {
+    fun <- .rcpp.RcppDate$RcppDatetime_operators
+    checkEquals(fun(as.numeric(as.POSIXct("2001-02-03 01:02:03.123456"))),
+                list(diff=3600, bigger=TRUE, smaller=FALSE, equal=FALSE, ge=TRUE, le=FALSE),
+                msg = "RcppDatetime.operators")
+}
+
+test.RcppDatetime.wrap <- function() {
+    fun <- .rcpp.RcppDate$RcppDatetime_wrap
+    checkEquals(as.numeric(fun()), as.numeric(as.POSIXct("2001-02-03 01:02:03.123456", tz="UTC")),
+                msg = "RcppDatetime.wrap")
+}

Deleted: pkg/Rcpp/inst/unitTests/runit.RcppDatetime.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.RcppDatetime.R	2010-07-07 15:36:51 UTC (rev 1825)
+++ pkg/Rcpp/inst/unitTests/runit.RcppDatetime.R	2010-07-07 15:48:29 UTC (rev 1826)
@@ -1,62 +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.RcppDatetime.get.functions <- function() {
-    src <- 'RcppDatetime dt = RcppDatetime(x);
-            RcppResultSet rs;
-            rs.add("year",     dt.getYear());
-            rs.add("month",    dt.getMonth());
-            rs.add("day",      dt.getDay());
-            rs.add("wday",     dt.getWeekday());
-            rs.add("hour",     dt.getHour());
-            rs.add("minute",   dt.getMinute());
-            rs.add("second",   dt.getSecond());
-            rs.add("microsec", dt.getMicroSec());
-            return rs.getReturnList();';
-    funx <- cppfunction(signature(x="numeric"), src)
-    checkEquals(funx(as.numeric(as.POSIXct("2001-02-03 01:02:03.123456"))),
-                list(year=2001, month=2, day=3, wday=6, hour=1, minute=2, second=3, microsec=123456),
-                msg = "RcppDate.get.functions")
-}
-
-test.RcppDatetime.operators <- function() {
-     src <- 'RcppDatetime d1 = RcppDatetime(946774923.123456);
-             //RcppDatetime d1 = RcppDatetime(1152338523.456789); // as.POSIXct("2006-07-08 01:02:03.456789")
-             RcppDatetime d2 = d1 + 60*60;
-             RcppResultSet rs;
-             rs.add("diff",    d2 - d1);
-             rs.add("bigger",  d2 > d1);
-             rs.add("smaller", d2 < d1);
-             rs.add("equal",   d2 == d1);
-             rs.add("ge",      d2 >= d1);
-             rs.add("le",      d2 <= d1);
-   	     return rs.getReturnList();';
-     funx <- cppfunction(signature(x="numeric"), src)
-     checkEquals(funx(as.numeric(as.POSIXct("2001-02-03 01:02:03.123456"))),
-                      list(diff=3600, bigger=TRUE, smaller=FALSE, equal=FALSE, ge=TRUE, le=FALSE), msg = "RcppDatetime.operators")
-}
-
-test.RcppDatetime.wrap <- function() {
-    src <- 'RcppDatetime dt = RcppDatetime(981162123.123456);
-	    return wrap(dt);';
-    funx <- cxxfunction(signature(), src, plugin = "Rcpp" )
-    checkEquals(as.numeric(funx()), as.numeric(as.POSIXct("2001-02-03 01:02:03.123456", tz="UTC")),
-                msg = "RcppDatetime.wrap")
-}
-



More information about the Rcpp-commits mailing list