Skip to content

Commit a8c39c9

Browse files
committed
Improve formula expansion testing
1 parent a4fabc2 commit a8c39c9

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

man/formula.substituting_formula.Rd

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-formula_math.R

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,43 @@ test_that("Expansion works", {
249249
find=quote(c),
250250
replace=quote(formulops_expand(d, e))
251251
),
252-
a~b(d, e)
252+
a~b(d, e),
253+
info="without names"
254+
)
255+
expect_equal(
256+
modify_formula(
257+
a~b(c=d),
258+
find=quote(d),
259+
replace=quote(formulops_expand(e, f))
260+
),
261+
a~b(e, f),
262+
info="with names in source"
263+
)
264+
expect_equal(
265+
modify_formula(
266+
a~b(c=d),
267+
find=quote(d),
268+
replace=quote(formulops_expand(g=e, h=f))
269+
),
270+
a~b(g=e, h=f),
271+
info="with names in replacement"
272+
)
273+
expect_equal(
274+
modify_formula(
275+
a~b(d, j)+k,
276+
find=quote(d),
277+
replace=quote(formulops_expand(g=e, h=f))
278+
),
279+
a~b(g=e, h=f, j)+k,
280+
info="without names in the longer source"
281+
)
282+
expect_equal(
283+
modify_formula(
284+
a~b(c=d, i=j)+k,
285+
find=quote(d),
286+
replace=quote(formulops_expand(g=e, h=f))
287+
),
288+
a~b(g=e, h=f, i=j)+k,
289+
info="with names in the longer source"
253290
)
254291
})

0 commit comments

Comments
 (0)