File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ context(" knitr engine" )
2
+
3
+ test_that(" eng_cmdstan throws correct errors" , {
4
+ skip_on_cran()
5
+ skip_if_not_installed(" knitr" )
6
+ expect_error(eng_cmdstan(list (output.var = 1 )), " must be a character string" )
7
+ expect_error(eng_cmdstan(list (output.var = c(" A" , " B" ))), " must be a character string" )
8
+ })
9
+
10
+ test_that(" eng_cmdstan works" , {
11
+ skip_on_cran()
12
+ skip_if_not_installed(" knitr" )
13
+ opts <- knitr :: opts_chunk $ merge(list (
14
+ output.var = " ABC" ,
15
+ file = testing_stan_file(" bernoulli" ),
16
+ cache = TRUE ,
17
+ cache.path = tempdir()
18
+ ))
19
+ expect_message(eng_cmdstan(opts ), " Compiling Stan program" )
20
+
21
+ opts $ eval <- FALSE
22
+ expect_silent(eng_cmdstan(opts ))
23
+ })
24
+
25
+ test_that(" register_knitr_engine works with and without override" , {
26
+ skip_on_cran()
27
+ skip_if_not_installed(" knitr" )
28
+
29
+ knitr :: knit_engines $ delete(keys = " stan" )
30
+ expect_false(" stan" %in% names(knitr :: knit_engines $ get()))
31
+
32
+ register_knitr_engine(override = TRUE )
33
+ expect_false(" cmdstan" %in% names(knitr :: knit_engines $ get()))
34
+ expect_true(" stan" %in% names(knitr :: knit_engines $ get()))
35
+
36
+ register_knitr_engine(override = FALSE )
37
+ expect_true(" cmdstan" %in% names(knitr :: knit_engines $ get()))
38
+
39
+ knitr :: knit_engines $ restore()
40
+ })
You can’t perform that action at this time.
0 commit comments