-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #453 from swirldev/dev
swirl 2.4.1
- Loading branch information
Showing
25 changed files
with
233 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
user_data/ | ||
^\.travis\.yml$ | ||
^cran-comments\.md$ | ||
^revdep$ |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ Description: Use the R console as an interactive learning | |
environment. Users receive immediate feedback as they are guided through | ||
self-paced lessons in data science and R programming. | ||
URL: http://swirlstats.com | ||
Version: 2.4.0 | ||
Version: 2.4.1 | ||
License: MIT + file LICENSE | ||
Authors@R: c( | ||
person("Sean", "Kross", email = "[email protected]", role = c("aut", "cre")), | ||
|
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
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
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 |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# The versions of the functions below have been graciously borrowed | ||
# from version 0.11.0 of the testthat package by | ||
# Hadley Wickham and others at RStudio. These APIs | ||
# were broken in later versions of testthat and we know the | ||
# old version works for our purposes. | ||
|
||
expectation_legacy <- function(passed, failure_msg, | ||
success_msg = "unknown", | ||
srcref = NULL) { | ||
structure( | ||
list( | ||
passed = passed, | ||
error = FALSE, | ||
skipped = FALSE, | ||
failure_msg = failure_msg, | ||
success_msg = success_msg, | ||
srcref = srcref | ||
), | ||
class = "expectation" | ||
) | ||
} | ||
|
||
#' @importFrom testthat compare | ||
equals_legacy <- function(expected, label = NULL, ...) { | ||
if (is.null(label)) { | ||
label <- findExpr("expected") | ||
} else if (!is.character(label) || length(label) != 1) { | ||
label <- deparse(label) | ||
} | ||
|
||
function(actual) { | ||
same <- compare(actual, expected, ...) | ||
|
||
expectation_legacy( | ||
same$equal, | ||
paste0("not equal to ", label, "\n", same$message), | ||
paste0("equals ", label) | ||
) | ||
} | ||
} | ||
|
||
is_a_legacy <- function(class) { | ||
function(x) { | ||
actual_s <- paste0(class(x), collapse = ", ") | ||
class_s <- paste(class, collapse = ", ") | ||
expectation_legacy( | ||
inherits(x, class), | ||
paste0("inherits from ", actual_s, " not ", class_s), | ||
paste0("inherits from ", class_s) | ||
) | ||
} | ||
} | ||
|
||
is_equivalent_to_legacy <- function(expected, label = NULL) { | ||
if (is.null(label)) { | ||
label <- findExpr("expected") | ||
} else if (!is.character(label) || length(label) != 1) { | ||
label <- deparse(label) | ||
} | ||
function(actual) { | ||
equals_legacy(expected, check.attributes = FALSE)(actual) | ||
} | ||
} | ||
|
||
is_identical_to_legacy <- function(expected, label = NULL) { | ||
if (is.null(label)) { | ||
label <- findExpr("expected") | ||
} else if (!is.character(label) || length(label) != 1) { | ||
label <- deparse(label) | ||
} | ||
|
||
function(actual) { | ||
if (identical(actual, expected)) { | ||
diff <- "" | ||
} else { | ||
same <- all.equal(expected, actual) | ||
if (isTRUE(same)) { | ||
diff <- "Objects equal but not identical" | ||
} else { | ||
diff <- paste0(same, collapse = "\n") | ||
} | ||
} | ||
|
||
expectation_legacy( | ||
identical(actual, expected), | ||
paste0("is not identical to ", label, ". Differences: \n", diff), | ||
paste0("is identical to ", label) | ||
) | ||
} | ||
} | ||
|
||
matches_legacy <- function(regexp, all = TRUE, ...) { | ||
stopifnot(is.character(regexp), length(regexp) == 1) | ||
function(char) { | ||
matches <- grepl(regexp, char, ...) | ||
if (length(char) > 1) { | ||
values <- paste0("Actual values:\n", | ||
paste0("* ", encodeString(char), collapse = "\n")) | ||
} else { | ||
values <- paste0("Actual value: \"", encodeString(char), "\"") | ||
} | ||
|
||
expectation_legacy( | ||
length(matches) > 0 && if (all) all(matches) else any(matches), | ||
paste0("does not match '", encodeString(regexp), "'. ", values), | ||
paste0("matches '", encodeString(regexp), "'") | ||
) | ||
} | ||
} |
Oops, something went wrong.