[Vegan-commits] r2691 - in pkg/permute/inst: . tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Nov 9 05:00:13 CET 2013


Author: gsimpson
Date: 2013-11-09 05:00:13 +0100 (Sat, 09 Nov 2013)
New Revision: 2691

Added:
   pkg/permute/inst/tests/test-check.R
Modified:
   pkg/permute/inst/ChangeLog
   pkg/permute/inst/tests/test-shuffleSet.R
Log:
more unit test; document changes

Modified: pkg/permute/inst/ChangeLog
===================================================================
--- pkg/permute/inst/ChangeLog	2013-11-09 03:59:38 UTC (rev 2690)
+++ pkg/permute/inst/ChangeLog	2013-11-09 04:00:13 UTC (rev 2691)
@@ -2,6 +2,12 @@
 
 permute ChangeLog
 
+Version 0.7-6
+
+	* summary.allPerms: Was printing two slightly different subtitles.
+
+	* More unit tests...
+
 Version 0.7-5
 
 	* how: the matched call is now returned permitting the use of

Added: pkg/permute/inst/tests/test-check.R
===================================================================
--- pkg/permute/inst/tests/test-check.R	                        (rev 0)
+++ pkg/permute/inst/tests/test-check.R	2013-11-09 04:00:13 UTC (rev 2691)
@@ -0,0 +1,25 @@
+library(testthat)
+library_if_available(permute)
+
+context("Testing check()")
+
+## test that check will return all perms including the observed
+test_that("check returns observed ordering in set of all permutations *if* asked to", {
+    ## simple permutation
+    h <- how(observed = TRUE)
+    pp <- check(4, control = h)
+    expect_that(nrow(pp$control$all.perms), equals(factorial(4)))
+
+    ## time series
+    h <- how(within = Within(type = "series"), observed = TRUE)
+    n <- 10
+    pp <- check(n, control = h)
+    expect_that(nrow(pp$control$all.perms), equals(n))
+
+    ## time series specified as a vector
+    h <- how(within = Within(type = "series"), observed = TRUE)
+    n <- 10
+    vec <- seq_len(n)
+    pp <- check(vec, control = h)
+    expect_that(nrow(pp$control$all.perms), equals(n))
+})

Modified: pkg/permute/inst/tests/test-shuffleSet.R
===================================================================
--- pkg/permute/inst/tests/test-shuffleSet.R	2013-11-09 03:59:38 UTC (rev 2690)
+++ pkg/permute/inst/tests/test-shuffleSet.R	2013-11-09 04:00:13 UTC (rev 2691)
@@ -18,3 +18,25 @@
         expect_that(p[i, ], equals(y))
     }
 })
+
+## test that nset permutations are always returned if
+## make = FALSE in how()
+test_that( "shuffleSet returns exactly nset permutations when make == FALSE", {
+    ## simple random permutation
+    h <- how(make = FALSE)
+    ss <- shuffleSet(n = 4, nset = 10, control = h)
+    expect_that(nrow(ss), equals(10))
+
+    ## time series
+    h <- how(within = Within(type = "series"), make = FALSE)
+    ss <- shuffleSet(n = 20, nset = 15, control = h)
+    expect_that(nrow(ss), equals(15))
+
+})
+
+## test that shuffleSet always returns a matrix, even for nset == 1
+test_that("shuffleSet returns a matrix even for nset == 1", {
+    h <- how()
+    ss <- shuffleSet(25, nset = 1, control = h)
+    expect_that(ss, is_a("matrix"))
+})



More information about the Vegan-commits mailing list