From a81bc2e7b5a88d3fe1e99a577e7e308c3502fd5d Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Tue, 28 Jun 2022 17:25:06 +0100 Subject: [PATCH] [PTRun][Calculator]Update Mages to 2.0.1 (#19087) * [PTRun][Calculator]Update Mages to 2.0.1 * Fix tests for the new precision --- .../ExtendedCalculatorParserTests.cs | 25 +++++++++++++++++-- ...oft.PowerToys.Run.Plugin.Calculator.csproj | 2 +- .../PowerLauncher/PowerLauncher.csproj | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs index 016718308b..288bbbc9a4 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs @@ -97,8 +97,6 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests private static IEnumerable Interpret_QuirkOutput_WhenCalled_Data => new[] { - new object[] { "0.100000000000000000000", 0.00776627963145224M }, // BUG: Because data structure - new object[] { "0.200000000000000000000000", 0.000000400752841041379M }, // BUG: Because data structure new object[] { "123 456", 56088M }, // BUG: Framework accepts ' ' as multiplication }; @@ -118,6 +116,29 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests Assert.AreEqual(expectedResult, result.Result); } + private static IEnumerable Interpret_GreaterPrecision_WhenCalled_Data => + new[] + { + new object[] { "0.100000000000000000000", 0.1M }, + new object[] { "0.200000000000000000000000", 0.2M }, + }; + + [DynamicData(nameof(Interpret_GreaterPrecision_WhenCalled_Data))] + [DataTestMethod] + public void Interpret_GreaterPrecision_WhenCalled(string input, decimal expectedResult) + { + // Arrange + var engine = new CalculateEngine(); + + // Act + // Using InvariantCulture since this is internal + var result = engine.Interpret(input, CultureInfo.InvariantCulture, out _); + + // Assert + Assert.IsNotNull(result); + Assert.AreEqual(expectedResult, result.Result); + } + private static IEnumerable Interpret_DifferentCulture_WhenCalled_Data => new[] { diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Microsoft.PowerToys.Run.Plugin.Calculator.csproj b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Microsoft.PowerToys.Run.Plugin.Calculator.csproj index ae997f5c50..0818702571 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Microsoft.PowerToys.Run.Plugin.Calculator.csproj +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Microsoft.PowerToys.Run.Plugin.Calculator.csproj @@ -45,7 +45,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj index e88f3f19d3..578dca1f85 100644 --- a/src/modules/launcher/PowerLauncher/PowerLauncher.csproj +++ b/src/modules/launcher/PowerLauncher/PowerLauncher.csproj @@ -80,7 +80,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive