From e69c100b08797cbf50ce74590f902b137badd0a4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 18:19:34 +0000 Subject: [PATCH 1/3] Initial plan From a146d1f43756525b54b29a0c4d9aa9a61dc31c88 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 26 Apr 2026 18:33:24 +0000 Subject: [PATCH 2/3] Update library/src/tests to use Std.* instead of Microsoft.Quantum.* Agent-Logs-Url: https://github.com/microsoft/qdk/sessions/2b7ae341-d509-4e7f-a71a-6d0f952abeff Co-authored-by: fedimser <14271071+fedimser@users.noreply.github.com> --- library/src/tests/arithmetic.rs | 126 ++++----- library/src/tests/arrays.rs | 234 ++++++++--------- library/src/tests/canon.rs | 28 +- library/src/tests/convert.rs | 28 +- library/src/tests/core.rs | 2 +- library/src/tests/diagnostics.rs | 82 +++--- library/src/tests/logical.rs | 10 +- library/src/tests/math.rs | 344 ++++++++++++------------- library/src/tests/measurement.rs | 36 +-- library/src/tests/state_preparation.rs | 6 +- library/src/tests/table_lookup.rs | 2 +- 11 files changed, 449 insertions(+), 449 deletions(-) diff --git a/library/src/tests/arithmetic.rs b/library/src/tests/arithmetic.rs index e898d9dcd1..ab9cab0f22 100644 --- a/library/src/tests/arithmetic.rs +++ b/library/src/tests/arithmetic.rs @@ -4,14 +4,14 @@ use super::{test_expression, test_expression_with_lib}; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.Unstable.Arithmetic namespace +// Tests for Std.Arithmetic namespace #[test] fn check_maj() { test_expression( { "{ - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use q = Qubit[3]; mutable r = []; for i in 0..7 { @@ -44,7 +44,7 @@ fn check_reflect_about_integer() { test_expression( { "{ - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; import Std.Diagnostics.*; operation ManuallyReflectAboutFive(register : Qubit[]) : Unit is Adj + Ctl { within { @@ -75,7 +75,7 @@ const INC_BY_LE_TEST_LIB: &str = include_str!("resources/src/inc_by_le.qs"); fn check_inc_by_le_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestIncByLE(\"Check IncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.IncByLE, 1)", + Std.Arithmetic.IncByLE, 1)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -85,7 +85,7 @@ fn check_inc_by_le_exhaustive_bitwidth_1() { fn check_inc_by_le_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestIncByLE(\"Check IncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.IncByLE, 2)", + Std.Arithmetic.IncByLE, 2)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -95,7 +95,7 @@ fn check_inc_by_le_exhaustive_bitwidth_2() { fn check_inc_by_le_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestIncByLE(\"Check IncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.IncByLE, 3)", + Std.Arithmetic.IncByLE, 3)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -106,7 +106,7 @@ fn check_inc_by_le_general() { test_expression( { "{ // General cases for IncByLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use x1 = Qubit[10]; use y1 = Qubit[10]; ApplyXorInPlace(279, x1); @@ -130,7 +130,7 @@ fn check_inc_by_le_general() { fn check_ripple_carry_ttk_inc_by_le_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryTTKIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryTTKIncByLE, 1)", + Std.Arithmetic.RippleCarryTTKIncByLE, 1)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -140,7 +140,7 @@ fn check_ripple_carry_ttk_inc_by_le_exhaustive_bitwidth_1() { fn check_ripple_carry_ttk_inc_by_le_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryTTKIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryTTKIncByLE, 2)", + Std.Arithmetic.RippleCarryTTKIncByLE, 2)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -150,7 +150,7 @@ fn check_ripple_carry_ttk_inc_by_le_exhaustive_bitwidth_2() { fn check_ripple_carry_ttk_inc_by_le_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryTTKIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryTTKIncByLE, 3)", + Std.Arithmetic.RippleCarryTTKIncByLE, 3)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -160,7 +160,7 @@ fn check_ripple_carry_ttk_inc_by_le_exhaustive_bitwidth_3() { fn check_ripple_carry_ttk_inc_by_le_exhaustive_bitwidth_4() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryTTKIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryTTKIncByLE, 4)", + Std.Arithmetic.RippleCarryTTKIncByLE, 4)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -171,7 +171,7 @@ fn check_ripple_carry_ttk_inc_by_le_general() { test_expression( { "{ // General cases for RippleCarryTTKIncByLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use x1 = Qubit[10]; use y1 = Qubit[10]; @@ -195,7 +195,7 @@ fn check_ripple_carry_ttk_inc_by_le_general() { fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryCGIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 1)", + Std.Arithmetic.RippleCarryCGIncByLE, 1)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -205,7 +205,7 @@ fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_1() { fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryCGIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 2)", + Std.Arithmetic.RippleCarryCGIncByLE, 2)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -215,7 +215,7 @@ fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_2() { fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryCGIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 3)", + Std.Arithmetic.RippleCarryCGIncByLE, 3)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -225,7 +225,7 @@ fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_3() { fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_4() { test_expression_with_lib( "Test.TestIncByLE(\"Check RippleCarryCGIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 4)", + Std.Arithmetic.RippleCarryCGIncByLE, 4)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -235,7 +235,7 @@ fn check_ripple_carry_cg_inc_by_le_exhaustive_bitwidth_4() { fn check_ripple_carry_inc_by_le_ctl_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestIncByLECtl(\"Check RippleCarryCGIncByLE(Ctl)\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 1)", + Std.Arithmetic.RippleCarryCGIncByLE, 1)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -245,7 +245,7 @@ fn check_ripple_carry_inc_by_le_ctl_exhaustive_bitwidth_1() { fn check_ripple_carry_inc_by_le_ctl_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestIncByLECtl(\"Check RippleCarryCGIncByLE(Ctl)\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 2)", + Std.Arithmetic.RippleCarryCGIncByLE, 2)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -255,7 +255,7 @@ fn check_ripple_carry_inc_by_le_ctl_exhaustive_bitwidth_2() { fn check_ripple_carry_inc_by_le_ctl_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestIncByLECtl(\"Check RippleCarryCGIncByLE(Ctl)\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 3)", + Std.Arithmetic.RippleCarryCGIncByLE, 3)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -265,7 +265,7 @@ fn check_ripple_carry_inc_by_le_ctl_exhaustive_bitwidth_3() { fn check_ripple_carry_inc_by_le_ctl_exhaustive_bitwidth_4() { test_expression_with_lib( "Test.TestIncByLECtl(\"Check RippleCarryCGIncByLE(Ctl)\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGIncByLE, 4)", + Std.Arithmetic.RippleCarryCGIncByLE, 4)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -276,7 +276,7 @@ fn check_ripple_carry_cg_inc_by_le_general() { test_expression( { "{ // General cases for RippleCarryCGIncByLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use x1 = Qubit[10]; use y1 = Qubit[10]; @@ -301,7 +301,7 @@ fn check_ripple_carry_cg_inc_by_le_general() { fn check_fourier_td_inc_by_le_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestIncByLE(\"Check FourierTDIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.FourierTDIncByLE, 1)", + Std.Arithmetic.FourierTDIncByLE, 1)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -311,7 +311,7 @@ fn check_fourier_td_inc_by_le_exhaustive_bitwidth_1() { fn check_fourier_td_inc_by_le_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestIncByLE(\"Check FourierTDIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.FourierTDIncByLE, 2)", + Std.Arithmetic.FourierTDIncByLE, 2)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -321,7 +321,7 @@ fn check_fourier_td_inc_by_le_exhaustive_bitwidth_2() { fn check_fourier_td_inc_by_le_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestIncByLE(\"Check FourierTDIncByLE\", - Microsoft.Quantum.Unstable.Arithmetic.FourierTDIncByLE, 3)", + Std.Arithmetic.FourierTDIncByLE, 3)", INC_BY_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -334,7 +334,7 @@ fn check_fourier_td_inc_by_le_exhaustive_bitwidth_3() { #[test] fn check_inc_by_le_using_add_le_exhaustive_bitwidth_1() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLE2(\"Check IncByLEUsingAddLE\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 1, 1)}", @@ -346,7 +346,7 @@ fn check_inc_by_le_using_add_le_exhaustive_bitwidth_1() { #[test] fn check_inc_by_le_using_add_le_exhaustive_bitwidth_2() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLE2(\"Check IncByLEUsingAddLE\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 2, 2)}", @@ -358,7 +358,7 @@ fn check_inc_by_le_using_add_le_exhaustive_bitwidth_2() { #[test] fn check_inc_by_le_using_add_le_exhaustive_bitwidth_3() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLE2(\"Check IncByLEUsingAddLE\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 3, 3)}", @@ -370,7 +370,7 @@ fn check_inc_by_le_using_add_le_exhaustive_bitwidth_3() { #[test] fn check_inc_by_le_using_add_le_exhaustive_bitwidth_4() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLE2(\"Check IncByLEUsingAddLE\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 4, 4)}", @@ -382,7 +382,7 @@ fn check_inc_by_le_using_add_le_exhaustive_bitwidth_4() { #[test] fn check_inc_by_le_using_add_le_ctl_exhaustive_bitwidth_1() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLECtl2(\"Check IncByLEUsingAddLE(Ctl)\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 1, 1)}", @@ -394,7 +394,7 @@ fn check_inc_by_le_using_add_le_ctl_exhaustive_bitwidth_1() { #[test] fn check_inc_by_le_using_add_le_ctl_exhaustive_bitwidth_2() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLECtl2(\"Check IncByLEUsingAddLE(Ctl)\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 2, 2)}", @@ -406,7 +406,7 @@ fn check_inc_by_le_using_add_le_ctl_exhaustive_bitwidth_2() { #[test] fn check_inc_by_le_using_add_le_ctl_exhaustive_bitwidth_3() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLECtl2(\"Check IncByLEUsingAddLE(Ctl)\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 3, 3)}", @@ -418,7 +418,7 @@ fn check_inc_by_le_using_add_le_ctl_exhaustive_bitwidth_3() { #[test] fn check_inc_by_le_using_add_le_ctl_exhaustive_bitwidth_4() { test_expression_with_lib( - "{import Microsoft.Quantum.Unstable.Arithmetic.*; + "{import Std.Arithmetic.*; Test.TestIncByLECtl2(\"Check IncByLEUsingAddLE(Ctl)\", IncByLEUsingAddLE(LookAheadDKRSAddLE,RippleCarryCGAddLE,_,_), 4, 4)}", @@ -432,7 +432,7 @@ fn check_inc_by_le_using_add_le_general() { test_expression( { "{ // General cases for IncByLEUsingAddLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use x1 = Qubit[10]; use y1 = Qubit[10]; @@ -458,7 +458,7 @@ fn check_inc_by_i_general() { test_expression( { "{ // General cases for IncByI - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use y0 = Qubit[1]; IncByI(0,y0); // 0 += 0 @@ -514,7 +514,7 @@ fn check_ripple_carry_cg_inc_by_i_general() { test_expression( { "{ // General cases for IncByIUsingIncByLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use y0 = Qubit[10]; ApplyXorInPlace(172, y0); @@ -553,7 +553,7 @@ fn check_inc_by_l_general() { test_expression( { "{ // General cases for IncByL - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use y0 = Qubit[1]; IncByL(0L,y0); // 0 += 0 @@ -609,7 +609,7 @@ fn check_ripple_carry_cg_inc_by_l_general() { test_expression( { "{ // Branching cases for IncByLUsingIncByLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use y0 = Qubit[10]; ApplyXorInPlace(172, y0); @@ -649,7 +649,7 @@ const ADD_LE_TEST_LIB: &str = include_str!("resources/src/add_le.qs"); fn check_add_le_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestAddLE(\"Check AddLE\", - Microsoft.Quantum.Unstable.Arithmetic.AddLE, 1)", + Std.Arithmetic.AddLE, 1)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -659,7 +659,7 @@ fn check_add_le_exhaustive_bitwidth_1() { fn check_add_le_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestAddLE(\"Check AddLE\", - Microsoft.Quantum.Unstable.Arithmetic.AddLE, 2)", + Std.Arithmetic.AddLE, 2)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -669,7 +669,7 @@ fn check_add_le_exhaustive_bitwidth_2() { fn check_add_le_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestAddLE(\"Check AddLE\", - Microsoft.Quantum.Unstable.Arithmetic.AddLE, 3)", + Std.Arithmetic.AddLE, 3)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -679,7 +679,7 @@ fn check_add_le_exhaustive_bitwidth_3() { fn check_add_le_exhaustive_bitwidth_4() { test_expression_with_lib( "Test.TestAddLE(\"Check AddLE\", - Microsoft.Quantum.Unstable.Arithmetic.AddLE, 4)", + Std.Arithmetic.AddLE, 4)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -690,7 +690,7 @@ fn check_add_le_general() { test_expression( { "{ // General cases for AddLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use x1 = Qubit[10]; use y1 = Qubit[10]; @@ -718,7 +718,7 @@ fn check_add_le_general() { fn check_ripple_carry_cg_add_le_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestAddLE(\"Check RippleCarryCGAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGAddLE, 1)", + Std.Arithmetic.RippleCarryCGAddLE, 1)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -728,7 +728,7 @@ fn check_ripple_carry_cg_add_le_exhaustive_bitwidth_1() { fn check_ripple_carry_cg_add_le_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestAddLE(\"Check RippleCarryCGAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGAddLE, 2)", + Std.Arithmetic.RippleCarryCGAddLE, 2)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -738,7 +738,7 @@ fn check_ripple_carry_cg_add_le_exhaustive_bitwidth_2() { fn check_ripple_carry_cg_add_le_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestAddLE(\"Check RippleCarryCGAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGAddLE, 3)", + Std.Arithmetic.RippleCarryCGAddLE, 3)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -748,7 +748,7 @@ fn check_ripple_carry_cg_add_le_exhaustive_bitwidth_3() { fn check_ripple_carry_cg_add_le_exhaustive_bitwidth_4() { test_expression_with_lib( "Test.TestAddLE(\"Check RippleCarryCGAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.RippleCarryCGAddLE, 4)", + Std.Arithmetic.RippleCarryCGAddLE, 4)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -759,7 +759,7 @@ fn check_ripple_carry_cg_add_le_general() { test_expression( { "{ // General cases for RippleCarryAddLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use x1 = Qubit[10]; use y1 = Qubit[10]; @@ -785,7 +785,7 @@ fn check_ripple_carry_cg_add_le_general() { fn check_lookahead_dkrs_add_le_exhaustive_bitwidth_1() { test_expression_with_lib( "Test.TestAddLE(\"Check LookAheadDKRSAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.LookAheadDKRSAddLE, 1)", + Std.Arithmetic.LookAheadDKRSAddLE, 1)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -795,7 +795,7 @@ fn check_lookahead_dkrs_add_le_exhaustive_bitwidth_1() { fn check_lookahead_dkrs_add_le_exhaustive_bitwidth_2() { test_expression_with_lib( "Test.TestAddLE(\"Check LookAheadDKRSAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.LookAheadDKRSAddLE, 2)", + Std.Arithmetic.LookAheadDKRSAddLE, 2)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -805,7 +805,7 @@ fn check_lookahead_dkrs_add_le_exhaustive_bitwidth_2() { fn check_lookahead_dkrs_add_le_exhaustive_bitwidth_3() { test_expression_with_lib( "Test.TestAddLE(\"Check LookAheadDKRSAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.LookAheadDKRSAddLE, 3)", + Std.Arithmetic.LookAheadDKRSAddLE, 3)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -815,7 +815,7 @@ fn check_lookahead_dkrs_add_le_exhaustive_bitwidth_3() { fn check_lookahead_dkrs_add_le_exhaustive_bitwidth_4() { test_expression_with_lib( "Test.TestAddLE(\"Check LookAheadDKRSAddLE\", - Microsoft.Quantum.Unstable.Arithmetic.LookAheadDKRSAddLE, 4)", + Std.Arithmetic.LookAheadDKRSAddLE, 4)", ADD_LE_TEST_LIB, &Value::Tuple(vec![].into(), None), ); @@ -826,7 +826,7 @@ fn check_lookahead_dkrs_add_le_general() { test_expression( { "{ // General cases for LookAheadDKRSAddLE - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use x1 = Qubit[10]; use y1 = Qubit[10]; @@ -850,7 +850,7 @@ const COMPARE_TEST_LIB: &str = include_str!("resources/src/compare.qs"); fn check_apply_if_less_l_exhaustive() { test_expression_with_lib( "Test.CompareWithBigInt(\"Check ApplyIfLessL\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfLessL(X,_,_,_), + Std.Arithmetic.ApplyIfLessL(X,_,_,_), (a, b) -> {a < b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -861,7 +861,7 @@ fn check_apply_if_less_l_exhaustive() { fn check_apply_if_less_or_equal_l_exhaustive() { test_expression_with_lib( "Test.CompareWithBigInt(\"Check ApplyIfLessOrEqualL\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfLessOrEqualL(X,_,_,_), + Std.Arithmetic.ApplyIfLessOrEqualL(X,_,_,_), (a, b) -> {a <= b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -872,7 +872,7 @@ fn check_apply_if_less_or_equal_l_exhaustive() { fn check_apply_if_equal_l_exhaustive() { test_expression_with_lib( "Test.CompareWithBigInt(\"Check ApplyIfEqualL\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfEqualL(X,_,_,_), + Std.Arithmetic.ApplyIfEqualL(X,_,_,_), (a, b) -> {a == b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -883,7 +883,7 @@ fn check_apply_if_equal_l_exhaustive() { fn check_apply_if_greater_or_equal_l_exhaustive() { test_expression_with_lib( "Test.CompareWithBigInt(\"Check ApplyIfGreaterOrEqualL\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfGreaterOrEqualL(X,_,_,_), + Std.Arithmetic.ApplyIfGreaterOrEqualL(X,_,_,_), (a, b) -> {a >= b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -894,7 +894,7 @@ fn check_apply_if_greater_or_equal_l_exhaustive() { fn check_apply_if_greater_l_exhaustive() { test_expression_with_lib( "Test.CompareWithBigInt(\"Check ApplyIfGreaterL\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfGreaterL(X,_,_,_), + Std.Arithmetic.ApplyIfGreaterL(X,_,_,_), (a, b) -> {a > b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -905,7 +905,7 @@ fn check_apply_if_greater_l_exhaustive() { fn check_apply_if_less_le_exhaustive() { test_expression_with_lib( "Test.CompareWithLE(\"Check ApplyIfLessLE\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfLessLE(X,_,_,_), + Std.Arithmetic.ApplyIfLessLE(X,_,_,_), (a, b) -> {a < b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -916,7 +916,7 @@ fn check_apply_if_less_le_exhaustive() { fn check_apply_if_less_or_equal_le_exhaustive() { test_expression_with_lib( "Test.CompareWithLE(\"Check ApplyIfLessOrEqualLE\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfLessOrEqualLE(X,_,_,_), + Std.Arithmetic.ApplyIfLessOrEqualLE(X,_,_,_), (a, b) -> {a <= b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -927,7 +927,7 @@ fn check_apply_if_less_or_equal_le_exhaustive() { fn check_apply_if_equal_le_exhaustive() { test_expression_with_lib( "Test.CompareWithLE(\"Check ApplyIfEqualLE\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfEqualLE(X,_,_,_), + Std.Arithmetic.ApplyIfEqualLE(X,_,_,_), (a, b) -> {a == b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -938,7 +938,7 @@ fn check_apply_if_equal_le_exhaustive() { fn check_apply_if_greater_or_equal_le_exhaustive() { test_expression_with_lib( "Test.CompareWithLE(\"Check ApplyIfGreaterOrEqualLE\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfGreaterOrEqualLE(X,_,_,_), + Std.Arithmetic.ApplyIfGreaterOrEqualLE(X,_,_,_), (a, b) -> {a >= b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -949,7 +949,7 @@ fn check_apply_if_greater_or_equal_le_exhaustive() { fn check_apply_if_greater_le_exhaustive() { test_expression_with_lib( "Test.CompareWithLE(\"Check ApplyIfGreaterLE\", 3, - Microsoft.Quantum.Unstable.Arithmetic.ApplyIfGreaterLE(X,_,_,_), + Std.Arithmetic.ApplyIfGreaterLE(X,_,_,_), (a, b) -> {a > b} )", COMPARE_TEST_LIB, &Value::Tuple(vec![].into(), None), @@ -960,7 +960,7 @@ fn check_apply_if_greater_le_exhaustive() { fn check_apply_if_less_l_non_x_action() { test_expression( "{ - import Microsoft.Quantum.Unstable.Arithmetic.*; + import Std.Arithmetic.*; use input = Qubit[10]; use output1 = Qubit[10]; use output2 = Qubit[10]; diff --git a/library/src/tests/arrays.rs b/library/src/tests/arrays.rs index 7b063b7962..80e7d98fe1 100644 --- a/library/src/tests/arrays.rs +++ b/library/src/tests/arrays.rs @@ -5,24 +5,24 @@ use super::test_expression; use num_bigint::BigInt; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.Arrays namespace +// Tests for Std.Arrays namespace #[test] fn check_all() { test_expression( - "Microsoft.Quantum.Arrays.All(x -> x != 0, [1, 2, 3, 4, 5])", + "Std.Arrays.All(x -> x != 0, [1, 2, 3, 4, 5])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.All(x -> x != 0, [1, 2, 0, 4, 5])", + "Std.Arrays.All(x -> x != 0, [1, 2, 0, 4, 5])", &Value::Bool(false), ); test_expression( - "Microsoft.Quantum.Arrays.All(x -> x == One, [One, One, One])", + "Std.Arrays.All(x -> x == One, [One, One, One])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.All(x -> x == One, [One, One, Zero])", + "Std.Arrays.All(x -> x == One, [One, One, Zero])", &Value::Bool(false), ); } @@ -30,11 +30,11 @@ fn check_all() { #[test] fn check_any() { test_expression( - "Microsoft.Quantum.Arrays.Any(x -> x % 2 == 0, [1, 3, 6, 7, 9])", + "Std.Arrays.Any(x -> x % 2 == 0, [1, 3, 6, 7, 9])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.Any(x -> x % 2 == 0, [1, 3, 5, 7, 9])", + "Std.Arrays.Any(x -> x % 2 == 0, [1, 3, 5, 7, 9])", &Value::Bool(false), ); } @@ -42,7 +42,7 @@ fn check_any() { #[test] fn check_chunks() { test_expression( - "Microsoft.Quantum.Arrays.Chunks(1, [10, 11, 12, 13, 14, 15])", + "Std.Arrays.Chunks(1, [10, 11, 12, 13, 14, 15])", &Value::Array( vec![ Value::Array(vec![Value::Int(10)].into()), @@ -58,16 +58,16 @@ fn check_chunks() { test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.Chunks(2, empty) + Std.Arrays.Chunks(2, empty) }", &Value::Array(vec![].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Chunks(2, [10])", + "Std.Arrays.Chunks(2, [10])", &Value::Array(vec![Value::Array(vec![Value::Int(10)].into())].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Chunks(2, [10, 11, 12, 13, 14, 15])", + "Std.Arrays.Chunks(2, [10, 11, 12, 13, 14, 15])", &Value::Array( vec![ Value::Array(vec![Value::Int(10), Value::Int(11)].into()), @@ -78,7 +78,7 @@ fn check_chunks() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Chunks(3, [10, 11, 12, 13, 14, 15])", + "Std.Arrays.Chunks(3, [10, 11, 12, 13, 14, 15])", &Value::Array( vec![ Value::Array(vec![Value::Int(10), Value::Int(11), Value::Int(12)].into()), @@ -88,7 +88,7 @@ fn check_chunks() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Chunks(4, [10, 11, 12, 13, 14, 15])", + "Std.Arrays.Chunks(4, [10, 11, 12, 13, 14, 15])", &Value::Array( vec![ Value::Array( @@ -110,23 +110,23 @@ fn check_chunks() { #[test] fn check_circularly_shifted() { test_expression( - "Microsoft.Quantum.Arrays.CircularlyShifted(0, [10, 11, 12])", + "Std.Arrays.CircularlyShifted(0, [10, 11, 12])", &Value::Array(vec![Value::Int(10), Value::Int(11), Value::Int(12)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.CircularlyShifted(1, [10, 11, 12])", + "Std.Arrays.CircularlyShifted(1, [10, 11, 12])", &Value::Array(vec![Value::Int(12), Value::Int(10), Value::Int(11)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.CircularlyShifted(-1, [10, 11, 12])", + "Std.Arrays.CircularlyShifted(-1, [10, 11, 12])", &Value::Array(vec![Value::Int(11), Value::Int(12), Value::Int(10)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.CircularlyShifted(500, [10, 11, 12])", + "Std.Arrays.CircularlyShifted(500, [10, 11, 12])", &Value::Array(vec![Value::Int(11), Value::Int(12), Value::Int(10)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.CircularlyShifted(-500, [10, 11, 12])", + "Std.Arrays.CircularlyShifted(-500, [10, 11, 12])", &Value::Array(vec![Value::Int(12), Value::Int(10), Value::Int(11)].into()), ); } @@ -134,15 +134,15 @@ fn check_circularly_shifted() { #[test] fn check_column_at() { test_expression( - "Microsoft.Quantum.Arrays.ColumnAt(0, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])", + "Std.Arrays.ColumnAt(0, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])", &Value::Array(vec![Value::Int(1), Value::Int(4), Value::Int(7)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.ColumnAt(2, [[true, true, true], [false, false, false]])", + "Std.Arrays.ColumnAt(2, [[true, true, true], [false, false, false]])", &Value::Array(vec![Value::Bool(true), Value::Bool(false)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.ColumnAt(1, [[One, One], [Zero, Zero], [Zero, One]])", + "Std.Arrays.ColumnAt(1, [[One, One], [Zero, Zero], [Zero, One]])", &Value::Array(vec![Value::RESULT_ONE, Value::RESULT_ZERO, Value::RESULT_ONE].into()), ); } @@ -150,11 +150,11 @@ fn check_column_at() { #[test] fn check_count() { test_expression( - "Microsoft.Quantum.Arrays.Count(x -> x % 2 != 0, [1, 3, 6, 7, 9])", + "Std.Arrays.Count(x -> x % 2 != 0, [1, 3, 6, 7, 9])", &Value::Int(4), ); test_expression( - "Microsoft.Quantum.Arrays.Count(x -> x % 2 == 0, [1, 3, 6, 7, 9])", + "Std.Arrays.Count(x -> x % 2 == 0, [1, 3, 6, 7, 9])", &Value::Int(1), ); } @@ -164,24 +164,24 @@ fn check_diagnonal() { test_expression( "{ let empty: Int[][] = []; - Microsoft.Quantum.Arrays.Diagonal(empty) + Std.Arrays.Diagonal(empty) }", &Value::Array(vec![].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Diagonal([[1]])", + "Std.Arrays.Diagonal([[1]])", &Value::Array(vec![Value::Int(1)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Diagonal([[1, 2, 3], [4, 5, 6], [7, 8, 9]])", + "Std.Arrays.Diagonal([[1, 2, 3], [4, 5, 6], [7, 8, 9]])", &Value::Array(vec![Value::Int(1), Value::Int(5), Value::Int(9)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Diagonal([[1, 2, 3], [4, 5, 6]])", + "Std.Arrays.Diagonal([[1, 2, 3], [4, 5, 6]])", &Value::Array(vec![Value::Int(1), Value::Int(5)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Diagonal([[1, 2], [3, 4], [5, 6]])", + "Std.Arrays.Diagonal([[1, 2], [3, 4], [5, 6]])", &Value::Array(vec![Value::Int(1), Value::Int(4)].into()), ); } @@ -191,7 +191,7 @@ fn check_draw_many() { test_expression( "{ use qubit = Qubit(); - let results = Microsoft.Quantum.Arrays.DrawMany(q => {X(q); M(q)}, 3, qubit); + let results = Std.Arrays.DrawMany(q => {X(q); M(q)}, 3, qubit); Reset(qubit); results }", @@ -204,12 +204,12 @@ fn check_excluding() { test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.Excluding(empty, empty) + Std.Arrays.Excluding(empty, empty) }", &Value::Array(vec![].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Excluding([], [10, 11, 12, 13, 14, 15])", + "Std.Arrays.Excluding([], [10, 11, 12, 13, 14, 15])", &Value::Array( vec![ Value::Int(10), @@ -223,11 +223,11 @@ fn check_excluding() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Excluding([1, 3, 4], [10, 11, 12, 13, 14, 15])", + "Std.Arrays.Excluding([1, 3, 4], [10, 11, 12, 13, 14, 15])", &Value::Array(vec![Value::Int(10), Value::Int(12), Value::Int(15)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Excluding([3, 1, 4, 1], [10, 11, 12, 13, 14, 15])", + "Std.Arrays.Excluding([3, 1, 4, 1], [10, 11, 12, 13, 14, 15])", &Value::Array(vec![Value::Int(10), Value::Int(12), Value::Int(15)].into()), ); } @@ -235,7 +235,7 @@ fn check_excluding() { #[test] fn check_enumerated() { test_expression( - "Microsoft.Quantum.Arrays.Enumerated([false, true, false])", + "Std.Arrays.Enumerated([false, true, false])", &Value::Array( vec![ Value::Tuple(vec![Value::Int(0), Value::Bool(false)].into(), None), @@ -250,11 +250,11 @@ fn check_enumerated() { #[test] fn check_filtered() { test_expression( - "Microsoft.Quantum.Arrays.Filtered(x -> x % 2 == 0, [0, 1, 2, 3, 4])", + "Std.Arrays.Filtered(x -> x % 2 == 0, [0, 1, 2, 3, 4])", &Value::Array(vec![Value::Int(0), Value::Int(2), Value::Int(4)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Filtered(x -> x % 2 != 0, [1, 2, 3, 4, 5])", + "Std.Arrays.Filtered(x -> x % 2 != 0, [1, 2, 3, 4, 5])", &Value::Array(vec![Value::Int(1), Value::Int(3), Value::Int(5)].into()), ); } @@ -262,7 +262,7 @@ fn check_filtered() { #[test] fn check_flat_mapped() { test_expression( - "Microsoft.Quantum.Arrays.FlatMapped(x -> Repeated(x, 2), [1, 2, 3])", + "Std.Arrays.FlatMapped(x -> Repeated(x, 2), [1, 2, 3])", &Value::Array( vec![ Value::Int(1), @@ -280,7 +280,7 @@ fn check_flat_mapped() { #[test] fn check_flattened() { test_expression( - "Microsoft.Quantum.Arrays.Flattened([[1, 2], [3], [4, 5, 6]])", + "Std.Arrays.Flattened([[1, 2], [3], [4, 5, 6]])", &Value::Array( vec![ Value::Int(1), @@ -298,15 +298,15 @@ fn check_flattened() { #[test] fn check_fold() { test_expression( - "Microsoft.Quantum.Arrays.Fold((x, y) -> x + y, 0, [1, 2, 3, 4, 5])", + "Std.Arrays.Fold((x, y) -> x + y, 0, [1, 2, 3, 4, 5])", &Value::Int(15), ); test_expression( - "Microsoft.Quantum.Arrays.Fold((x, y) -> x or y, false, [true, false, true])", + "Std.Arrays.Fold((x, y) -> x or y, false, [true, false, true])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.Fold((x, y) -> x and y, true, [true, false, true])", + "Std.Arrays.Fold((x, y) -> x and y, true, [true, false, true])", &Value::Bool(false), ); } @@ -316,8 +316,8 @@ fn check_for_each() { test_expression( "{ use register = Qubit[3]; - Microsoft.Quantum.Arrays.ForEach - (q => {X(q); Microsoft.Quantum.Measurement.MResetZ(q)}, + Std.Arrays.ForEach + (q => {X(q); Std.Measurement.MResetZ(q)}, register) }", &Value::Array(vec![Value::RESULT_ONE, Value::RESULT_ONE, Value::RESULT_ONE].into()), @@ -326,13 +326,13 @@ fn check_for_each() { #[test] fn check_head() { - test_expression("Microsoft.Quantum.Arrays.Head([5,6,7,8])", &Value::Int(5)); + test_expression("Std.Arrays.Head([5,6,7,8])", &Value::Int(5)); } #[test] fn check_head_and_rest() { test_expression( - "Microsoft.Quantum.Arrays.HeadAndRest([5,6,7,8])", + "Std.Arrays.HeadAndRest([5,6,7,8])", &Value::Tuple( vec![ Value::Int(5), @@ -347,15 +347,15 @@ fn check_head_and_rest() { #[test] fn check_index_of() { test_expression( - "Microsoft.Quantum.Arrays.IndexOf(x -> x % 2 != 0, [10, 8, 6, 5, 4])", + "Std.Arrays.IndexOf(x -> x % 2 != 0, [10, 8, 6, 5, 4])", &Value::Int(3), ); test_expression( - "Microsoft.Quantum.Arrays.IndexOf(x -> x % 2 == 0, [1, 3, 4, 5, 7])", + "Std.Arrays.IndexOf(x -> x % 2 == 0, [1, 3, 4, 5, 7])", &Value::Int(2), ); test_expression( - "Microsoft.Quantum.Arrays.IndexOf(x -> x % 2 == 0, [1, 3, 5, 7, 9])", + "Std.Arrays.IndexOf(x -> x % 2 == 0, [1, 3, 5, 7, 9])", &Value::Int(-1), ); } @@ -363,15 +363,15 @@ fn check_index_of() { #[test] fn check_index_range() { test_expression( - "Microsoft.Quantum.Arrays.IndexRange([7,6,5,4])::Start", + "Std.Arrays.IndexRange([7,6,5,4])::Start", &Value::Int(0), ); test_expression( - "Microsoft.Quantum.Arrays.IndexRange([7,6,5,4])::Step", + "Std.Arrays.IndexRange([7,6,5,4])::Step", &Value::Int(1), ); test_expression( - "Microsoft.Quantum.Arrays.IndexRange([7,6,5,4])::End", + "Std.Arrays.IndexRange([7,6,5,4])::End", &Value::Int(3), ); } @@ -379,7 +379,7 @@ fn check_index_range() { #[test] fn check_interleaved() { test_expression( - "Microsoft.Quantum.Arrays.Interleaved([1, 2, 3], [-1, -2, -3])", + "Std.Arrays.Interleaved([1, 2, 3], [-1, -2, -3])", &Value::Array( vec![ Value::Int(1), @@ -393,7 +393,7 @@ fn check_interleaved() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Interleaved([true, true], [false])", + "Std.Arrays.Interleaved([true, true], [false])", &Value::Array(vec![Value::Bool(true), Value::Bool(false), Value::Bool(true)].into()), ); } @@ -403,13 +403,13 @@ fn check_is_empty() { test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.IsEmpty(empty) + Std.Arrays.IsEmpty(empty) }", &Value::Bool(true), ); - test_expression("Microsoft.Quantum.Arrays.IsEmpty([1])", &Value::Bool(false)); + test_expression("Std.Arrays.IsEmpty([1])", &Value::Bool(false)); test_expression( - "Microsoft.Quantum.Arrays.IsEmpty([1, 2, 3, 4, 5])", + "Std.Arrays.IsEmpty([1, 2, 3, 4, 5])", &Value::Bool(false), ); } @@ -419,24 +419,24 @@ fn check_is_rectangular_array() { test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.IsRectangularArray([empty]) + Std.Arrays.IsRectangularArray([empty]) }", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsRectangularArray([[1]])", + "Std.Arrays.IsRectangularArray([[1]])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsRectangularArray([[1, 2], [3, 4]])", + "Std.Arrays.IsRectangularArray([[1, 2], [3, 4]])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsRectangularArray([[1, 2, 3], [4, 5, 6]])", + "Std.Arrays.IsRectangularArray([[1, 2, 3], [4, 5, 6]])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsRectangularArray([[1, 2], [3, 4, 5]])", + "Std.Arrays.IsRectangularArray([[1, 2], [3, 4, 5]])", &Value::Bool(false), ); } @@ -446,28 +446,28 @@ fn check_is_sorted() { test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.IsSorted((x, y) -> x <= y, empty) + Std.Arrays.IsSorted((x, y) -> x <= y, empty) }", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsSorted((x, y) -> x <= y, [1])", + "Std.Arrays.IsSorted((x, y) -> x <= y, [1])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsSorted((x, y) -> x <= y, [1, 2, 3, 4, 5])", + "Std.Arrays.IsSorted((x, y) -> x <= y, [1, 2, 3, 4, 5])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsSorted((x, y) -> x >= y, [5, 4, 3, 2, 1])", + "Std.Arrays.IsSorted((x, y) -> x >= y, [5, 4, 3, 2, 1])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsSorted((x, y) -> x <= y, [1, 2, 3, 5, 4])", + "Std.Arrays.IsSorted((x, y) -> x <= y, [1, 2, 3, 5, 4])", &Value::Bool(false), ); test_expression( - "Microsoft.Quantum.Arrays.IsSorted((x, y) -> x <= y, [5, 4, 3, 2, 1])", + "Std.Arrays.IsSorted((x, y) -> x <= y, [5, 4, 3, 2, 1])", &Value::Bool(false), ); } @@ -477,24 +477,24 @@ fn check_is_square_array() { test_expression( "{ let empty: Int[][] = []; - Microsoft.Quantum.Arrays.IsSquareArray(empty) + Std.Arrays.IsSquareArray(empty) }", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsSquareArray([[1]])", + "Std.Arrays.IsSquareArray([[1]])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsSquareArray([[1, 2], [3, 4]])", + "Std.Arrays.IsSquareArray([[1, 2], [3, 4]])", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Arrays.IsSquareArray([[1, 2, 3], [4, 5, 6]])", + "Std.Arrays.IsSquareArray([[1, 2, 3], [4, 5, 6]])", &Value::Bool(false), ); test_expression( - "Microsoft.Quantum.Arrays.IsSquareArray([[1, 2], [3, 4], [5, 6]])", + "Std.Arrays.IsSquareArray([[1, 2], [3, 4], [5, 6]])", &Value::Bool(false), ); } @@ -502,7 +502,7 @@ fn check_is_square_array() { #[test] fn check_mapped() { test_expression( - "Microsoft.Quantum.Arrays.Mapped(i -> i * 2, [0, 1, 2])", + "Std.Arrays.Mapped(i -> i * 2, [0, 1, 2])", &Value::Array(vec![Value::Int(0), Value::Int(2), Value::Int(4)].into()), ); } @@ -510,7 +510,7 @@ fn check_mapped() { #[test] fn check_mapped_by_index() { test_expression( - "Microsoft.Quantum.Arrays.MappedByIndex((index, element) -> index == element ,[0, -1, 2])", + "Std.Arrays.MappedByIndex((index, element) -> index == element ,[0, -1, 2])", &Value::Array(vec![Value::Bool(true), Value::Bool(false), Value::Bool(true)].into()), ); } @@ -518,7 +518,7 @@ fn check_mapped_by_index() { #[test] fn check_mapped_over_range() { test_expression( - "Microsoft.Quantum.Arrays.MappedOverRange(x -> x + 1, 0..2..10)", + "Std.Arrays.MappedOverRange(x -> x + 1, 0..2..10)", &Value::Array( vec![ Value::Int(1), @@ -532,7 +532,7 @@ fn check_mapped_over_range() { ), ); test_expression( - "Microsoft.Quantum.Arrays.MappedOverRange(x -> x * 2, 3..-1..1)", + "Std.Arrays.MappedOverRange(x -> x * 2, 3..-1..1)", &Value::Array(vec![Value::Int(6), Value::Int(4), Value::Int(2)].into()), ); } @@ -540,7 +540,7 @@ fn check_mapped_over_range() { #[test] fn check_most() { test_expression( - "Microsoft.Quantum.Arrays.Most([5, 6, 7, 8])", + "Std.Arrays.Most([5, 6, 7, 8])", &Value::Array(vec![Value::Int(5), Value::Int(6), Value::Int(7)].into()), ); } @@ -548,7 +548,7 @@ fn check_most() { #[test] fn check_most_and_tail() { test_expression( - "Microsoft.Quantum.Arrays.MostAndTail([5, 6, 7, 8])", + "Std.Arrays.MostAndTail([5, 6, 7, 8])", &Value::Tuple( vec![ Value::Array(vec![Value::Int(5), Value::Int(6), Value::Int(7)].into()), @@ -563,7 +563,7 @@ fn check_most_and_tail() { #[test] fn check_padded() { test_expression( - "Microsoft.Quantum.Arrays.Padded(-5, 2, [10, 11, 12])", + "Std.Arrays.Padded(-5, 2, [10, 11, 12])", &Value::Array( vec![ Value::Int(10), @@ -576,7 +576,7 @@ fn check_padded() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Padded(5, 2, [10, 11, 12])", + "Std.Arrays.Padded(5, 2, [10, 11, 12])", &Value::Array( vec![ Value::Int(2), @@ -589,11 +589,11 @@ fn check_padded() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Padded(3, 2, [10, 11, 12])", + "Std.Arrays.Padded(3, 2, [10, 11, 12])", &Value::Array(vec![Value::Int(10), Value::Int(11), Value::Int(12)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Padded(-3, 2, [10, 11, 12])", + "Std.Arrays.Padded(-3, 2, [10, 11, 12])", &Value::Array(vec![Value::Int(10), Value::Int(11), Value::Int(12)].into()), ); } @@ -601,7 +601,7 @@ fn check_padded() { #[test] fn check_partitioned() { test_expression( - "Microsoft.Quantum.Arrays.Partitioned([2, 1], [2, 3, 5, 7])", + "Std.Arrays.Partitioned([2, 1], [2, 3, 5, 7])", &Value::Array( vec![ Value::Array(vec![Value::Int(2), Value::Int(3)].into()), @@ -612,7 +612,7 @@ fn check_partitioned() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Partitioned([2, 2], [2, 3, 5, 7])", + "Std.Arrays.Partitioned([2, 2], [2, 3, 5, 7])", &Value::Array( vec![ Value::Array(vec![Value::Int(2), Value::Int(3)].into()), @@ -627,11 +627,11 @@ fn check_partitioned() { #[test] fn check_sequence_i() { test_expression( - "Microsoft.Quantum.Arrays.SequenceI(0, 3)", + "Std.Arrays.SequenceI(0, 3)", &Value::Array(vec![Value::Int(0), Value::Int(1), Value::Int(2), Value::Int(3)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.SequenceI(-5, -2)", + "Std.Arrays.SequenceI(-5, -2)", &Value::Array( vec![ Value::Int(-5), @@ -647,7 +647,7 @@ fn check_sequence_i() { #[test] fn check_sequence_l() { test_expression( - "Microsoft.Quantum.Arrays.SequenceL(0L, 3L)", + "Std.Arrays.SequenceL(0L, 3L)", &Value::Array( vec![ Value::BigInt(BigInt::from(0)), @@ -659,7 +659,7 @@ fn check_sequence_l() { ), ); test_expression( - "Microsoft.Quantum.Arrays.SequenceL(-5L, -2L)", + "Std.Arrays.SequenceL(-5L, -2L)", &Value::Array( vec![ Value::BigInt(BigInt::from(-5)), @@ -677,16 +677,16 @@ fn check_sorted() { test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.Sorted((x, y) -> x <= y, empty) + Std.Arrays.Sorted((x, y) -> x <= y, empty) }", &Value::Array(vec![].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Sorted((x, y) -> x <= y, [-1])", + "Std.Arrays.Sorted((x, y) -> x <= y, [-1])", &Value::Array(vec![Value::Int(-1)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Sorted((x, y) -> x <= y, [1, 2, 0, 4, 3])", + "Std.Arrays.Sorted((x, y) -> x <= y, [1, 2, 0, 4, 3])", &Value::Array( vec![ Value::Int(0), @@ -699,7 +699,7 @@ fn check_sorted() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Sorted((x, y) -> x >= y, [1, 2, 0, 4, 3])", + "Std.Arrays.Sorted((x, y) -> x >= y, [1, 2, 0, 4, 3])", &Value::Array( vec![ Value::Int(4), @@ -712,7 +712,7 @@ fn check_sorted() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Sorted((x, y) -> x <= y, [-1, 2, 0, 1, -2])", + "Std.Arrays.Sorted((x, y) -> x <= y, [-1, 2, 0, 1, -2])", &Value::Array( vec![ Value::Int(-2), @@ -729,7 +729,7 @@ fn check_sorted() { #[test] fn check_rest() { test_expression( - "Microsoft.Quantum.Arrays.Rest([5,6,7,8])", + "Std.Arrays.Rest([5,6,7,8])", &Value::Array(vec![Value::Int(6), Value::Int(7), Value::Int(8)].into()), ); } @@ -737,7 +737,7 @@ fn check_rest() { #[test] fn check_reversed() { test_expression( - "Microsoft.Quantum.Arrays.Reversed([5,6,7,8])", + "Std.Arrays.Reversed([5,6,7,8])", &Value::Array(vec![Value::Int(8), Value::Int(7), Value::Int(6), Value::Int(5)].into()), ); } @@ -745,15 +745,15 @@ fn check_reversed() { #[test] fn check_subarray() { test_expression( - "Microsoft.Quantum.Arrays.Subarray([3, 0, 2, 1], [1, 2, 3, 4])", + "Std.Arrays.Subarray([3, 0, 2, 1], [1, 2, 3, 4])", &Value::Array(vec![Value::Int(4), Value::Int(1), Value::Int(3), Value::Int(2)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Subarray([1, 2, 2], [1, 2, 3, 4])", + "Std.Arrays.Subarray([1, 2, 2], [1, 2, 3, 4])", &Value::Array(vec![Value::Int(2), Value::Int(3), Value::Int(3)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Subarray([0, 0, 0, 0, 0], [false])", + "Std.Arrays.Subarray([0, 0, 0, 0, 0], [false])", &Value::Array( vec![ Value::Bool(false), @@ -770,7 +770,7 @@ fn check_subarray() { #[test] fn check_swapped() { test_expression( - "Microsoft.Quantum.Arrays.Swapped(1, 3, [0, 1, 2, 3, 4])", + "Std.Arrays.Swapped(1, 3, [0, 1, 2, 3, 4])", &Value::Array( vec![ Value::Int(0), @@ -786,13 +786,13 @@ fn check_swapped() { #[test] fn check_tail() { - test_expression("Microsoft.Quantum.Arrays.Tail([5,6,7,8])", &Value::Int(8)); + test_expression("Std.Arrays.Tail([5,6,7,8])", &Value::Int(8)); } #[test] fn check_transposed() { test_expression( - "Microsoft.Quantum.Arrays.Transposed([[1, 2, 3], [4, 5, 6]])", + "Std.Arrays.Transposed([[1, 2, 3], [4, 5, 6]])", &Value::Array( vec![ Value::Array(vec![Value::Int(1), Value::Int(4)].into()), @@ -803,7 +803,7 @@ fn check_transposed() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Transposed([[1, 4], [2, 5], [3, 6]])", + "Std.Arrays.Transposed([[1, 4], [2, 5], [3, 6]])", &Value::Array( vec![ Value::Array(vec![Value::Int(1), Value::Int(2), Value::Int(3)].into()), @@ -819,7 +819,7 @@ fn check_unzipped() { test_expression( "{ let empty: (Int, Int)[] = []; - Microsoft.Quantum.Arrays.Unzipped(empty) + Std.Arrays.Unzipped(empty) }", &Value::Tuple( vec![Value::Array(vec![].into()), Value::Array(vec![].into())].into(), @@ -827,7 +827,7 @@ fn check_unzipped() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Unzipped([(5, true), (4, false), (3, true), (2, true), (1, false)])", + "Std.Arrays.Unzipped([(5, true), (4, false), (3, true), (2, true), (1, false)])", &Value::Tuple( vec![ Value::Array( @@ -856,7 +856,7 @@ fn check_unzipped() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Unzipped([(true, 5), (false, 4), (true, 3), (true, 2), (false, 1)])", + "Std.Arrays.Unzipped([(true, 5), (false, 4), (true, 3), (true, 2), (false, 1)])", &Value::Tuple( vec![ Value::Array( @@ -889,11 +889,11 @@ fn check_unzipped() { #[test] fn check_where() { test_expression( - "Microsoft.Quantum.Arrays.Where(x -> x % 2 == 0, [0, 1, 2, 3, 4])", + "Std.Arrays.Where(x -> x % 2 == 0, [0, 1, 2, 3, 4])", &Value::Array(vec![Value::Int(0), Value::Int(2), Value::Int(4)].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Where(x -> x % 2 != 0, [1, 2, 3, 4, 5])", + "Std.Arrays.Where(x -> x % 2 != 0, [1, 2, 3, 4, 5])", &Value::Array(vec![Value::Int(0), Value::Int(2), Value::Int(4)].into()), ); } @@ -901,7 +901,7 @@ fn check_where() { #[test] fn check_windows() { test_expression( - "Microsoft.Quantum.Arrays.Windows(1, [1, 2, 3, 4, 5])", + "Std.Arrays.Windows(1, [1, 2, 3, 4, 5])", &Value::Array( vec![ Value::Array(vec![Value::Int(1)].into()), @@ -914,7 +914,7 @@ fn check_windows() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Windows(3, [1, 2, 3, 4, 5])", + "Std.Arrays.Windows(3, [1, 2, 3, 4, 5])", &Value::Array( vec![ Value::Array(vec![Value::Int(1), Value::Int(2), Value::Int(3)].into()), @@ -925,7 +925,7 @@ fn check_windows() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Windows(5, [1, 2, 3, 4, 5])", + "Std.Arrays.Windows(5, [1, 2, 3, 4, 5])", &Value::Array( vec![Value::Array( vec![ @@ -947,26 +947,26 @@ fn check_zipped() { test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.Zipped(empty, empty) + Std.Arrays.Zipped(empty, empty) }", &Value::Array(vec![].into()), ); test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.Zipped([1], empty) + Std.Arrays.Zipped([1], empty) }", &Value::Array(vec![].into()), ); test_expression( "{ let empty: Int[] = []; - Microsoft.Quantum.Arrays.Zipped(empty, [false]) + Std.Arrays.Zipped(empty, [false]) }", &Value::Array(vec![].into()), ); test_expression( - "Microsoft.Quantum.Arrays.Zipped([1, 2, 3, 4, 5], [false, true, true, false, true])", + "Std.Arrays.Zipped([1, 2, 3, 4, 5], [false, true, true, false, true])", &Value::Array( vec![ Value::Tuple(vec![Value::Int(1), Value::Bool(false)].into(), None), @@ -979,7 +979,7 @@ fn check_zipped() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Zipped([false, true, true, false, true], [1, 2, 3, 4, 5])", + "Std.Arrays.Zipped([false, true, true, false, true], [1, 2, 3, 4, 5])", &Value::Array( vec![ Value::Tuple(vec![Value::Bool(false), Value::Int(1)].into(), None), @@ -992,7 +992,7 @@ fn check_zipped() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Zipped([1, 2, 3], [false, true, true, false, true])", + "Std.Arrays.Zipped([1, 2, 3], [false, true, true, false, true])", &Value::Array( vec![ Value::Tuple(vec![Value::Int(1), Value::Bool(false)].into(), None), @@ -1003,7 +1003,7 @@ fn check_zipped() { ), ); test_expression( - "Microsoft.Quantum.Arrays.Zipped([1, 2, 3, 4, 5], [false, true, true])", + "Std.Arrays.Zipped([1, 2, 3, 4, 5], [false, true, true])", &Value::Array( vec![ Value::Tuple(vec![Value::Int(1), Value::Bool(false)].into(), None), diff --git a/library/src/tests/canon.rs b/library/src/tests/canon.rs index e632d714f6..df713caece 100644 --- a/library/src/tests/canon.rs +++ b/library/src/tests/canon.rs @@ -5,7 +5,7 @@ use super::{test_expression, test_expression_with_lib}; use indoc::indoc; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.Canon namespace +// Tests for Std.Canon namespace #[test] fn check_apply_to_each() { @@ -13,7 +13,7 @@ fn check_apply_to_each() { indoc! {r#"{ use register = Qubit[3]; ApplyToEach(X, register); - let results = Microsoft.Quantum.Measurement.MeasureEachZ(register); + let results = Std.Measurement.MeasureEachZ(register); ResetAll(register); results }"#}, @@ -27,8 +27,8 @@ fn check_apply_to_each_a() { indoc! {r#"{ use register = Qubit[3]; ApplyToEach(X, register); - Adjoint Microsoft.Quantum.Canon.ApplyToEachA(X, register); - let results = Microsoft.Quantum.Measurement.MResetEachZ(register); + Adjoint Std.Canon.ApplyToEachA(X, register); + let results = Std.Measurement.MResetEachZ(register); results }"#}, &Value::Array(vec![Value::RESULT_ZERO, Value::RESULT_ZERO, Value::RESULT_ZERO].into()), @@ -41,8 +41,8 @@ fn check_apply_to_each_c_applied() { indoc! {r#"{ use control = Qubit(); use register = Qubit[3]; - Controlled Microsoft.Quantum.Canon.ApplyToEachC([control], (X, register)); - let results = Microsoft.Quantum.Measurement.MResetEachZ(register); + Controlled Std.Canon.ApplyToEachC([control], (X, register)); + let results = Std.Measurement.MResetEachZ(register); Reset(control); results }"#}, @@ -57,8 +57,8 @@ fn check_apply_to_each_c_not_applied() { use control = Qubit(); use register = Qubit[3]; X(control); - Controlled Microsoft.Quantum.Canon.ApplyToEachC([control], (X, register)); - let results = Microsoft.Quantum.Measurement.MResetEachZ(register); + Controlled Std.Canon.ApplyToEachC([control], (X, register)); + let results = Std.Measurement.MResetEachZ(register); Reset(control); results }"#}, @@ -72,9 +72,9 @@ fn check_apply_to_each_ca_applied() { indoc! {r#"{ use control = Qubit(); use register = Qubit[3]; - Microsoft.Quantum.Canon.ApplyToEach(X, register); - Controlled Adjoint Microsoft.Quantum.Canon.ApplyToEachCA([control], (X, register)); - let results = Microsoft.Quantum.Measurement.MResetEachZ(register); + Std.Canon.ApplyToEach(X, register); + Controlled Adjoint Std.Canon.ApplyToEachCA([control], (X, register)); + let results = Std.Measurement.MResetEachZ(register); Reset(control); results }"#}, @@ -89,9 +89,9 @@ fn check_apply_to_each_ca_not_applied() { use control = Qubit(); use register = Qubit[3]; X(control); - Microsoft.Quantum.Canon.ApplyToEach(X, register); - Controlled Adjoint Microsoft.Quantum.Canon.ApplyToEachCA([control], (X, register)); - let results = Microsoft.Quantum.Measurement.MResetEachZ(register); + Std.Canon.ApplyToEach(X, register); + Controlled Adjoint Std.Canon.ApplyToEachCA([control], (X, register)); + let results = Std.Measurement.MResetEachZ(register); Reset(control); results }"#}, diff --git a/library/src/tests/convert.rs b/library/src/tests/convert.rs index bd2c0cc885..14a90b6fff 100644 --- a/library/src/tests/convert.rs +++ b/library/src/tests/convert.rs @@ -4,12 +4,12 @@ use super::test_expression; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.Convert namespace +// Tests for Std.Convert namespace #[test] fn check_bool_array_as_int() { test_expression( - "Microsoft.Quantum.Convert.BoolArrayAsInt([true, false, true, false])", + "Std.Convert.BoolArrayAsInt([true, false, true, false])", &Value::Int(0b0101), ); } @@ -17,7 +17,7 @@ fn check_bool_array_as_int() { #[test] fn check_int_as_bool_array() { test_expression( - "Microsoft.Quantum.Convert.IntAsBoolArray(5,4)", + "Std.Convert.IntAsBoolArray(5,4)", &Value::Array( vec![ Value::Bool(true), @@ -33,7 +33,7 @@ fn check_int_as_bool_array() { #[test] fn check_bigint_as_bool_array() { test_expression( - "Microsoft.Quantum.Convert.BigIntAsBoolArray(18446744073709551616L, 128)", // note: 18446744073709551616L == 2^64 + "Std.Convert.BigIntAsBoolArray(18446744073709551616L, 128)", // note: 18446744073709551616L == 2^64 &Value::Array( vec![ Value::Bool(false), @@ -204,7 +204,7 @@ fn check_big_int_as_int_min() { #[test] fn check_bool_array_as_big_int() { test_expression( - "Microsoft.Quantum.Convert.BoolArrayAsBigInt([false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])", + "Std.Convert.BoolArrayAsBigInt([false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false])", &Value::BigInt(18_446_744_073_709_551_616_u128.into()), ); } @@ -212,7 +212,7 @@ fn check_bool_array_as_big_int() { #[test] fn check_result_array_as_int() { test_expression( - "Microsoft.Quantum.Convert.ResultArrayAsInt([One, Zero, One, Zero])", + "Std.Convert.ResultArrayAsInt([One, Zero, One, Zero])", &Value::Int(0b0101), ); } @@ -220,7 +220,7 @@ fn check_result_array_as_int() { #[test] fn check_result_zero_as_bool() { test_expression( - "Microsoft.Quantum.Convert.ResultAsBool(Zero)", + "Std.Convert.ResultAsBool(Zero)", &Value::Bool(false), ); } @@ -228,7 +228,7 @@ fn check_result_zero_as_bool() { #[test] fn check_result_one_as_bool() { test_expression( - "Microsoft.Quantum.Convert.ResultAsBool(One)", + "Std.Convert.ResultAsBool(One)", &Value::Bool(true), ); } @@ -236,7 +236,7 @@ fn check_result_one_as_bool() { #[test] fn check_result_array_as_bool_array() { test_expression( - "Microsoft.Quantum.Convert.ResultArrayAsBoolArray([One, Zero, One, Zero])", + "Std.Convert.ResultArrayAsBoolArray([One, Zero, One, Zero])", &Value::Array( vec![ Value::Bool(true), @@ -252,7 +252,7 @@ fn check_result_array_as_bool_array() { #[test] fn check_bool_true_as_result() { test_expression( - "Microsoft.Quantum.Convert.BoolAsResult(true)", + "Std.Convert.BoolAsResult(true)", &Value::RESULT_ONE, ); } @@ -260,7 +260,7 @@ fn check_bool_true_as_result() { #[test] fn check_bool_false_as_result() { test_expression( - "Microsoft.Quantum.Convert.BoolAsResult(false)", + "Std.Convert.BoolAsResult(false)", &Value::RESULT_ZERO, ); } @@ -268,7 +268,7 @@ fn check_bool_false_as_result() { #[test] fn check_bool_array_as_result_array() { test_expression( - "Microsoft.Quantum.Convert.BoolArrayAsResultArray([true, false, true, false])", + "Std.Convert.BoolArrayAsResultArray([true, false, true, false])", &Value::Array( vec![ Value::RESULT_ONE, @@ -288,7 +288,7 @@ fn test_complex_as_complex_polar() { "{ import Std.Math.*; let a = Complex(2.0*Cos(1.0), 2.0*Sin(1.0)); - Microsoft.Quantum.Convert.ComplexAsComplexPolar(a) + Std.Convert.ComplexAsComplexPolar(a) }" }, &Value::Tuple(vec![Value::Double(2.0), Value::Double(1.0)].into(), None), @@ -302,7 +302,7 @@ fn test_complex_polar_as_complex() { "{ import Std.Math.*; let a = ComplexPolar(Sqrt(5.0), ArcTan2(1.0, 2.0)); - Microsoft.Quantum.Convert.ComplexPolarAsComplex(a) + Std.Convert.ComplexPolarAsComplex(a) }" }, &Value::Tuple(vec![Value::Double(2.0), Value::Double(1.0)].into(), None), diff --git a/library/src/tests/core.rs b/library/src/tests/core.rs index 039eae1262..eb9399e14e 100644 --- a/library/src/tests/core.rs +++ b/library/src/tests/core.rs @@ -4,7 +4,7 @@ use super::test_expression; use qsc::interpret::{Value, ValueRange}; -// Tests for Microsoft.Quantum.Core namespace +// Tests for the core namespace #[test] fn check_range_1_5() { diff --git a/library/src/tests/diagnostics.rs b/library/src/tests/diagnostics.rs index 6bde07df52..f30dfeaa96 100644 --- a/library/src/tests/diagnostics.rs +++ b/library/src/tests/diagnostics.rs @@ -47,7 +47,7 @@ fn check_operations_are_equal() { #[test] fn check_dumpoperation_for_i() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => I(qs[0]))", + "Std.Diagnostics.DumpOperation(1, qs => I(qs[0]))", &Value::unit(), ); expect![[r#" @@ -61,7 +61,7 @@ fn check_dumpoperation_for_i() { #[test] fn check_dumpoperation_for_x() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => X(qs[0]))", + "Std.Diagnostics.DumpOperation(1, qs => X(qs[0]))", &Value::unit(), ); expect![[r#" @@ -75,7 +75,7 @@ fn check_dumpoperation_for_x() { #[test] fn check_dumpoperation_for_h() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => H(qs[0]))", + "Std.Diagnostics.DumpOperation(1, qs => H(qs[0]))", &Value::unit(), ); expect![[r#" @@ -89,7 +89,7 @@ fn check_dumpoperation_for_h() { #[test] fn check_dumpoperation_for_y() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => Y(qs[0]))", + "Std.Diagnostics.DumpOperation(1, qs => Y(qs[0]))", &Value::unit(), ); expect![[r#" @@ -103,7 +103,7 @@ fn check_dumpoperation_for_y() { #[test] fn check_dumpoperation_for_ccnot() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(3, qs => CCNOT(qs[0], qs[1], qs[2]))", + "Std.Diagnostics.DumpOperation(3, qs => CCNOT(qs[0], qs[1], qs[2]))", &Value::unit(), ); expect![[r#" @@ -122,7 +122,7 @@ fn check_dumpoperation_for_ccnot() { #[test] fn check_dumpoperation_with_extra_qubits_allocated() { let output = test_expression( - "{use qs = Qubit[2]; Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => H(qs[0]))}", + "{use qs = Qubit[2]; Std.Diagnostics.DumpOperation(1, qs => H(qs[0]))}", &Value::unit(), ); expect![[r#" @@ -137,8 +137,8 @@ fn check_dumpoperation_with_extra_qubits_allocated() { fn check_start_stop_counting_operation_called_3_times() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingOperation; - import Microsoft.Quantum.Diagnostics.StopCountingOperation; + import Std.Diagnostics.StartCountingOperation; + import Std.Diagnostics.StopCountingOperation; operation op1() : Unit {} operation op2() : Unit { op1(); } @@ -155,8 +155,8 @@ fn check_start_stop_counting_operation_called_3_times() { fn check_start_stop_counting_operation_called_0_times() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingOperation; - import Microsoft.Quantum.Diagnostics.StopCountingOperation; + import Std.Diagnostics.StartCountingOperation; + import Std.Diagnostics.StopCountingOperation; operation op1() : Unit {} operation op2() : Unit { op1(); } @@ -172,8 +172,8 @@ fn check_start_stop_counting_operation_called_0_times() { fn check_lambda_counted_separately_from_operation() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingOperation; - import Microsoft.Quantum.Diagnostics.StopCountingOperation; + import Std.Diagnostics.StartCountingOperation; + import Std.Diagnostics.StopCountingOperation; operation op1() : Unit {} StartCountingOperation(op1); @@ -191,8 +191,8 @@ fn check_lambda_counted_separately_from_operation() { fn check_multiple_controls_counted_together() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingOperation; - import Microsoft.Quantum.Diagnostics.StopCountingOperation; + import Std.Diagnostics.StartCountingOperation; + import Std.Diagnostics.StopCountingOperation; operation op1() : Unit is Adj + Ctl {} StartCountingOperation(Controlled op1); @@ -209,8 +209,8 @@ fn check_multiple_controls_counted_together() { fn check_counting_operation_differentiates_between_body_adj_ctl() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingOperation; - import Microsoft.Quantum.Diagnostics.StopCountingOperation; + import Std.Diagnostics.StartCountingOperation; + import Std.Diagnostics.StopCountingOperation; operation op1() : Unit is Adj + Ctl {} StartCountingOperation(op1); @@ -232,8 +232,8 @@ fn check_counting_operation_differentiates_between_body_adj_ctl() { fn check_start_stop_counting_function_called_3_times() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingFunction; - import Microsoft.Quantum.Diagnostics.StopCountingFunction; + import Std.Diagnostics.StartCountingFunction; + import Std.Diagnostics.StopCountingFunction; function f1() : Unit {} function f2() : Unit { f1(); } @@ -250,8 +250,8 @@ fn check_start_stop_counting_function_called_3_times() { fn check_start_stop_counting_function_called_0_times() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingFunction; - import Microsoft.Quantum.Diagnostics.StopCountingFunction; + import Std.Diagnostics.StartCountingFunction; + import Std.Diagnostics.StopCountingFunction; function f1() : Unit {} function f2() : Unit { f1(); } @@ -267,8 +267,8 @@ fn check_start_stop_counting_function_called_0_times() { fn check_start_counting_qubits_for_one_allocation() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingQubits; - import Microsoft.Quantum.Diagnostics.StopCountingQubits; + import Std.Diagnostics.StartCountingQubits; + import Std.Diagnostics.StopCountingQubits; StartCountingQubits(); use q = Qubit(); @@ -282,8 +282,8 @@ fn check_start_counting_qubits_for_one_allocation() { fn check_start_counting_qubits_for_tuple_allocation() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingQubits; - import Microsoft.Quantum.Diagnostics.StopCountingQubits; + import Std.Diagnostics.StartCountingQubits; + import Std.Diagnostics.StopCountingQubits; StartCountingQubits(); use (q0, q1) = (Qubit(), Qubit()); @@ -297,8 +297,8 @@ fn check_start_counting_qubits_for_tuple_allocation() { fn check_start_counting_qubits_for_array_allocation() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingQubits; - import Microsoft.Quantum.Diagnostics.StopCountingQubits; + import Std.Diagnostics.StartCountingQubits; + import Std.Diagnostics.StopCountingQubits; StartCountingQubits(); use qs = Qubit[2]; @@ -312,8 +312,8 @@ fn check_start_counting_qubits_for_array_allocation() { fn check_start_counting_qubits_after_allocation_gives_zero() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingQubits; - import Microsoft.Quantum.Diagnostics.StopCountingQubits; + import Std.Diagnostics.StartCountingQubits; + import Std.Diagnostics.StopCountingQubits; use q = Qubit(); StartCountingQubits(); @@ -327,8 +327,8 @@ fn check_start_counting_qubits_after_allocation_gives_zero() { fn check_start_counting_qubits_sees_same_qubit_as_single_count() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingQubits; - import Microsoft.Quantum.Diagnostics.StopCountingQubits; + import Std.Diagnostics.StartCountingQubits; + import Std.Diagnostics.StopCountingQubits; StartCountingQubits(); { @@ -347,8 +347,8 @@ fn check_start_counting_qubits_sees_same_qubit_as_single_count() { fn check_start_counting_qubits_works_with_manual_out_of_order_allocation_release() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingQubits; - import Microsoft.Quantum.Diagnostics.StopCountingQubits; + import Std.Diagnostics.StartCountingQubits; + import Std.Diagnostics.StopCountingQubits; import QIR.Runtime.__quantum__rt__qubit_allocate; import QIR.Runtime.__quantum__rt__qubit_release; @@ -369,9 +369,9 @@ fn check_start_counting_qubits_works_with_manual_out_of_order_allocation_release fn check_counting_qubits_works_with_allocation_in_operation_calls() { test_expression( "{ - import Microsoft.Quantum.Diagnostics.StartCountingQubits; - import Microsoft.Quantum.Diagnostics.StopCountingQubits; - import Microsoft.Quantum.Diagnostics.CheckOperationsAreEqual; + import Std.Diagnostics.StartCountingQubits; + import Std.Diagnostics.StopCountingQubits; + import Std.Diagnostics.CheckOperationsAreEqual; StartCountingQubits(); let numQubits = 2; @@ -388,7 +388,7 @@ fn check_counting_qubits_works_with_allocation_in_operation_calls() { #[test] fn check_dumpoperation_with_extra_qubits_in_superposition() { let output = test_expression( - "{use qs = Qubit[2]; H(qs[0]); Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => H(qs[0])); Reset(qs[0]);}", + "{use qs = Qubit[2]; H(qs[0]); Std.Diagnostics.DumpOperation(1, qs => H(qs[0])); Reset(qs[0]);}", &Value::unit(), ); expect![[r#" @@ -402,7 +402,7 @@ fn check_dumpoperation_with_extra_qubits_in_superposition() { #[test] fn check_dumpoperation_with_extra_qubits_global_phase_reflected_in_matrix() { let output = test_expression( - "{use qs = Qubit[2]; R(PauliI, Std.Math.PI() / 2.0, qs[0]); Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => H(qs[0])); Reset(qs[0]);}", + "{use qs = Qubit[2]; R(PauliI, Std.Math.PI() / 2.0, qs[0]); Std.Diagnostics.DumpOperation(1, qs => H(qs[0])); Reset(qs[0]);}", &Value::unit(), ); expect![[r#" @@ -416,7 +416,7 @@ fn check_dumpoperation_with_extra_qubits_global_phase_reflected_in_matrix() { #[test] fn check_dumpoperation_with_extra_qubits_relative_phase_not_reflected_in_matrix() { let output = test_expression( - "{use qs = Qubit[2]; R1(Std.Math.PI() / 2.0, qs[0]); Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => H(qs[0])); Reset(qs[0]);}", + "{use qs = Qubit[2]; R1(Std.Math.PI() / 2.0, qs[0]); Std.Diagnostics.DumpOperation(1, qs => H(qs[0])); Reset(qs[0]);}", &Value::unit(), ); expect![[r#" @@ -430,7 +430,7 @@ fn check_dumpoperation_with_extra_qubits_relative_phase_not_reflected_in_matrix( #[test] fn check_dump_operation_for_r1_of_pi() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(1, qs => R1(Std.Math.PI(), qs[0]))", + "Std.Diagnostics.DumpOperation(1, qs => R1(Std.Math.PI(), qs[0]))", &Value::unit(), ); expect![[r#" @@ -444,7 +444,7 @@ fn check_dump_operation_for_r1_of_pi() { #[test] fn check_dump_operation_for_r1_of_pi_with_one_control() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(2, qs => Controlled R1(qs[...0], (Std.Math.PI(), qs[1])))", + "Std.Diagnostics.DumpOperation(2, qs => Controlled R1(qs[...0], (Std.Math.PI(), qs[1])))", &Value::unit(), ); expect![[r#" @@ -460,7 +460,7 @@ fn check_dump_operation_for_r1_of_pi_with_one_control() { #[test] fn check_dump_operation_for_r1_of_pi_with_two_controls() { let output = test_expression( - "Microsoft.Quantum.Diagnostics.DumpOperation(3, qs => Controlled R1(qs[...1], (Std.Math.PI(), qs[2])))", + "Std.Diagnostics.DumpOperation(3, qs => Controlled R1(qs[...1], (Std.Math.PI(), qs[2])))", &Value::unit(), ); expect![[r#" diff --git a/library/src/tests/logical.rs b/library/src/tests/logical.rs index aef0fe2533..b652084ec9 100644 --- a/library/src/tests/logical.rs +++ b/library/src/tests/logical.rs @@ -4,24 +4,24 @@ use super::test_expression; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.Logical namespace +// Tests for Std.Logical namespace #[test] fn check_xor() { test_expression( - "Microsoft.Quantum.Logical.Xor(false, false)", + "Std.Logical.Xor(false, false)", &Value::Bool(false), ); test_expression( - "Microsoft.Quantum.Logical.Xor(false, true)", + "Std.Logical.Xor(false, true)", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Logical.Xor(true, false)", + "Std.Logical.Xor(true, false)", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Logical.Xor(true, true)", + "Std.Logical.Xor(true, true)", &Value::Bool(false), ); } diff --git a/library/src/tests/math.rs b/library/src/tests/math.rs index e184775c7b..f1dc4f3d10 100644 --- a/library/src/tests/math.rs +++ b/library/src/tests/math.rs @@ -10,7 +10,7 @@ use std::{f64::consts::PI, str::FromStr}; #[test] fn check_pi() { test_expression( - "Microsoft.Quantum.Math.PI()", + "Std.Math.PI()", &Value::Double(std::f64::consts::PI), ); } @@ -18,7 +18,7 @@ fn check_pi() { #[test] fn check_e() { test_expression( - "Microsoft.Quantum.Math.E()", + "Std.Math.E()", &Value::Double(std::f64::consts::E), ); } @@ -26,7 +26,7 @@ fn check_e() { #[test] fn check_log_of_2() { test_expression( - "Microsoft.Quantum.Math.LogOf2()", + "Std.Math.LogOf2()", &Value::Double(std::f64::consts::LN_2), ); } @@ -38,12 +38,12 @@ fn check_log_of_2() { #[test] fn check_is_nan() { test_expression( - "Microsoft.Quantum.Math.IsNaN(0.0 / 0.0)", + "Std.Math.IsNaN(0.0 / 0.0)", &Value::Bool(true), ); - test_expression("Microsoft.Quantum.Math.IsNaN(1.0)", &Value::Bool(false)); + test_expression("Std.Math.IsNaN(1.0)", &Value::Bool(false)); test_expression( - "Microsoft.Quantum.Math.IsNaN(Microsoft.Quantum.Math.ArcSin(2.0))", + "Std.Math.IsNaN(Std.Math.ArcSin(2.0))", &Value::Bool(true), ); } @@ -51,15 +51,15 @@ fn check_is_nan() { #[test] fn check_is_infinite() { test_expression( - "Microsoft.Quantum.Math.IsInfinite(1.0 / 0.0)", + "Std.Math.IsInfinite(1.0 / 0.0)", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Math.IsInfinite(0.0 / 0.0)", + "Std.Math.IsInfinite(0.0 / 0.0)", &Value::Bool(false), ); test_expression( - "Microsoft.Quantum.Math.IsInfinite(-1.0 / 0.0)", + "Std.Math.IsInfinite(-1.0 / 0.0)", &Value::Bool(true), ); } @@ -70,103 +70,103 @@ fn check_is_infinite() { #[test] fn check_sign_i() { - test_expression("Microsoft.Quantum.Math.SignI(0)", &Value::Int(0)); - test_expression("Microsoft.Quantum.Math.SignI(1000)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.SignI(-1000)", &Value::Int(-1)); + test_expression("Std.Math.SignI(0)", &Value::Int(0)); + test_expression("Std.Math.SignI(1000)", &Value::Int(1)); + test_expression("Std.Math.SignI(-1000)", &Value::Int(-1)); } #[test] fn check_sign_d() { - test_expression("Microsoft.Quantum.Math.SignD(0.0)", &Value::Int(0)); - test_expression("Microsoft.Quantum.Math.SignD(0.005)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.SignD(-0.005)", &Value::Int(-1)); + test_expression("Std.Math.SignD(0.0)", &Value::Int(0)); + test_expression("Std.Math.SignD(0.005)", &Value::Int(1)); + test_expression("Std.Math.SignD(-0.005)", &Value::Int(-1)); } #[test] fn check_sign_l() { - test_expression("Microsoft.Quantum.Math.SignL(0L)", &Value::Int(0)); + test_expression("Std.Math.SignL(0L)", &Value::Int(0)); test_expression( - "Microsoft.Quantum.Math.SignL(9999999999999999999999999999999999999999L)", + "Std.Math.SignL(9999999999999999999999999999999999999999L)", &Value::Int(1), ); test_expression( - "Microsoft.Quantum.Math.SignL(-9999999999999999999999999999999999999999L)", + "Std.Math.SignL(-9999999999999999999999999999999999999999L)", &Value::Int(-1), ); } #[test] fn check_abs_i() { - test_expression("Microsoft.Quantum.Math.AbsI(0)", &Value::Int(0)); - test_expression("Microsoft.Quantum.Math.AbsI(1000)", &Value::Int(1000)); - test_expression("Microsoft.Quantum.Math.AbsI(-1000)", &Value::Int(1000)); + test_expression("Std.Math.AbsI(0)", &Value::Int(0)); + test_expression("Std.Math.AbsI(1000)", &Value::Int(1000)); + test_expression("Std.Math.AbsI(-1000)", &Value::Int(1000)); test_expression( - "Microsoft.Quantum.Math.AbsI(-0x8000_0000_0000_0000)", + "Std.Math.AbsI(-0x8000_0000_0000_0000)", &Value::Int(-0x8000_0000_0000_0000), ); } #[test] fn check_abs_d() { - test_expression("Microsoft.Quantum.Math.AbsD(0.0)", &Value::Double(0.0)); - test_expression("Microsoft.Quantum.Math.AbsD(0.005)", &Value::Double(0.005)); - test_expression("Microsoft.Quantum.Math.AbsD(-0.005)", &Value::Double(0.005)); + test_expression("Std.Math.AbsD(0.0)", &Value::Double(0.0)); + test_expression("Std.Math.AbsD(0.005)", &Value::Double(0.005)); + test_expression("Std.Math.AbsD(-0.005)", &Value::Double(0.005)); } #[test] fn check_abs_l() { test_expression( - "Microsoft.Quantum.Math.AbsL(0L)", + "Std.Math.AbsL(0L)", &Value::BigInt(BigInt::from(0)), ); test_expression( - "Microsoft.Quantum.Math.AbsL(9999L)", + "Std.Math.AbsL(9999L)", &Value::BigInt(BigInt::from(9999)), ); test_expression( - "Microsoft.Quantum.Math.AbsL(-9999L)", + "Std.Math.AbsL(-9999L)", &Value::BigInt(BigInt::from(9999)), ); } #[test] fn check_max_i() { - test_expression("Microsoft.Quantum.Math.MaxI(-5,7)", &Value::Int(7)); - test_expression("Microsoft.Quantum.Math.MaxI(-7,0)", &Value::Int(0)); + test_expression("Std.Math.MaxI(-5,7)", &Value::Int(7)); + test_expression("Std.Math.MaxI(-7,0)", &Value::Int(0)); } #[test] fn check_max_d() { - test_expression("Microsoft.Quantum.Math.MaxD(-5.0,7.0)", &Value::Double(7.0)); - test_expression("Microsoft.Quantum.Math.MaxD(-7.0,0.0)", &Value::Double(0.0)); + test_expression("Std.Math.MaxD(-5.0,7.0)", &Value::Double(7.0)); + test_expression("Std.Math.MaxD(-7.0,0.0)", &Value::Double(0.0)); } #[test] fn check_max_l() { test_expression( - "Microsoft.Quantum.Math.MaxL(-5L,7L)", + "Std.Math.MaxL(-5L,7L)", &Value::BigInt(BigInt::from(7)), ); test_expression( - "Microsoft.Quantum.Math.MaxL(-7L,0L)", + "Std.Math.MaxL(-7L,0L)", &Value::BigInt(BigInt::from(0)), ); } #[test] fn check_min_i() { - test_expression("Microsoft.Quantum.Math.MinI(-5,7)", &Value::Int(-5)); - test_expression("Microsoft.Quantum.Math.MinI(-7,0)", &Value::Int(-7)); + test_expression("Std.Math.MinI(-5,7)", &Value::Int(-5)); + test_expression("Std.Math.MinI(-7,0)", &Value::Int(-7)); } #[test] fn check_min_d() { test_expression( - "Microsoft.Quantum.Math.MinD(-5.0,7.0)", + "Std.Math.MinD(-5.0,7.0)", &Value::Double(-5.0), ); test_expression( - "Microsoft.Quantum.Math.MinD(-7.0,0.0)", + "Std.Math.MinD(-7.0,0.0)", &Value::Double(-7.0), ); } @@ -174,11 +174,11 @@ fn check_min_d() { #[test] fn check_min_l() { test_expression( - "Microsoft.Quantum.Math.MinL(-5L,7L)", + "Std.Math.MinL(-5L,7L)", &Value::BigInt(BigInt::from(-5)), ); test_expression( - "Microsoft.Quantum.Math.MinL(-7L,0L)", + "Std.Math.MinL(-7L,0L)", &Value::BigInt(BigInt::from(-7)), ); } @@ -186,21 +186,21 @@ fn check_min_l() { #[test] fn check_min() { test_expression( - "Microsoft.Quantum.Math.Min([-5, 7, 1, 10])", + "Std.Math.Min([-5, 7, 1, 10])", &Value::Int(-5), ); - test_expression("Microsoft.Quantum.Math.Min([5, 7, 1, 10])", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.Min([1])", &Value::Int(1)); + test_expression("Std.Math.Min([5, 7, 1, 10])", &Value::Int(1)); + test_expression("Std.Math.Min([1])", &Value::Int(1)); } #[test] fn check_max() { test_expression( - "Microsoft.Quantum.Math.Max([10, 7, 1, -20])", + "Std.Math.Max([10, 7, 1, -20])", &Value::Int(10), ); - test_expression("Microsoft.Quantum.Math.Max([5, 7, 1, 20])", &Value::Int(20)); - test_expression("Microsoft.Quantum.Math.Max([1])", &Value::Int(1)); + test_expression("Std.Math.Max([5, 7, 1, 20])", &Value::Int(20)); + test_expression("Std.Math.Max([1])", &Value::Int(1)); } // @@ -210,7 +210,7 @@ fn check_max() { #[test] fn check_arccos() { test_expression( - "Microsoft.Quantum.Math.ArcCos(0.43)", + "Std.Math.ArcCos(0.43)", &Value::Double(0.43_f64.acos()), ); } @@ -218,7 +218,7 @@ fn check_arccos() { #[test] fn check_arcsin() { test_expression( - "Microsoft.Quantum.Math.ArcSin(0.43)", + "Std.Math.ArcSin(0.43)", &Value::Double(0.43_f64.asin()), ); } @@ -226,7 +226,7 @@ fn check_arcsin() { #[test] fn check_arctan() { test_expression( - "Microsoft.Quantum.Math.ArcTan(43.43)", + "Std.Math.ArcTan(43.43)", &Value::Double(43.43_f64.atan()), ); } @@ -234,7 +234,7 @@ fn check_arctan() { #[test] fn check_arctan2() { test_expression( - "Microsoft.Quantum.Math.ArcTan2(43.0,17.0)", + "Std.Math.ArcTan2(43.0,17.0)", &Value::Double(43.0_f64.atan2(17.0)), ); } @@ -242,7 +242,7 @@ fn check_arctan2() { #[test] fn check_cos() { test_expression( - "Microsoft.Quantum.Math.Cos(1.11)", + "Std.Math.Cos(1.11)", &Value::Double(1.11_f64.cos()), ); } @@ -250,7 +250,7 @@ fn check_cos() { #[test] fn check_cosh() { test_expression( - "Microsoft.Quantum.Math.Cosh(1.11)", + "Std.Math.Cosh(1.11)", &Value::Double(1.11_f64.cosh()), ); } @@ -258,7 +258,7 @@ fn check_cosh() { #[test] fn check_sin() { test_expression( - "Microsoft.Quantum.Math.Sin(2.22)", + "Std.Math.Sin(2.22)", &Value::Double(2.22_f64.sin()), ); } @@ -266,7 +266,7 @@ fn check_sin() { #[test] fn check_sinh() { test_expression( - "Microsoft.Quantum.Math.Sinh(2.22)", + "Std.Math.Sinh(2.22)", &Value::Double(2.22_f64.sinh()), ); } @@ -274,7 +274,7 @@ fn check_sinh() { #[test] fn check_tan() { test_expression( - "Microsoft.Quantum.Math.Tan(1.23)", + "Std.Math.Tan(1.23)", &Value::Double(1.23_f64.tan()), ); } @@ -282,7 +282,7 @@ fn check_tan() { #[test] fn check_tanh() { test_expression( - "Microsoft.Quantum.Math.Tanh(1.23)", + "Std.Math.Tanh(1.23)", &Value::Double(1.23_f64.tanh()), ); } @@ -290,7 +290,7 @@ fn check_tanh() { #[test] fn check_arccosh() { test_expression( - "Microsoft.Quantum.Math.ArcCosh(1.234)", + "Std.Math.ArcCosh(1.234)", &Value::Double(1.234_f64.acosh()), ); } @@ -298,7 +298,7 @@ fn check_arccosh() { #[test] fn check_arcsinh() { test_expression( - "Microsoft.Quantum.Math.ArcSinh(10.0)", + "Std.Math.ArcSinh(10.0)", &Value::Double(10.0_f64.asinh()), ); } @@ -306,7 +306,7 @@ fn check_arcsinh() { #[test] fn check_arctanh() { test_expression( - "Microsoft.Quantum.Math.ArcTanh(0.5)", + "Std.Math.ArcTanh(0.5)", &Value::Double(0.5_f64.atanh()), ); } @@ -318,7 +318,7 @@ fn check_arctanh() { #[test] fn check_sqrt() { test_expression( - "Microsoft.Quantum.Math.Sqrt(57121.0)", + "Std.Math.Sqrt(57121.0)", &Value::Double(239.0), ); } @@ -326,21 +326,21 @@ fn check_sqrt() { #[test] fn check_log() { test_expression( - "Microsoft.Quantum.Math.Log(57121.0)", + "Std.Math.Log(57121.0)", &Value::Double(57121.0_f64.ln()), ); } #[test] fn check_log10() { - test_expression("Microsoft.Quantum.Math.Log10(1.0)", &Value::Double(0.0)); - test_expression("Microsoft.Quantum.Math.Log10(10.0)", &Value::Double(1.0)); + test_expression("Std.Math.Log10(1.0)", &Value::Double(0.0)); + test_expression("Std.Math.Log10(10.0)", &Value::Double(1.0)); } #[test] fn check_lg() { - test_expression("Microsoft.Quantum.Math.Lg(1.0)", &Value::Double(0.0)); - test_expression("Microsoft.Quantum.Math.Lg(2.0)", &Value::Double(1.0)); + test_expression("Std.Math.Lg(1.0)", &Value::Double(0.0)); + test_expression("Std.Math.Lg(2.0)", &Value::Double(1.0)); } // @@ -349,20 +349,20 @@ fn check_lg() { #[test] fn check_truncate() { - test_expression("Microsoft.Quantum.Math.Truncate(3.1)", &Value::Int(3)); - test_expression("Microsoft.Quantum.Math.Truncate(-3.7)", &Value::Int(-3)); + test_expression("Std.Math.Truncate(3.1)", &Value::Int(3)); + test_expression("Std.Math.Truncate(-3.7)", &Value::Int(-3)); } #[test] fn check_ceiling() { - test_expression("Microsoft.Quantum.Math.Ceiling(3.1)", &Value::Int(4)); - test_expression("Microsoft.Quantum.Math.Ceiling(-3.7)", &Value::Int(-3)); + test_expression("Std.Math.Ceiling(3.1)", &Value::Int(4)); + test_expression("Std.Math.Ceiling(-3.7)", &Value::Int(-3)); } #[test] fn check_floor() { - test_expression("Microsoft.Quantum.Math.Floor(3.7)", &Value::Int(3)); - test_expression("Microsoft.Quantum.Math.Floor(-3.1)", &Value::Int(-4)); + test_expression("Std.Math.Floor(3.7)", &Value::Int(3)); + test_expression("Std.Math.Floor(-3.1)", &Value::Int(-4)); } #[test] @@ -398,11 +398,11 @@ fn check_round_away_from_zero() { #[test] fn check_divrem_i() { test_expression( - "Microsoft.Quantum.Math.DivRemI(20, 3)", + "Std.Math.DivRemI(20, 3)", &Value::Tuple(vec![Value::Int(6), Value::Int(2)].into(), None), ); test_expression( - "Microsoft.Quantum.Math.DivRemI(-20, 3)", + "Std.Math.DivRemI(-20, 3)", &Value::Tuple(vec![Value::Int(-6), Value::Int(-2)].into(), None), ); } @@ -410,7 +410,7 @@ fn check_divrem_i() { #[test] fn check_divrem_l() { test_expression( - "Microsoft.Quantum.Math.DivRemL(20L, 3L)", + "Std.Math.DivRemL(20L, 3L)", &Value::Tuple( vec![ Value::BigInt(BigInt::from(6)), @@ -421,7 +421,7 @@ fn check_divrem_l() { ), ); test_expression( - "Microsoft.Quantum.Math.DivRemL(-20L, 3L)", + "Std.Math.DivRemL(-20L, 3L)", &Value::Tuple( vec![ Value::BigInt(BigInt::from(-6)), @@ -435,64 +435,64 @@ fn check_divrem_l() { #[test] fn check_modulus_i() { - test_expression("Microsoft.Quantum.Math.ModulusI(20, 3)", &Value::Int(2)); - test_expression("Microsoft.Quantum.Math.ModulusI(-20, 3)", &Value::Int(1)); + test_expression("Std.Math.ModulusI(20, 3)", &Value::Int(2)); + test_expression("Std.Math.ModulusI(-20, 3)", &Value::Int(1)); } #[test] fn check_modulus_l() { test_expression( - "Microsoft.Quantum.Math.ModulusL(20L, 3L)", + "Std.Math.ModulusL(20L, 3L)", &Value::BigInt(BigInt::from(2)), ); test_expression( - "Microsoft.Quantum.Math.ModulusL(-20L, 3L)", + "Std.Math.ModulusL(-20L, 3L)", &Value::BigInt(BigInt::from(1)), ); } #[test] fn check_exp_mod_i() { - test_expression("Microsoft.Quantum.Math.ExpModI(1,10,10)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.ExpModI(10,0,10)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.ExpModI(2,10,10)", &Value::Int(4)); + test_expression("Std.Math.ExpModI(1,10,10)", &Value::Int(1)); + test_expression("Std.Math.ExpModI(10,0,10)", &Value::Int(1)); + test_expression("Std.Math.ExpModI(2,10,10)", &Value::Int(4)); } #[test] fn check_exp_mod_l() { test_expression( - "Microsoft.Quantum.Math.ExpModL(1L,10L,10L)", + "Std.Math.ExpModL(1L,10L,10L)", &Value::BigInt(BigInt::from(1)), ); test_expression( - "Microsoft.Quantum.Math.ExpModL(10L,0L,10L)", + "Std.Math.ExpModL(10L,0L,10L)", &Value::BigInt(BigInt::from(1)), ); test_expression( - "Microsoft.Quantum.Math.ExpModL(2L,10L,10L)", + "Std.Math.ExpModL(2L,10L,10L)", &Value::BigInt(BigInt::from(4)), ); } #[test] fn check_inverse_mod_i() { - test_expression("Microsoft.Quantum.Math.InverseModI(2,5)", &Value::Int(3)); - test_expression("Microsoft.Quantum.Math.InverseModI(3,10)", &Value::Int(7)); - test_expression("Microsoft.Quantum.Math.InverseModI(-1,5)", &Value::Int(4)); + test_expression("Std.Math.InverseModI(2,5)", &Value::Int(3)); + test_expression("Std.Math.InverseModI(3,10)", &Value::Int(7)); + test_expression("Std.Math.InverseModI(-1,5)", &Value::Int(4)); } #[test] fn check_inverse_mod_l() { test_expression( - "Microsoft.Quantum.Math.InverseModL(2L,5L)", + "Std.Math.InverseModL(2L,5L)", &Value::BigInt(BigInt::from(3)), ); test_expression( - "Microsoft.Quantum.Math.InverseModL(3L,10L)", + "Std.Math.InverseModL(3L,10L)", &Value::BigInt(BigInt::from(7)), ); test_expression( - "Microsoft.Quantum.Math.InverseModL(-1L,5L)", + "Std.Math.InverseModL(-1L,5L)", &Value::BigInt(BigInt::from(4)), ); } @@ -503,15 +503,15 @@ fn check_inverse_mod_l() { #[test] fn check_gcd_i() { test_expression( - "Microsoft.Quantum.Math.GreatestCommonDivisorI(0,0)", + "Std.Math.GreatestCommonDivisorI(0,0)", &Value::Int(0), ); test_expression( - "Microsoft.Quantum.Math.GreatestCommonDivisorI(2*3*5,2*3*7)", + "Std.Math.GreatestCommonDivisorI(2*3*5,2*3*7)", &Value::Int(2 * 3), ); test_expression( - "Microsoft.Quantum.Math.GreatestCommonDivisorI(39088169,63245986)", + "Std.Math.GreatestCommonDivisorI(39088169,63245986)", &Value::Int(1), ); } @@ -519,15 +519,15 @@ fn check_gcd_i() { #[test] fn check_gcd_l() { test_expression( - "Microsoft.Quantum.Math.GreatestCommonDivisorL(0L,0L)", + "Std.Math.GreatestCommonDivisorL(0L,0L)", &Value::BigInt(BigInt::from(0)), ); test_expression( - "Microsoft.Quantum.Math.GreatestCommonDivisorL(2L*3L*5L,2L*3L*7L)", + "Std.Math.GreatestCommonDivisorL(2L*3L*5L,2L*3L*7L)", &Value::BigInt(BigInt::from(2 * 3)), ); test_expression( - "Microsoft.Quantum.Math.GreatestCommonDivisorL(222232244629420445529739893461909967206666939096499764990979600L,359579325206583560961765665172189099052367214309267232255589801L)", + "Std.Math.GreatestCommonDivisorL(222232244629420445529739893461909967206666939096499764990979600L,359579325206583560961765665172189099052367214309267232255589801L)", &Value::BigInt(BigInt::from(1)), ); } @@ -535,15 +535,15 @@ fn check_gcd_l() { #[test] fn check_is_coprime_i() { test_expression( - "Microsoft.Quantum.Math.IsCoprimeI(44,35)", + "Std.Math.IsCoprimeI(44,35)", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Math.IsCoprimeI(6,9)", + "Std.Math.IsCoprimeI(6,9)", &Value::Bool(false), ); test_expression( - "Microsoft.Quantum.Math.IsCoprimeI(1, -1)", + "Std.Math.IsCoprimeI(1, -1)", &Value::Bool(true), ); } @@ -551,15 +551,15 @@ fn check_is_coprime_i() { #[test] fn check_is_coprime_l() { test_expression( - "Microsoft.Quantum.Math.IsCoprimeL(739696442014594807059393047166976L,7609583501588058567047119140625L)", + "Std.Math.IsCoprimeL(739696442014594807059393047166976L,7609583501588058567047119140625L)", &Value::Bool(true), ); test_expression( - "Microsoft.Quantum.Math.IsCoprimeL(6L,9L)", + "Std.Math.IsCoprimeL(6L,9L)", &Value::Bool(false), ); test_expression( - "Microsoft.Quantum.Math.IsCoprimeL(1L, -1L)", + "Std.Math.IsCoprimeL(1L, -1L)", &Value::Bool(true), ); } @@ -570,23 +570,23 @@ fn check_cfc_i() { // we can ignore this implementation details or update a function // to return canonical result. test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentI((72,100), 2)", + "Std.Math.ContinuedFractionConvergentI((72,100), 2)", &Value::Tuple(vec![Value::Int(-1), Value::Int(-1)].into(), None), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentI((72,100), 3)", + "Std.Math.ContinuedFractionConvergentI((72,100), 3)", &Value::Tuple(vec![Value::Int(2), Value::Int(3)].into(), None), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentI((72,100), 4)", + "Std.Math.ContinuedFractionConvergentI((72,100), 4)", &Value::Tuple(vec![Value::Int(-3), Value::Int(-4)].into(), None), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentI((72,100), 7)", + "Std.Math.ContinuedFractionConvergentI((72,100), 7)", &Value::Tuple(vec![Value::Int(5), Value::Int(7)].into(), None), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentI((72,100), 25)", + "Std.Math.ContinuedFractionConvergentI((72,100), 25)", &Value::Tuple(vec![Value::Int(-18), Value::Int(-25)].into(), None), ); } @@ -597,7 +597,7 @@ fn check_cfc_l() { // we can ignore this implementation details or update a function // to return canonical result. test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentL((72L,100L), 2L)", + "Std.Math.ContinuedFractionConvergentL((72L,100L), 2L)", &Value::Tuple( vec![ Value::BigInt(BigInt::from(-1)), @@ -608,7 +608,7 @@ fn check_cfc_l() { ), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentL((72L,100L), 3L)", + "Std.Math.ContinuedFractionConvergentL((72L,100L), 3L)", &Value::Tuple( vec![ Value::BigInt(BigInt::from(2)), @@ -619,7 +619,7 @@ fn check_cfc_l() { ), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentL((72L,100L), 25L)", + "Std.Math.ContinuedFractionConvergentL((72L,100L), 25L)", &Value::Tuple( vec![ Value::BigInt(BigInt::from(-18)), @@ -630,7 +630,7 @@ fn check_cfc_l() { ), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentL((170141183460469231731687303715884105727L,331780596164137120496034969018767441441L), 2L)", + "Std.Math.ContinuedFractionConvergentL((170141183460469231731687303715884105727L,331780596164137120496034969018767441441L), 2L)", &Value::Tuple( vec![ Value::BigInt(BigInt::from(1)), @@ -641,7 +641,7 @@ fn check_cfc_l() { ), ); test_expression( - "Microsoft.Quantum.Math.ContinuedFractionConvergentL((170141183460469231731687303715884105727L,331780596164137120496034969018767441441L), 1000000L)", + "Std.Math.ContinuedFractionConvergentL((170141183460469231731687303715884105727L,331780596164137120496034969018767441441L), 1000000L)", &Value::Tuple( vec![ Value::BigInt(BigInt::from(33_781)), @@ -666,39 +666,39 @@ fn check_real_mod() { &Value::Double(0.5 * PI), ); test_expression( - "Microsoft.Quantum.Math.RealMod(10.5, 2.3, 1.2)", + "Std.Math.RealMod(10.5, 2.3, 1.2)", &Value::Double(1.3), ); test_expression( - "Microsoft.Quantum.Math.RealMod(3.6, 2.4, -1.2)", + "Std.Math.RealMod(3.6, 2.4, -1.2)", &Value::Double(-1.2), ); } #[test] fn check_bitsize_i() { - test_expression("Microsoft.Quantum.Math.BitSizeI(0)", &Value::Int(0)); - test_expression("Microsoft.Quantum.Math.BitSizeI(1)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.BitSizeI(2)", &Value::Int(2)); - test_expression("Microsoft.Quantum.Math.BitSizeI(3)", &Value::Int(2)); + test_expression("Std.Math.BitSizeI(0)", &Value::Int(0)); + test_expression("Std.Math.BitSizeI(1)", &Value::Int(1)); + test_expression("Std.Math.BitSizeI(2)", &Value::Int(2)); + test_expression("Std.Math.BitSizeI(3)", &Value::Int(2)); test_expression( - "Microsoft.Quantum.Math.BitSizeI(0x7FFFFFFFFFFFFFFF)", + "Std.Math.BitSizeI(0x7FFFFFFFFFFFFFFF)", &Value::Int(63), ); } #[test] fn check_bitsize_l() { - test_expression("Microsoft.Quantum.Math.BitSizeL(0L)", &Value::Int(0)); - test_expression("Microsoft.Quantum.Math.BitSizeL(1L)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.BitSizeL(2L)", &Value::Int(2)); - test_expression("Microsoft.Quantum.Math.BitSizeL(3L)", &Value::Int(2)); + test_expression("Std.Math.BitSizeL(0L)", &Value::Int(0)); + test_expression("Std.Math.BitSizeL(1L)", &Value::Int(1)); + test_expression("Std.Math.BitSizeL(2L)", &Value::Int(2)); + test_expression("Std.Math.BitSizeL(3L)", &Value::Int(2)); test_expression( - "Microsoft.Quantum.Math.BitSizeL(0x7FFFFFFFFFFFFFFFL)", + "Std.Math.BitSizeL(0x7FFFFFFFFFFFFFFFL)", &Value::Int(63), ); test_expression( - "Microsoft.Quantum.Math.BitSizeL(0x8FFFFFFFFFFFFFFFL)", + "Std.Math.BitSizeL(0x8FFFFFFFFFFFFFFFL)", &Value::Int(64), ); } @@ -706,15 +706,15 @@ fn check_bitsize_l() { #[test] fn check_trailing_zero_count_i() { test_expression( - "Microsoft.Quantum.Math.TrailingZeroCountI(7)", + "Std.Math.TrailingZeroCountI(7)", &Value::Int(0), ); test_expression( - "Microsoft.Quantum.Math.TrailingZeroCountI(2)", + "Std.Math.TrailingZeroCountI(2)", &Value::Int(1), ); test_expression( - "Microsoft.Quantum.Math.TrailingZeroCountI(7616)", + "Std.Math.TrailingZeroCountI(7616)", &Value::Int(6), ); } @@ -722,25 +722,25 @@ fn check_trailing_zero_count_i() { #[test] fn check_trailing_zero_count_l() { test_expression( - "Microsoft.Quantum.Math.TrailingZeroCountL(7L)", + "Std.Math.TrailingZeroCountL(7L)", &Value::Int(0), ); test_expression( - "Microsoft.Quantum.Math.TrailingZeroCountL(2L)", + "Std.Math.TrailingZeroCountL(2L)", &Value::Int(1), ); test_expression( - "Microsoft.Quantum.Math.TrailingZeroCountL(1L<<<163)", + "Std.Math.TrailingZeroCountL(1L<<<163)", &Value::Int(163), ); } #[test] fn check_hamming_weight() { - test_expression("Microsoft.Quantum.Math.HammingWeightI(2)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.HammingWeightI(14)", &Value::Int(3)); + test_expression("Std.Math.HammingWeightI(2)", &Value::Int(1)); + test_expression("Std.Math.HammingWeightI(14)", &Value::Int(3)); test_expression( - "Microsoft.Quantum.Math.HammingWeightI(1<<<5)", + "Std.Math.HammingWeightI(1<<<5)", &Value::Int(1), ); } @@ -751,11 +751,11 @@ fn check_hamming_weight() { #[test] fn check_factorial_i() { - test_expression("Microsoft.Quantum.Math.FactorialI(0)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.FactorialI(1)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.FactorialI(2)", &Value::Int(2)); + test_expression("Std.Math.FactorialI(0)", &Value::Int(1)); + test_expression("Std.Math.FactorialI(1)", &Value::Int(1)); + test_expression("Std.Math.FactorialI(2)", &Value::Int(2)); test_expression( - "Microsoft.Quantum.Math.FactorialI(10)", + "Std.Math.FactorialI(10)", &Value::Int(3_628_800), ); } @@ -763,23 +763,23 @@ fn check_factorial_i() { #[test] fn check_factorial_l() { test_expression( - "Microsoft.Quantum.Math.FactorialL(0)", + "Std.Math.FactorialL(0)", &Value::BigInt(BigInt::from(1)), ); test_expression( - "Microsoft.Quantum.Math.FactorialL(1)", + "Std.Math.FactorialL(1)", &Value::BigInt(BigInt::from(1)), ); test_expression( - "Microsoft.Quantum.Math.FactorialL(2)", + "Std.Math.FactorialL(2)", &Value::BigInt(BigInt::from(2)), ); test_expression( - "Microsoft.Quantum.Math.FactorialL(10)", + "Std.Math.FactorialL(10)", &Value::BigInt(BigInt::from(3_628_800)), ); test_expression( - "Microsoft.Quantum.Math.FactorialL(170)", + "Std.Math.FactorialL(170)", &Value::BigInt(BigInt::from_str( "7257415615307998967396728211129263114716991681296451376543577798900561843401706157852350749242617459511490991237838520776666022565442753025328900773207510902400430280058295603966612599658257104398558294257568966313439612262571094946806711205568880457193340212661452800000000000000000000000000000000000000000" ).expect("Cannot parse static BigInt in Rust code.")) @@ -789,11 +789,11 @@ fn check_factorial_l() { #[test] fn check_approximate_factorial() { test_expression( - "Microsoft.Quantum.Math.ApproximateFactorial(0)", + "Std.Math.ApproximateFactorial(0)", &Value::Double(1.0), ); test_expression( - "Microsoft.Quantum.Math.ApproximateFactorial(2)", + "Std.Math.ApproximateFactorial(2)", &Value::Double(2.0), ); // NOTE: Tests for larger numbers can be added @@ -803,15 +803,15 @@ fn check_approximate_factorial() { #[test] fn check_log_gamma_d() { test_expression( - "Microsoft.Quantum.Math.LogGammaD(3.14)", + "Std.Math.LogGammaD(3.14)", &Value::Double(0.826_138_704_777_028), ); test_expression( - "Microsoft.Quantum.Math.LogGammaD(0.782)", + "Std.Math.LogGammaD(0.782)", &Value::Double(0.169_806_721_914_044), ); test_expression( - "Microsoft.Quantum.Math.LogGammaD(1234.567)", + "Std.Math.LogGammaD(1234.567)", &Value::Double(7_551.027_809_984_276), ); } @@ -819,11 +819,11 @@ fn check_log_gamma_d() { #[test] fn check_log_factorial_d() { test_expression( - "Microsoft.Quantum.Math.LogFactorialD(2000)", + "Std.Math.LogFactorialD(2000)", &Value::Double(13_206.524_350_513_8), ); test_expression( - "Microsoft.Quantum.Math.LogFactorialD(4321)", + "Std.Math.LogFactorialD(4321)", &Value::Double(31_856.241_848_248_7), ); } @@ -831,27 +831,27 @@ fn check_log_factorial_d() { #[test] fn check_binom() { test_expression( - "Microsoft.Quantum.Math.Binom(31, 7)", + "Std.Math.Binom(31, 7)", &Value::Int(2_629_575), ); - test_expression("Microsoft.Quantum.Math.Binom(23, 9)", &Value::Int(817_190)); - test_expression("Microsoft.Quantum.Math.Binom(13, 5)", &Value::Int(1_287)); - test_expression("Microsoft.Quantum.Math.Binom(4, 0)", &Value::Int(1)); - test_expression("Microsoft.Quantum.Math.Binom(4, 4)", &Value::Int(1)); + test_expression("Std.Math.Binom(23, 9)", &Value::Int(817_190)); + test_expression("Std.Math.Binom(13, 5)", &Value::Int(1_287)); + test_expression("Std.Math.Binom(4, 0)", &Value::Int(1)); + test_expression("Std.Math.Binom(4, 4)", &Value::Int(1)); } #[test] fn check_square_norm() { test_expression( - "Microsoft.Quantum.Math.SquaredNorm([2.0])", + "Std.Math.SquaredNorm([2.0])", &Value::Double(4.0), ); test_expression( - "Microsoft.Quantum.Math.SquaredNorm([-1.0, 1.0])", + "Std.Math.SquaredNorm([-1.0, 1.0])", &Value::Double(2.0), ); test_expression( - "Microsoft.Quantum.Math.SquaredNorm([3.0, 4.0])", + "Std.Math.SquaredNorm([3.0, 4.0])", &Value::Double(25.0), ); } @@ -859,19 +859,19 @@ fn check_square_norm() { #[test] fn check_p_norm() { test_expression( - "Microsoft.Quantum.Math.PNorm(1.0, [-0.1, 0.2, 0.3])", + "Std.Math.PNorm(1.0, [-0.1, 0.2, 0.3])", &Value::Double(0.6), ); test_expression( - "Microsoft.Quantum.Math.PNorm(1.5, [0.1, -0.2, 0.3])", + "Std.Math.PNorm(1.5, [0.1, -0.2, 0.3])", &Value::Double(0.433_462_287_211_361), ); test_expression( - "Microsoft.Quantum.Math.PNorm(2.0, [0.1, 0.2, -0.3])", + "Std.Math.PNorm(2.0, [0.1, 0.2, -0.3])", &Value::Double(0.374_165_738_677_394_17), ); test_expression( - "Microsoft.Quantum.Math.PNorm(3.0, [0.0, 0.0])", + "Std.Math.PNorm(3.0, [0.0, 0.0])", &Value::Double(0.0), ); } @@ -879,7 +879,7 @@ fn check_p_norm() { #[test] fn check_p_normalized() { test_expression( - "Microsoft.Quantum.Math.PNormalized(1.0, [-0.1, 0.2, 0.5])", + "Std.Math.PNormalized(1.0, [-0.1, 0.2, 0.5])", &Value::Array( vec![ Value::Double(-0.125), @@ -890,11 +890,11 @@ fn check_p_normalized() { ), ); test_expression( - "Microsoft.Quantum.Math.PNormalized(2.0, [3.0, 4.0])", + "Std.Math.PNormalized(2.0, [3.0, 4.0])", &Value::Array(vec![Value::Double(0.6), Value::Double(0.8)].into()), ); test_expression( - "Microsoft.Quantum.Math.PNormalized(3.0, [0.0, 0.0])", + "Std.Math.PNormalized(3.0, [0.0, 0.0])", &Value::Array(vec![Value::Double(0.0), Value::Double(0.0)].into()), ); } @@ -1219,15 +1219,15 @@ fn check_devide_by_cp() { #[test] fn check_smallest_fixed_point() { test_expression( - "Microsoft.Quantum.Math.SmallestFixedPoint(1,0)", + "Std.Math.SmallestFixedPoint(1,0)", &Value::Double(-1.0), ); test_expression( - "Microsoft.Quantum.Math.SmallestFixedPoint(0,1)", + "Std.Math.SmallestFixedPoint(0,1)", &Value::Double(-0.5), ); test_expression( - "Microsoft.Quantum.Math.SmallestFixedPoint(10,5)", + "Std.Math.SmallestFixedPoint(10,5)", &Value::Double(-512.0), ); } @@ -1235,15 +1235,15 @@ fn check_smallest_fixed_point() { #[test] fn check_largest_fixed_point() { test_expression( - "Microsoft.Quantum.Math.LargestFixedPoint(1,0)", + "Std.Math.LargestFixedPoint(1,0)", &Value::Double(0.0), ); test_expression( - "Microsoft.Quantum.Math.LargestFixedPoint(0,1)", + "Std.Math.LargestFixedPoint(0,1)", &Value::Double(0.0), ); test_expression( - "Microsoft.Quantum.Math.LargestFixedPoint(10,5)", + "Std.Math.LargestFixedPoint(10,5)", &Value::Double(511.96875), ); } diff --git a/library/src/tests/measurement.rs b/library/src/tests/measurement.rs index c6a5d2533c..577c4ab575 100644 --- a/library/src/tests/measurement.rs +++ b/library/src/tests/measurement.rs @@ -5,14 +5,14 @@ use super::test_expression; use indoc::indoc; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.Measurement namespace +// Tests for Std.Measurement namespace #[test] fn check_measure_all_z() { test_expression( indoc! {r#"{ use register = Qubit[2]; - let result = Microsoft.Quantum.Measurement.MeasureAllZ(register); + let result = Std.Measurement.MeasureAllZ(register); ResetAll(register); result }"#}, @@ -21,8 +21,8 @@ fn check_measure_all_z() { test_expression( indoc! {r#"{ use register = Qubit[2]; - Microsoft.Quantum.Arrays.ForEach(X, register); - let result = Microsoft.Quantum.Measurement.MeasureAllZ(register); + Std.Arrays.ForEach(X, register); + let result = Std.Measurement.MeasureAllZ(register); ResetAll(register); result }"#}, @@ -32,7 +32,7 @@ fn check_measure_all_z() { indoc! {r#"{ use register = Qubit[2]; X(register[0]); - let result = Microsoft.Quantum.Measurement.MeasureAllZ(register); + let result = Std.Measurement.MeasureAllZ(register); ResetAll(register); result }"#}, @@ -42,7 +42,7 @@ fn check_measure_all_z() { indoc! {r#"{ use register = Qubit[2]; X(register[1]); - let result = Microsoft.Quantum.Measurement.MeasureAllZ(register); + let result = Std.Measurement.MeasureAllZ(register); ResetAll(register); result }"#}, @@ -57,7 +57,7 @@ fn check_measure_each_z() { use register = Qubit[3]; X(register[0]); X(register[2]); - let results = Microsoft.Quantum.Measurement.MeasureEachZ(register); + let results = Std.Measurement.MeasureEachZ(register); ResetAll(register); results }"#}, @@ -72,8 +72,8 @@ fn check_mreset_each_z() { use register = Qubit[3]; X(register[0]); X(register[2]); - let resultsA = Microsoft.Quantum.Measurement.MResetEachZ(register); - let resultsB = Microsoft.Quantum.Measurement.MeasureEachZ(register); + let resultsA = Std.Measurement.MResetEachZ(register); + let resultsB = Std.Measurement.MeasureEachZ(register); (resultsA, resultsB) }"#}, &Value::Tuple( @@ -95,9 +95,9 @@ fn check_mreset_x() { indoc! {r#"{ use register = Qubit[2]; X(register[1]); - Microsoft.Quantum.Canon.ApplyToEach(H, register); - let r0 = Microsoft.Quantum.Measurement.MResetX(register[0]); - let r1 = Microsoft.Quantum.Measurement.MResetX(register[1]); + Std.Canon.ApplyToEach(H, register); + let r0 = Std.Measurement.MResetX(register[0]); + let r1 = Std.Measurement.MResetX(register[1]); [r0, r1] }"#}, &Value::Array(vec![Value::RESULT_ZERO, Value::RESULT_ONE].into()), @@ -110,10 +110,10 @@ fn check_mreset_y() { indoc! {r#"{ use register = Qubit[2]; X(register[1]); - Microsoft.Quantum.Canon.ApplyToEach(H, register); - Microsoft.Quantum.Canon.ApplyToEach(S, register); - let r0 = Microsoft.Quantum.Measurement.MResetY(register[0]); - let r1 = Microsoft.Quantum.Measurement.MResetY(register[1]); + Std.Canon.ApplyToEach(H, register); + Std.Canon.ApplyToEach(S, register); + let r0 = Std.Measurement.MResetY(register[0]); + let r1 = Std.Measurement.MResetY(register[1]); [r0, r1] }"#}, &Value::Array(vec![Value::RESULT_ZERO, Value::RESULT_ONE].into()), @@ -126,8 +126,8 @@ fn check_mreset_z() { indoc! {r#"{ use register = Qubit[2]; X(register[1]); - let r0 = Microsoft.Quantum.Measurement.MResetZ(register[0]); - let r1 = Microsoft.Quantum.Measurement.MResetZ(register[1]); + let r0 = Std.Measurement.MResetZ(register[0]); + let r1 = Std.Measurement.MResetZ(register[1]); [r0, r1] }"#}, &Value::Array(vec![Value::RESULT_ZERO, Value::RESULT_ONE].into()), diff --git a/library/src/tests/state_preparation.rs b/library/src/tests/state_preparation.rs index da5e530f10..1e4b212bd5 100644 --- a/library/src/tests/state_preparation.rs +++ b/library/src/tests/state_preparation.rs @@ -7,7 +7,7 @@ use super::test_expression_with_lib; use expect_test::expect; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.StatePreparation namespace +// Tests for Std.StatePreparation namespace const STATE_PREPARATION_TEST_LIB: &str = include_str!("resources/src/state_preparation.qs"); @@ -242,8 +242,8 @@ fn check_preparation_doc_sample() { import Std.Math.*; let amplitudes = [Sqrt(0.125), 0.0, Sqrt(0.875), 0.0]; use qubits = Qubit[2]; - Microsoft.Quantum.Unstable.StatePreparation.PreparePureStateD(amplitudes, qubits); - Microsoft.Quantum.Diagnostics.DumpMachine(); + Std.StatePreparation.PreparePureStateD(amplitudes, qubits); + Std.Diagnostics.DumpMachine(); ResetAll(qubits); }", &Value::Tuple(vec![].into(), None), ); diff --git a/library/src/tests/table_lookup.rs b/library/src/tests/table_lookup.rs index 1ed95b5d55..ac0e0c1eb3 100644 --- a/library/src/tests/table_lookup.rs +++ b/library/src/tests/table_lookup.rs @@ -4,7 +4,7 @@ use super::test_expression_with_lib; use qsc::interpret::Value; -// Tests for Microsoft.Quantum.TableLookup namespace +// Tests for Std.TableLookup namespace const SELECT_TEST_LIB: &str = include_str!("resources/src/select.qs"); From 2c545d9949a83cb7132155ee0876abe690ffa88f Mon Sep 17 00:00:00 2001 From: Dima Fedoriaka Date: Mon, 27 Apr 2026 09:53:39 -0700 Subject: [PATCH 3/3] cargo fmt --- library/src/tests/arrays.rs | 30 +--- library/src/tests/convert.rs | 20 +-- library/src/tests/logical.rs | 20 +-- library/src/tests/math.rs | 340 +++++++---------------------------- 4 files changed, 82 insertions(+), 328 deletions(-) diff --git a/library/src/tests/arrays.rs b/library/src/tests/arrays.rs index 80e7d98fe1..f24eda6502 100644 --- a/library/src/tests/arrays.rs +++ b/library/src/tests/arrays.rs @@ -362,18 +362,9 @@ fn check_index_of() { #[test] fn check_index_range() { - test_expression( - "Std.Arrays.IndexRange([7,6,5,4])::Start", - &Value::Int(0), - ); - test_expression( - "Std.Arrays.IndexRange([7,6,5,4])::Step", - &Value::Int(1), - ); - test_expression( - "Std.Arrays.IndexRange([7,6,5,4])::End", - &Value::Int(3), - ); + test_expression("Std.Arrays.IndexRange([7,6,5,4])::Start", &Value::Int(0)); + test_expression("Std.Arrays.IndexRange([7,6,5,4])::Step", &Value::Int(1)); + test_expression("Std.Arrays.IndexRange([7,6,5,4])::End", &Value::Int(3)); } #[test] @@ -408,10 +399,7 @@ fn check_is_empty() { &Value::Bool(true), ); test_expression("Std.Arrays.IsEmpty([1])", &Value::Bool(false)); - test_expression( - "Std.Arrays.IsEmpty([1, 2, 3, 4, 5])", - &Value::Bool(false), - ); + test_expression("Std.Arrays.IsEmpty([1, 2, 3, 4, 5])", &Value::Bool(false)); } #[test] @@ -423,10 +411,7 @@ fn check_is_rectangular_array() { }", &Value::Bool(true), ); - test_expression( - "Std.Arrays.IsRectangularArray([[1]])", - &Value::Bool(true), - ); + test_expression("Std.Arrays.IsRectangularArray([[1]])", &Value::Bool(true)); test_expression( "Std.Arrays.IsRectangularArray([[1, 2], [3, 4]])", &Value::Bool(true), @@ -481,10 +466,7 @@ fn check_is_square_array() { }", &Value::Bool(true), ); - test_expression( - "Std.Arrays.IsSquareArray([[1]])", - &Value::Bool(true), - ); + test_expression("Std.Arrays.IsSquareArray([[1]])", &Value::Bool(true)); test_expression( "Std.Arrays.IsSquareArray([[1, 2], [3, 4]])", &Value::Bool(true), diff --git a/library/src/tests/convert.rs b/library/src/tests/convert.rs index 14a90b6fff..865de9f04a 100644 --- a/library/src/tests/convert.rs +++ b/library/src/tests/convert.rs @@ -219,18 +219,12 @@ fn check_result_array_as_int() { #[test] fn check_result_zero_as_bool() { - test_expression( - "Std.Convert.ResultAsBool(Zero)", - &Value::Bool(false), - ); + test_expression("Std.Convert.ResultAsBool(Zero)", &Value::Bool(false)); } #[test] fn check_result_one_as_bool() { - test_expression( - "Std.Convert.ResultAsBool(One)", - &Value::Bool(true), - ); + test_expression("Std.Convert.ResultAsBool(One)", &Value::Bool(true)); } #[test] @@ -251,18 +245,12 @@ fn check_result_array_as_bool_array() { #[test] fn check_bool_true_as_result() { - test_expression( - "Std.Convert.BoolAsResult(true)", - &Value::RESULT_ONE, - ); + test_expression("Std.Convert.BoolAsResult(true)", &Value::RESULT_ONE); } #[test] fn check_bool_false_as_result() { - test_expression( - "Std.Convert.BoolAsResult(false)", - &Value::RESULT_ZERO, - ); + test_expression("Std.Convert.BoolAsResult(false)", &Value::RESULT_ZERO); } #[test] diff --git a/library/src/tests/logical.rs b/library/src/tests/logical.rs index b652084ec9..f4ed8752a5 100644 --- a/library/src/tests/logical.rs +++ b/library/src/tests/logical.rs @@ -8,20 +8,8 @@ use qsc::interpret::Value; #[test] fn check_xor() { - test_expression( - "Std.Logical.Xor(false, false)", - &Value::Bool(false), - ); - test_expression( - "Std.Logical.Xor(false, true)", - &Value::Bool(true), - ); - test_expression( - "Std.Logical.Xor(true, false)", - &Value::Bool(true), - ); - test_expression( - "Std.Logical.Xor(true, true)", - &Value::Bool(false), - ); + test_expression("Std.Logical.Xor(false, false)", &Value::Bool(false)); + test_expression("Std.Logical.Xor(false, true)", &Value::Bool(true)); + test_expression("Std.Logical.Xor(true, false)", &Value::Bool(true)); + test_expression("Std.Logical.Xor(true, true)", &Value::Bool(false)); } diff --git a/library/src/tests/math.rs b/library/src/tests/math.rs index f1dc4f3d10..1858ec0603 100644 --- a/library/src/tests/math.rs +++ b/library/src/tests/math.rs @@ -9,26 +9,17 @@ use std::{f64::consts::PI, str::FromStr}; #[test] fn check_pi() { - test_expression( - "Std.Math.PI()", - &Value::Double(std::f64::consts::PI), - ); + test_expression("Std.Math.PI()", &Value::Double(std::f64::consts::PI)); } #[test] fn check_e() { - test_expression( - "Std.Math.E()", - &Value::Double(std::f64::consts::E), - ); + test_expression("Std.Math.E()", &Value::Double(std::f64::consts::E)); } #[test] fn check_log_of_2() { - test_expression( - "Std.Math.LogOf2()", - &Value::Double(std::f64::consts::LN_2), - ); + test_expression("Std.Math.LogOf2()", &Value::Double(std::f64::consts::LN_2)); } // @@ -37,31 +28,16 @@ fn check_log_of_2() { #[test] fn check_is_nan() { - test_expression( - "Std.Math.IsNaN(0.0 / 0.0)", - &Value::Bool(true), - ); + test_expression("Std.Math.IsNaN(0.0 / 0.0)", &Value::Bool(true)); test_expression("Std.Math.IsNaN(1.0)", &Value::Bool(false)); - test_expression( - "Std.Math.IsNaN(Std.Math.ArcSin(2.0))", - &Value::Bool(true), - ); + test_expression("Std.Math.IsNaN(Std.Math.ArcSin(2.0))", &Value::Bool(true)); } #[test] fn check_is_infinite() { - test_expression( - "Std.Math.IsInfinite(1.0 / 0.0)", - &Value::Bool(true), - ); - test_expression( - "Std.Math.IsInfinite(0.0 / 0.0)", - &Value::Bool(false), - ); - test_expression( - "Std.Math.IsInfinite(-1.0 / 0.0)", - &Value::Bool(true), - ); + test_expression("Std.Math.IsInfinite(1.0 / 0.0)", &Value::Bool(true)); + test_expression("Std.Math.IsInfinite(0.0 / 0.0)", &Value::Bool(false)); + test_expression("Std.Math.IsInfinite(-1.0 / 0.0)", &Value::Bool(true)); } // @@ -115,18 +91,9 @@ fn check_abs_d() { #[test] fn check_abs_l() { - test_expression( - "Std.Math.AbsL(0L)", - &Value::BigInt(BigInt::from(0)), - ); - test_expression( - "Std.Math.AbsL(9999L)", - &Value::BigInt(BigInt::from(9999)), - ); - test_expression( - "Std.Math.AbsL(-9999L)", - &Value::BigInt(BigInt::from(9999)), - ); + test_expression("Std.Math.AbsL(0L)", &Value::BigInt(BigInt::from(0))); + test_expression("Std.Math.AbsL(9999L)", &Value::BigInt(BigInt::from(9999))); + test_expression("Std.Math.AbsL(-9999L)", &Value::BigInt(BigInt::from(9999))); } #[test] @@ -143,14 +110,8 @@ fn check_max_d() { #[test] fn check_max_l() { - test_expression( - "Std.Math.MaxL(-5L,7L)", - &Value::BigInt(BigInt::from(7)), - ); - test_expression( - "Std.Math.MaxL(-7L,0L)", - &Value::BigInt(BigInt::from(0)), - ); + test_expression("Std.Math.MaxL(-5L,7L)", &Value::BigInt(BigInt::from(7))); + test_expression("Std.Math.MaxL(-7L,0L)", &Value::BigInt(BigInt::from(0))); } #[test] @@ -161,44 +122,26 @@ fn check_min_i() { #[test] fn check_min_d() { - test_expression( - "Std.Math.MinD(-5.0,7.0)", - &Value::Double(-5.0), - ); - test_expression( - "Std.Math.MinD(-7.0,0.0)", - &Value::Double(-7.0), - ); + test_expression("Std.Math.MinD(-5.0,7.0)", &Value::Double(-5.0)); + test_expression("Std.Math.MinD(-7.0,0.0)", &Value::Double(-7.0)); } #[test] fn check_min_l() { - test_expression( - "Std.Math.MinL(-5L,7L)", - &Value::BigInt(BigInt::from(-5)), - ); - test_expression( - "Std.Math.MinL(-7L,0L)", - &Value::BigInt(BigInt::from(-7)), - ); + test_expression("Std.Math.MinL(-5L,7L)", &Value::BigInt(BigInt::from(-5))); + test_expression("Std.Math.MinL(-7L,0L)", &Value::BigInt(BigInt::from(-7))); } #[test] fn check_min() { - test_expression( - "Std.Math.Min([-5, 7, 1, 10])", - &Value::Int(-5), - ); + test_expression("Std.Math.Min([-5, 7, 1, 10])", &Value::Int(-5)); test_expression("Std.Math.Min([5, 7, 1, 10])", &Value::Int(1)); test_expression("Std.Math.Min([1])", &Value::Int(1)); } #[test] fn check_max() { - test_expression( - "Std.Math.Max([10, 7, 1, -20])", - &Value::Int(10), - ); + test_expression("Std.Math.Max([10, 7, 1, -20])", &Value::Int(10)); test_expression("Std.Math.Max([5, 7, 1, 20])", &Value::Int(20)); test_expression("Std.Math.Max([1])", &Value::Int(1)); } @@ -209,26 +152,17 @@ fn check_max() { #[test] fn check_arccos() { - test_expression( - "Std.Math.ArcCos(0.43)", - &Value::Double(0.43_f64.acos()), - ); + test_expression("Std.Math.ArcCos(0.43)", &Value::Double(0.43_f64.acos())); } #[test] fn check_arcsin() { - test_expression( - "Std.Math.ArcSin(0.43)", - &Value::Double(0.43_f64.asin()), - ); + test_expression("Std.Math.ArcSin(0.43)", &Value::Double(0.43_f64.asin())); } #[test] fn check_arctan() { - test_expression( - "Std.Math.ArcTan(43.43)", - &Value::Double(43.43_f64.atan()), - ); + test_expression("Std.Math.ArcTan(43.43)", &Value::Double(43.43_f64.atan())); } #[test] @@ -241,74 +175,47 @@ fn check_arctan2() { #[test] fn check_cos() { - test_expression( - "Std.Math.Cos(1.11)", - &Value::Double(1.11_f64.cos()), - ); + test_expression("Std.Math.Cos(1.11)", &Value::Double(1.11_f64.cos())); } #[test] fn check_cosh() { - test_expression( - "Std.Math.Cosh(1.11)", - &Value::Double(1.11_f64.cosh()), - ); + test_expression("Std.Math.Cosh(1.11)", &Value::Double(1.11_f64.cosh())); } #[test] fn check_sin() { - test_expression( - "Std.Math.Sin(2.22)", - &Value::Double(2.22_f64.sin()), - ); + test_expression("Std.Math.Sin(2.22)", &Value::Double(2.22_f64.sin())); } #[test] fn check_sinh() { - test_expression( - "Std.Math.Sinh(2.22)", - &Value::Double(2.22_f64.sinh()), - ); + test_expression("Std.Math.Sinh(2.22)", &Value::Double(2.22_f64.sinh())); } #[test] fn check_tan() { - test_expression( - "Std.Math.Tan(1.23)", - &Value::Double(1.23_f64.tan()), - ); + test_expression("Std.Math.Tan(1.23)", &Value::Double(1.23_f64.tan())); } #[test] fn check_tanh() { - test_expression( - "Std.Math.Tanh(1.23)", - &Value::Double(1.23_f64.tanh()), - ); + test_expression("Std.Math.Tanh(1.23)", &Value::Double(1.23_f64.tanh())); } #[test] fn check_arccosh() { - test_expression( - "Std.Math.ArcCosh(1.234)", - &Value::Double(1.234_f64.acosh()), - ); + test_expression("Std.Math.ArcCosh(1.234)", &Value::Double(1.234_f64.acosh())); } #[test] fn check_arcsinh() { - test_expression( - "Std.Math.ArcSinh(10.0)", - &Value::Double(10.0_f64.asinh()), - ); + test_expression("Std.Math.ArcSinh(10.0)", &Value::Double(10.0_f64.asinh())); } #[test] fn check_arctanh() { - test_expression( - "Std.Math.ArcTanh(0.5)", - &Value::Double(0.5_f64.atanh()), - ); + test_expression("Std.Math.ArcTanh(0.5)", &Value::Double(0.5_f64.atanh())); } // @@ -317,18 +224,12 @@ fn check_arctanh() { #[test] fn check_sqrt() { - test_expression( - "Std.Math.Sqrt(57121.0)", - &Value::Double(239.0), - ); + test_expression("Std.Math.Sqrt(57121.0)", &Value::Double(239.0)); } #[test] fn check_log() { - test_expression( - "Std.Math.Log(57121.0)", - &Value::Double(57121.0_f64.ln()), - ); + test_expression("Std.Math.Log(57121.0)", &Value::Double(57121.0_f64.ln())); } #[test] @@ -502,10 +403,7 @@ fn check_inverse_mod_l() { // #[test] fn check_gcd_i() { - test_expression( - "Std.Math.GreatestCommonDivisorI(0,0)", - &Value::Int(0), - ); + test_expression("Std.Math.GreatestCommonDivisorI(0,0)", &Value::Int(0)); test_expression( "Std.Math.GreatestCommonDivisorI(2*3*5,2*3*7)", &Value::Int(2 * 3), @@ -534,18 +432,9 @@ fn check_gcd_l() { #[test] fn check_is_coprime_i() { - test_expression( - "Std.Math.IsCoprimeI(44,35)", - &Value::Bool(true), - ); - test_expression( - "Std.Math.IsCoprimeI(6,9)", - &Value::Bool(false), - ); - test_expression( - "Std.Math.IsCoprimeI(1, -1)", - &Value::Bool(true), - ); + test_expression("Std.Math.IsCoprimeI(44,35)", &Value::Bool(true)); + test_expression("Std.Math.IsCoprimeI(6,9)", &Value::Bool(false)); + test_expression("Std.Math.IsCoprimeI(1, -1)", &Value::Bool(true)); } #[test] @@ -554,14 +443,8 @@ fn check_is_coprime_l() { "Std.Math.IsCoprimeL(739696442014594807059393047166976L,7609583501588058567047119140625L)", &Value::Bool(true), ); - test_expression( - "Std.Math.IsCoprimeL(6L,9L)", - &Value::Bool(false), - ); - test_expression( - "Std.Math.IsCoprimeL(1L, -1L)", - &Value::Bool(true), - ); + test_expression("Std.Math.IsCoprimeL(6L,9L)", &Value::Bool(false)); + test_expression("Std.Math.IsCoprimeL(1L, -1L)", &Value::Bool(true)); } #[test] @@ -665,14 +548,8 @@ fn check_real_mod() { RealMod(0.5 * PI(), 2.0 * PI(), -PI()/2.0) }", &Value::Double(0.5 * PI), ); - test_expression( - "Std.Math.RealMod(10.5, 2.3, 1.2)", - &Value::Double(1.3), - ); - test_expression( - "Std.Math.RealMod(3.6, 2.4, -1.2)", - &Value::Double(-1.2), - ); + test_expression("Std.Math.RealMod(10.5, 2.3, 1.2)", &Value::Double(1.3)); + test_expression("Std.Math.RealMod(3.6, 2.4, -1.2)", &Value::Double(-1.2)); } #[test] @@ -681,10 +558,7 @@ fn check_bitsize_i() { test_expression("Std.Math.BitSizeI(1)", &Value::Int(1)); test_expression("Std.Math.BitSizeI(2)", &Value::Int(2)); test_expression("Std.Math.BitSizeI(3)", &Value::Int(2)); - test_expression( - "Std.Math.BitSizeI(0x7FFFFFFFFFFFFFFF)", - &Value::Int(63), - ); + test_expression("Std.Math.BitSizeI(0x7FFFFFFFFFFFFFFF)", &Value::Int(63)); } #[test] @@ -693,56 +567,29 @@ fn check_bitsize_l() { test_expression("Std.Math.BitSizeL(1L)", &Value::Int(1)); test_expression("Std.Math.BitSizeL(2L)", &Value::Int(2)); test_expression("Std.Math.BitSizeL(3L)", &Value::Int(2)); - test_expression( - "Std.Math.BitSizeL(0x7FFFFFFFFFFFFFFFL)", - &Value::Int(63), - ); - test_expression( - "Std.Math.BitSizeL(0x8FFFFFFFFFFFFFFFL)", - &Value::Int(64), - ); + test_expression("Std.Math.BitSizeL(0x7FFFFFFFFFFFFFFFL)", &Value::Int(63)); + test_expression("Std.Math.BitSizeL(0x8FFFFFFFFFFFFFFFL)", &Value::Int(64)); } #[test] fn check_trailing_zero_count_i() { - test_expression( - "Std.Math.TrailingZeroCountI(7)", - &Value::Int(0), - ); - test_expression( - "Std.Math.TrailingZeroCountI(2)", - &Value::Int(1), - ); - test_expression( - "Std.Math.TrailingZeroCountI(7616)", - &Value::Int(6), - ); + test_expression("Std.Math.TrailingZeroCountI(7)", &Value::Int(0)); + test_expression("Std.Math.TrailingZeroCountI(2)", &Value::Int(1)); + test_expression("Std.Math.TrailingZeroCountI(7616)", &Value::Int(6)); } #[test] fn check_trailing_zero_count_l() { - test_expression( - "Std.Math.TrailingZeroCountL(7L)", - &Value::Int(0), - ); - test_expression( - "Std.Math.TrailingZeroCountL(2L)", - &Value::Int(1), - ); - test_expression( - "Std.Math.TrailingZeroCountL(1L<<<163)", - &Value::Int(163), - ); + test_expression("Std.Math.TrailingZeroCountL(7L)", &Value::Int(0)); + test_expression("Std.Math.TrailingZeroCountL(2L)", &Value::Int(1)); + test_expression("Std.Math.TrailingZeroCountL(1L<<<163)", &Value::Int(163)); } #[test] fn check_hamming_weight() { test_expression("Std.Math.HammingWeightI(2)", &Value::Int(1)); test_expression("Std.Math.HammingWeightI(14)", &Value::Int(3)); - test_expression( - "Std.Math.HammingWeightI(1<<<5)", - &Value::Int(1), - ); + test_expression("Std.Math.HammingWeightI(1<<<5)", &Value::Int(1)); } // @@ -754,26 +601,14 @@ fn check_factorial_i() { test_expression("Std.Math.FactorialI(0)", &Value::Int(1)); test_expression("Std.Math.FactorialI(1)", &Value::Int(1)); test_expression("Std.Math.FactorialI(2)", &Value::Int(2)); - test_expression( - "Std.Math.FactorialI(10)", - &Value::Int(3_628_800), - ); + test_expression("Std.Math.FactorialI(10)", &Value::Int(3_628_800)); } #[test] fn check_factorial_l() { - test_expression( - "Std.Math.FactorialL(0)", - &Value::BigInt(BigInt::from(1)), - ); - test_expression( - "Std.Math.FactorialL(1)", - &Value::BigInt(BigInt::from(1)), - ); - test_expression( - "Std.Math.FactorialL(2)", - &Value::BigInt(BigInt::from(2)), - ); + test_expression("Std.Math.FactorialL(0)", &Value::BigInt(BigInt::from(1))); + test_expression("Std.Math.FactorialL(1)", &Value::BigInt(BigInt::from(1))); + test_expression("Std.Math.FactorialL(2)", &Value::BigInt(BigInt::from(2))); test_expression( "Std.Math.FactorialL(10)", &Value::BigInt(BigInt::from(3_628_800)), @@ -788,14 +623,8 @@ fn check_factorial_l() { #[test] fn check_approximate_factorial() { - test_expression( - "Std.Math.ApproximateFactorial(0)", - &Value::Double(1.0), - ); - test_expression( - "Std.Math.ApproximateFactorial(2)", - &Value::Double(2.0), - ); + test_expression("Std.Math.ApproximateFactorial(0)", &Value::Double(1.0)); + test_expression("Std.Math.ApproximateFactorial(2)", &Value::Double(2.0)); // NOTE: Tests for larger numbers can be added // when approximate comparison is implemented. } @@ -830,10 +659,7 @@ fn check_log_factorial_d() { #[test] fn check_binom() { - test_expression( - "Std.Math.Binom(31, 7)", - &Value::Int(2_629_575), - ); + test_expression("Std.Math.Binom(31, 7)", &Value::Int(2_629_575)); test_expression("Std.Math.Binom(23, 9)", &Value::Int(817_190)); test_expression("Std.Math.Binom(13, 5)", &Value::Int(1_287)); test_expression("Std.Math.Binom(4, 0)", &Value::Int(1)); @@ -842,26 +668,14 @@ fn check_binom() { #[test] fn check_square_norm() { - test_expression( - "Std.Math.SquaredNorm([2.0])", - &Value::Double(4.0), - ); - test_expression( - "Std.Math.SquaredNorm([-1.0, 1.0])", - &Value::Double(2.0), - ); - test_expression( - "Std.Math.SquaredNorm([3.0, 4.0])", - &Value::Double(25.0), - ); + test_expression("Std.Math.SquaredNorm([2.0])", &Value::Double(4.0)); + test_expression("Std.Math.SquaredNorm([-1.0, 1.0])", &Value::Double(2.0)); + test_expression("Std.Math.SquaredNorm([3.0, 4.0])", &Value::Double(25.0)); } #[test] fn check_p_norm() { - test_expression( - "Std.Math.PNorm(1.0, [-0.1, 0.2, 0.3])", - &Value::Double(0.6), - ); + test_expression("Std.Math.PNorm(1.0, [-0.1, 0.2, 0.3])", &Value::Double(0.6)); test_expression( "Std.Math.PNorm(1.5, [0.1, -0.2, 0.3])", &Value::Double(0.433_462_287_211_361), @@ -870,10 +684,7 @@ fn check_p_norm() { "Std.Math.PNorm(2.0, [0.1, 0.2, -0.3])", &Value::Double(0.374_165_738_677_394_17), ); - test_expression( - "Std.Math.PNorm(3.0, [0.0, 0.0])", - &Value::Double(0.0), - ); + test_expression("Std.Math.PNorm(3.0, [0.0, 0.0])", &Value::Double(0.0)); } #[test] @@ -1218,30 +1029,15 @@ fn check_devide_by_cp() { #[test] fn check_smallest_fixed_point() { - test_expression( - "Std.Math.SmallestFixedPoint(1,0)", - &Value::Double(-1.0), - ); - test_expression( - "Std.Math.SmallestFixedPoint(0,1)", - &Value::Double(-0.5), - ); - test_expression( - "Std.Math.SmallestFixedPoint(10,5)", - &Value::Double(-512.0), - ); + test_expression("Std.Math.SmallestFixedPoint(1,0)", &Value::Double(-1.0)); + test_expression("Std.Math.SmallestFixedPoint(0,1)", &Value::Double(-0.5)); + test_expression("Std.Math.SmallestFixedPoint(10,5)", &Value::Double(-512.0)); } #[test] fn check_largest_fixed_point() { - test_expression( - "Std.Math.LargestFixedPoint(1,0)", - &Value::Double(0.0), - ); - test_expression( - "Std.Math.LargestFixedPoint(0,1)", - &Value::Double(0.0), - ); + test_expression("Std.Math.LargestFixedPoint(1,0)", &Value::Double(0.0)); + test_expression("Std.Math.LargestFixedPoint(0,1)", &Value::Double(0.0)); test_expression( "Std.Math.LargestFixedPoint(10,5)", &Value::Double(511.96875),