public void AllocateQubit2Test()
        {
            using var sim = new QuantumSimulator();
            try
            {
                IgnorableAssert.Disable();
                QVoid res = sim.Execute <AllocateQubit2, QVoid, QVoid>(QVoid.Instance);
            }
            catch (ExecutionFailException)
            {
                var stackFrames = sim.CallStack;

                // Make sure that the call stack isn't null before proceeding.
                Assert.NotNull(stackFrames);

                // The following assumes that Assert is on Q# stack.
                Assert.Equal(2, stackFrames !.Length);

                Assert.Equal("Microsoft.Quantum.Diagnostics.AssertMeasurement", stackFrames[0].Callable.FullName);
                Assert.Equal(namespacePrefix + "AllocateQubit2", stackFrames[1].Callable.FullName);

                Assert.Equal(OperationFunctor.Body, stackFrames[0].Callable.Variant);
                Assert.Equal(OperationFunctor.Body, stackFrames[1].Callable.Variant);

                Assert.Equal(94, stackFrames[1].FailedLineNumber);
            }
            finally
            {
                IgnorableAssert.Enable();
            }
        }
Example #2
0
        public void AllocateQubit2Test()
        {
            using (var sim = new QuantumSimulator())
            {
                try
                {
                    IgnorableAssert.Disable();
                    QVoid res = sim.Execute <AllocateQubit2, QVoid, QVoid>(QVoid.Instance);
                }
                catch (ExecutionFailException)
                {
                    StackFrame[] stackFrames = sim.CallStack;

                    // The following assumes that Assert is on Q# stack.
                    Assert.Equal(2, stackFrames.Length);

                    Assert.Equal("Microsoft.Quantum.Intrinsic.Assert", stackFrames[0].Callable.FullName);
                    Assert.Equal(namespacePrefix + "AllocateQubit2", stackFrames[1].Callable.FullName);

                    Assert.Equal(OperationFunctor.Body, stackFrames[0].Callable.Variant);
                    Assert.Equal(OperationFunctor.Body, stackFrames[1].Callable.Variant);

                    Assert.Equal(94, stackFrames[1].FailedLineNumber);
                }
                finally
                {
                    IgnorableAssert.Enable();
                }
            }
        }