From bec465bb0ba5dd0dc159d126bf92d37a27537d88 Mon Sep 17 00:00:00 2001 From: Scott Carda Date: Wed, 8 Jul 2020 11:34:40 -0700 Subject: [PATCH] Remove negative tests from execution testing. --- .../ClassicallyControlledSupportTests.qs | 1406 ++++++++--------- .../ClassicallyControlledSupportTests.qs | 66 - .../UnitTests/HoneywellSimulation.qs | 36 - .../TestProjects/UnitTests/QCISimulation.qs | 36 - 4 files changed, 670 insertions(+), 874 deletions(-) diff --git a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/ClassicallyControlledSupportTests.qs b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/ClassicallyControlledSupportTests.qs index 7c14d01adcf..2cd17b39207 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/ClassicallyControlledSupportTests.qs +++ b/src/Simulation/Simulators.Tests/TestProjects/HoneywellExe/ClassicallyControlledSupportTests.qs @@ -1,19 +1,19 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - - -namespace Microsoft.Quantum.Simulation.Testing.Honeywell.ClassicallyControlledSupportTests { - - open Microsoft.Quantum.Intrinsic; - - operation SubOp1() : Unit { } - operation SubOp2() : Unit { } - operation SubOp3() : Unit { } - - operation SubOpCA1() : Unit is Ctl + Adj { } - operation SubOpCA2() : Unit is Ctl + Adj { } - operation SubOpCA3() : Unit is Ctl + Adj { } - +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + + +namespace Microsoft.Quantum.Simulation.Testing.Honeywell.ClassicallyControlledSupportTests { + + open Microsoft.Quantum.Intrinsic; + + operation SubOp1() : Unit { } + operation SubOp2() : Unit { } + operation SubOp3() : Unit { } + + operation SubOpCA1() : Unit is Ctl + Adj { } + operation SubOpCA2() : Unit is Ctl + Adj { } + operation SubOpCA3() : Unit is Ctl + Adj { } + operation BranchOnMeasurement() : Unit { using (q = Qubit()) { H(q); @@ -23,724 +23,658 @@ namespace Microsoft.Quantum.Simulation.Testing.Honeywell.ClassicallyControlledSu } Reset(q); } - } - - operation BasicLift() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - SubOp3(); - let temp = 4; - using (q = Qubit()) { - let temp2 = q; - } - } - } - - operation LiftLoops() : Unit { - let r = Zero; - if (r == Zero) { - for (index in 0 .. 3) { - let temp = index; - } - - repeat { - let success = true; - } until (success) - fixup { - let temp2 = 0; - } - } - } - - operation LiftSingleNonCall() : Unit { - let r = Zero; - if (r == Zero) { - let temp = 2; - } - } - - operation DontLiftReturnStatements() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - return (); - } - } - - function SubFunc1() : Unit { } - function SubFunc2() : Unit { } - function SubFunc3() : Unit { } - - function DontLiftFunctions() : Unit { - let r = Zero; - if (r == Zero) { - SubFunc1(); - SubFunc2(); - SubFunc3(); - } - } - - operation LiftSelfContainedMutable() : Unit { - let r = Zero; - if (r == Zero) { - mutable temp = 3; - set temp = 4; - } - } - - operation DontLiftGeneralMutable() : Unit { - let r = Zero; - mutable temp = 3; - if (r == Zero) { - set temp = 4; - } - } - - operation PartiallyResolved<'Q, 'W> (q : 'Q, w : 'W) : Unit { } - - operation ArgumentsPartiallyResolveTypeParameters() : Unit { - let r = Zero; - if (r == Zero) { - PartiallyResolved(1, 1.0); - } - } - - operation LiftFunctorApplication() : Unit { - let r = Zero; - if (r == Zero) { - Adjoint SubOpCA1(); - } - } - - operation PartialApplication(q : Int, w : Double) : Unit { } - - operation LiftPartialApplication() : Unit { - let r = Zero; - if (r == Zero) { - (PartialApplication(1, _))(1.0); - } - } - - operation LiftArrayItemCall() : Unit { - let f = [SubOp1]; - let r = Zero; - if (r == Zero) { - f[0](); - } - } - - operation LiftOneNotBoth() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - } - else { - SubOp3(); - } - } - - operation IfInvalid() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - return (); - } else { - SubOp2(); - SubOp3(); - } - } - - operation ElseInvalid() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - } else { - SubOp2(); - SubOp3(); - return (); - } - } - - operation BothInvalid() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - return (); - } else { - SubOp2(); - SubOp3(); - return (); - } - } - - operation ApplyIfZero_Test() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - } - } - - operation ApplyIfOne_Test() : Unit { - let r = Zero; - if (r == One) { - SubOp1(); - } - } - - operation ApplyIfZeroElseOne() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - } else { - SubOp2(); - } - } - - operation ApplyIfOneElseZero() : Unit { - let r = Zero; - if (r == One) { - SubOp1(); - } else { - SubOp2(); - } - } - - operation IfElif() : Unit { - let r = Zero; - - if (r == Zero) { - SubOp1(); - } elif (r == One) { - SubOp2(); - } else { - SubOp3(); - } - } - - operation AndCondition() : Unit { - let r = Zero; - if (r == Zero and r == One) { - SubOp1(); - } else { - SubOp2(); - } - } - - operation OrCondition() : Unit { - let r = Zero; - if (r == Zero or r == One) { - SubOp1(); - } else { - SubOp2(); - } - } - - operation ApplyConditionally() : Unit { - let r1 = Zero; - let r2 = Zero; - if (r1 == r2) { - SubOp1(); - } - else { - SubOp2(); - } - } - - operation ApplyConditionallyWithNoOp() : Unit { - let r1 = Zero; - let r2 = Zero; - if (r1 == r2) { - SubOp1(); - } - } - - operation InequalityWithApplyConditionally() : Unit { - let r1 = Zero; - let r2 = Zero; - if (r1 != r2) { - SubOp1(); - } - else { - SubOp2(); - } - } - - operation InequalityWithApplyIfOneElseZero() : Unit { - let r = Zero; - if (r != Zero) { - SubOp1(); - } - else { - SubOp2(); - } - } - - operation InequalityWithApplyIfZeroElseOne() : Unit { - let r = Zero; - if (r != One) { - SubOp1(); - } - else { - SubOp2(); - } - } - - operation InequalityWithApplyIfOne() : Unit { - let r = Zero; - if (r != Zero) { - SubOp1(); - } - } - - operation InequalityWithApplyIfZero() : Unit { - let r = Zero; - if (r != One) { - SubOp1(); - } - } - - operation LiteralOnTheLeft() : Unit { - let r = Zero; - if (Zero == r) { - SubOp1(); - } - } - - // ToDo: Uncomment once #17245 is fixed. - //operation GenericsSupport<'A, 'B, 'C>() : Unit { - // let r = Zero; - // - // if (r == Zero) { - // SubOp1(); - // SubOp2(); - // } - //} - - operation WithinBlockSupport() : Unit { - let r = One; - within { - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } apply { - if (r == One) { - SubOpCA2(); - SubOpCA3(); - } - } - } - - operation AdjointSupportProvided() : Unit is Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - adjoint (...) { - let w = One; - - if (w == One) { - SubOpCA2(); - SubOpCA3(); - } - } - } - - operation AdjointSupportSelf() : Unit is Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - adjoint self; - } - - operation AdjointSupportInvert() : Unit is Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - adjoint invert; - } - - operation ControlledSupportProvided() : Unit is Ctl { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA2(); - SubOpCA3(); - } - } - } - - operation ControlledSupportDistribute() : Unit is Ctl { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled distribute; - } - - operation ControlledAdjointSupportProvided_ProvidedBody() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled adjoint (ctl, ...) { - let y = One; - - if (y == One) { - SubOpCA2(); - SubOpCA3(); - } - } - } - - operation ControlledAdjointSupportProvided_ProvidedAdjoint() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - adjoint (...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - controlled adjoint (ctl, ...) { - let y = One; - - if (y == One) { - SubOpCA2(); - SubOpCA3(); - } - } - } - - operation ControlledAdjointSupportProvided_ProvidedControlled() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - controlled adjoint (ctl, ...) { - let y = One; - - if (y == One) { - SubOpCA2(); - SubOpCA3(); - } - } - } - - operation ControlledAdjointSupportProvided_ProvidedAll() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - adjoint (...) { - let y = One; - - if (y == One) { - SubOpCA2(); - SubOpCA3(); - } - } - - controlled adjoint (ctl, ...) { - let b = One; - - if (b == One) { - let temp1 = 0; - let temp2 = 0; - SubOpCA3(); - } - } - } - - operation ControlledAdjointSupportDistribute_DistributeBody() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled adjoint distribute; - } - - operation ControlledAdjointSupportDistribute_DistributeAdjoint() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - adjoint (...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - controlled adjoint distribute; - } - - operation ControlledAdjointSupportDistribute_DistributeControlled() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - controlled adjoint distribute; - } - - operation ControlledAdjointSupportDistribute_DistributeAll() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - adjoint (...) { - let y = One; - - if (y == One) { - SubOpCA2(); - SubOpCA3(); - } - } - - controlled adjoint distribute; - } - - operation ControlledAdjointSupportInvert_InvertBody() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled adjoint invert; - } - - operation ControlledAdjointSupportInvert_InvertAdjoint() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - adjoint (...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - controlled adjoint invert; - } - - operation ControlledAdjointSupportInvert_InvertControlled() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - controlled adjoint invert; - } - - operation ControlledAdjointSupportInvert_InvertAll() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - adjoint (...) { - let y = One; - - if (y == One) { - SubOpCA2(); - SubOpCA3(); - } - } - - controlled adjoint invert; - } - - operation ControlledAdjointSupportSelf_SelfBody() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled adjoint self; - } - - operation ControlledAdjointSupportSelf_SelfControlled() : Unit is Ctl + Adj { - body (...) { - let r = Zero; - - if (r == Zero) { - SubOpCA1(); - SubOpCA2(); - } - } - - controlled (ctl, ...) { - let w = One; - - if (w == One) { - SubOpCA3(); - SubOpCA1(); - } - } - - controlled adjoint self; - } + } + + operation BasicLift() : Unit { + let r = Zero; + if (r == Zero) { + SubOp1(); + SubOp2(); + SubOp3(); + let temp = 4; + using (q = Qubit()) { + let temp2 = q; + } + } + } + + operation LiftLoops() : Unit { + let r = Zero; + if (r == Zero) { + for (index in 0 .. 3) { + let temp = index; + } + + repeat { + let success = true; + } until (success) + fixup { + let temp2 = 0; + } + } + } + + operation LiftSingleNonCall() : Unit { + let r = Zero; + if (r == Zero) { + let temp = 2; + } + } + + operation LiftSelfContainedMutable() : Unit { + let r = Zero; + if (r == Zero) { + mutable temp = 3; + set temp = 4; + } + } + + operation PartiallyResolved<'Q, 'W> (q : 'Q, w : 'W) : Unit { } + + operation ArgumentsPartiallyResolveTypeParameters() : Unit { + let r = Zero; + if (r == Zero) { + PartiallyResolved(1, 1.0); + } + } + + operation LiftFunctorApplication() : Unit { + let r = Zero; + if (r == Zero) { + Adjoint SubOpCA1(); + } + } + + operation PartialApplication(q : Int, w : Double) : Unit { } + + operation LiftPartialApplication() : Unit { + let r = Zero; + if (r == Zero) { + (PartialApplication(1, _))(1.0); + } + } + + operation LiftArrayItemCall() : Unit { + let f = [SubOp1]; + let r = Zero; + if (r == Zero) { + f[0](); + } + } + + operation LiftOneNotBoth() : Unit { + let r = Zero; + if (r == Zero) { + SubOp1(); + SubOp2(); + } + else { + SubOp3(); + } + } + + operation ApplyIfZero_Test() : Unit { + let r = Zero; + if (r == Zero) { + SubOp1(); + } + } + + operation ApplyIfOne_Test() : Unit { + let r = Zero; + if (r == One) { + SubOp1(); + } + } + + operation ApplyIfZeroElseOne() : Unit { + let r = Zero; + if (r == Zero) { + SubOp1(); + } else { + SubOp2(); + } + } + + operation ApplyIfOneElseZero() : Unit { + let r = Zero; + if (r == One) { + SubOp1(); + } else { + SubOp2(); + } + } + + operation IfElif() : Unit { + let r = Zero; + + if (r == Zero) { + SubOp1(); + } elif (r == One) { + SubOp2(); + } else { + SubOp3(); + } + } + + operation AndCondition() : Unit { + let r = Zero; + if (r == Zero and r == One) { + SubOp1(); + } else { + SubOp2(); + } + } + + operation OrCondition() : Unit { + let r = Zero; + if (r == Zero or r == One) { + SubOp1(); + } else { + SubOp2(); + } + } + + operation ApplyConditionally() : Unit { + let r1 = Zero; + let r2 = Zero; + if (r1 == r2) { + SubOp1(); + } + else { + SubOp2(); + } + } + + operation ApplyConditionallyWithNoOp() : Unit { + let r1 = Zero; + let r2 = Zero; + if (r1 == r2) { + SubOp1(); + } + } + + operation InequalityWithApplyConditionally() : Unit { + let r1 = Zero; + let r2 = Zero; + if (r1 != r2) { + SubOp1(); + } + else { + SubOp2(); + } + } + + operation InequalityWithApplyIfOneElseZero() : Unit { + let r = Zero; + if (r != Zero) { + SubOp1(); + } + else { + SubOp2(); + } + } + + operation InequalityWithApplyIfZeroElseOne() : Unit { + let r = Zero; + if (r != One) { + SubOp1(); + } + else { + SubOp2(); + } + } + + operation InequalityWithApplyIfOne() : Unit { + let r = Zero; + if (r != Zero) { + SubOp1(); + } + } + + operation InequalityWithApplyIfZero() : Unit { + let r = Zero; + if (r != One) { + SubOp1(); + } + } + + operation LiteralOnTheLeft() : Unit { + let r = Zero; + if (Zero == r) { + SubOp1(); + } + } + + // ToDo: Uncomment once #17245 is fixed. + //operation GenericsSupport<'A, 'B, 'C>() : Unit { + // let r = Zero; + // + // if (r == Zero) { + // SubOp1(); + // SubOp2(); + // } + //} + + operation WithinBlockSupport() : Unit { + let r = One; + within { + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } apply { + if (r == One) { + SubOpCA2(); + SubOpCA3(); + } + } + } + + operation AdjointSupportProvided() : Unit is Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + adjoint (...) { + let w = One; + + if (w == One) { + SubOpCA2(); + SubOpCA3(); + } + } + } + + operation AdjointSupportSelf() : Unit is Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + adjoint self; + } + + operation AdjointSupportInvert() : Unit is Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + adjoint invert; + } + + operation ControlledSupportProvided() : Unit is Ctl { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA2(); + SubOpCA3(); + } + } + } + + operation ControlledSupportDistribute() : Unit is Ctl { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled distribute; + } + + operation ControlledAdjointSupportProvided_ProvidedBody() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled adjoint (ctl, ...) { + let y = One; + + if (y == One) { + SubOpCA2(); + SubOpCA3(); + } + } + } + + operation ControlledAdjointSupportProvided_ProvidedAdjoint() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + adjoint (...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + controlled adjoint (ctl, ...) { + let y = One; + + if (y == One) { + SubOpCA2(); + SubOpCA3(); + } + } + } + + operation ControlledAdjointSupportProvided_ProvidedControlled() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + controlled adjoint (ctl, ...) { + let y = One; + + if (y == One) { + SubOpCA2(); + SubOpCA3(); + } + } + } + + operation ControlledAdjointSupportProvided_ProvidedAll() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + adjoint (...) { + let y = One; + + if (y == One) { + SubOpCA2(); + SubOpCA3(); + } + } + + controlled adjoint (ctl, ...) { + let b = One; + + if (b == One) { + let temp1 = 0; + let temp2 = 0; + SubOpCA3(); + } + } + } + + operation ControlledAdjointSupportDistribute_DistributeBody() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled adjoint distribute; + } + + operation ControlledAdjointSupportDistribute_DistributeAdjoint() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + adjoint (...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + controlled adjoint distribute; + } + + operation ControlledAdjointSupportDistribute_DistributeControlled() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + controlled adjoint distribute; + } + + operation ControlledAdjointSupportDistribute_DistributeAll() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + adjoint (...) { + let y = One; + + if (y == One) { + SubOpCA2(); + SubOpCA3(); + } + } + + controlled adjoint distribute; + } + + operation ControlledAdjointSupportInvert_InvertBody() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled adjoint invert; + } + + operation ControlledAdjointSupportInvert_InvertAdjoint() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + adjoint (...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + controlled adjoint invert; + } + + operation ControlledAdjointSupportInvert_InvertControlled() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + controlled adjoint invert; + } + + operation ControlledAdjointSupportInvert_InvertAll() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + adjoint (...) { + let y = One; + + if (y == One) { + SubOpCA2(); + SubOpCA3(); + } + } + + controlled adjoint invert; + } + + operation ControlledAdjointSupportSelf_SelfBody() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled adjoint self; + } + + operation ControlledAdjointSupportSelf_SelfControlled() : Unit is Ctl + Adj { + body (...) { + let r = Zero; + + if (r == Zero) { + SubOpCA1(); + SubOpCA2(); + } + } + + controlled (ctl, ...) { + let w = One; + + if (w == One) { + SubOpCA3(); + SubOpCA1(); + } + } + + controlled adjoint self; + } } \ No newline at end of file diff --git a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/ClassicallyControlledSupportTests.qs b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/ClassicallyControlledSupportTests.qs index dd229588369..f6e0979ebf8 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/QCIExe/ClassicallyControlledSupportTests.qs +++ b/src/Simulation/Simulators.Tests/TestProjects/QCIExe/ClassicallyControlledSupportTests.qs @@ -60,27 +60,6 @@ namespace Microsoft.Quantum.Simulation.Testing.QCI.ClassicallyControlledSupportT let temp = 2; } } - - operation DontLiftReturnStatements() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - return (); - } - } - - function SubFunc1() : Unit { } - function SubFunc2() : Unit { } - function SubFunc3() : Unit { } - - function DontLiftFunctions() : Unit { - let r = Zero; - if (r == Zero) { - SubFunc1(); - SubFunc2(); - SubFunc3(); - } - } operation LiftSelfContainedMutable() : Unit { let r = Zero; @@ -90,14 +69,6 @@ namespace Microsoft.Quantum.Simulation.Testing.QCI.ClassicallyControlledSupportT } } - operation DontLiftGeneralMutable() : Unit { - let r = Zero; - mutable temp = 3; - if (r == Zero) { - set temp = 4; - } - } - operation PartiallyResolved<'Q, 'W> (q : 'Q, w : 'W) : Unit { } operation ArgumentsPartiallyResolveTypeParameters() : Unit { @@ -141,43 +112,6 @@ namespace Microsoft.Quantum.Simulation.Testing.QCI.ClassicallyControlledSupportT SubOp3(); } } - - operation IfInvalid() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - return (); - } else { - SubOp2(); - SubOp3(); - } - } - - operation ElseInvalid() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - } else { - SubOp2(); - SubOp3(); - return (); - } - } - - operation BothInvalid() : Unit { - let r = Zero; - if (r == Zero) { - SubOp1(); - SubOp2(); - return (); - } else { - SubOp2(); - SubOp3(); - return (); - } - } operation ApplyIfZero_Test() : Unit { let r = Zero; diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/HoneywellSimulation.qs b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/HoneywellSimulation.qs index c31aef77bcd..6082ac038ad 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/HoneywellSimulation.qs +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/HoneywellSimulation.qs @@ -43,30 +43,12 @@ namespace Microsoft.Quantum.Simulation.Testing.Honeywell { LiftSingleNonCall(); } - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation DontLiftReturnStatementsTest() : Unit { - DontLiftReturnStatements(); - } - - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation DontLiftFunctionsTest() : Unit { - DontLiftFunctions(); - } - @Test("QuantumSimulator") @Test("ResourcesEstimator") operation LiftSelfContainedMutableTest() : Unit { LiftSelfContainedMutable(); } - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation DontLiftGeneralMutableTest() : Unit { - DontLiftGeneralMutable(); - } - @Test("QuantumSimulator") @Test("ResourcesEstimator") operation ArgumentsPartiallyResolveTypeParametersTest() : Unit { @@ -97,24 +79,6 @@ namespace Microsoft.Quantum.Simulation.Testing.Honeywell { LiftOneNotBoth(); } - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation IfInvalidTest() : Unit { - IfInvalid(); - } - - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation ElseInvalidTest() : Unit { - ElseInvalid(); - } - - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation BothInvalidTest() : Unit { - BothInvalid(); - } - @Test("QuantumSimulator") @Test("ResourcesEstimator") operation ApplyIfZeroTest() : Unit { diff --git a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/QCISimulation.qs b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/QCISimulation.qs index fb3f1e89316..5cc75f4577f 100644 --- a/src/Simulation/Simulators.Tests/TestProjects/UnitTests/QCISimulation.qs +++ b/src/Simulation/Simulators.Tests/TestProjects/UnitTests/QCISimulation.qs @@ -43,30 +43,12 @@ namespace Microsoft.Quantum.Simulation.Testing.QCI { LiftSingleNonCall(); } - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation DontLiftReturnStatementsTest() : Unit { - DontLiftReturnStatements(); - } - - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation DontLiftFunctionsTest() : Unit { - DontLiftFunctions(); - } - @Test("QuantumSimulator") @Test("ResourcesEstimator") operation LiftSelfContainedMutableTest() : Unit { LiftSelfContainedMutable(); } - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation DontLiftGeneralMutableTest() : Unit { - DontLiftGeneralMutable(); - } - @Test("QuantumSimulator") @Test("ResourcesEstimator") operation ArgumentsPartiallyResolveTypeParametersTest() : Unit { @@ -97,24 +79,6 @@ namespace Microsoft.Quantum.Simulation.Testing.QCI { LiftOneNotBoth(); } - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation IfInvalidTest() : Unit { - IfInvalid(); - } - - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation ElseInvalidTest() : Unit { - ElseInvalid(); - } - - @Test("QuantumSimulator") - @Test("ResourcesEstimator") - operation BothInvalidTest() : Unit { - BothInvalid(); - } - @Test("QuantumSimulator") @Test("ResourcesEstimator") operation ApplyIfZeroTest() : Unit {