Skip to content

Commit

Permalink
ever fine tuning about heuristic #28
Browse files Browse the repository at this point in the history
  • Loading branch information
piccolbo committed Apr 17, 2015
1 parent 8200825 commit 082bc47
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions pkg/R/quickcheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,34 @@ check.covr =
install_github(\"jimhester/covr@b181831f0fd4299f70c330b87a73d9ec2d13433\")")

tested.functions =
function(expr, envir) {
function(assertion) {
funs =
names(
do.call(
c,
mget(
all.names(expr),
envir = envir,
ifnotfound = list(list()),
inherits = TRUE,
mode = "function")))
mask = funs %in% c(ls(search()[1]), ls(search()[2]))
unique(
names(
do.call(
c,
mget(
all.names(body(assertion)),
envir = environment(assertion),
ifnotfound = list(list()),
inherits = TRUE,
mode = "function"))))
mask =
funs %in%
c(
ls(environment(assertion)),
ls(parent.env(environment(assertion))))
funs[mask]}

test =
function(
assertion,
sample.size = default(sample.size %||% severity),
stop = !interactive(),
about = tested.functions(body(assertion), parent.frame()),
about = tested.functions(assertion),
cover = FALSE) {
about = as.character(about)
print(paste("Testing", paste(about, collapse = " ")))
seed =
cksum(
digest(
Expand All @@ -171,8 +178,6 @@ test =
message("Using seed ", seed)
set.seed(seed)
stopifnot(is.function(assertion))
if(!is.character(about))
about = as.character(substitute(about))
envir = parent.frame()
if(is.logical(cover))
cover = {
Expand Down Expand Up @@ -287,9 +292,7 @@ test.set = function(..., block = {}) {
ll = list()
ll[[name]] = x$assertion
ll})))
retval = structure(retval[sort(names(retval))], class = "TestSet")
print(retval)
retval}
structure(retval[sort(names(retval))], class = "TestSet")}

get.source =
function(f) {
Expand Down

0 comments on commit 082bc47

Please sign in to comment.