@@ -11,15 +11,32 @@ transformed data {
1111`
1212var opt_test = stanc . stanc ( "optimization" , opt_model , [ ] ) ;
1313var ind = opt_test . result . search ( "int t = 1; t <= 5; \\+\\+t" ) ;
14- if ( ind == - 1 ) {
15- console . log ( "ERROR: Optimization without the O flag!" )
16- }
14+ console . assert ( ind > - 1 , "ERROR: Optimization without the O flag!" )
1715
1816var opt_test = stanc . stanc ( "optimization" , opt_model , [ "O" ] ) ;
1917var ind = opt_test . result . search ( "int t = 1; t <= 5; \\+\\+t" ) ;
20- if ( ind > - 1 ) {
21- console . log ( "ERROR: No optimization without the O flag!" )
18+ console . assert ( ind < 0 , "ERROR: No optimization without the O flag!" )
19+
20+ var ad_model = `
21+ data {
22+ matrix[10, 10] X_d;
23+ }
24+ parameters {
25+ matrix[10, 10] X_p;
26+ }
27+
28+ transformed parameters {
29+ matrix[10, 10] X_tp1 = X_d;
2230}
31+ `
32+
33+ var opt_test = stanc . stanc ( "optimization" , ad_model , [ "O1" ] ) ;
34+ var ind = opt_test . result . search ( "\\<double, -1, -1\\> X_tp1" ) ;
35+ console . assert ( ind > - 1 , "ERROR: No AD optimization with the O1 flag!" )
36+
37+ var opt_test = stanc . stanc ( "optimization" , ad_model , [ "O0" ] ) ;
38+ var ind = opt_test . result . search ( "\\<local_scalar_t__, -1, -1\\> X_tp1" ) ;
39+ console . assert ( ind > - 1 , "ERROR: AD optimization without the O1 flag!" )
2340
2441var glm_model = `
2542data {
@@ -42,16 +59,14 @@ data {
4259var no_opencl_test = stanc . stanc ( "no_opencl" , glm_model ) ;
4360utils . print_error ( no_opencl_test )
4461var ind = no_opencl_test . result . search ( "matrix_cl<int> y_opencl__" ) ;
45- if ( ind > - 1 ) {
46- console . log ( "ERROR: OpenCL code found without the use-opencl flag!" )
47- }
62+ console . assert ( ind < 0 , "ERROR: OpenCL code found without the use-opencl flag!" )
63+
4864
4965var opencl_test = stanc . stanc ( "opencl" , glm_model , [ "use-opencl" ] ) ;
5066utils . print_error ( opencl_test )
5167var ind = opencl_test . result . search ( "matrix_cl<int> y_opencl__" ) ;
52- if ( ind == - 1 ) {
53- console . log ( "ERROR: No OpenCL code found with the use-opencl flag!" )
54- }
68+ console . assert ( ind > - 1 , "ERROR: No OpenCL code found with the use-opencl flag!" )
69+
5570
5671// multiple flags
5772
@@ -86,6 +101,5 @@ utils.print_error(opencl_test)
86101var opencl_test = stanc . stanc ( "opencl" , glm_model2 , [ "use-opencl" , "allow-undefined" ] ) ;
87102utils . print_error ( opencl_test )
88103var ind = opencl_test . result . search ( "matrix_cl<int> y_opencl__" ) ;
89- if ( ind == - 1 ) {
90- console . log ( "ERROR: No OpenCL code found with the use-opencl flag!" )
91- }
104+ console . assert ( ind > - 1 , "ERROR: No OpenCL code found with the use-opencl flag!" )
105+
0 commit comments