Skip to content

Commit 4f32c0e

Browse files
committed
Merge remote-tracking branch 'origin/main' into cran/v0.3.0
2 parents 383cfef + 30f99b1 commit 4f32c0e

6 files changed

Lines changed: 99 additions & 122 deletions

tests/testthat/test-cran-budget.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
test_that("CRAN smoke budget stays small", {
2+
smoke_files <- list.files(
3+
test_path(),
4+
pattern = "^test-cran-smoke-.*\\.R$",
5+
full.names = TRUE
6+
)
7+
lines <- unlist(lapply(smoke_files, readLines), use.names = FALSE)
8+
quick_entrypoints <- sum(grepl("expect_quick_(equal|identical)\\(", lines))
9+
quick_entrypoints <- quick_entrypoints + sum(grepl("\\bquick\\(", lines))
10+
11+
expect_lte(quick_entrypoints, 1L)
12+
})

tests/testthat/test-cran-smoke-closures.R

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/testthat/test-cran-smoke-iterables.R

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/testthat/test-cran-smoke-matrix.R

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Compact end-to-end coverage kept on CRAN.
2+
3+
test_that("CRAN smoke: core language and matrix paths compile and run", {
4+
fn <- function(
5+
vals,
6+
mask_mat,
7+
lhs,
8+
rhs_mat,
9+
chol_mat,
10+
solve_rhs,
11+
design,
12+
response
13+
) {
14+
declare(
15+
type(vals = double(NA)),
16+
type(mask_mat = double(NA, NA)),
17+
type(lhs = double(2, 3)),
18+
type(rhs_mat = double(3, 2)),
19+
type(chol_mat = double(n, n)),
20+
type(solve_rhs = double(n)),
21+
type(design = double(p, k)),
22+
type(response = double(p))
23+
)
24+
25+
bump <- function() {
26+
vals <<- vals + 1.0
27+
NULL
28+
}
29+
bump()
30+
31+
shifted <- sapply(seq_along(vals), function(i) sin(vals[i]))
32+
reversed <- rev(shifted)
33+
filtered <- reversed[reversed > 0]
34+
35+
lang_total <- 0.0
36+
for (elt in filtered) {
37+
lang_total <- lang_total + elt
38+
}
39+
40+
matrix_total <- sum(mask_mat[mask_mat > 3.0])
41+
matrix_total <- matrix_total + sum(lhs %*% rhs_mat)
42+
matrix_total <- matrix_total + sum(solve(chol_mat, solve_rhs))
43+
matrix_total <- matrix_total + sum(qr.solve(design, response))
44+
matrix_total <- matrix_total + sum(chol(chol_mat))
45+
46+
lang_total + matrix_total
47+
}
48+
49+
vals <- c(-2, -1, 0, 1, 2, 3)
50+
mask_mat <- matrix(as.double(1:6), nrow = 2L, ncol = 3L, byrow = TRUE)
51+
52+
set.seed(2)
53+
lhs <- matrix(rnorm(6), nrow = 2L)
54+
rhs_mat <- matrix(rnorm(6), nrow = 3L)
55+
n <- 4L
56+
k <- 2L
57+
base <- matrix(rnorm(n * n), nrow = n)
58+
chol_mat <- crossprod(base) + diag(n)
59+
solve_rhs <- rnorm(n)
60+
design <- matrix(rnorm(6 * k), nrow = 6L)
61+
response <- rnorm(6)
62+
63+
q_fn <- expect_no_warning(quick(fn))
64+
expected <- fn(
65+
vals,
66+
mask_mat,
67+
lhs,
68+
rhs_mat,
69+
chol_mat,
70+
solve_rhs,
71+
design,
72+
response
73+
)
74+
actual <- q_fn(
75+
vals,
76+
mask_mat,
77+
lhs,
78+
rhs_mat,
79+
chol_mat,
80+
solve_rhs,
81+
design,
82+
response
83+
)
84+
85+
expect_equal(actual, expected)
86+
expect_identical(typeof(actual), typeof(expected))
87+
})

tests/testthat/test-cran-smoke-vector-ops.R

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)