Skip to content

Commit

Permalink
Fix #234: random seed issues
Browse files Browse the repository at this point in the history
well, not really fix, but at least add a test
that should fail if the random seed isn't handled
properly
  • Loading branch information
brodieG committed Nov 23, 2017
2 parents 3c0de8b + 8e018b8 commit 2ccffdb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Expand Up @@ -15,6 +15,7 @@
now.
* [#245](https://github.com/brodieG/unitizer/issues/245) Report parse warnings
at prompt.
* [#234](https://github.com/brodieG/unitizer/issues/234) Random seed issues.
* Wrap `diffObj` call in `try` to avoid killing `unitizer` section when
`diffObj` errors.
* Modify `test_dir` calls to use `wrap` on `testthat` versions greater than
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/helper/runtt.R
Expand Up @@ -90,6 +90,7 @@ local({
"prompt",
"rename",
"repairenvs",
"random",
"search",
"section",
"shim",
Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/testthat.random.R
@@ -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")
})

0 comments on commit 2ccffdb

Please sign in to comment.