test_that("get_xy extracts x,y from data.frame, matrix, and field_layout", { df <- data.frame(x = 1:3, y = 4:6, other = 7:9) expect_equal(get_xy(df), cbind(x = 1:3, y = 4:6)) m <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2) got <- get_xy(m) expect_equal(dim(got), c(3L, 2L)) expect_error(get_xy(data.frame(a = 1, b = 2)), "x.*y") }) test_that("with_seed is reproducible and restores RNG state", { set.seed(999) before <- runif(1) a <- with_seed(42, runif(3)) b <- with_seed(42, runif(3)) expect_equal(a, b) # reproducible after <- runif(1) # RNG stream continues as if untouched set.seed(999); runif(1) expect_equal(after, runif(1)) # state was restored })