-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workshop protected arguments warning (#1216)
- Loading branch information
1 parent
58e4329
commit a4f9811
Showing
9 changed files
with
89 additions
and
65 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# warns informatively about protected arguments | ||
|
||
Code | ||
.res <- check_eng_args(args = list(a = 1, b = 2, c = 3, e = 5), obj = obj, | ||
core_args = core_args) | ||
Condition | ||
Warning: | ||
The arguments `a`, `b`, and `c` cannot be manually modified and were removed. | ||
|
||
--- | ||
|
||
Code | ||
.res <- check_eng_args(args = list(b = 2, c = 3, e = 5), obj = obj, core_args = core_args) | ||
Condition | ||
Warning: | ||
The arguments `b` and `c` cannot be manually modified and were removed. | ||
|
||
--- | ||
|
||
Code | ||
.res <- check_eng_args(args = list(c = 3, e = 5), obj = obj, core_args = core_args) | ||
Condition | ||
Warning: | ||
The argument `c` cannot be manually modified and was removed. | ||
|
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,43 @@ | ||
test_that("warns informatively about protected arguments", { | ||
obj <- list(protect = c("a", "b")) | ||
core_args <- c("c", "d") | ||
|
||
expect_snapshot( | ||
.res <- check_eng_args( | ||
args = list(a = 1, b = 2, c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
) | ||
) | ||
|
||
expect_named(.res, "e") | ||
|
||
expect_snapshot( | ||
.res <- check_eng_args( | ||
args = list(b = 2, c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
) | ||
) | ||
|
||
expect_named(.res, "e") | ||
|
||
expect_snapshot( | ||
.res <- check_eng_args( | ||
args = list(c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
) | ||
) | ||
|
||
expect_named(.res, "e") | ||
|
||
expect_warning( | ||
check_eng_args( | ||
args = list(a = 1, b = 2, c = 3, e = 5), | ||
obj = obj, | ||
core_args = core_args | ||
), | ||
class = "parsnip_protected_arg_warning" | ||
) | ||
}) |
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