forked from swirldev/swirl_courses
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomTests.R
More file actions
20 lines (17 loc) · 706 Bytes
/
customTests.R
File metadata and controls
20 lines (17 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# So swirl does not repeat execution of plot commands
# Returns TRUE if e$val is identical to the value that would
# have been created by the correct expression.
creates_val_identical_to <- function(correctExpr){
e <- get("e", parent.frame())
correctVal <- eval(parse(text=correctExpr), cleanEnv(e$snapshot))
results <- expectThat(e$val,
is_identical_to(correctVal, label=correctExpr),
label=deparse(e$expr))
return(results$passed)
}
# Returns TRUE if e$expr matches any of the expressions given
# (as characters) in the argument.
ANY_of_exprs <- function(...){
e <- get("e", parent.frame())
any(sapply(c(...), function(expr)omnitest(expr)))
}