-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
nteetor
committed
Jul 26, 2017
1 parent
c86a17d
commit 9f3d176
Showing
4 changed files
with
204 additions
and
158 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 |
---|---|---|
@@ -1,66 +1,67 @@ | ||
context(' * testing massign') | ||
context(" * testing massign") | ||
|
||
test_that('massign handles flat lists', { | ||
massign(list('a'), list(1)) | ||
test_that("massign handles flat lists", { | ||
massign(list("a"), list(1)) | ||
expect_equal(a, 1) | ||
|
||
massign(list('b', 'c'), list(3, 'foo')) | ||
massign(list("b", "c"), list(3, "foo")) | ||
expect_equal(b, 3) | ||
expect_equal(c, 'foo') | ||
expect_equal(c, "foo") | ||
}) | ||
|
||
test_that('massign handles nested lists', { | ||
massign(list('a', list('b')), list(1, list(2))) | ||
test_that("massign handles nested lists", { | ||
massign(list("a", list("b")), list(1, list(2))) | ||
expect_equal(a, 1) | ||
expect_equal(b, 2) | ||
|
||
massign(list('c', list('d', 'e'), 'f'), list(5, list(6, 7), 8)) | ||
massign(list("c", list("d", "e"), "f"), list(5, list(6, 7), 8)) | ||
expect_equal(c, 5) | ||
expect_equal(d, 6) | ||
expect_equal(e, 7) | ||
expect_equal(f, 8) | ||
|
||
massign(list(list('g', 'h'), list('i', 'j')), list(list('gee', 'ech'), list('ay', 'jey'))) | ||
expect_equal(g, 'gee') | ||
expect_equal(h, 'ech') | ||
expect_equal(i, 'ay') | ||
expect_equal(j, 'jey') | ||
massign(list(list("g", "h"), list("i", "j")), list(list("gee", "ech"), list("ay", "jey"))) | ||
expect_equal(g, "gee") | ||
expect_equal(h, "ech") | ||
expect_equal(i, "ay") | ||
expect_equal(j, "jey") | ||
}) | ||
|
||
test_that('massign will not destructure flat list', { | ||
massign(list('a', 'b'), list(1, list(2, 3))) | ||
test_that("massign will not destructure flat list", { | ||
massign(list("a", "b"), list(1, list(2, 3))) | ||
expect_equal(a, 1) | ||
expect_equal(b, list(2, 3)) | ||
massign(list(list('c', 'd'), 'e'), list(list('foo', list('bar', 'baz')), 'buzz')) | ||
expect_equal(c, 'foo') | ||
expect_equal(d, list('bar', 'baz')) | ||
expect_equal(e, 'buzz') | ||
massign(list(list("c", "d"), "e"), list(list("foo", list("bar", "baz")), "buzz")) | ||
expect_equal(c, "foo") | ||
expect_equal(d, list("bar", "baz")) | ||
expect_equal(e, "buzz") | ||
}) | ||
|
||
test_that('massign does not assign .', { | ||
massign(list('.'), list('pick me, pick me')) | ||
expect_false(exists('.', inherits = FALSE)) | ||
test_that("massign does not assign .", { | ||
massign(list("."), list("pick me, pick me")) | ||
expect_false(exists(".", inherits = FALSE)) | ||
|
||
massign(list('a', '.', 'b'), list(1, 2, 3)) | ||
massign(list("a", ".", "b"), list(1, 2, 3)) | ||
expect_equal(a, 1) | ||
expect_false(exists('.', inherits = FALSE)) | ||
expect_false(exists(".", inherits = FALSE)) | ||
expect_equal(b, 3) | ||
}) | ||
|
||
test_that('massign does not destructure when using rest prefix', { | ||
massign(list('...rest'), list(1, list(2, 3))) | ||
test_that("massign does not destructure when using rest prefix", { | ||
massign(list("...rest"), list(1, list(2, 3))) | ||
expect_equal(rest, list(1, list(2, 3))) | ||
|
||
massign(list('a', '...all'), list(1, list('a', 'b'))) | ||
massign(list("a", "...all"), list(1, list("a", "b"))) | ||
expect_equal(a, 1) | ||
expect_equal(all, list('a', 'b')) | ||
expect_equal(all, list("a", "b")) | ||
|
||
massign(list('f', '...rest'), list('foo', 'bar', 'baz')) | ||
expect_equal(f, 'foo') | ||
expect_equal(rest, list('bar', 'baz')) | ||
massign(list("f", "...rest"), list("foo", "bar", "baz")) | ||
expect_equal(f, "foo") | ||
expect_equal(rest, list("bar", "baz")) | ||
}) | ||
|
||
test_that('massign throws error for invalid rest prefix', { | ||
expect_error(massign(list('a', '...'), list(1, 2)), | ||
'invalid collector variable') | ||
test_that("massign throws error for invalid rest prefix", { | ||
skip("skipped for now per issue #18") | ||
expect_error(massign(list("a", "..."), list(1, 2)), | ||
"invalid collector variable") | ||
}) |
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
Oops, something went wrong.