Nothing
test_that("rlm_check_id accepts one usable name", {
expect_invisible(rlm_check_id("qwen3-4b", "model"))
expect_identical(rlm_check_id("qwen3-4b", "model"), "qwen3-4b")
# A name with braces must not reach cli as a format string. The probe has to
# be a value that fails, or cli_abort() is never called and nothing is proved.
expect_error(
rlm_check_id(c("model{x}", "other"), "model"),
"2 values rather than one"
)
})
test_that("rlm_check_id names the argument and the rule for every fault", {
expect_error(rlm_check_id(NULL, "model"), "You gave NULL")
expect_error(rlm_check_id(1, "model"), "You gave a numeric value")
expect_error(rlm_check_id(TRUE, "model"), "You gave a logical value")
expect_error(rlm_check_id(list("a"), "model"), "You gave a list value")
expect_error(rlm_check_id(factor("a"), "model"), "You gave a factor value")
expect_error(
rlm_check_id(c("a", "b"), "model"),
"You gave 2 values rather than one"
)
expect_error(
rlm_check_id(character(0), "model"),
"You gave 0 values rather than one"
)
expect_error(rlm_check_id(NA_character_, "model"), "You gave NA")
expect_error(rlm_check_id("", "model"), "You gave an empty string")
expect_error(rlm_check_id(" ", "model"), "whitespace only")
expect_error(rlm_check_id("\f", "model"), "whitespace only")
expect_error(rlm_check_id("\v", "model"), "whitespace only")
expect_error(
rlm_check_id(matrix("a-model"), "model"),
"an array rather than a single string"
)
})
test_that("id_fault picks the article that the class name takes", {
expect_error(rlm_check_id(1L, "model"), "You gave an integer value")
expect_error(rlm_check_id(1.5, "model"), "You gave a numeric value")
expect_identical(article_for("integer"), "an")
expect_identical(article_for("environment"), "an")
expect_identical(article_for("list"), "a")
expect_identical(article_for("factor"), "a")
})
test_that("a name carrying braces cannot reach cli as a format string", {
# The detail is interpolated as a value, so braces inside it are never read
# as cli markup. A raw `{x}` in the message text would abort differently.
expect_error(
rlm_check_id(c("model{x}", "other{.emph y}"), "model"),
"2 values rather than one"
)
expect_error(rlm_check_id(structure(1, class = "{weird}"), "model"), "value")
})
test_that("rlm_check_id reports the argument name it was given", {
expect_error(rlm_check_id("", "job_id"), "job_id")
expect_error(rlm_check_id("", "model"), "model")
})
test_that("rlm_check_text takes a non-empty character vector with no NA", {
expect_identical(rlm_check_text(c("a", "b"), "input"), c("a", "b"))
expect_error(rlm_check_text(1:3, "input"), "non-empty character vector")
expect_error(
rlm_check_text(character(0), "input"),
"non-empty character vector"
)
expect_error(rlm_check_text(list("a"), "input"), "non-empty character vector")
})
test_that("rlm_check_text rejects an NA wherever it sits", {
expect_error(rlm_check_text(NA_character_, "input"), "1 NA value\\.")
expect_error(rlm_check_text(c(NA, "b", "c"), "input"), "1 NA value\\.")
expect_error(rlm_check_text(c("a", "b", NA), "input"), "1 NA value\\.")
expect_error(rlm_check_text(c("a", NA, "c"), "input"), "1 NA value\\.")
expect_error(
rlm_check_text(c(NA_character_, NA_character_), "input"),
"2 NA values\\."
)
expect_error(rlm_check_text(c("a", NA), "inputs"), "inputs")
})
test_that("rlm_check_no_na lets every non-character shape through", {
msgs <- list(list(role = "user", content = "hi"))
expect_identical(rlm_check_no_na(msgs, "input"), msgs)
expect_identical(rlm_check_no_na(1:3, "input"), 1:3)
expect_identical(rlm_check_no_na(NULL, "input"), NULL)
# A list holding NA is not a character vector, so it passes.
expect_identical(rlm_check_no_na(list(NA), "input"), list(NA))
})
test_that("rlm_check_no_na rejects an NA inside a character vector", {
expect_error(rlm_check_no_na(NA_character_, "input"), "no missing values")
expect_error(rlm_check_no_na(c("a", NA), "input"), "1 NA value\\.")
expect_identical(rlm_check_no_na(character(0), "input"), character(0))
})
test_that("rlm_check_wait accepts a usable number of seconds", {
expect_invisible(rlm_check_wait(10))
expect_identical(rlm_check_wait(10), 10)
expect_identical(rlm_check_wait(0), 0)
expect_identical(rlm_check_wait(0L), 0L)
expect_identical(rlm_check_wait(2.5), 2.5)
})
test_that("rlm_check_wait names the argument and the rule for every fault", {
expect_error(rlm_check_wait(NULL), "You gave NULL")
expect_error(rlm_check_wait("10"), "You gave a character value")
expect_error(rlm_check_wait(TRUE), "You gave a logical value")
expect_error(rlm_check_wait(list(10)), "You gave a list value")
expect_error(
rlm_check_wait(matrix(10)),
"an array rather than a single number"
)
expect_error(rlm_check_wait(c(1, 2)), "You gave 2 values rather than one")
expect_error(
rlm_check_wait(numeric(0)),
"You gave 0 values rather than one"
)
expect_error(rlm_check_wait(NA), "You gave a missing value")
expect_error(rlm_check_wait(NA_real_), "You gave a missing value")
# is.na(NaN) is TRUE, so NaN reports as the missing value it is.
expect_error(rlm_check_wait(NaN), "You gave a missing value")
expect_error(rlm_check_wait(Inf), "not finite")
expect_error(rlm_check_wait(-Inf), "not finite")
expect_error(rlm_check_wait(-1), "a negative number of seconds")
# Every message names the argument, and the name follows the `arg` given.
expect_error(rlm_check_wait(-1), "wait")
expect_error(rlm_check_wait(-1, "pause"), "pause")
})
test_that("a rlm_check_wait abort carries no rlmstudio condition class", {
# D-008: an argument fault is a programming error, so a caller has nothing
# to catch it for. Only the classes cli_abort() attaches may be present.
faults <- list(NULL, "10", NA, NaN, Inf, -1, c(1, 2), matrix(10))
for (i in seq_along(faults)) {
err <- tryCatch(
rlm_check_wait(faults[[i]]),
condition = function(e) e
)
expect_s3_class(err, "rlang_error")
expect_false(
any(grepl("^rlmstudio", class(err))),
info = paste("fault", i, "classes:", paste(class(err), collapse = ", "))
)
}
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.