From 7514758b8c2b1f6dcd31546e891f0ae714d38017 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 15 Jan 2021 16:05:56 +0100 Subject: [PATCH] [Run][Calculator Plugin] Add hyperbolic functions (#9104) * Add hyperbolic functions as valid input * Add test cases for hyperbolic functions * Update expect.txt Adding in spelling Co-authored-by: Clint Rutkas --- .github/actions/spell-check/expect.txt | 3 +++ .../ExtendedCalculatorParserTests.cs | 6 ++++++ .../Plugins/Microsoft.Plugin.Calculator/CalculateHelper.cs | 1 + 3 files changed, 10 insertions(+) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 2e2d0f9723..319a31be1f 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -86,6 +86,9 @@ appx appxmanifest APSTUDIO AQS +arcosh +arsinh +artanh ARemapped argb argc diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs index 30036aa3cf..85c63e7354 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs @@ -62,6 +62,7 @@ namespace Microsoft.Plugin.Calculator.UnitTests [TestCase("8.43 + 4.43 - 12.86", 0D)] [TestCase("8.43 + 4.43 - 12.8", 0.06D)] [TestCase("exp(5)", 148.413159102577D)] + [TestCase("cosh(0)", 1D)] public void Interpret_NoErrors_WhenCalledWithRounding(string input, decimal expectedResult) { // Arrange @@ -120,6 +121,10 @@ namespace Microsoft.Plugin.Calculator.UnitTests [TestCase("sqrt( 36)", true)] [TestCase("max 4", false)] [TestCase("sin(0)", true)] + [TestCase("sinh(1)", true)] + [TestCase("tanh(0)", true)] + [TestCase("artanh(pi/2)", true)] + [TestCase("cosh", false)] [TestCase("cos", false)] [TestCase("abs", false)] [TestCase("1+1.1e3", true)] @@ -136,6 +141,7 @@ namespace Microsoft.Plugin.Calculator.UnitTests [TestCase("1-1")] [TestCase("sin(0)")] + [TestCase("sinh(0)")] public void Interpret_MustReturnResult_WhenResultIsZero(string input) { // Arrange diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/CalculateHelper.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/CalculateHelper.cs index 30c81b1652..281312bd07 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/CalculateHelper.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Calculator/CalculateHelper.cs @@ -14,6 +14,7 @@ namespace Microsoft.Plugin.Calculator @"ceil\s*\(|floor\s*\(|exp\s*\(|max\s*\(|min\s*\(|abs\s*\(|log\s*\(|ln\s*\(|sqrt\s*\(|pow\s*\(|" + @"factorial\s*\(|sign\s*\(|round\s*\(|rand\s*\(|" + @"sin\s*\(|cos\s*\(|tan\s*\(|arcsin\s*\(|arccos\s*\(|arctan\s*\(|" + + @"sinh\s*\(|cosh\s*\(|tanh\s*\(|arsinh\s*\(|arcosh\s*\(|artanh\s*\(|" + @"pi|" + @"==|~=|&&|\|\||" + @"e|[0-9]|[\+\-\*\/\^\., ""]|[\(\)\|\!\[\]]" +