Skip to content

Commit

Permalink
#54 test shared env for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbarbone committed May 1, 2023
1 parent 984901f commit 2f5d230
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/testthat/test-class-command-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,32 @@ test_that("positional defaults [#52]", {
expect_identical(obj, exp)
})

test_that("pass arg as default [#54]", {
ca <- command_args(include = NA)
arg <- new_arg("-a", action = "flag")
ca$add_argument(arg)
ca$add_argument("-b", default = arg)

obj <- ca$parse()
exp <- list(a = FALSE, b = FALSE)
expect_identical(obj, exp)

ca$set_input("-a")
obj <- ca$parse()
exp <- list(a = TRUE, b = TRUE)
expect_identical(obj, exp)

ca$set_input("-b")
obj <- ca$parse()
exp <- list(a = FALSE, b = TRUE)
expect_identical(obj, exp)

ca$set_input(c("-a", "-b"))
obj <- ca$parse()
exp <- list(a = TRUE, b = TRUE)
expect_identical(obj, exp)
})

test_that("snapshots", {
ca <- command_args(string = "foo bar --fizz")
ca$add_description("this does a thing")
Expand Down

0 comments on commit 2f5d230

Please sign in to comment.