@@ -214,14 +214,57 @@ spec = do
214
214
result `shouldSatisfy` (\ str -> " TermQuantumCtrlsGate TermVariable (Var ((3,22),q1)),TermVariable (Var ((3,28),q3)),TermVariable (Var ((3,34),q4)) BasisStateOne,BasisStateOne,BasisStateOne)" `isInfixOf` str)
215
215
result `shouldSatisfy` (\ str -> " (TermGate GateY)) (TermVariable (Var ((3,67),q2)))" `isInfixOf` str)
216
216
217
- -- do let single
218
- -- do let sugar single
219
- -- do let multiple
220
217
221
218
context " when provided with a small program fragment" $ do
222
219
it " returns a syntax tree processed in the intermediate syntax tree format" $ do
223
- result <- testProgramAndShowResults " test/programs/code-fragments/program_fragment_18.lq"
220
+ result <- testProgramAndShowResults " test/programs/code-fragments/program_fragment_15.lq"
221
+ result `shouldSatisfy` (\ str -> " Function fun (2,1)" `isInfixOf` str)
222
+ result `shouldSatisfy` (\ str -> " TypeBit" `isInfixOf` str)
223
+ result `shouldSatisfy` (\ str -> " TermApply (TermNew (2,16)) (TermBasisState BasisStateMinusI)" `isInfixOf` str)
224
+ result `shouldSatisfy` (\ str -> " TermMeasure (3,7)" `isInfixOf` str)
225
+ result `shouldSatisfy` (\ str -> " (TermVariable (Var ((3,14),gate))) (TermGate GateX))" `isInfixOf` str)
226
+ result `shouldSatisfy` (\ str -> " TermVariable (Var ((3,21),q)))" `isInfixOf` str)
227
+
228
+ context " when provided with a small program fragment" $ do
229
+ it " returns a syntax tree processed in the intermediate syntax tree format" $ do
230
+ result <- testProgramAndShowResults " test/programs/code-fragments/program_fragment_16.lq"
231
+ result `shouldSatisfy` (\ str -> " Function fun (2,1)" `isInfixOf` str)
232
+ result `shouldSatisfy` (\ str -> " TypeBit" `isInfixOf` str)
233
+ result `shouldSatisfy` (\ str -> " (TermApply (TermNew (2,12)) (TermBasisState BasisStateZero)" `isInfixOf` str)
234
+ result `shouldSatisfy` (\ str -> " TermMeasure (3,7)" `isInfixOf` str)
235
+ result `shouldSatisfy` (\ str -> " (TermVariable (Var ((3,14),gate))) (TermGate GateZ))" `isInfixOf` str)
236
+ result `shouldSatisfy` (\ str -> " TermVariable (Var ((3,21),q)))" `isInfixOf` str)
237
+
238
+ context " when provided with a small program fragment" $ do
239
+ it " returns a syntax tree processed in the intermediate syntax tree format" $ do
240
+ result <- testProgramAndShowResults " test/programs/code-fragments/program_fragment_17.lq"
224
241
result `shouldSatisfy` (\ str -> " Function fun (2,1)" `isInfixOf` str)
225
242
result `shouldSatisfy` (\ str -> " TypeQbit" `isInfixOf` str)
226
243
result `shouldSatisfy` (\ str -> " TermApply (TermNew (2,7)) (TermBasisState BasisStateZero)" `isInfixOf` str)
227
244
245
+ context " when provided with a small program fragment" $ do
246
+ it " returns a syntax tree processed in the intermediate syntax tree format" $ do
247
+ result <- testProgramAndShowResults " test/programs/code-fragments/program_fragment_18.lq"
248
+ result `shouldSatisfy` (\ str -> " Function fun (2,1)" `isInfixOf` str)
249
+ result `shouldSatisfy` (\ str -> " TypeQbit :**: 3" `isInfixOf` str)
250
+ result `shouldSatisfy` (\ str -> " TermTuple (TermApply (TermNew" `isInfixOf` str)
251
+ result `shouldSatisfy` (\ str -> " TermBasisState BasisStateZero" `isInfixOf` str)
252
+
253
+ context " when provided with a small program fragment" $ do
254
+ it " returns a syntax tree processed in the intermediate syntax tree format" $ do
255
+ result <- testProgramAndShowResults " test/programs/code-fragments/program_fragment_19.lq"
256
+ result `shouldSatisfy` (\ str -> " Function fun (2,1)" `isInfixOf` str)
257
+ result `shouldSatisfy` (\ str -> " TypeQbit :*: TypeQbit" `isInfixOf` str)
258
+ result `shouldSatisfy` (\ str -> " TermTuple" `isInfixOf` str)
259
+ result `shouldSatisfy` (\ str -> " (TermApply (TermVariable (Var ((2,8),gate))) (TermGate GateH)) (TermNew (2,15))) (TermBasisState BasisStateZero))" `isInfixOf` str)
260
+
261
+ context " when provided with a small program fragment" $ do
262
+ it " returns a syntax tree processed in the intermediate syntax tree format" $ do
263
+ result <- testProgramAndShowResults " test/programs/code-fragments/program_fragment_20.lq"
264
+ result `shouldSatisfy` (\ str -> " Function fun (2,1)" `isInfixOf` str)
265
+ result `shouldSatisfy` (\ str -> " TypeQbit" `isInfixOf` str)
266
+ result `shouldSatisfy` (\ str -> " TermLetSingle" `isInfixOf` str)
267
+ result `shouldSatisfy` (\ str -> " (TermMeasure (2,17)) (TermVariable (Var ((2,23),gate)))) (TermGate GateH)) (TermNew (2,30))) (TermBasisState BasisStateZero))" `isInfixOf` str)
268
+ result `shouldSatisfy` (\ str -> " TermIfElse (TermVariable (Var ((3,10),bit))" `isInfixOf` str)
269
+ result `shouldSatisfy` (\ str -> " TermApply (TermApply (TermApply (TermVariable (Var ((3,19),gate))) (TermGate GateH)) (TermNew (3,26))" `isInfixOf` str)
270
+ result `shouldSatisfy` (\ str -> " TermApply (TermNew (3,38)) (TermBasisState BasisStateOne)" `isInfixOf` str)
0 commit comments