@@ -117,6 +117,57 @@ define
117
117
. expect ( "Failed to type check problem" ) ;
118
118
}
119
119
120
+ #[ test]
121
+ #[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test) ]
122
+ fn empty_where ( ) {
123
+ let input = "
124
+ min 1
125
+ s.t.
126
+ 1 <= 1
127
+ where
128
+ " ;
129
+ RoocParser :: new ( input. to_string ( ) )
130
+ . parse_and_transform ( vec ! [ ] , & IndexMap :: new ( ) )
131
+ . expect ( "Failed to parse and transform problem" ) ;
132
+ RoocParser :: new ( input. to_string ( ) )
133
+ . type_check ( & vec ! [ ] , & IndexMap :: new ( ) )
134
+ . expect ( "Failed to type check problem" ) ;
135
+ }
136
+ #[ test]
137
+ #[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test) ]
138
+ fn empty_define ( ) {
139
+ let input = "
140
+ min 1
141
+ s.t.
142
+ 1 <= 1
143
+ define
144
+ " ;
145
+ RoocParser :: new ( input. to_string ( ) )
146
+ . parse_and_transform ( vec ! [ ] , & IndexMap :: new ( ) )
147
+ . expect ( "Failed to parse and transform problem" ) ;
148
+ RoocParser :: new ( input. to_string ( ) )
149
+ . type_check ( & vec ! [ ] , & IndexMap :: new ( ) )
150
+ . expect ( "Failed to type check problem" ) ;
151
+ }
152
+
153
+ #[ test]
154
+ #[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test) ]
155
+ fn empty_where_define ( ) {
156
+ let input = "
157
+ min 1
158
+ s.t.
159
+ 1 <= 1
160
+ where
161
+ define
162
+ " ;
163
+ RoocParser :: new ( input. to_string ( ) )
164
+ . parse_and_transform ( vec ! [ ] , & IndexMap :: new ( ) )
165
+ . expect ( "Failed to parse and transform problem" ) ;
166
+ RoocParser :: new ( input. to_string ( ) )
167
+ . type_check ( & vec ! [ ] , & IndexMap :: new ( ) )
168
+ . expect ( "Failed to type check problem" ) ;
169
+ }
170
+
120
171
#[ test]
121
172
#[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test) ]
122
173
fn test_parser_variants4 ( ) {
@@ -134,6 +185,7 @@ define
134
185
max {1, 2, 3} >= 1
135
186
where
136
187
let A = [1, 2, 3, 4]
188
+ define
137
189
" ;
138
190
RoocParser :: new ( input. to_string ( ) )
139
191
. parse_and_transform ( vec ! [ ] , & IndexMap :: new ( ) )
@@ -185,6 +237,7 @@ define
185
237
|x + y|z + 2 >= 1
186
238
187
239
2(x + y)3|x + y|z + 2 >= 1
240
+ where
188
241
define
189
242
x,y,z as Real
190
243
" ;
@@ -252,7 +305,8 @@ define
252
305
s.t.
253
306
S >= 1
254
307
where
255
- let S = \" Hello\"
308
+ let S = \" Hello\" \
309
+ define
256
310
" ;
257
311
RoocParser :: new ( input. to_string ( ) )
258
312
. parse_and_transform ( vec ! [ ] , & IndexMap :: new ( ) )
@@ -276,6 +330,7 @@ define
276
330
[0,1,0],
277
331
[0,0,1]
278
332
]
333
+ define
279
334
" ;
280
335
RoocParser :: new ( input. to_string ( ) )
281
336
. parse_and_transform ( vec ! [ ] , & IndexMap :: new ( ) )
@@ -314,6 +369,31 @@ define
314
369
. expect ( "Failed to type check problem" ) ;
315
370
}
316
371
372
+ #[ test]
373
+ #[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test) ]
374
+ fn non_utf8 ( ) {
375
+ let input = "
376
+ max 2x_1 + x_2 - x_3
377
+ subject to
378
+ //write the constraints here
379
+ 5x_1 - 2x_2 + 8x_3 ≤ 15
380
+ 8x_1+3x_2 -x_3 ≥ 9
381
+ x_1+x_2+x_3≤6
382
+ where
383
+
384
+ define
385
+ // define the model's variables here
386
+ x_1 as Real
387
+ x_2 as Real
388
+ x_3 as Real
389
+ " ;
390
+
391
+ //i expect to get an error, and not panic
392
+ RoocParser :: new ( input. to_string ( ) )
393
+ . parse_and_transform ( vec ! [ ] , & IndexMap :: new ( ) )
394
+ . expect_err ( "" ) ;
395
+ }
396
+
317
397
#[ test]
318
398
#[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test) ]
319
399
fn test_const_decl_1 ( ) {
0 commit comments