[Eventstudies-commits] r377 - pkg/inst/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 15 01:49:10 CEST 2014


Author: chiraganand
Date: 2014-10-15 01:49:09 +0200 (Wed, 15 Oct 2014)
New Revision: 377

Modified:
   pkg/inst/tests/test_eventstudy.R
   pkg/inst/tests/test_interfaces.R
Log:
Added a test case to check for time-based classes for phys2eventtime, fixed other test cases to comply to this.

Modified: pkg/inst/tests/test_eventstudy.R
===================================================================
--- pkg/inst/tests/test_eventstudy.R	2014-10-09 01:13:33 UTC (rev 376)
+++ pkg/inst/tests/test_eventstudy.R	2014-10-14 23:49:09 UTC (rev 377)
@@ -67,4 +67,12 @@
 a <- phys2eventtime(p, eventslist, width = 2)
 expect_that(as.numeric(a$z.e["0",]),
             equals(as.numeric(p$ITC[as.Date(eventdate_output), ])))
+
+
+## events$when should be a time-based class
+cat("\nTesting class of events$when: ")
+eventdate <- "2004-01-09"
+eventslist <- data.frame(name = "ITC", when = eventdate,
+                         stringsAsFactors = FALSE)
+expect_error(a <- phys2eventtime(p, eventslist, width = 2), regexp = "events\\$when.*class.*$")
 })

Modified: pkg/inst/tests/test_interfaces.R
===================================================================
--- pkg/inst/tests/test_interfaces.R	2014-10-09 01:13:33 UTC (rev 376)
+++ pkg/inst/tests/test_interfaces.R	2014-10-14 23:49:09 UTC (rev 377)
@@ -35,7 +35,7 @@
     expected_outcomes <- c("success", "success")
 
     test_events <- data.frame(name = "ONGC",
-                              when = c("2011-08-01", "2010-05-14"),
+                              when = as.Date(c("2011-08-01", "2010-05-14")),
                               stringsAsFactors = FALSE)
     test_returns<- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
                                      drop = FALSE]
@@ -56,7 +56,7 @@
     expected_outcomes <- c("success", "success")
 
     test_events <- data.frame(name = "ONGC",
-                              when = c("2011-08-01", "2010-05-14"),
+                              when = as.Date(c("2011-08-01", "2010-05-14")),
                               stringsAsFactors = FALSE)
     test_returns<- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
                                      drop = FALSE]
@@ -79,7 +79,7 @@
     expected_outcomes <- c("success", "success")
 
     test_events <- data.frame(name = "ONGC",
-                              when = c("2011-08-01", "2010-05-14"),
+                              when = as.Date(c("2011-08-01", "2010-05-14")),
                               stringsAsFactors = FALSE)
     test_returns<- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
                                      drop = FALSE]
@@ -97,7 +97,7 @@
 ### Remapping
     cat("\nChecking remapping: ")
     test_events <- data.frame(name = "ONGC",
-                              when = c("2011-08-01", "2010-05-14"),
+                              when = as.Date(c("2011-08-01", "2010-05-14")),
                               stringsAsFactors = FALSE)
     test_returns <- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
                                       drop = FALSE]



More information about the Eventstudies-commits mailing list