Skip to content

Commit

Permalink
Merge branch 'issue-25': Further tweaks to error message plus add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinsimpson committed Feb 11, 2019
2 parents e4e75a4 + ac05019 commit 245ac45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/evaluate_smooth.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}
smooth_ids <- which_smooth(object, smooth) # which smooths match 'smooth'
if (identical(length(smooth_ids), 0L)) {
stop("Request smooth not found in the model <", smooth, ">", call. = FALSE)
stop("Requested smooth '", smooth, "' not found", call. = FALSE)
}
smooth_labels <- select_smooth(object, smooth)

Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-evaluate-smooth-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ test_that("evaluate_smooth throws a message with more than one term", {
"Supplied more than 1 'smooth'; using only the first")
})

test_that("evaluate_smooth throws error if smooth not found", {
expect_error(evaluate_smooth(m1, smooth = "s(z)"),
"Requested smooth 's(z)' not found",
fixed = TRUE)
})

test_that("evaluate_smooth works for a GAMM", {
sm <- evaluate_smooth(m2, "s(x2)")
expect_is(sm, "evaluated_1d_smooth")
Expand Down

0 comments on commit 245ac45

Please sign in to comment.