@@ -190,3 +190,312 @@ Warning: Unable to updated deprecated new array syntax in input from line 6, cha
190190"""
191191
192192 run input expectedOutput expectedWarnings
193+
194+ [<Fact>]
195+ [<Trait( " Category" , " Statement Kinds Support" ) >]
196+ let ``Expression Statement Support`` () =
197+ let input =
198+ """ namespace Foo {
199+ operation Bar1(x : Int) : Unit {}
200+ operation Bar2() : Unit {
201+ Bar1((new Int[3])[2]);
202+ }
203+ }"""
204+
205+ let expectedOutput =
206+ """ namespace Foo {
207+ operation Bar1(x : Int) : Unit {}
208+ operation Bar2() : Unit {
209+ Bar1(([0, size = 3])[2]);
210+ }
211+ }"""
212+
213+ run input expectedOutput String.Empty
214+
215+ [<Fact>]
216+ [<Trait( " Category" , " Statement Kinds Support" ) >]
217+ let ``Return Statement Support`` () =
218+ let input =
219+ """ namespace Foo {
220+ operation Bar() : Int {
221+ return (new Int[3])[0];
222+ }
223+ }"""
224+
225+ let expectedOutput =
226+ """ namespace Foo {
227+ operation Bar() : Int {
228+ return ([0, size = 3])[0];
229+ }
230+ }"""
231+
232+ run input expectedOutput String.Empty
233+
234+ [<Fact>]
235+ [<Trait( " Category" , " Statement Kinds Support" ) >]
236+ let ``Fail Statement Support`` () =
237+ let input =
238+ """ namespace Foo {
239+ operation Bar() : Unit {
240+ fail (new String[3])[0];
241+ }
242+ }"""
243+
244+ let expectedOutput =
245+ """ namespace Foo {
246+ operation Bar() : Unit {
247+ fail (["", size = 3])[0];
248+ }
249+ }"""
250+
251+ run input expectedOutput String.Empty
252+
253+ [<Fact>]
254+ [<Trait( " Category" , " Statement Kinds Support" ) >]
255+ let ``Let Statement Support`` () =
256+ let input =
257+ """ namespace Foo {
258+ operation Bar() : Unit {
259+ let x = new Double[3];
260+ }
261+ }"""
262+
263+ let expectedOutput =
264+ """ namespace Foo {
265+ operation Bar() : Unit {
266+ let x = [0.0, size = 3];
267+ }
268+ }"""
269+
270+ run input expectedOutput String.Empty
271+
272+ [<Fact>]
273+ [<Trait( " Category" , " Statement Kinds Support" ) >]
274+ let ``Mutable Statement Support`` () =
275+ let input =
276+ """ namespace Foo {
277+ operation Bar() : Unit {
278+ mutable x = new Double[3];
279+ }
280+ }"""
281+
282+ let expectedOutput =
283+ """ namespace Foo {
284+ operation Bar() : Unit {
285+ mutable x = [0.0, size = 3];
286+ }
287+ }"""
288+
289+ run input expectedOutput String.Empty
290+
291+ [<Fact>]
292+ [<Trait( " Category" , " Statement Kinds Support" ) >]
293+ let ``Set Statement Support`` () =
294+ let input =
295+ """ namespace Foo {
296+ operation Bar() : Unit {
297+ mutable x = new Double[3];
298+ set x = new Double[4];
299+ }
300+ }"""
301+
302+ let expectedOutput =
303+ """ namespace Foo {
304+ operation Bar() : Unit {
305+ mutable x = [0.0, size = 3];
306+ set x = [0.0, size = 4];
307+ }
308+ }"""
309+
310+ run input expectedOutput String.Empty
311+
312+ [<Fact>]
313+ [<Trait( " Category" , " Statement Kinds Support" ) >]
314+ let ``Update Statement Support`` () =
315+ let input =
316+ """ namespace Foo {
317+ operation Bar() : Unit {
318+ mutable x = 4;
319+ set x += (new Int[2])[0];
320+ }
321+ }"""
322+
323+ let expectedOutput =
324+ """ namespace Foo {
325+ operation Bar() : Unit {
326+ mutable x = 4;
327+ set x += ([0, size = 2])[0];
328+ }
329+ }"""
330+
331+ run input expectedOutput String.Empty
332+
333+ [<Fact>]
334+ [<Trait( " Category" , " Statement Kinds Support" ) >]
335+ let ``Set With Statement Support`` () =
336+ let input =
337+ """ namespace Foo {
338+ operation Bar() : Unit {
339+ mutable x = new Double[][3];
340+ set x w/= (new Int[2])[0] <- new Double[2];
341+ set x w/= 1 <- new Double[3];
342+ set x w/= 2 <- new Double[4];
343+ }
344+ }"""
345+
346+ let expectedOutput =
347+ """ namespace Foo {
348+ operation Bar() : Unit {
349+ mutable x = [[0.0, size = 0], size = 3];
350+ set x w/= ([0, size = 2])[0] <- [0.0, size = 2];
351+ set x w/= 1 <- [0.0, size = 3];
352+ set x w/= 2 <- [0.0, size = 4];
353+ }
354+ }"""
355+
356+ run input expectedOutput String.Empty
357+
358+ [<Fact>]
359+ [<Trait( " Category" , " Statement Kinds Support" ) >]
360+ let ``If Statements Support`` () =
361+ let input =
362+ """ namespace Foo {
363+ operation Bar() : Unit {
364+ if ((new Bool[1])[0]) {
365+ let x1 = new Int[3];
366+ } elif ((new Bool[2])[0]) {
367+ let x2 = new Double[2];
368+ } else {
369+ let x3 = new String[1];
370+ }
371+ }
372+ }"""
373+
374+ let expectedOutput =
375+ """ namespace Foo {
376+ operation Bar() : Unit {
377+ if (([false, size = 1])[0]) {
378+ let x1 = [0, size = 3];
379+ } elif (([false, size = 2])[0]) {
380+ let x2 = [0.0, size = 2];
381+ } else {
382+ let x3 = ["", size = 1];
383+ }
384+ }
385+ }"""
386+
387+ run input expectedOutput String.Empty
388+
389+ [<Fact>]
390+ [<Trait( " Category" , " Statement Kinds Support" ) >]
391+ let ``For Statement Support`` () =
392+ let input =
393+ """ namespace Foo {
394+ operation Bar() : Unit {
395+ for i in (new Range[1])[0] {
396+ let x = new Int[3];
397+ }
398+ }
399+ }"""
400+
401+ let expectedOutput =
402+ """ namespace Foo {
403+ operation Bar() : Unit {
404+ for i in ([1..0, size = 1])[0] {
405+ let x = [0, size = 3];
406+ }
407+ }
408+ }"""
409+
410+ run input expectedOutput String.Empty
411+
412+ [<Fact>]
413+ [<Trait( " Category" , " Statement Kinds Support" ) >]
414+ let ``While Statement Support`` () =
415+ let input =
416+ """ namespace Foo {
417+ function Bar() : Unit {
418+ while (new Bool[1])[0] {
419+ let x = new Int[3];
420+ }
421+ }
422+ }"""
423+
424+ let expectedOutput =
425+ """ namespace Foo {
426+ function Bar() : Unit {
427+ while ([false, size = 1])[0] {
428+ let x = [0, size = 3];
429+ }
430+ }
431+ }"""
432+
433+ run input expectedOutput String.Empty
434+
435+ [<Fact>]
436+ [<Trait( " Category" , " Statement Kinds Support" ) >]
437+ let ``Repeat - Until Statements Support`` () =
438+ let input =
439+ """ namespace Foo {
440+ operation Bar() : Unit {
441+ repeat
442+ {
443+ let x1 = new Int[3];
444+ } until (new Bool[1])[0];
445+
446+ repeat
447+ {
448+ let x2 = new Double[4];
449+ } until (new Bool[1])[0]
450+ fixup {
451+ let x3 = new String[2];
452+ }
453+ }
454+ }"""
455+
456+ let expectedOutput =
457+ """ namespace Foo {
458+ operation Bar() : Unit {
459+ repeat
460+ {
461+ let x1 = [0, size = 3];
462+ } until ([false, size = 1])[0];
463+
464+ repeat
465+ {
466+ let x2 = [0.0, size = 4];
467+ } until ([false, size = 1])[0]
468+ fixup {
469+ let x3 = ["", size = 2];
470+ }
471+ }
472+ }"""
473+
474+ run input expectedOutput String.Empty
475+
476+ [<Fact>]
477+ [<Trait( " Category" , " Statement Kinds Support" ) >]
478+ let ``Within - Apply Statements Support`` () =
479+ let input =
480+ """ namespace Foo {
481+ operation Bar() : Unit {
482+ within {
483+ let x1 = new Int[3];
484+ } apply {
485+ let x2 = new Double[4];
486+ }
487+ }
488+ }"""
489+
490+ let expectedOutput =
491+ """ namespace Foo {
492+ operation Bar() : Unit {
493+ within {
494+ let x1 = [0, size = 3];
495+ } apply {
496+ let x2 = [0.0, size = 4];
497+ }
498+ }
499+ }"""
500+
501+ run input expectedOutput String.Empty
0 commit comments