[Sciviews-commits] r513 - komodo/SciViews-K pkg/svUnit
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jan 12 12:28:09 CET 2013
Author: phgrosjean
Date: 2013-01-12 12:28:08 +0100 (Sat, 12 Jan 2013)
New Revision: 513
Added:
pkg/svUnit/TestsvUnit.R
Modified:
komodo/SciViews-K/install.rdf
Log:
Switch to SciViews-K 0.9-30
Add of a test file in svUnit
Modified: komodo/SciViews-K/install.rdf
===================================================================
--- komodo/SciViews-K/install.rdf 2013-01-11 17:28:27 UTC (rev 512)
+++ komodo/SciViews-K/install.rdf 2013-01-12 11:28:08 UTC (rev 513)
@@ -5,7 +5,7 @@
<em:unpack>true</em:unpack>
<em:id>sciviewsk at sciviews.org</em:id>
<em:name>SciViews-K</em:name>
- <em:version>0.9.29</em:version>
+ <em:version>0.9.30</em:version>
<em:description>Edit R code with Komodo</em:description>
<em:creator>Philippe Grosjean</em:creator>
<em:contributor>Romain Francois</em:contributor>
Added: pkg/svUnit/TestsvUnit.R
===================================================================
--- pkg/svUnit/TestsvUnit.R (rev 0)
+++ pkg/svUnit/TestsvUnit.R 2013-01-12 11:28:08 UTC (rev 513)
@@ -0,0 +1,49 @@
+## To be promoted as a demo?
+require(svUnit)
+options(svUnit.excludeList = NULL)
+foo <- function(x, y = 2) return(x * y)
+#is.test(foo) # No
+## Create test cases for this function
+test(foo) <- function () {
+ checkEqualsNumeric(4, foo(2))
+ checkEqualsNumeric(5, foo(2, 3)) # Should fail
+ checkTrue(is.test(foo))
+ checkTrue(is.test(test(foo)))
+ checkIdentical(attr(foo, "test"), test(foo))
+ checkException(foo(2, dfgfg))
+ #DEACTIVATED("My deactivation message")
+ checkException(foo("bb"))
+}
+
+test_simple <- svTest(function () {
+ checkTrue(1 == 1, "test1")
+ checkTrue(1 == 2, "test2")
+ checkTrue(1 == var, "test3")
+})
+
+## This is for an example!
+clearLog()
+imax <- 3
+jmax <- 100
+l <- 50
+Rprof()
+for (i in 1:imax) {
+ .LogTest <- paste("Test", i, sep = "")
+ .LogTag <- paste("#", i, sep = "")
+ res <- system.time({
+ for (j in 1:jmax) checkTrue(i<=j, "My test")
+ }, gcFirst = TRUE)[3]
+ print(res)
+ flush.console()
+}
+Rprof(NULL)
+summaryRprof()$by.self
+summary(.Log[[.LogTest]])
+rm(.LogTest, .LogTag)
+unlink("Rprof.out")
+
+Rprof()
+system.time(for (i in 1:100) runTest(test.bar))[3]
+Rprof(NULL)
+summaryRprof()
+unlink("Rprof.out")
More information about the Sciviews-commits
mailing list