Skip to content

Commit 65344e9

Browse files
committed
test cases for printing
1 parent 64c7f98 commit 65344e9

11 files changed

+48
-0
lines changed

tests/testthat/test_boost_tree_C50.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ test_that('C5.0 execution', {
3232
),
3333
regexp = NA
3434
)
35+
expect_output(print(res), "parsnip model object")
36+
3537
expect_error(
3638
res <- fit_xy(
3739
lc_basic,

tests/testthat/test_linear_reg.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ test_that('lm execution', {
225225
),
226226
regexp = NA
227227
)
228+
expect_output(print(res), "parsnip model object")
229+
228230
expect_error(
229231
res <- fit_xy(
230232
iris_basic,

tests/testthat/test_logistic_reg.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ test_that('glm execution', {
245245
),
246246
regexp = NA
247247
)
248+
expect_output(print(res), "parsnip model object")
249+
248250
expect_error(
249251
res <- fit(
250252
lc_basic,

tests/testthat/test_mars.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ test_that('mars execution', {
139139
),
140140
regexp = NA
141141
)
142+
expect_output(print(res), "parsnip model object")
143+
142144
expect_error(
143145
res <- fit_xy(
144146
iris_basic,

tests/testthat/test_misc.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,34 @@ test_that('getting y names from terms', {
5656

5757
})
5858

59+
# ------------------------------------------------------------------------------
60+
61+
test_that('S3 method dispatch/registration', {
62+
63+
expect_error(
64+
res <-
65+
null_model() %>%
66+
set_engine("parsnip") %>%
67+
set_mode("regression") %>%
68+
fit(mpg ~ ., data = mtcars) %>%
69+
tidy(),
70+
regex = NA
71+
)
72+
expect_true(tibble::is_tibble(res))
73+
74+
expect_error(
75+
res <-
76+
null_model() %>%
77+
set_engine("parsnip") %>%
78+
set_mode("classification") %>%
79+
fit(Species ~ ., data = iris) %>%
80+
tidy(),
81+
regex = NA
82+
)
83+
expect_true(tibble::is_tibble(res))
84+
85+
86+
87+
})
88+
89+

tests/testthat/test_mlp_nnet.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ test_that('nnet execution, classification', {
2727
),
2828
regexp = NA
2929
)
30+
expect_output(print(res), "parsnip model object")
31+
3032
expect_error(
3133
res <- parsnip::fit_xy(
3234
iris_nnet,

tests/testthat/test_multinom_reg_nnet.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ test_that('model fitting', {
4141
),
4242
regexp = NA
4343
)
44+
expect_output(print(fit1), "parsnip model object")
4445

4546
set.seed(257)
4647
expect_error(

tests/testthat/test_rand_forest_ranger.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ test_that('ranger classification execution', {
3434
),
3535
regexp = NA
3636
)
37+
expect_output(print(res), "parsnip model object")
3738

3839
expect_error(
3940
res <- fit_xy(

tests/testthat/test_surv_reg_survreg.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ test_that('survival execution', {
2828
),
2929
regexp = NA
3030
)
31+
expect_output(print(res), "parsnip model object")
3132
expect_error(
3233
res <- fit(
3334
surv_lnorm,

tests/testthat/test_svm_poly.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ test_that('svm poly regression', {
139139

140140
expect_false(has_multi_predict(res))
141141
expect_equal(multi_predict_args(res), NA_character_)
142+
expect_output(print(res), "parsnip model object")
142143

143144
expect_error(
144145
fit(

0 commit comments

Comments
 (0)