Skip to content

Commit 990ab98

Browse files
author
Florence Bockting
committed
tests: check for vectorized in monkey-patch
1 parent e086c9c commit 990ab98

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

tests/testthat/test-ppc-distributions.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,9 @@ testthat::test_that("ppc_pit_ecdf takes correct PIT computation branch", {
729729
# Replace the PIT computation block (the large if/else if/else)
730730
# with a version that emits diagnostics
731731
which(sapply(as.list(body(ppc_pit_ecdf)), function(e) {
732-
is.call(e) && deparse(e[[1]]) == "if" &&
733-
grepl("pareto_pit", deparse(e[[2]]))
732+
if (!is.call(e)) return(FALSE)
733+
identical(e[[1]], as.name("if")) &&
734+
grepl("pareto_pit", paste(deparse(e[[2]]), collapse = " "))
734735
}))[1]
735736
]] <- quote({
736737

tests/testthat/test-ppc-loo.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ testthat::test_that("ppc_loo_pit_ecdf takes correct PIT computation branch", {
609609
# Replace the PIT computation block (the large if/else if/else)
610610
# with a version that emits diagnostics
611611
which(sapply(as.list(body(ppc_loo_pit_ecdf)), function(e) {
612-
is.call(e) && deparse(e[[1]]) == "if" &&
613-
grepl("pareto_pit", deparse(e[[2]]))
612+
if (!is.call(e)) return(FALSE)
613+
identical(e[[1]], as.name("if")) &&
614+
grepl("pareto_pit", paste(deparse(e[[2]]), collapse = " "))
614615
}))[1]
615616
]] <- quote({
616617

0 commit comments

Comments
 (0)