Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
well, not really fix, but at least add a test that should fail if the random seed isn't handled properly
- Loading branch information
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,7 @@ local({ | |
"prompt", | ||
"rename", | ||
"repairenvs", | ||
"random", | ||
"search", | ||
"section", | ||
"shim", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
context('random') | ||
|
||
test_that('random seed', { | ||
dir <- tempfile() | ||
file <- file.path(dir, 'randtest.R') | ||
on.exit(unlink(dir, recursive=TRUE)) | ||
|
||
dir.create(dir) | ||
|
||
cat('sample(1:100)\n', file=file) | ||
|
||
set.seed(1) | ||
capture.output(unitize(file, auto.accept='new')) | ||
|
||
# changing seed should have no effect on result | ||
set.seed(23) | ||
capture.output(res <- unitize(file)) | ||
|
||
expect_equal(as.character(res$status), "Passed") | ||
}) |