tests/testthat/test-lang-use.R

test_that("Empty lang_use() returns 'unset'", {
  .lang_env$session <- NULL
  expect_snapshot(
    lang_use(.lang = "english")
  )
})

test_that("lang_use() works with 'ollama'", {
  expect_snapshot(
    lang_use("ollama", "model")
  )
})

test_that("lang_use() works", {
  expect_snapshot(
    lang_use("simulate_llm", "echo", .cache = "path/to/cache", .lang = "test")
  )
})

test_that("lang_use() works with ellmer", {
  x <- simulate_ellmer()
  expect_snapshot(
    lang_use(x, .cache = "path/to/cache", .lang = "test")
  )
})

test_that("lang_use() works with additional arguments", {
  expect_snapshot(
    lang_use(
      "simulate_llm",
      "echo",
      temp = 0.8,
      .cache = "path/to/cache",
      .lang = "test"
    )
  )
})

test_that("lang_use() works with disabled cache", {
  expect_snapshot(
    lang_use("simulate_llm", "echo", .cache = "", .lang = "test")
  )
})

test_that("Warning is displayed if .lang_chat is set", {
  withr::with_options(
    list(.lang_chat = 3),
    expect_snapshot(lang_use(.silent = TRUE))
  )
})

Try the lang package in your browser

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

lang documentation built on June 5, 2026, 5:08 p.m.