microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
katas/content/complex_arithmetic/cartesian_to_polar/Verification.qs
23lines · modecode
| 1 | namespace Kata.Verification { |
| 2 | import Std.Convert.*; |
| 3 | import Std.Math.*; |
| 4 | |
| 5 | @EntryPoint() |
| 6 | operation CheckSolution() : Bool { |
| 7 | for _ in 0..24 { |
| 8 | let x = DrawRandomComplex(); |
| 9 | |
| 10 | let expected = ComplexAsComplexPolar(x); |
| 11 | let actual = Kata.ComplexToComplexPolar(x); |
| 12 | |
| 13 | if not ComplexPolarEqual(expected, actual) { |
| 14 | Message("Incorrect"); |
| 15 | Message($"For x = {ComplexAsString(x)} expected return {ComplexPolarAsString(expected)}, actual return {ComplexPolarAsString(actual)}."); |
| 16 | return false; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | Message("Correct!"); |
| 21 | return true; |
| 22 | } |
| 23 | } |
| 24 | |