From 2fc255bf0e339329b8fadc289ca3793abf6f92cd Mon Sep 17 00:00:00 2001 From: Andres Paz Date: Tue, 27 Oct 2020 00:51:03 -0700 Subject: [PATCH 1/6] Update manifest for signed builds (#357) --- Build/manifest.ps1 | 44 +++++++++++++++++++++++++++++++++++--------- Build/steps.yml | 6 ++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/Build/manifest.ps1 b/Build/manifest.ps1 index fe82d57e8ef..2e86b8dc423 100644 --- a/Build/manifest.ps1 +++ b/Build/manifest.ps1 @@ -1,16 +1,35 @@ -#!/usr/bin/env pwsh -#Requires -PSEdition Core +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +<# + .SYNOPSIS + Provides the list of artifacts (Packages and Assemblies) generated by this repository. + + .PARAMETER OutputFormat + Specifies if the output of this script should be a hashtable with the artifacts + as strings with the absolute path (AbsolutePath) or FileInfo structures. +#> +param( + [ValidateSet('FileInfo','AbsolutePath')] + [string] $OutputFormat = 'FileInfo' +); + & "$PSScriptRoot/set-env.ps1" -@{ +$artifacts = @{ Packages = @( - "Microsoft.Quantum.Standard", - "Microsoft.Quantum.Standard.Visualization", "Microsoft.Quantum.Chemistry", + "Microsoft.Quantum.Chemistry.DataModel", + "Microsoft.Quantum.Chemistry.Jupyter", + "Microsoft.Quantum.Chemistry.Runtime", + "Microsoft.Quantum.Chemistry.Tools", + "Microsoft.Quantum.MachineLearning", "Microsoft.Quantum.Numerics", - "Microsoft.Quantum.MachineLearning" - ); + "Microsoft.Quantum.Standard", + "Microsoft.Quantum.Standard.Visualization" + ) | ForEach-Object { Join-Path $Env:NUGET_OUTDIR "$_.$Env:NUGET_VERSION.nupkg" }; + Assemblies = @( ".\Standard\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Standard.dll", ".\Visualization\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Standard.Visualization.dll", @@ -19,5 +38,12 @@ ".\Chemistry\src\DataModel\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.DataModel.dll", ".\Chemistry\src\Runtime\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Runtime.dll", ".\Chemistry\src\Tools\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\qdk-chem.dll" - ) | ForEach-Object { Get-Item (Join-Path $PSScriptRoot ".." $_) }; -} | Write-Output; + ) | ForEach-Object { Join-Path $PSScriptRoot (Join-Path ".." $_) }; +} + +if ($OutputFormat -eq 'FileInfo') { + $artifacts.Packages = $artifacts.Packages | ForEach-Object { Get-Item $_ }; + $artifacts.Assemblies = $artifacts.Assemblies | ForEach-Object { Get-Item $_ }; +} + +$artifacts | Write-Output; diff --git a/Build/steps.yml b/Build/steps.yml index 2f386fd117b..4e6aebbfbe2 100644 --- a/Build/steps.yml +++ b/Build/steps.yml @@ -36,4 +36,10 @@ steps: workingDirectory: $(System.DefaultWorkingDirectory)/Build +- pwsh: .\manifest.ps1 + displayName: "List built packages & assemblies" + workingDirectory: '$(System.DefaultWorkingDirectory)/Build' + condition: succeededOrFailed() + + - template: step-wrap-up.yml From 0a84a07d721700b06750f245de3a192c4e5b9b1c Mon Sep 17 00:00:00 2001 From: Andres Paz Date: Wed, 28 Oct 2020 20:52:33 -0700 Subject: [PATCH 2/6] Missed dll for signing (#361) --- Build/manifest.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Build/manifest.ps1 b/Build/manifest.ps1 index 2e86b8dc423..9765de673a3 100644 --- a/Build/manifest.ps1 +++ b/Build/manifest.ps1 @@ -36,6 +36,7 @@ $artifacts = @{ ".\Numerics\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Numerics.dll", ".\MachineLearning\src\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.MachineLearning.dll", ".\Chemistry\src\DataModel\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.DataModel.dll", + ".\Chemistry\src\Jupyter\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Jupyter.dll", ".\Chemistry\src\Runtime\bin\$Env:BUILD_CONFIGURATION\netstandard2.1\Microsoft.Quantum.Chemistry.Runtime.dll", ".\Chemistry\src\Tools\bin\$Env:BUILD_CONFIGURATION\netcoreapp3.1\qdk-chem.dll" ) | ForEach-Object { Join-Path $PSScriptRoot (Join-Path ".." $_) }; From 50dd29b7c863e8ca5a0697ffad9e76ac012dc473 Mon Sep 17 00:00:00 2001 From: Irina Hristova Date: Fri, 30 Oct 2020 08:15:50 +0200 Subject: [PATCH 3/6] Update unit tests to use @Test attribute (#350) * Update tests using the @Test attribute. * Update tests using the @Test() attribute. * Flip actual and expected. * Update Standard/tests/Math/OperatorFunctionTests.qs Co-authored-by: Chris Granade Co-authored-by: Chris Granade Co-authored-by: Chris Granade Co-authored-by: Mathias Soeken --- Standard/tests/AmplitudeAmplificationTests.qs | 11 +- Standard/tests/ApplyMultiControlledTests.qs | 3 +- Standard/tests/ApplyRepeatedOverTests.qs | 10 +- Standard/tests/Arithmetic/ReflectionTests.qs | 3 +- Standard/tests/ArithmeticTests.qs | 14 +-- Standard/tests/ArrayTests.qs | 46 ++++---- Standard/tests/AssertTests.qs | 13 +-- Standard/tests/BitwiseTests.qs | 3 +- Standard/tests/CombinatorTests.qs | 101 ++++++++++-------- Standard/tests/CommonGateTests.qs | 15 ++- Standard/tests/ConversionTests.qs | 6 +- Standard/tests/EnumerationTests.qs | 24 +++-- Standard/tests/Logical/BooleanTests.qs | 15 ++- Standard/tests/Logical/ComparisonTests.qs | 1 + Standard/tests/Logical/PredicateTests.qs | 22 ++-- Standard/tests/Math/MathTests.qs | 50 ++++----- Standard/tests/Math/OperatorFunctionTests.qs | 91 ++++++++-------- Standard/tests/Measurement/ResetTests.qs | 7 +- Standard/tests/MultiplexerTests.qs | 11 +- .../tests/Optimization/UnivariateTests.qs | 4 +- Standard/tests/PairTests.qs | 5 +- Standard/tests/PauliTests.qs | 7 +- Standard/tests/QFTTests.qs | 3 +- Standard/tests/QcvvTests.qs | 19 ++-- Standard/tests/QeccTests.qs | 42 ++++---- Standard/tests/QuantumPhaseEstimationTests.qs | 3 +- Standard/tests/QubitizationTests.qs | 21 ++-- Standard/tests/StatePreparationTests.qs | 13 ++- Standard/tests/TypeConversionTests.qs | 6 +- .../UniformSuperpositionPreparationTests.qs | 4 +- 30 files changed, 326 insertions(+), 247 deletions(-) diff --git a/Standard/tests/AmplitudeAmplificationTests.qs b/Standard/tests/AmplitudeAmplificationTests.qs index 4f731c119e8..f25ebe30718 100644 --- a/Standard/tests/AmplitudeAmplificationTests.qs +++ b/Standard/tests/AmplitudeAmplificationTests.qs @@ -31,7 +31,8 @@ namespace Microsoft.Quantum.Tests { /// In this minimal example, there are no system qubits, only a single flag qubit. /// ExampleStatePrep is already of type StateOracle, so we call /// StandardAmplitudeAmplification(iterations: Int, stateOracle : StateOracle, idxFlagQubit : Int startQubits: Qubit[]) : () - operation AmpAmpByOracleTest () : Unit { + @Test("QuantumSimulator") + operation CheckAmpAmpByOracle () : Unit { using (qubits = Qubit[1]) { ResetAll(qubits); @@ -54,8 +55,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation AmpAmpObliviousByOraclePhasesTest () : Unit { + @Test("QuantumSimulator") + operation CheckAmpAmpObliviousByOraclePhases () : Unit { using (qubits = Qubit[1]) { ResetAll(qubits); @@ -80,8 +81,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation AmpAmpTargetStateReflectionOracleTest () : Unit { + @Test("QuantumSimulator") + operation CheckAmpAmpTargetStateReflectionOracle () : Unit { using (qubits = Qubit[1]) { ResetAll(qubits); diff --git a/Standard/tests/ApplyMultiControlledTests.qs b/Standard/tests/ApplyMultiControlledTests.qs index e05139732bd..e5ef7cbe1c4 100644 --- a/Standard/tests/ApplyMultiControlledTests.qs +++ b/Standard/tests/ApplyMultiControlledTests.qs @@ -11,7 +11,8 @@ namespace Microsoft.Quantum.Tests { /// Tests multiply controlled not implementation that uses /// ApplyMultiControlledCA against multiply controlled version of /// the Microsoft.Quantum.Intrinsic.X - operation ApplyMultiControlledTest () : Unit { + @Test("QuantumSimulator") + operation CheckApplyMultiControlled() : Unit { let twoQubitOp = CNOT; diff --git a/Standard/tests/ApplyRepeatedOverTests.qs b/Standard/tests/ApplyRepeatedOverTests.qs index 51594b46a3e..7bb4220d151 100644 --- a/Standard/tests/ApplyRepeatedOverTests.qs +++ b/Standard/tests/ApplyRepeatedOverTests.qs @@ -8,8 +8,8 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Diagnostics; open Microsoft.Quantum.Arrays; - - operation ApplySeriesOfOpsTest() : Unit { + @Test("QuantumSimulator") + operation CheckApplySeriesOfOps() : Unit { // create the sample ops + their targets here let op1 = ApplyToFirstQubit(X, _); let op2 = ApplyToFirstTwoQubits(CNOT, _); @@ -34,7 +34,8 @@ namespace Microsoft.Quantum.Tests { ApplyToEachCA(H, Subarray([1, 2, 3, 4], register)); } - operation ApplyRepeatedOpTest() : Unit { + @Test("QuantumSimulator") + operation CheckApplyRepeatedOp() : Unit { let op = ApplyToFirstThreeQubits(CCNOT, _); let targets = [[0, 1, 2], [2, 1, 0], [3, 4, 5], [2, 4, 0], [5, 3, 1]]; AssertOperationsEqualReferenced(6, ApplyOpRepeatedlyOver(op, targets, _), SampleApplyRepeatedOp(_)); @@ -49,7 +50,8 @@ namespace Microsoft.Quantum.Tests { CCNOT(register[5], register[3], register[1]); } - operation PermuteQubitsTest() : Unit { + @Test("QuantumSimulator") + operation CheckPermuteQubits() : Unit { let sampleOrder = [5, 3, 2, 0, 1, 4]; AssertOperationsEqualReferenced(6, PermuteQubits(sampleOrder, _) , SamplePermuteQubits); } diff --git a/Standard/tests/Arithmetic/ReflectionTests.qs b/Standard/tests/Arithmetic/ReflectionTests.qs index 5002490cd97..7f87f7dfb5f 100644 --- a/Standard/tests/Arithmetic/ReflectionTests.qs +++ b/Standard/tests/Arithmetic/ReflectionTests.qs @@ -19,7 +19,8 @@ namespace Microsoft.Quantum.Tests { ReflectAboutInteger(5, littleEndian); } - operation ReflectAboutIntegerTest() : Unit { + @Test("QuantumSimulator") + operation CheckReflectAboutInteger() : Unit { AssertOperationsEqualReferenced(3, ReflectAboutFiveUsingLibrary, ManuallyReflectAboutFive diff --git a/Standard/tests/ArithmeticTests.qs b/Standard/tests/ArithmeticTests.qs index e841a3092c3..e15edf9a6c9 100644 --- a/Standard/tests/ArithmeticTests.qs +++ b/Standard/tests/ArithmeticTests.qs @@ -18,9 +18,9 @@ namespace Microsoft.Quantum.ArithmeticTests { } } - - operation ApplyXorInPlaceTest () : Unit { - + @Test("QuantumSimulator") + operation CheckApplyXorInPlace() : Unit { + ApplyToEach(InPlaceXorTestHelper, [(63, 6), (42, 6)]); } @@ -42,7 +42,7 @@ namespace Microsoft.Quantum.ArithmeticTests { /// Exhaustively tests Microsoft.Quantum.Artihmetic.IncrementByInteger /// on 4 qubits @Test("QuantumSimulator") - operation IncrementByIntegerTest () : Unit { + operation CheckIncrementByInteger() : Unit { let numberOfQubits = 4; @@ -86,7 +86,7 @@ namespace Microsoft.Quantum.ArithmeticTests { /// Tests Microsoft.Quantum.Arithmetic.IncrementByModularInteger /// on 4 qubits with modulus 13 @Test("QuantumSimulator") - operation IncrementByModularIntegerTest () : Unit { + operation CheckIncrementByModularInteger() : Unit { let numberOfQubits = 4; let modulus = 13; @@ -122,7 +122,7 @@ namespace Microsoft.Quantum.ArithmeticTests { /// Tests Microsoft.Quantum.Canon.ModularAddProductLE /// on 4 qubits with modulus 13 @Test("QuantumSimulator") - operation MultiplyAndAddByModularIntegerTest () : Unit { + operation CheckMultiplyAndAddByModularInteger() : Unit { let numberOfQubits = 4; let modulus = 13; @@ -160,7 +160,7 @@ namespace Microsoft.Quantum.ArithmeticTests { /// Tests Microsoft.Quantum.Canon.ModularMultiplyByConstantLE /// on 4 qubits with modulus 13 @Test("QuantumSimulator") - operation MultiplyByModularIntegerTest () : Unit { + operation CheckMultiplyByModularInteger() : Unit { let numberOfQubits = 4; let modulus = 13; diff --git a/Standard/tests/ArrayTests.qs b/Standard/tests/ArrayTests.qs index 3aa1b38be19..71f5ecc8777 100644 --- a/Standard/tests/ArrayTests.qs +++ b/Standard/tests/ArrayTests.qs @@ -91,8 +91,8 @@ namespace Microsoft.Quantum.Tests { EqualityFactI(fnArray[3](7), 49, $"ConstantArray(Int, Int -> Int) had the wrong value."); } - - function SubarrayTest () : Unit { + @Test("QuantumSimulator") + function SubarrayIsCorrect () : Unit { let array0 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let subarrayOdd = Subarray([1, 3, 5, 7, 9], array0); let subarrayEven = Subarray([0, 2, 4, 6, 8, 10], array0); @@ -116,21 +116,20 @@ namespace Microsoft.Quantum.Tests { EqualityFactI(countEvens, 5, $"the even elements of [1..10] were not correctly counted."); } - - function ReverseTest () : Unit { - + @Test("QuantumSimulator") + function ReversedIsCorrect() : Unit { let array = [1, 2, 3]; Ignore(Mapped(EqualityFactI(_, _, $"Reversed failed."), Zipped([3, 2, 1], Reversed(array)))); } - - function ExcludingTest () : Unit { + @Test("QuantumSimulator") + function ExcludingIsCorrect() : Unit { let array = [10, 11, 12, 13, 14, 15]; Ignore(Mapped(EqualityFactI(_, _, $"Excluding failed."), Zipped([10, 11, 13, 14], Excluding([2, 5], array)))); } - - function PadTest () : Unit { + @Test("QuantumSimulator") + function PaddedIsCorrect() : Unit { mutable arrayTestCase = [(-5, 2, [10, 11, 12], [10, 11, 12, 2, 2]), (5, 2, [10, 11, 12], [2, 2, 10, 11, 12]), (-3, -2, [10, 11, 12], [10, 11, 12])]; @@ -141,7 +140,8 @@ namespace Microsoft.Quantum.Tests { } } - function EnumeratedTest() : Unit { + @Test("QuantumSimulator") + function EnumeratedIsCorrect() : Unit { let example = [37, 12]; let expected = [(0, 37), (1, 12)]; let actual = Enumerated(example); @@ -152,7 +152,8 @@ namespace Microsoft.Quantum.Tests { } } - function SequenceITest() : Unit { + @Test("QuantumSimulator") + function SequenceIIsCorrect() : Unit { let example = [(0, 3), (23, 29), (-5, -2)]; let expected = [[0, 1, 2, 3], [23, 24, 25, 26, 27, 28, 29], [-5, -4, -3, -2]]; let actual = Mapped(SequenceI, example); @@ -165,7 +166,8 @@ namespace Microsoft.Quantum.Tests { } } - function SequenceLTest() : Unit { + @Test("QuantumSimulator") + function SequenceLIsCorrect() : Unit { let example = [(0L, 3L), (23L, 29L), (-5L, -2L)]; let expected = [[0L, 1L, 2L, 3L], [23L, 24L, 25L, 26L, 27L, 28L, 29L], [-5L, -4L, -3L, -2L]]; let actual = Mapped(SequenceL, example); @@ -177,8 +179,8 @@ namespace Microsoft.Quantum.Tests { } } } - - function SequenceForNumbersTest() : Unit { + @Test("QuantumSimulator") + function SequenceForNumbersIsCorrect() : Unit { let example = [3, 5, 0]; let expected = [[0, 1, 2, 3], [0, 1, 2, 3, 4, 5], [0]]; let actual = Mapped(SequenceI(0, _), example); @@ -191,7 +193,8 @@ namespace Microsoft.Quantum.Tests { } } - function IsEmptyTest() : Unit { + @Test("QuantumSimulator") + function IsEmptyIsCorrect() : Unit { Fact(IsEmpty(new Int[0]), "Empty array marked as non-empty."); Fact(IsEmpty(new Qubit[0]), "Empty array marked as non-empty."); Fact(IsEmpty(new (Double, (Int -> String))[0]), "Empty array marked as non-empty."); @@ -199,7 +202,8 @@ namespace Microsoft.Quantum.Tests { Fact(not IsEmpty([""]), "Non-empty array marked as empty."); } - function SwapOrderToPermuteArrayTest() : Unit { + @Test("QuantumSimulator") + function SwapOrderToPermuteArrayIsCorrect() : Unit { let newOrder = [0, 4, 2, 1, 3]; let expected = [(1, 4), (1, 3)]; let actual = _SwapOrderToPermuteArray(newOrder); @@ -214,7 +218,8 @@ namespace Microsoft.Quantum.Tests { } } - function SwappedTest() : Unit { + @Test("QuantumSimulator") + function SwappedIsCorrect() : Unit { let example = [2, 4, 6, 8, 10]; let expected = [2, 8, 6, 4, 10]; let leftIndex = 1; @@ -227,7 +232,8 @@ namespace Microsoft.Quantum.Tests { } } - function TupleArrayAsNestedArrayTest() : Unit { + @Test("QuantumSimulator") + function TupleArrayAsNestedArrayIsCorrect() : Unit { let example = [(0, 1), (2, 3), (4, 5), (6, 7)]; let expected = [[0, 1], [2, 3], [4, 5], [6, 7]]; @@ -240,8 +246,8 @@ namespace Microsoft.Quantum.Tests { } } - - function EqualATest() : Unit { + @Test("QuantumSimulator") + function EqualAIsCorrect() : Unit { // arrays of integers let equalArrays = EqualA(EqualI, [2, 3, 4], [2, 3, 4]); Fact(equalArrays, "Equal arrays were not reported as equal"); diff --git a/Standard/tests/AssertTests.qs b/Standard/tests/AssertTests.qs index 30e8eb2ea76..945435f038f 100644 --- a/Standard/tests/AssertTests.qs +++ b/Standard/tests/AssertTests.qs @@ -12,7 +12,7 @@ namespace Microsoft.Quantum.Tests { // with the intent of testing the assert and testing harness mechanisms themselves. operation EmptyTest() : Unit { } - operation PreparationTest() : Unit { + operation TestPreparation() : Unit { using (qubit = Qubit()) { Diag.AssertMeasurementProbability([PauliZ], [qubit], Zero, 1.0, $"Freshly prepared qubit was not in |0〉 state.", 1E-10); } @@ -56,7 +56,8 @@ namespace Microsoft.Quantum.Tests { /// These tests are already performed in Solid itself, such that /// this operation tests whether we can reproduce that using our /// operation equality assertions. - operation SelfAdjointOperationsTest() : Unit { + @Diag.Test("QuantumSimulator") + operation TestSelfAdjointOperations() : Unit { for (op in [I, X, Y, Z, H]) { Diag.AssertOperationsEqualReferenced(3, ApplyToEach(op, _), ApplyToEachA(op, _)); } @@ -77,8 +78,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation AssertProbIntTest() : Unit { + @Diag.Test("QuantumSimulator") + operation TestAssertProbInt() : Unit { let theta = 0.123; let prob = 0.015052858190174602; let tolerance = 1E-09; @@ -93,8 +94,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation AssertPhaseTest() : Unit { + @Diag.Test("QuantumSimulator") + operation TestAssertPhase() : Unit { let phase = 0.456; let tolerance = 1E-09; diff --git a/Standard/tests/BitwiseTests.qs b/Standard/tests/BitwiseTests.qs index f20aca9a954..2dd8401f608 100644 --- a/Standard/tests/BitwiseTests.qs +++ b/Standard/tests/BitwiseTests.qs @@ -5,7 +5,8 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Bitwise; open Microsoft.Quantum.Diagnostics; - function ShiftTest() : Unit { + @Test("QuantumSimulator") + function ShiftIsCorrect() : Unit { let smallValue = 5; // 0b101 EqualityFactI(20, LeftShiftedI(smallValue, 2), "Shifted values incorrect."); EqualityFactI(2, RightShiftedI(smallValue, 1), "Shifted values incorrect."); diff --git a/Standard/tests/CombinatorTests.qs b/Standard/tests/CombinatorTests.qs index ad06f1803d7..cf9c7e3d267 100644 --- a/Standard/tests/CombinatorTests.qs +++ b/Standard/tests/CombinatorTests.qs @@ -8,14 +8,14 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Diagnostics; open Microsoft.Quantum.Arrays; - - function ComposeTest () : Unit { + @Test("QuantumSimulator") + function ComposeIsCorrect() : Unit { let target = [3, 17, 2]; EqualityFactI((Compose(ModulusI(_, 14), Max))(target), 3, $"Compose(ModulusI(_, 14), Max) did not return expected result."); } - - operation WithTest () : Unit { + @Test("QuantumSimulator") + operation TestWith() : Unit { let actual = ApplyWith(H, X, _); let expected = Z; @@ -25,22 +25,23 @@ namespace Microsoft.Quantum.Tests { // Make sure that if CurryTest fails, it's because of Curry and not // something else. - operation CurryPreTest () : Unit { + @Test("QuantumSimulator") + operation PreTestCurried() : Unit { AssertOperationsEqualInPlace(1, Exp([PauliZ], 1.7, _), Exp([PauliZ], 1.7, _)); AssertOperationsEqualReferenced(1, Exp([PauliZ], 1.7, _), Exp([PauliZ], 1.7, _)); } - - operation CurryTest () : Unit { + @Test("QuantumSimulator") + operation TestCurried() : Unit { let curried = CurriedOp(Exp([PauliZ], _, _)); AssertOperationsEqualInPlace(1, curried(1.7), Exp([PauliZ], 1.7, _)); AssertOperationsEqualReferenced(1, curried(1.7), Exp([PauliZ], 1.7, _)); } - - operation BindTest () : Unit { + @Test("QuantumSimulator") + operation TestBind() : Unit { let bound = BoundCA([H, X, H]); AssertOperationsEqualReferenced(3, ApplyToEach(bound, _), ApplyToEachA(Z, _)); @@ -52,8 +53,8 @@ namespace Microsoft.Quantum.Tests { return op; } - - operation BindATest () : Unit { + @Test("QuantumSimulator") + operation TestBindA() : Unit { let bound = BoundA(Mapped(StripControlled, [T, T])); AssertOperationsEqualReferenced(3, ApplyToEach(bound, _), ApplyToEachA(S, _)); @@ -80,8 +81,8 @@ namespace Microsoft.Quantum.Tests { return op; } - - operation BindCTest () : Unit { + @Test("QuantumSimulator") + operation TestBindC() : Unit { let stripped = Mapped(StripAdjoint, [T, T]); let bound = BoundC(stripped); @@ -91,8 +92,8 @@ namespace Microsoft.Quantum.Tests { AssertOperationsEqualReferenced(6, op, target); } - - operation BindCATest () : Unit { + @Test("QuantumSimulator") + operation TestBindCA() : Unit { let bound = BoundCA([T, T]); AssertOperationsEqualReferenced(3, ApplyToEach(bound, _), ApplyToEachA(S, _)); AssertOperationsEqualReferenced(3, ApplyToEach(Adjoint bound, _), ApplyToEachA(Adjoint S, _)); @@ -101,8 +102,8 @@ namespace Microsoft.Quantum.Tests { AssertOperationsEqualReferenced(4, op, target); } - - operation OperationPowTest () : Unit { + @Test("QuantumSimulator") + operation TestOperationPow() : Unit { AssertOperationsEqualReferenced(3, ApplyToEach(OperationPow(H, 2), _), NoOp); AssertOperationsEqualReferenced(3, ApplyToEach(OperationPow(Z, 2), _), NoOp); @@ -110,8 +111,8 @@ namespace Microsoft.Quantum.Tests { AssertOperationsEqualReferenced(3, ApplyToEach(OperationPow(T, 8), _), NoOp); } - - operation ApplyToSubregisterTest () : Unit { + @Test("QuantumSimulator") + operation TestApplyToSubregister() : Unit { let bigOp = ApplyPauli([PauliI, PauliX, PauliY, PauliZ, PauliI], _); let smallOp = ApplyPauli([PauliX, PauliY, PauliZ], _); @@ -169,8 +170,8 @@ namespace Microsoft.Quantum.Tests { controlled adjoint distribute; } - - operation CControlledTest () : Unit { + @Test("QuantumSimulator") + operation TestCControlled() : Unit { AssertOperationsEqualReferenced(3, CControlledActual(H, _), CControlledExpected(H, _)); AssertOperationsEqualReferenced(3, CControlledActual(Z, _), CControlledExpected(Z, _)); @@ -178,7 +179,7 @@ namespace Microsoft.Quantum.Tests { AssertOperationsEqualReferenced(3, CControlledActual(T, _), CControlledExpected(T, _)); } - + @Test("QuantumSimulator") operation CControlledTestC () : Unit { AssertOperationsEqualReferenced(3, CControlledActualC(H, _), CControlledExpected(H, _)); @@ -187,7 +188,7 @@ namespace Microsoft.Quantum.Tests { AssertOperationsEqualReferenced(3, CControlledActualC(T, _), CControlledExpected(T, _)); } - + @Test("QuantumSimulator") operation CControlledTestA () : Unit { AssertOperationsEqualReferenced(3, CControlledActualA(H, _), CControlledExpected(H, _)); @@ -196,7 +197,7 @@ namespace Microsoft.Quantum.Tests { AssertOperationsEqualReferenced(3, CControlledActualA(T, _), CControlledExpected(T, _)); } - + @Test("QuantumSimulator") operation CControlledTestCA () : Unit { AssertOperationsEqualReferenced(3, CControlledActualCA(H, _), CControlledExpected(H, _)); @@ -205,43 +206,50 @@ namespace Microsoft.Quantum.Tests { AssertOperationsEqualReferenced(3, CControlledActualCA(T, _), CControlledExpected(T, _)); } - operation ApplyIfZeroTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfZero() : Unit { AssertOperationsEqualReferenced(2, ApplyIfZero(One, (ApplyToEach(H, _), _)), ApplyToEachA(I, _)); AssertOperationsEqualReferenced(2, ApplyIfZero(Zero, (ApplyToEach(H, _), _)), ApplyToEachA(H, _)); } - operation ApplyIfOneTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfOne() : Unit { AssertOperationsEqualReferenced(2, ApplyIfOne(One, (ApplyToEach(H, _), _)), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfOne(Zero, (ApplyToEach(H, _), _)), ApplyToEachA(I, _)); } - - operation ApplyIfZeroCTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfZeroC() : Unit { AssertOperationsEqualReferenced(2, ApplyIfZeroC(One, (ApplyToEachC(H, _), _)), ApplyToEachA(I, _)); AssertOperationsEqualReferenced(2, ApplyIfZeroC(Zero, (ApplyToEachC(H, _), _)), ApplyToEachA(H, _)); } - operation ApplyIfOneCTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfOneC() : Unit { AssertOperationsEqualReferenced(2, ApplyIfOneC(One, (ApplyToEachC(H, _), _)), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfOneC(Zero, (ApplyToEachC(H, _), _)), ApplyToEachA(I, _)); } - operation ApplyIfZeroCATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfZeroCA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfZeroCA(One, (ApplyToEachCA(H, _), _)), ApplyToEachA(I, _)); AssertOperationsEqualReferenced(2, ApplyIfZeroCA(Zero, (ApplyToEachCA(H, _), _)), ApplyToEachA(H, _)); } - operation ApplyIfOneCATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfOneCA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfOneCA(One, (ApplyToEachCA(H, _), _)), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfOneCA(Zero, (ApplyToEachCA(H, _), _)), ApplyToEachA(I, _)); } - operation ApplyIfZeroATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfZeroA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfZeroA(One, (ApplyToEachA(H, _), _)), ApplyToEachA(I, _)); AssertOperationsEqualReferenced(2, ApplyIfZeroA(Zero, (ApplyToEachA(H, _), _)), ApplyToEachA(H, _)); } - operation ApplyIfOneATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfOneA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfOneA(One, (ApplyToEachA(H, _), _)), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfOneA(Zero, (ApplyToEachA(H, _), _)), ApplyToEachA(I, _)); } @@ -254,7 +262,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseRTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseR() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseRCase(Zero, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseRCase(One, _), ApplyToEachA(X, _)); } @@ -267,7 +276,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseRATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseRA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseRACase(Zero, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseRACase(One, _), ApplyToEachA(X, _)); } @@ -280,7 +290,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseRCTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseRC() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseRCCase(Zero, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseRCCase(One, _), ApplyToEachA(X, _)); } @@ -293,7 +304,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseRCATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseRCA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseRCACase(Zero, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseRCACase(One, _), ApplyToEachA(X, _)); } @@ -306,7 +318,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseBTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseB() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseBCase(true, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseBCase(false, _), ApplyToEachA(X, _)); } @@ -319,7 +332,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseBATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseBA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseBACase(true, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseBACase(false, _), ApplyToEachA(X, _)); } @@ -332,7 +346,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseBCTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseBC() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseBCCase(true, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseBCCase(false, _), ApplyToEachA(X, _)); } @@ -345,7 +360,8 @@ namespace Microsoft.Quantum.Tests { ); } - operation ApplyIfElseBCATest() : Unit { + @Test("QuantumSimulator") + operation TestApplyIfElseBCA() : Unit { AssertOperationsEqualReferenced(2, ApplyIfElseBCACase(true, _), ApplyToEachA(H, _)); AssertOperationsEqualReferenced(2, ApplyIfElseBCACase(false, _), ApplyToEachA(X, _)); } @@ -354,7 +370,8 @@ namespace Microsoft.Quantum.Tests { X(qubits[1]); } - operation ApplyToElementTest() : Unit { + @Test("QuantumSimulator") + operation TestApplyToElement() : Unit { AssertOperationsEqualReferenced(3, ApplyToElement(X, 1, _), ApplyXToSecondQubit diff --git a/Standard/tests/CommonGateTests.qs b/Standard/tests/CommonGateTests.qs index dbe41666f3f..946f759e836 100644 --- a/Standard/tests/CommonGateTests.qs +++ b/Standard/tests/CommonGateTests.qs @@ -17,26 +17,30 @@ namespace Microsoft.Quantum.Tests { adjoint auto; } - operation CXTest() : Unit { + @Test("QuantumSimulator") + operation TestCX() : Unit { let actual = ApplyCShorthandToRegister(CX, _); let expected = ApplyControlledOpToRegister(X, _); AssertOperationsEqualReferenced(2, actual, expected); } - operation CYTest() : Unit { + @Test("QuantumSimulator") + operation TestCY() : Unit { let actual = ApplyCShorthandToRegister(CY, _); let expected = ApplyControlledOpToRegister(Y, _); AssertOperationsEqualReferenced(2, actual, expected); } - operation CZTest() : Unit { + @Test("QuantumSimulator") + operation TestCZ() : Unit { let actual = ApplyCShorthandToRegister(CZ, _); let expected = ApplyControlledOpToRegister(Z, _); AssertOperationsEqualReferenced(2, actual, expected); } // Verify Fermionic SWAP gives the correct qubit values - operation ApplyFermionicSWAPValueTest() : Unit { + @Test("QuantumSimulator") + operation CheckApplyFermionicSWAPValue() : Unit { using ((left, right) = (Qubit(), Qubit())) { // 00 ApplyFermionicSWAP(left, right); @@ -69,7 +73,8 @@ namespace Microsoft.Quantum.Tests { } // Verify Fermionic SWAP gives the correct phase change - operation ApplyFermionicSWAPPhaseTest() : Unit { + @Test("QuantumSimulator") + operation CheckApplyFermionicSWAPPhase() : Unit { using ((left, right) = (Qubit(), Qubit())) { // 00 VerifyFermionicSWAPPhaseHelper(Zero, left, right); diff --git a/Standard/tests/ConversionTests.qs b/Standard/tests/ConversionTests.qs index b60833f6fb1..328ad1eb322 100644 --- a/Standard/tests/ConversionTests.qs +++ b/Standard/tests/ConversionTests.qs @@ -5,14 +5,16 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Canon; open Microsoft.Quantum.Convert; - function ResultArrayAsIntTest () : Unit { + @Test("QuantumSimulator") + function ResultArrayAsIntIsCorrect() : Unit { EqualityFactI(ResultArrayAsInt([Zero, Zero]), 0, $"Expected [Zero, Zero] to be represented by 0."); EqualityFactI(ResultArrayAsInt([One, Zero]), 1, $"Expected [One, Zero] to be represented by 1."); EqualityFactI(ResultArrayAsInt([Zero, One]), 2, $"Expected [Zero, One] to be represented by 2."); EqualityFactI(ResultArrayAsInt([One, One]), 3, $"Expected [One, One] to be represented by 3."); } - function BoolArrFromPositiveIntTest () : Unit { + @Test("QuantumSimulator") + function BoolArrFromPositiveIntIsCorrect() : Unit { for (number in 0 .. 100) { let bits = IntAsBoolArray(number, 9); let inte = BoolArrayAsInt(bits); diff --git a/Standard/tests/EnumerationTests.qs b/Standard/tests/EnumerationTests.qs index 5e9db499f26..05c32f3e5ed 100644 --- a/Standard/tests/EnumerationTests.qs +++ b/Standard/tests/EnumerationTests.qs @@ -30,29 +30,29 @@ namespace Microsoft.Quantum.Tests { return a * a; } - - function ForAllTest () : Unit { + @Test("QuantumSimulator") + function ForAllIsCorrect() : Unit { EqualityFactB(All(IsSingleDigit, [3, 4, 7, 8]), true, $"the elements [3, 4, 7, 8] were not found to be single digit numbers."); EqualityFactB(All(IsSingleDigit, [3, 4, 7, 18]), false, $"the elements [3, 4, 7, 18] were found to be single digit numbers."); } - - - function ForAnyTest () : Unit { + + @Test("QuantumSimulator") + function ForAnyIsCorrect() : Unit { EqualityFactB(Any(IsEven, [3, 7, 99, -4]), true, $"the elements [3, 7, 99, -4] were not found to contain at least one even number."); EqualityFactB(Any(IsEven, [3, 7, 99, -41]), false, $"the elements [3, 7, 99, -4] were not found to contain at least one even number."); } - - function FoldTest () : Unit { + @Test("QuantumSimulator") + function FoldIsCorrect() : Unit { let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; EqualityFactI(Fold(Add, 0, array), 55, $"folding the summation over [1..10] did not yield 55."); } - - function MapTest () : Unit { + @Test("QuantumSimulator") + function MapIsCorrect() : Unit { let array = [1, 2, 3, 4]; let squaredArray = Mapped(Squarer, array); @@ -86,13 +86,15 @@ namespace Microsoft.Quantum.Tests { AllEqualityFactI(numbers, [1, 2, 3, 1, 2, 3, 1, 2, 3], "Flattened failed"); } - function ExtremaTest () : Unit { + @Test("QuantumSimulator") + function ExtremaIsCorrect() : Unit { let array = [-10, 10, 7, 0]; EqualityFactI(-10, Min(array), $"Min failed."); EqualityFactI(10, Max(array), $"Max failed."); } - function IndexOfTest() : Unit { + @Test("QuantumSimulator") + function IndexOfIsCorrect() : Unit { let array = [1, 3, 21, -7, 2, 19]; let actual = IndexOf(IsEven, array); EqualityFactI(4, actual, $"Expected 4, got {actual}."); diff --git a/Standard/tests/Logical/BooleanTests.qs b/Standard/tests/Logical/BooleanTests.qs index 9900278fd75..ebc6f73855a 100644 --- a/Standard/tests/Logical/BooleanTests.qs +++ b/Standard/tests/Logical/BooleanTests.qs @@ -5,32 +5,37 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Logical; open Microsoft.Quantum.Diagnostics; - function NotTest() : Unit { + @Test("QuantumSimulator") + function NotIsCorrect() : Unit { Fact(Not(false), "Not returned wrong output."); } - function AndTest() : Unit { + @Test("QuantumSimulator") + function AndIsCorrect() : Unit { Fact(not And(false, false), "And returned wrong output."); Fact(not And(false, true), "And returned wrong output."); Fact(not And(true, false), "And returned wrong output."); Fact(And(true, true), "And returned wrong output."); } - function OrTest() : Unit { + @Test("QuantumSimulator") + function OrIsCorrect() : Unit { Fact(not Or(false, false), "Or returned wrong output."); Fact(Or(false, true), "Or returned wrong output."); Fact(Or(true, false), "Or returned wrong output."); Fact(Or(true, true), "Or returned wrong output."); } - function XorTest() : Unit { + @Test("QuantumSimulator") + function XorIsCorrect() : Unit { Fact(not Xor(false, false), "Xor returned wrong output."); Fact(Xor(false, true), "Xor returned wrong output."); Fact(Xor(true, false), "Xor returned wrong output."); Fact(not Xor(true, true), "Xor returned wrong output."); } - function ConditionedTest() : Unit { + @Test("QuantumSimulator") + function ConditionedIsCorrect() : Unit { EqualityFactI(Conditioned(true, 42, -1), 42, "Conditioned returned wrong output."); EqualityFactL(Conditioned(false, 42L, -1L), -1L, "Conditioned returned wrong output."); } diff --git a/Standard/tests/Logical/ComparisonTests.qs b/Standard/tests/Logical/ComparisonTests.qs index 9afd776c33d..a426c729396 100644 --- a/Standard/tests/Logical/ComparisonTests.qs +++ b/Standard/tests/Logical/ComparisonTests.qs @@ -7,6 +7,7 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Math; open Microsoft.Quantum.Arrays; + @Test("QuantumSimulator") function LexographicComparisonIsCorrect() : Unit { let lexographicComparison = LexographicComparison(LessThanOrEqualD); Fact( diff --git a/Standard/tests/Logical/PredicateTests.qs b/Standard/tests/Logical/PredicateTests.qs index 5c970d97e46..b27b3b6936f 100644 --- a/Standard/tests/Logical/PredicateTests.qs +++ b/Standard/tests/Logical/PredicateTests.qs @@ -6,7 +6,8 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Diagnostics; open Microsoft.Quantum.Math; - function EqualTest() : Unit { + @Test("QuantumSimulator") + function EqualIsCorrect() : Unit { Fact(EqualI(42, 42), "EqualI returned wrong output."); Fact(not EqualI(42, 73), "EqualI returned wrong output."); @@ -29,7 +30,8 @@ namespace Microsoft.Quantum.Tests { Fact(not EqualCP(ComplexPolar(1.0, 2.0), ComplexPolar(1.0, 73.0)), "EqualCP returned wrong output."); } - function NotEqualTest() : Unit { + @Test("QuantumSimulator") + function NotEqualIsCorrect() : Unit { Fact(not NotEqualI(42, 42), "NotEqualI returned wrong output."); Fact(NotEqualI(42, 73), "NotEqualI returned wrong output."); @@ -52,7 +54,8 @@ namespace Microsoft.Quantum.Tests { Fact(NotEqualCP(ComplexPolar(1.0, 2.0), ComplexPolar(1.0, 73.0)), "NotEqualCP returned wrong output."); } - function GreaterThanTest() : Unit { + @Test("QuantumSimulator") + function GreaterThanIsCorrect() : Unit { Fact(GreaterThanI(75, 32), "GreaterThanI returned wrong output."); Fact(not GreaterThanI(-13, 32), "GreaterThanI returned wrong output."); @@ -63,7 +66,8 @@ namespace Microsoft.Quantum.Tests { Fact(not GreaterThanL(-13L, 32L), "GreaterThanL returned wrong output."); } - function LessThanTest() : Unit { + @Test("QuantumSimulator") + function LessThanIsCorrect() : Unit { Fact(not LessThanI(75, 32), "LessThanI returned wrong output."); Fact(LessThanI(-13, 32), "LessThanI returned wrong output."); @@ -74,7 +78,8 @@ namespace Microsoft.Quantum.Tests { Fact(LessThanL(-13L, 32L), "LessThanL returned wrong output."); } - function GreaterThanOrEqualTest() : Unit { + @Test("QuantumSimulator") + function GreaterThanOrEqualIsCorrect() : Unit { Fact(GreaterThanOrEqualI(75, 75), "GreaterThanOrEqualI returned wrong output."); Fact(not GreaterThanOrEqualI(-13, 32), "GreaterThanOrEqualI returned wrong output."); @@ -85,7 +90,8 @@ namespace Microsoft.Quantum.Tests { Fact(not GreaterThanOrEqualL(-13L, 32L), "GreaterThanOrEqualL returned wrong output."); } - function LessThanOrEqualTest() : Unit { + @Test("QuantumSimulator") + function LessThanOrEqualIsCorrect() : Unit { Fact(LessThanOrEqualI(75, 75), "LessThanOrEqualI returned wrong output."); Fact(not LessThanOrEqualI(32, -13), "LessThanOrEqualI returned wrong output."); @@ -96,10 +102,10 @@ namespace Microsoft.Quantum.Tests { Fact(not LessThanOrEqualL(32L, -13L), "LessThanOrEqualL returned wrong output."); } - function NearlyEqualDTest() : Unit { + @Test("QuantumSimulator") + function NearlyEqualDIsCorrect() : Unit { Fact(NearlyEqualD(1.0, 1.0), "Exactly equal numbers marked as not nearly equal."); Fact(NearlyEqualD(1.0, 1.0 + 1e-15), "Nearly equal numbers marked as not nearly equal."); Fact(not NearlyEqualD(1.0, 1000.0), "Not nearly equal numbers marked as nearly equal."); } - } diff --git a/Standard/tests/Math/MathTests.qs b/Standard/tests/Math/MathTests.qs index 3a8c27b1321..b4fd41dfb35 100644 --- a/Standard/tests/Math/MathTests.qs +++ b/Standard/tests/Math/MathTests.qs @@ -6,7 +6,8 @@ namespace Microsoft.Quantum.Canon { open Microsoft.Quantum.Diagnostics; open Microsoft.Quantum.Arrays; - function NativeFnsAreCallableTest () : Unit { + @Test("QuantumSimulator") + function NativeFnsAreCallable () : Unit { let arg = PI() / 2.0; NearEqualityFactD(Sin(arg), 1.0); @@ -16,15 +17,15 @@ namespace Microsoft.Quantum.Canon { NearEqualityFactD(ArcSin(arcArg), arg); } - - function RealModTest () : Unit { + @Test("QuantumSimulator") + function RealModIsCorrect () : Unit { NearEqualityFactD(RealMod(5.5 * PI(), 2.0 * PI(), 0.0), 1.5 * PI()); NearEqualityFactD(RealMod(0.5 * PI(), 2.0 * PI(), -PI() / 2.0), 0.5 * PI()); } - - function ArcHyperbolicFnsTest () : Unit { + @Test("QuantumSimulator") + function ArcHyperbolicFnsAreCorrect () : Unit { // These tests were generated using NumPy's implementations // of the inverse hyperbolic functions. @@ -33,7 +34,6 @@ namespace Microsoft.Quantum.Canon { NearEqualityFactD(ArcSinh(-0.7), -0.65266656608235574); } - function ExtendedGreatestCommonDivisorITestHelper (a : Int, b : Int, gcd : Int) : Unit { Message($"Testing {a}, {b}, {gcd} "); @@ -43,14 +43,15 @@ namespace Microsoft.Quantum.Canon { EqualityFactI(expected, actual, $"Expected absolute value of gcd to be {expected}, got {actual}"); } - - function ExtendedGreatestCommonDivisorITest () : Unit { + @Test("QuantumSimulator") + function ExtendedGreatestCommonDivisorIIsCorrect () : Unit { let testTuples = [(1, 1, 1), (1, -1, 1), (-1, 1, 1), (-1, -1, 1), (5, 7, 1), (-5, 7, 1), (3, 15, 3)]; Ignore(Mapped(ExtendedGreatestCommonDivisorITestHelper, testTuples)); } - function GreatestCommonDivisorLTest() : Unit { + @Test("QuantumSimulator") + function GreatestCommonDivisorLIsCorrect() : Unit { EqualityFactL( GreatestCommonDivisorL( 44958225298979240833230460209285719018635426448048959524915L, @@ -60,24 +61,22 @@ namespace Microsoft.Quantum.Canon { "GCD returned wrong result for BigInt inputs." ); } - - - function BitSizeTest () : Unit { + @Test("QuantumSimulator") + function BitSizeIsCorrect () : Unit { EqualityFactI(BitSizeI(3), 2, $"BitSizeI(3) must be 2"); EqualityFactI(BitSizeI(7), 3, $"BitSizeI(7) must be 2"); } - - function ExpModTest () : Unit { + @Test("QuantumSimulator") + function ExpModIsCorrect () : Unit { // this test is generated using Mathematica PowerMod function let result = ExpModI(5, 4611686018427387903, 7); EqualityFactI(result, 6, $"The result must be 6, got {result}"); } - - + function ContinuedFractionConvergentTestHelper (numerator : Int, denominator : Int) : Unit { let bitSize = 2 * BitSizeI(denominator); @@ -86,15 +85,14 @@ namespace Microsoft.Quantum.Canon { EqualityFactB(AbsI(u) == numerator and AbsI(v) == denominator, true, $"The result must be ±{numerator}/±{denominator} got {u}/{v}"); } - function ContinuedFractionConvergentEdgeCaseTestHelper (numerator : Int, denominator : Int, bound : Int) : Unit { let (num, denom) = (ContinuedFractionConvergentI(Fraction(numerator, denominator), bound))!; EqualityFactB(AbsI(num) == numerator and AbsI(denom) == denominator, true, $"The result must be ±{numerator}/±{denominator} got {num}/{denom}"); } - - function ContinuedFractionConvergentTest () : Unit { + @Test("QuantumSimulator") + function ContinuedFractionConvergentIsCorrect () : Unit { let testTuples = [(29, 47), (17, 37), (15, 67)]; Ignore(Mapped(ContinuedFractionConvergentTestHelper, testTuples)); @@ -102,8 +100,8 @@ namespace Microsoft.Quantum.Canon { Ignore(Mapped(ContinuedFractionConvergentEdgeCaseTestHelper, edgeCaseTestTuples)); } - - function ComplexMathTest () : Unit { + @Test("QuantumSimulator") + function ComplexMathIsCorrect () : Unit { mutable complexCases = [(0.123, 0.321), (0.123, -0.321), (-0.123, 0.321), (-0.123, -0.321)]; @@ -128,8 +126,8 @@ namespace Microsoft.Quantum.Canon { } } - - function PNormTest () : Unit { + @Test("QuantumSimulator") + function PNormIsCorrect () : Unit { mutable testCases = [ (1.0, [-0.1, 0.2, 0.3], 0.6), @@ -151,12 +149,10 @@ namespace Microsoft.Quantum.Canon { } } - function SquaredNormTest() : Unit { + @Test("QuantumSimulator") + function SquaredNormIsCorrect() : Unit { NearEqualityFactD(SquaredNorm([2.0]), 4.0); NearEqualityFactD(SquaredNorm([1.0, 1.0]), 2.0); NearEqualityFactD(SquaredNorm([3.0, 4.0]), 25.0); } - } - - diff --git a/Standard/tests/Math/OperatorFunctionTests.qs b/Standard/tests/Math/OperatorFunctionTests.qs index 10c36d3eb85..f155ce01dfc 100644 --- a/Standard/tests/Math/OperatorFunctionTests.qs +++ b/Standard/tests/Math/OperatorFunctionTests.qs @@ -17,64 +17,67 @@ namespace Microsoft.Quantum.Tests { function TWO_PI_4_C() : Complex { return ComplexPolarAsComplex(TWO_PI_4_CP()); } function TWO_PI_4_CP() : ComplexPolar { return ComplexPolar(2.0, PI() / 4.0); } - // FIXME: expected and actual are flipped uniformly in this file. - // this has no effect other than making unit test failures slightly - // harder to read. - - function NegationTest() : Unit { - EqualityFactI(-42, NegationI(42), "NegationI returned wrong output."); - NearEqualityFactD(-42.0, NegationD(42.0)); - EqualityFactL(-42L, NegationL(42L), "NegationI returned wrong output."); - NearEqualityFactC(Complex(1.0, 2.0), NegationC(Complex(-1.0, -2.0))); + @Test("QuantumSimulator") + function NegationIsCorrect() : Unit { + EqualityFactI(NegationI(42), -42, "NegationI returned wrong output."); + NearEqualityFactD(NegationD(42.0), -42.0); + EqualityFactL(NegationL(42L), -42L, "NegationI returned wrong output."); + NearEqualityFactC(NegationC(Complex(-1.0, -2.0)), Complex(1.0, 2.0)); NearEqualityFactCP( - ComplexPolar(1.0, PI() / 4.0), - NegationCP(ComplexPolar(1.0, 5.0 * PI() / 4.0)) + NegationCP(ComplexPolar(1.0, 5.0 * PI() / 4.0)), + ComplexPolar(1.0, PI() / 4.0) ); } - function PlusTest() : Unit { - EqualityFactI(-40, PlusI(-72, 32), "PlusI returned wrong output."); - NearEqualityFactD(-40.0, PlusD(-72.0, 32.0)); - EqualityFactL(-40L, PlusL(-72L, 32L), "PlusL returned wrong output."); - NearEqualityFactC(TWO_C(), PlusC(ONE_C(), ONE_C())); - NearEqualityFactCP(TWO_CP(), PlusCP(ONE_CP(), ONE_CP())); + @Test("QuantumSimulator") + function PlusIsCorrect() : Unit { + EqualityFactI(PlusI(-72, 32), -40, "PlusI returned wrong output."); + NearEqualityFactD(PlusD(-72.0, 32.0), -40.0); + EqualityFactL(PlusL(-72L, 32L), -40L, "PlusL returned wrong output."); + NearEqualityFactC(PlusC(ONE_C(), ONE_C()), TWO_C()); + NearEqualityFactCP(PlusCP(ONE_CP(), ONE_CP()), TWO_CP()); } - function MinusTest() : Unit { - EqualityFactI(40, MinusI(72, 32), "MinusI returned wrong output."); - NearEqualityFactD(40.0, MinusD(72.0, 32.0)); - EqualityFactL(40L, MinusL(72L, 32L), "MinusL returned wrong output."); - NearEqualityFactC(ONE_C(), MinusC(TWO_C(), ONE_C())); - NearEqualityFactCP(ONE_CP(), MinusCP(TWO_CP(), ONE_CP())); + @Test("QuantumSimulator") + function MinusIsCorrect() : Unit { + EqualityFactI(MinusI(72, 32), 40, "MinusI returned wrong output."); + NearEqualityFactD(MinusD(72.0, 32.0), 40.0); + EqualityFactL(MinusL(72L, 32L), 40L, "MinusL returned wrong output."); + NearEqualityFactC(MinusC(TWO_C(), ONE_C()), ONE_C()); + NearEqualityFactCP(MinusCP(TWO_CP(), ONE_CP()), ONE_CP()); } - function TimesTest() : Unit { - EqualityFactI(40, TimesI(-10, -4), "TimesI returned wrong output."); - NearEqualityFactD(40.0, TimesD(-10.0, -4.0)); - EqualityFactL(40L, TimesL(-10L, -4L), "TimesL returned wrong output."); - NearEqualityFactC(TWO_C(), TimesC(TWO_C(), ONE_C())); - NearEqualityFactCP(TWO_CP(), TimesCP(TWO_CP(), ONE_CP())); + @Test("QuantumSimulator") + function TimesIsCorrect() : Unit { + EqualityFactI(TimesI(-10, -4), 40, "TimesI returned wrong output."); + NearEqualityFactD(TimesD(-10.0, -4.0), 40.0); + EqualityFactL(TimesL(-10L, -4L), 40L, "TimesL returned wrong output."); + NearEqualityFactC(TimesC(TWO_C(), ONE_C()), TWO_C()); + NearEqualityFactCP(TimesCP(TWO_CP(), ONE_CP()), TWO_CP()); } - function DivdedByTest() : Unit { - EqualityFactI(10, DividedByI(-40, -4), "DividedByI returned wrong output."); - NearEqualityFactD(10.0, DividedByD(-40.0, -4.0)); - EqualityFactL(10L, DividedByL(-40L, -4L), "DividedByL returned wrong output."); - NearEqualityFactC(PI_4_C(), DividedByC(TWO_PI_4_C(), TWO_C())); - NearEqualityFactCP(PI_4_CP(), DividedByCP(TWO_PI_4_CP(), TWO_CP())); + @Test("QuantumSimulator") + function DividedByIsCorrect() : Unit { + EqualityFactI(DividedByI(-40, -4), 10, "DividedByI returned wrong output."); + NearEqualityFactD(DividedByD(-40.0, -4.0), 10.0); + EqualityFactL(DividedByL(-40L, -4L), 10L, "DividedByL returned wrong output."); + NearEqualityFactC(DividedByC(TWO_PI_4_C(), TWO_C()), PI_4_C()); + NearEqualityFactCP(DividedByCP(TWO_PI_4_CP(), TWO_CP()), PI_4_CP()); } - function ModTest() : Unit { - EqualityFactI(2, ModI(17, 5), "ModI returned wrong output."); - EqualityFactL(2L, ModL(17L, 5L), "ModL returned wrong output."); + @Test("QuantumSimulator") + function ModIsCorrect() : Unit { + EqualityFactI(ModI(17, 5), 2, "ModI returned wrong output."); + EqualityFactL(ModL(17L, 5L), 2L, "ModL returned wrong output."); } - function PowTest() : Unit { - EqualityFactI(6561, PowI(3, 8), "PowI returned wrong output."); - NearEqualityFactD(157.58648490814928441592231285347, PowD(2.0, 7.3)); - EqualityFactL(239072435685151324847153L, PowL(17L, 19), "PowL returned wrong output."); - NearEqualityFactC(PI_2_C(), PowC(PI_4_C(), TWO_C())); - NearEqualityFactCP(PI_2_CP(), PowCP(PI_4_CP(), TWO_CP())); + @Test("QuantumSimulator") + function PowIsCorrect() : Unit { + EqualityFactI(PowI(3, 8), 6561, "PowI returned wrong output."); + NearEqualityFactD(PowD(2.0, 7.3), 157.58648490814928441592231285347); + EqualityFactL(PowL(17L, 19), 239072435685151324847153L, "PowL returned wrong output."); + NearEqualityFactC(PowC(PI_4_C(), TWO_C()), PI_2_C()); + NearEqualityFactCP(PowCP(PI_4_CP(), TWO_CP()), PI_2_CP()); } } diff --git a/Standard/tests/Measurement/ResetTests.qs b/Standard/tests/Measurement/ResetTests.qs index 45056d785e2..aaf98e2cc60 100644 --- a/Standard/tests/Measurement/ResetTests.qs +++ b/Standard/tests/Measurement/ResetTests.qs @@ -6,7 +6,7 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Intrinsic; open Microsoft.Quantum.Diagnostics; - operation CheckSetToBasisState(desired : Result) : Unit { + operation CheckSetToBasisStateHelper(desired : Result) : Unit { using (q = Qubit()) { Ry(0.1234, q); SetToBasisState(desired, q); @@ -15,9 +15,10 @@ namespace Microsoft.Quantum.Tests { } } - operation SetToBasisStateTest() : Unit { + @Test("QuantumSimulator") + operation CheckSetToBasisState() : Unit { for (desired in [Zero, One]) { - CheckSetToBasisState(desired); + CheckSetToBasisStateHelper(desired); } } diff --git a/Standard/tests/MultiplexerTests.qs b/Standard/tests/MultiplexerTests.qs index 9e166c30956..f23a680eb9a 100644 --- a/Standard/tests/MultiplexerTests.qs +++ b/Standard/tests/MultiplexerTests.qs @@ -147,8 +147,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation ApplyDiagonalUnitaryTest () : Unit { + @Diag.Test("QuantumSimulator") + operation TestApplyDiagonalUnitary() : Unit { let maxQubits = 4; @@ -331,8 +331,8 @@ namespace Microsoft.Quantum.Tests { return result; } - - operation MultiplexOperationsTest () : Unit { + @Diag.Test("QuantumSimulator") + operation TestMultiplexOperations() : Unit { mutable result = Zero; @@ -505,7 +505,8 @@ namespace Microsoft.Quantum.Tests { } } - operation MultiplexOperationsFromGeneratorTest() : Unit{ + @Diag.Test("QuantumSimulator") + operation TestMultiplexOperationsFromGenerator() : Unit{ body (...) { mutable result = Zero; diff --git a/Standard/tests/Optimization/UnivariateTests.qs b/Standard/tests/Optimization/UnivariateTests.qs index 73301bcb343..d43d988e53e 100644 --- a/Standard/tests/Optimization/UnivariateTests.qs +++ b/Standard/tests/Optimization/UnivariateTests.qs @@ -10,8 +10,8 @@ namespace Microsoft.Quantum.Tests { return PowD((x - minima), 2.0); } - // @Test("QuantumSimulator") - function MinimizedParabolaTest() : Unit { + @Test("QuantumSimulator") + function MinimizedParabolaIsCorrect() : Unit { let optimum = LocalUnivariateMinimum(ParabolaCase(3.14, _), (-7.0, +12.0), 1e-10); NearEqualityFactD(optimum::Coordinate, 3.14); NearEqualityFactD(optimum::Value, 0.0); diff --git a/Standard/tests/PairTests.qs b/Standard/tests/PairTests.qs index 0f70826bbcd..e4dca98a3e6 100644 --- a/Standard/tests/PairTests.qs +++ b/Standard/tests/PairTests.qs @@ -3,9 +3,10 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Canon; + open Microsoft.Quantum.Diagnostics; - - function PairTest () : Unit { + @Test("QuantumSimulator") + function PairIsCorrect() : Unit { let pair = (12, PauliZ); diff --git a/Standard/tests/PauliTests.qs b/Standard/tests/PauliTests.qs index e2911973dec..a60e8447b31 100644 --- a/Standard/tests/PauliTests.qs +++ b/Standard/tests/PauliTests.qs @@ -5,9 +5,10 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Intrinsic; open Microsoft.Quantum.Canon; open Microsoft.Quantum.Measurement; - - - operation MeasureWithScratchTest () : Unit { + open Microsoft.Quantum.Diagnostics; + + @Test("QuantumSimulator") + operation TestMeasureWithScratch() : Unit { using (register = Qubit[2]) { PrepareEntangledState([register[0]], [register[1]]); diff --git a/Standard/tests/QFTTests.qs b/Standard/tests/QFTTests.qs index 40be1c455fe..e0eeee11696 100644 --- a/Standard/tests/QFTTests.qs +++ b/Standard/tests/QFTTests.qs @@ -93,7 +93,8 @@ namespace Microsoft.Quantum.Tests { /// # Summary /// Compares QFT to the hard-coded implementations - operation QFTTest () : Unit { + @Test("QuantumSimulator") + operation TestQFT() : Unit { let testFunctions = [QFT1, QFT2, QFT3, QFT4]; for (i in IndexRange(testFunctions)) { diff --git a/Standard/tests/QcvvTests.qs b/Standard/tests/QcvvTests.qs index bb7a85ccced..cbc35f9bbe4 100644 --- a/Standard/tests/QcvvTests.qs +++ b/Standard/tests/QcvvTests.qs @@ -12,7 +12,8 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Math; open Microsoft.Quantum.Measurement as Meas; - operation ChoiStateTest () : Unit { + @Test("QuantumSimulator") + operation TestChoiState() : Unit { using (register = Qubit[2]) { PrepareChoiStateCA(NoOp, [register[0]], [register[1]]); @@ -28,7 +29,8 @@ namespace Microsoft.Quantum.Tests { Message("stage prepared"); } - operation EstimateFrequencyTest () : Unit { + @Test("QuantumSimulator") + operation TestEstimateFrequency() : Unit { let freq1 = EstimateFrequency(ApplyToEach(H, _), Meas.MeasureAllZ, 1, 1000); EqualityWithinToleranceFact(freq1, 0.5, 0.1); @@ -55,7 +57,8 @@ namespace Microsoft.Quantum.Tests { EqualityWithinToleranceFact(expectation, actualFreq, tolerance); } - operation EstimateFrequencyBinomialTest() : Unit { + @Test("QuantumSimulator") + operation TestEstimateFrequencyBinomial() : Unit { // If this is larger, tests fail less often, but more false negatives // slip through. let nStdDevs = 3.0; @@ -98,7 +101,8 @@ namespace Microsoft.Quantum.Tests { } // Probabilistic test. Might fail occasionally - operation RobustPhaseEstimationTest () : Unit { + @Test("QuantumSimulator") + operation TestRobustPhaseEstimation() : Unit { let bitsPrecision = 10; @@ -109,8 +113,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation PrepareQubitTest () : Unit { + @Test("QuantumSimulator") + operation TestPrepareQubit() : Unit { using (qubit = Qubit()) { let bases = [PauliI, PauliX, PauliY, PauliZ]; @@ -122,7 +126,8 @@ namespace Microsoft.Quantum.Tests { } } - operation SingleQubitProcessTomographyMeasurementTest () : Unit { + @Test("QuantumSimulator") + operation TestSingleQubitProcessTomographyMeasurement() : Unit { EqualityFactR(SingleQubitProcessTomographyMeasurement(PauliI, PauliI, H), Zero, $"Failed at ⟪I | H | I⟫."); EqualityFactR(SingleQubitProcessTomographyMeasurement(PauliX, PauliI, H), Zero, $"Failed at ⟪I | H | X⟫."); EqualityFactR(SingleQubitProcessTomographyMeasurement(PauliY, PauliI, H), Zero, $"Failed at ⟪I | H | Y⟫."); diff --git a/Standard/tests/QeccTests.qs b/Standard/tests/QeccTests.qs index ed2670db7bb..8827115e78e 100644 --- a/Standard/tests/QeccTests.qs +++ b/Standard/tests/QeccTests.qs @@ -57,7 +57,8 @@ namespace Microsoft.Quantum.Tests { /// # Summary /// Ensures that the bit flip code can correct a single arbitrary /// bit-flip ($X$) error. - operation BitFlipTest () : Unit { + @Test("QuantumSimulator") + operation TestBitFlip() : Unit { let code = BitFlipCode(); let fn = BitFlipRecoveryFn(); @@ -71,7 +72,8 @@ namespace Microsoft.Quantum.Tests { /// # Summary /// Ensures that the 5-qubit perfect code can correct an arbitrary /// single-qubit error. - operation FiveQubitCodeTest () : Unit { + @Test("QuantumSimulator") + operation TestFiveQubitCode() : Unit { let code = FiveQubitCode(); let fn = FiveQubitCodeRecoveryFn(); @@ -83,7 +85,8 @@ namespace Microsoft.Quantum.Tests { // TODO: split this test up into several smaller tests. - operation FiveQubitTediousTest () : Unit { + @Test("QuantumSimulator") + operation TestFiveQubitTedious() : Unit { let s = SyndromeMeasOp(MeasureStabilizerGenerators([[PauliX, PauliZ, PauliZ, PauliX, PauliI], [PauliI, PauliX, PauliZ, PauliZ, PauliX], [PauliX, PauliI, PauliX, PauliZ, PauliZ], [PauliZ, PauliX, PauliI, PauliX, PauliZ]], _, MeasureWithScratch)); @@ -164,8 +167,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation FiveQubitTest () : Unit { + @Test("QuantumSimulator") + operation TestFiveQubit() : Unit { let s = SyndromeMeasOp(MeasureStabilizerGenerators([[PauliX, PauliZ, PauliZ, PauliX, PauliI], [PauliI, PauliX, PauliZ, PauliZ, PauliX], [PauliX, PauliI, PauliX, PauliZ, PauliZ], [PauliZ, PauliX, PauliI, PauliX, PauliZ]], _, MeasureWithScratch)); @@ -212,8 +215,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation SteaneCodeEncoderTest () : Unit { + @Test("QuantumSimulator") + operation TestSteaneCodeEncoder() : Unit { using (aux = Qubit[7]) { SteaneCodeEncoderImpl(aux[0 .. 0], aux[1 .. 6]); @@ -246,8 +249,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation Pi4YInjectionTest () : Unit { + @Test("QuantumSimulator") + operation TestPi4YInjection() : Unit { using (anc = Qubit[2]) { @@ -266,8 +269,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation Pi4YInjectionAdjointTest () : Unit { + @Test("QuantumSimulator") + operation TestPi4YInjectionAdjoint() : Unit { using (anc = Qubit[2]) { @@ -290,7 +293,8 @@ namespace Microsoft.Quantum.Tests { /// # Summary /// Applies logical operators before and after the encoding circuit, /// that as a whole acts as identity. - operation KDLogicalOperatorTest () : Unit { + @Test("QuantumSimulator") + operation TestKDLogicalOperator() : Unit { using (anc = Qubit[7]) { X(anc[0]); @@ -317,8 +321,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation KDSyndromeTest () : Unit { + @Test("QuantumSimulator") + operation TestKDSyndrome() : Unit { using (anc = Qubit[7]) { @@ -339,8 +343,8 @@ namespace Microsoft.Quantum.Tests { } } - - operation KnillDistillationNoErrorTest () : Unit { + @Test("QuantumSimulator") + operation TestKnillDistillationNoError() : Unit { using (register = Qubit[15]) { @@ -363,7 +367,8 @@ namespace Microsoft.Quantum.Tests { /// Here we do not attempt to correct detected errors, /// since corrections would make the output magic state /// less accurate, compared to post-selection on zero syndrome. - operation KDTest () : Unit { + @Test("QuantumSimulator") + operation TestKD() : Unit { using (rm = Qubit[15]) { ApplyToEach(Ry(PI() / 4.0, _), rm); @@ -446,7 +451,8 @@ namespace Microsoft.Quantum.Tests { /// # Summary /// Ensures that the 7-qubit Steane code can correct an arbitrary /// single-qubit error. - operation SteaneCodeTest () : Unit { + @Test("QuantumSimulator") + operation TestSteaneCode() : Unit { let code = SteaneCode(); let (fnX, fnZ) = SteaneCodeRecoveryFns(); diff --git a/Standard/tests/QuantumPhaseEstimationTests.qs b/Standard/tests/QuantumPhaseEstimationTests.qs index 352839d20c7..e4c9f4e1f9f 100644 --- a/Standard/tests/QuantumPhaseEstimationTests.qs +++ b/Standard/tests/QuantumPhaseEstimationTests.qs @@ -14,7 +14,8 @@ namespace Microsoft.Quantum.Tests { /// Assert that the QuantumPhaseEstimation operation for the T gate /// return 0000 in the controlRegister when targetState is 0 and /// return 0010 when the targetState is 1 - operation QuantumPhaseEstimationTest () : Unit { + @Test("QuantumSimulator") + operation TestQuantumPhaseEstimation() : Unit { let oracle = DiscreteOracle(ApplyTOracle); diff --git a/Standard/tests/QubitizationTests.qs b/Standard/tests/QubitizationTests.qs index ff3f330e267..1e625c7da07 100644 --- a/Standard/tests/QubitizationTests.qs +++ b/Standard/tests/QubitizationTests.qs @@ -25,7 +25,8 @@ namespace Microsoft.Quantum.Tests { } // This checks that BlockEncodingByLCU encodes the correct Hamiltonian. - operation BlockEncodingByLCUTest() : Unit { + @Test("QuantumSimulator") + operation TestBlockEncodingByLCU() : Unit { body (...) { let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper(); let LCU = BlockEncodingByLCU(statePreparation, selector); @@ -48,7 +49,8 @@ namespace Microsoft.Quantum.Tests { } // This checks that BlockEncodingReflectionByLCU encodes the correct Hamiltonian. - operation BlockEncodingReflectionByLCUTest() : Unit { + @Test("QuantumSimulator") + operation TestBlockEncodingReflectionByLCU() : Unit { body (...) { let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper(); let LCU = BlockEncodingReflectionByLCU(statePreparation, selector); @@ -74,7 +76,8 @@ namespace Microsoft.Quantum.Tests { } // This checks that QuantumWalkByQubitization encodes the correct Hamiltonian. - operation QuantumWalkByQubitizationTest() : Unit { + @Test("QuantumSimulator") + operation TestQuantumWalkByQubitization() : Unit { body (...) { let (eigenvalues, prob, inverseAngle, statePreparation, selector) = LCUTestHelper(); let LCU = QuantumWalkByQubitization(BlockEncodingReflectionByLCU(statePreparation, selector)); @@ -101,7 +104,8 @@ namespace Microsoft.Quantum.Tests { // QubitizationPauliEvolutionSet.qs tests // This encodes the Hamiltonian (cos^2(angle) I+sin^2(angle) X)/2. - operation PauliBlockEncodingLCUTest() : Unit { + @Test("QuantumSimulator") + operation TestPauliBlockEncodingLCU() : Unit { body (...) { let angle = 0.123; let cosSquared = Cos(angle) * Cos(angle); @@ -135,7 +139,8 @@ namespace Microsoft.Quantum.Tests { } // Array.qs tests - function RangeAsIntArrayTest() : Unit { + @Test("QuantumSimulator") + function TestRangeAsIntArray() : Unit { mutable testCases = new (Int[], Range)[4]; let e = new Int[0]; set testCases w/= 0 <- ([1, 3, 5, 7], 1..2..8); @@ -149,7 +154,8 @@ namespace Microsoft.Quantum.Tests { } } - operation InPlaceMajorityTest() : Unit { + @Test("QuantumSimulator") + operation TestInPlaceMajority() : Unit { body (...) { // Majority function truth table: x;y;z | output let testCases = [[false, false, false, false], @@ -183,7 +189,8 @@ namespace Microsoft.Quantum.Tests { } } - operation ApplyRippleCarryComparatorTest() : Unit{ + @Test("QuantumSimulator") + operation TestApplyRippleCarryComparator() : Unit{ body (...) { let nQubits = 4; let intMax = 2^nQubits-1; diff --git a/Standard/tests/StatePreparationTests.qs b/Standard/tests/StatePreparationTests.qs index 8cb1b5be137..5c37e4f817e 100644 --- a/Standard/tests/StatePreparationTests.qs +++ b/Standard/tests/StatePreparationTests.qs @@ -14,8 +14,8 @@ namespace Microsoft.Quantum.Tests { // number of qubits, abs(amplitude), phase newtype StatePreparationTestCase = (Int, Double[], Double[]); - - operation StatePreparationPositiveCoefficientsTest () : Unit { + @Diag.Test("QuantumSimulator") + operation TestStatePreparationPositiveCoefficients() : Unit { let tolerance = 1E-09; mutable testCases = new StatePreparationTestCase[100]; @@ -74,7 +74,8 @@ namespace Microsoft.Quantum.Tests { // Test phase factor on 1-qubit uniform superposition. - operation StatePreparationComplexCoefficientsQubitPhaseTest () : Unit { + @Diag.Test("QuantumSimulator") + operation TestStatePreparationComplexCoefficientsQubitPhase() : Unit { let tolerance = 1E-09; mutable testCases = new StatePreparationTestCase[10]; @@ -120,7 +121,8 @@ namespace Microsoft.Quantum.Tests { // Test probabilities and phases factor of multi-qubit uniform superposition. - operation StatePreparationComplexCoefficientsMultiQubitPhaseTest () : Unit { + @Diag.Test("QuantumSimulator") + operation TestStatePreparationComplexCoefficientsMultiQubitPhase() : Unit { let tolerance = 1E-09; mutable testCases = new StatePreparationTestCase[10]; @@ -198,7 +200,8 @@ namespace Microsoft.Quantum.Tests { // Test probabilities and phases of arbitrary multi-qubit superposition. - operation StatePreparationComplexCoefficientsArbitraryMultiQubitPhaseTest () : Unit { + @Diag.Test("QuantumSimulator") + operation TestStatePreparationComplexCoefficientsArbitraryMultiQubitPhase() : Unit { let tolerance = 1E-09; mutable testCases = new StatePreparationTestCase[10]; diff --git a/Standard/tests/TypeConversionTests.qs b/Standard/tests/TypeConversionTests.qs index 669d78d7f6d..5c6f7c07f4a 100644 --- a/Standard/tests/TypeConversionTests.qs +++ b/Standard/tests/TypeConversionTests.qs @@ -14,11 +14,13 @@ namespace Microsoft.Quantum.Tests { return op(input); } - operation CallTest() : Unit { + @Test("ToffoliSimulator") + operation TestCall() : Unit { EqualityFactI(Call(Square, 4), 16, "Call failed with Square."); } - operation ToOperationTest() : Unit { + @Test("ToffoliSimulator") + operation TestToOperation() : Unit { let op = FunctionAsOperation(Square); EqualityFactI(ApplyOp(op, 3), 9, "ToOperation failed with Square."); } diff --git a/Standard/tests/UniformSuperpositionPreparationTests.qs b/Standard/tests/UniformSuperpositionPreparationTests.qs index e2c3da7545b..6e1edda3347 100644 --- a/Standard/tests/UniformSuperpositionPreparationTests.qs +++ b/Standard/tests/UniformSuperpositionPreparationTests.qs @@ -11,8 +11,8 @@ namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Measurement; open Microsoft.Quantum.Arrays; - - operation PrepareUniformSuperpositionTest() : Unit { + @Test("QuantumSimulator") + operation TestPrepareUniformSuperposition() : Unit { body (...) { let nQubits = 5; using(qubits = Qubit[nQubits]) { From 1218ec1f9daf1e98e7d51da7487607c68b76329f Mon Sep 17 00:00:00 2001 From: Andres Paz Date: Fri, 30 Oct 2020 00:54:46 -0700 Subject: [PATCH 4/6] signing for magic (#362) --- Chemistry/src/Jupyter/Jupyter.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Chemistry/src/Jupyter/Jupyter.csproj b/Chemistry/src/Jupyter/Jupyter.csproj index c949abacfd0..79cd4321aea 100644 --- a/Chemistry/src/Jupyter/Jupyter.csproj +++ b/Chemistry/src/Jupyter/Jupyter.csproj @@ -29,6 +29,10 @@ + + + + From e7fb6ef0534eb27e0055ee3e04f0913f1f300bfa Mon Sep 17 00:00:00 2001 From: Ryan Shaffer Date: Wed, 4 Nov 2020 17:15:37 -0500 Subject: [PATCH 5/6] Build 0.13.2010.2604. (#364) Co-authored-by: Ricardo Espinoza Co-authored-by: Andres Paz --- Build/props/tests.props | 2 +- Chemistry/src/Runtime/Runtime.csproj | 4 ++-- Chemistry/tests/ChemistryTests/QSharpTests.csproj | 2 +- Chemistry/tests/SystemTests/SystemTests.csproj | 2 +- MachineLearning/src/MachineLearning.csproj | 2 +- MachineLearning/tests/MachineLearningTests.csproj | 2 +- Numerics/src/Numerics.csproj | 4 ++-- Numerics/tests/NumericsTests.csproj | 2 +- Standard/src/Standard.csproj | 4 ++-- Standard/tests/Standard.Tests.csproj | 2 +- Visualization/src/Visualization.csproj | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Build/props/tests.props b/Build/props/tests.props index 93da9885b9e..42d54c268c2 100644 --- a/Build/props/tests.props +++ b/Build/props/tests.props @@ -6,7 +6,7 @@ - + diff --git a/Chemistry/src/Runtime/Runtime.csproj b/Chemistry/src/Runtime/Runtime.csproj index 3c6a82671de..efeb34ff5a0 100644 --- a/Chemistry/src/Runtime/Runtime.csproj +++ b/Chemistry/src/Runtime/Runtime.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -40,7 +40,7 @@ - + diff --git a/Chemistry/tests/ChemistryTests/QSharpTests.csproj b/Chemistry/tests/ChemistryTests/QSharpTests.csproj index 812d30ef794..fcbb8e7e1dd 100644 --- a/Chemistry/tests/ChemistryTests/QSharpTests.csproj +++ b/Chemistry/tests/ChemistryTests/QSharpTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Chemistry/tests/SystemTests/SystemTests.csproj b/Chemistry/tests/SystemTests/SystemTests.csproj index 83495463ace..f133cd8fabd 100644 --- a/Chemistry/tests/SystemTests/SystemTests.csproj +++ b/Chemistry/tests/SystemTests/SystemTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/MachineLearning/src/MachineLearning.csproj b/MachineLearning/src/MachineLearning.csproj index 6ffd2451c74..999b34d9ca0 100644 --- a/MachineLearning/src/MachineLearning.csproj +++ b/MachineLearning/src/MachineLearning.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 Microsoft.Quantum.MachineLearning diff --git a/MachineLearning/tests/MachineLearningTests.csproj b/MachineLearning/tests/MachineLearningTests.csproj index d883fd37d5c..fbbc152c906 100644 --- a/MachineLearning/tests/MachineLearningTests.csproj +++ b/MachineLearning/tests/MachineLearningTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Numerics/src/Numerics.csproj b/Numerics/src/Numerics.csproj index 6a96efeb443..561b715307d 100644 --- a/Numerics/src/Numerics.csproj +++ b/Numerics/src/Numerics.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -41,7 +41,7 @@ - + diff --git a/Numerics/tests/NumericsTests.csproj b/Numerics/tests/NumericsTests.csproj index 312522abe65..39deb1b2374 100644 --- a/Numerics/tests/NumericsTests.csproj +++ b/Numerics/tests/NumericsTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Standard/src/Standard.csproj b/Standard/src/Standard.csproj index 17f676aed0f..21410763c29 100644 --- a/Standard/src/Standard.csproj +++ b/Standard/src/Standard.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -37,7 +37,7 @@ - + diff --git a/Standard/tests/Standard.Tests.csproj b/Standard/tests/Standard.Tests.csproj index c7fdb20e54c..76379e68e2c 100644 --- a/Standard/tests/Standard.Tests.csproj +++ b/Standard/tests/Standard.Tests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Visualization/src/Visualization.csproj b/Visualization/src/Visualization.csproj index 5ad41e9f98d..53f1fbfd2d9 100644 --- a/Visualization/src/Visualization.csproj +++ b/Visualization/src/Visualization.csproj @@ -32,9 +32,9 @@ - + - + From eec61bc3ceac472b84fd5edf93877d987143c2e1 Mon Sep 17 00:00:00 2001 From: bettinaheim <34236215+bettinaheim@users.noreply.github.com> Date: Wed, 4 Nov 2020 21:28:59 -0800 Subject: [PATCH 6/6] Adapting to API update in qsharp-runtime/#370 (#363) --- Build/props/tests.props | 2 +- Chemistry/src/Runtime/Runtime.csproj | 4 +-- .../tests/ChemistryTests/QSharpTests.csproj | 2 +- .../tests/SystemTests/SystemTests.csproj | 2 +- MachineLearning.sln | 31 ++++++++++++++----- MachineLearning/src/MachineLearning.csproj | 2 +- .../tests/MachineLearningTests.csproj | 2 +- Numerics/src/Numerics.csproj | 4 +-- Numerics/tests/NumericsTests.csproj | 2 +- .../Emulation/AllowQubitAllocations.cs | 14 ++++----- .../src/Diagnostics/Emulation/Internal.cs | 2 +- Standard/src/Standard.csproj | 4 +-- Standard/tests/Standard.Tests.csproj | 2 +- Visualization/src/Visualization.csproj | 4 +-- 14 files changed, 47 insertions(+), 30 deletions(-) diff --git a/Build/props/tests.props b/Build/props/tests.props index 42d54c268c2..5cc3d169a4a 100644 --- a/Build/props/tests.props +++ b/Build/props/tests.props @@ -6,7 +6,7 @@ - + diff --git a/Chemistry/src/Runtime/Runtime.csproj b/Chemistry/src/Runtime/Runtime.csproj index efeb34ff5a0..af4bcb22167 100644 --- a/Chemistry/src/Runtime/Runtime.csproj +++ b/Chemistry/src/Runtime/Runtime.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -40,7 +40,7 @@ - + diff --git a/Chemistry/tests/ChemistryTests/QSharpTests.csproj b/Chemistry/tests/ChemistryTests/QSharpTests.csproj index fcbb8e7e1dd..93341456f6e 100644 --- a/Chemistry/tests/ChemistryTests/QSharpTests.csproj +++ b/Chemistry/tests/ChemistryTests/QSharpTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Chemistry/tests/SystemTests/SystemTests.csproj b/Chemistry/tests/SystemTests/SystemTests.csproj index f133cd8fabd..fb9aaedeaac 100644 --- a/Chemistry/tests/SystemTests/SystemTests.csproj +++ b/Chemistry/tests/SystemTests/SystemTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/MachineLearning.sln b/MachineLearning.sln index a083c3f402f..adf6e4fcc2c 100644 --- a/MachineLearning.sln +++ b/MachineLearning.sln @@ -1,13 +1,15 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26124.0 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 MinimumVisualStudioVersion = 15.0.26124.0 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MachineLearning", "MachineLearning", "{D067C787-94C3-4DB8-9012-1F22AE784BEF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MachineLearningTests", "MachineLearning\tests\MachineLearningTests.csproj", "{94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MachineLearningTests", "MachineLearning\tests\MachineLearningTests.csproj", "{94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MachineLearning", "MachineLearning\src\MachineLearning.csproj", "{B045BF35-6BE6-4982-9618-8725C70D3F91}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MachineLearning", "MachineLearning\src\MachineLearning.csproj", "{B045BF35-6BE6-4982-9618-8725C70D3F91}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Standard", "Standard\src\Standard.csproj", "{9907AAA7-10DA-470B-A154-5A19D1A831E6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -18,9 +20,6 @@ Global Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -46,9 +45,27 @@ Global {B045BF35-6BE6-4982-9618-8725C70D3F91}.Release|x64.Build.0 = Release|Any CPU {B045BF35-6BE6-4982-9618-8725C70D3F91}.Release|x86.ActiveCfg = Release|Any CPU {B045BF35-6BE6-4982-9618-8725C70D3F91}.Release|x86.Build.0 = Release|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x64.ActiveCfg = Debug|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x64.Build.0 = Debug|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x86.ActiveCfg = Debug|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Debug|x86.Build.0 = Debug|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|Any CPU.Build.0 = Release|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x64.ActiveCfg = Release|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x64.Build.0 = Release|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x86.ActiveCfg = Release|Any CPU + {9907AAA7-10DA-470B-A154-5A19D1A831E6}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {94EBDF5F-0A9D-4CE5-9D16-3FF323B8792C} = {D067C787-94C3-4DB8-9012-1F22AE784BEF} {B045BF35-6BE6-4982-9618-8725C70D3F91} = {D067C787-94C3-4DB8-9012-1F22AE784BEF} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {08B056E4-F7DA-4802-B23C-BB11D6616F5E} + EndGlobalSection EndGlobal diff --git a/MachineLearning/src/MachineLearning.csproj b/MachineLearning/src/MachineLearning.csproj index 999b34d9ca0..5017c5932ff 100644 --- a/MachineLearning/src/MachineLearning.csproj +++ b/MachineLearning/src/MachineLearning.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 Microsoft.Quantum.MachineLearning diff --git a/MachineLearning/tests/MachineLearningTests.csproj b/MachineLearning/tests/MachineLearningTests.csproj index fbbc152c906..871614428cc 100644 --- a/MachineLearning/tests/MachineLearningTests.csproj +++ b/MachineLearning/tests/MachineLearningTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Numerics/src/Numerics.csproj b/Numerics/src/Numerics.csproj index 561b715307d..ce9c826d092 100644 --- a/Numerics/src/Numerics.csproj +++ b/Numerics/src/Numerics.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -41,7 +41,7 @@ - + diff --git a/Numerics/tests/NumericsTests.csproj b/Numerics/tests/NumericsTests.csproj index 39deb1b2374..cca28980f6a 100644 --- a/Numerics/tests/NumericsTests.csproj +++ b/Numerics/tests/NumericsTests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Standard/src/Diagnostics/Emulation/AllowQubitAllocations.cs b/Standard/src/Diagnostics/Emulation/AllowQubitAllocations.cs index 65d007010b3..96420b9a0eb 100644 --- a/Standard/src/Diagnostics/Emulation/AllowQubitAllocations.cs +++ b/Standard/src/Diagnostics/Emulation/AllowQubitAllocations.cs @@ -51,17 +51,17 @@ public Native(IOperationFactory m) : base(m) ); } }, - setup: handler => Simulator.OnAllocateQubits += handler, - cleanup: handler => Simulator.OnAllocateQubits -= handler + setup: handler => Simulator.BeforeAllocateQubits += handler, + cleanup: handler => Simulator.BeforeAllocateQubits -= handler ), - new ActionDisposer>>( - register => + new ActionDisposer>( + nQubits => { - nQubitsAllocated -= register.Length; + nQubitsAllocated -= nQubits; }, - setup: handler => Simulator.OnReleaseQubits += handler, - cleanup: handler => Simulator.OnReleaseQubits -= handler + setup: handler => Simulator.AfterReleaseQubits += handler, + cleanup: handler => Simulator.AfterReleaseQubits -= handler ) )); diff --git a/Standard/src/Diagnostics/Emulation/Internal.cs b/Standard/src/Diagnostics/Emulation/Internal.cs index b8c8fef117b..1480f962e37 100644 --- a/Standard/src/Diagnostics/Emulation/Internal.cs +++ b/Standard/src/Diagnostics/Emulation/Internal.cs @@ -33,7 +33,7 @@ public override bool Callback(uint idx, double real, double img) public override bool Dump(IQArray? qubits = null) { - var count = qubits?.Length ?? Simulator.QubitManager!.GetAllocatedQubitsCount(); + var count = qubits?.Length ?? Simulator.QubitManager!.AllocatedQubitsCount; var nQubitsPerRegister = ((int)count / 2); Data = np.empty(new Shape(1 << ((int)count), 2)); var result = base.Dump(qubits); diff --git a/Standard/src/Standard.csproj b/Standard/src/Standard.csproj index 21410763c29..8407e189ef5 100644 --- a/Standard/src/Standard.csproj +++ b/Standard/src/Standard.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -37,7 +37,7 @@ - + diff --git a/Standard/tests/Standard.Tests.csproj b/Standard/tests/Standard.Tests.csproj index 76379e68e2c..0e9be961006 100644 --- a/Standard/tests/Standard.Tests.csproj +++ b/Standard/tests/Standard.Tests.csproj @@ -1,4 +1,4 @@ - + diff --git a/Visualization/src/Visualization.csproj b/Visualization/src/Visualization.csproj index 53f1fbfd2d9..f148ebf7929 100644 --- a/Visualization/src/Visualization.csproj +++ b/Visualization/src/Visualization.csproj @@ -32,9 +32,9 @@ - + - +