Skip to content

Commit ed5c73a

Browse files
committed
added code to test interface logic checks
1 parent 39ecfc3 commit ed5c73a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library(testthat)
2+
library(parsnip)
3+
library(recipes)
4+
library(rlang)
5+
6+
rec <- recipe(~ ., data = iris)
7+
f <- y ~ x
8+
9+
tester <-
10+
function(object, formula = NULL, recipe = NULL, x = NULL, y = NULL, data = NULL)
11+
parsnip:::check_interface(formula, recipe, x, y, data, match.call(expand.dots = TRUE))
12+
13+
test_that('good args', {
14+
expect_equal(tester(NULL, formula = f, data = iris), "formula")
15+
expect_equal(tester(NULL, recipe = rec, data = iris), "recipe")
16+
expect_equal(tester(NULL, x = iris, y = iris), "xy")
17+
expect_equal(tester(NULL, f, data = iris), "formula")
18+
expect_equal(tester(NULL, formula = f, data = iris, y = iris), "formula")
19+
})
20+
21+
test_that('unnamed args', {
22+
expect_error(tester(NULL, rec, data = iris))
23+
expect_error(tester(NULL, iris, y = iris))
24+
expect_error(tester(NULL, data = iris))
25+
})
26+
27+
test_that('wrong args', {
28+
expect_error(tester(NULL, x = iris, data = iris))
29+
expect_error(tester(NULL, f, x = iris, y = iris, data = iris))
30+
})
31+
32+

0 commit comments

Comments
 (0)