forked from stan-dev/cmdstanr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-cpp_opts.R
More file actions
71 lines (66 loc) · 1.81 KB
/
test-cpp_opts.R
File metadata and controls
71 lines (66 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
test_that("parse_exe_info_string works", {
expect_equal_ignore_order(
parse_exe_info_string("
stan_version_major = 2
stan_version_minor = 38
stan_version_patch = 0
STAN_THREADS=false
STAN_MPI=false
STAN_OPENCL=true
STAN_NO_RANGE_CHECKS=false
STAN_CPP_OPTIMS=false
"),
list(
stan_version = "2.38.0",
stan_threads = FALSE,
stan_mpi = FALSE,
stan_opencl = TRUE,
stan_no_range_checks = FALSE,
stan_cpp_optims = FALSE
)
)
})
test_that("validate_cpp_options works", {
expect_equal_ignore_order(
validate_cpp_options(list(
Stan_Threads = TRUE,
STAN_OPENCL = NULL,
aBc = FALSE
)),
list(
stan_threads = TRUE,
stan_opencl = NULL,
abc = FALSE
)
)
expect_warning(validate_cpp_options(list(STAN_OPENCL = FALSE)))
})
test_that("exe_info cpp_options comparison works", {
exe_info_all_flags_off <- exe_info_style_cpp_options(list())
exe_info_all_flags_off[["stan_version"]] <- "35.0.0"
expect_true(exe_info_reflects_cpp_options(
exe_info_all_flags_off,
list()
))
expect_true(exe_info_reflects_cpp_options(
list(stan_opencl = FALSE),
list(stan_opencl = NULL)
))
expect_not_true(exe_info_reflects_cpp_options(
list(stan_opencl = FALSE),
list(stan_opencl = FALSE)
))
expect_not_true(exe_info_reflects_cpp_options(
list(stan_opencl = FALSE, stan_threads = FALSE),
list(stan_opencl = NULL, stan_threads = TRUE)
))
expect_not_true(exe_info_reflects_cpp_options(
list(stan_opencl = FALSE, stan_threads = FALSE),
list(stan_opencl = NULL, stan_threads = TRUE, EXTRA_ARG = TRUE)
))
# no exe_info -> no recompile based on cpp info
expect_warning(
expect_true(exe_info_reflects_cpp_options(list(), list())),
"Recompiling is recommended"
)
})