tests/testthat/test-friendly-size.R

test_that("dimension mismatch errors show axis", {
  fn <- function(x) {
    declare(type(x = double(2, 3)))
    sum(x)
  }
  qfn <- quick(fn)

  expect_error(
    qfn(matrix(as.double(1:6), nrow = 3, ncol = 2)),
    "dim(x)[1] must be 2, not 3",
    fixed = TRUE
  )

  expect_error(
    qfn(matrix(as.double(1:4), nrow = 2, ncol = 2)),
    "dim(x)[2] must be 3, not 2",
    fixed = TRUE
  )
})

Try the quickr package in your browser

Any scripts or data that you put into this service are public.

quickr documentation built on Aug. 26, 2025, 1:07 a.m.