Skip to content

Commit

Permalink
Test that arguments are matched by position/name before/after dots
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
egnha committed Jun 6, 2018
1 parent 3d18b58 commit 7a6204a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/testthat/test-compose.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,25 @@ test_that("unquoting operators can be literally expressed", {
expect_equal(f(x), rlang::exprs(1, 2))
})

test_that("arguments matched by position/name before/after dots (#6)", {
f <- (function(x, ...) list(x = x, ...)) %>>>% identity
expect_identical(f(1), list(x = 1))
expect_identical(f(1, 2), list(x = 1, 2))

f <- (function(..., y = "y") list(..., y = y)) %>>>% identity
expect_identical(f(1), list(1, y = "y"))
expect_identical(f(y = "Y", 1), list(1, y = "Y"))

f <- (function(x, ..., y = "y") list(x = x, ..., y = y)) %>>>% identity
expect_identical(f(1), list(x = 1, y = "y"))
expect_identical(f(1, 2), list(x = 1, 2, y = "y"))
expect_identical(f(1, 2, y = "Y"), list(x = 1, 2, y = "Y"))

# "degenerate" case
f <- (function(...) list(...)) %>>>% identity
expect_identical(f(x = 1, 2), list(x = 1, 2))
})

context("Decomposing compositions")

test_that("tree structure of composition preserved when converting to list", {
Expand Down

0 comments on commit 7a6204a

Please sign in to comment.