lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject lucenenet git commit: BUG: Lucene.Net.Tests.Expressions.JS.TestJavascriptFunction - Need to build stings using the invariant culture, or a comma may be inserted into a single parameter making it look like 2 parameters to the parser
Date Thu, 02 Mar 2017 19:53:22 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/api-work bf68997d4 -> b812247eb


BUG: Lucene.Net.Tests.Expressions.JS.TestJavascriptFunction - Need to build stings using the
invariant culture, or a comma may be inserted into a single parameter making it look like
2 parameters to the parser


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/b812247e
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/b812247e
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/b812247e

Branch: refs/heads/api-work
Commit: b812247eb54d887c0cb2eecd71e8a5d2da67a522
Parents: bf68997
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Fri Mar 3 02:28:17 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Fri Mar 3 02:28:17 2017 +0700

----------------------------------------------------------------------
 .../JS/TestJavascriptFunction.cs                | 62 ++++++++++++++------
 1 file changed, 45 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b812247e/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptFunction.cs b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptFunction.cs
index d15995c..f9ff011 100644
--- a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptFunction.cs
+++ b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptFunction.cs
@@ -1,6 +1,7 @@
 using Lucene.Net.Util;
 using NUnit.Framework;
 using System;
+using System.Globalization;
 
 namespace Lucene.Net.Expressions.JS
 {
@@ -141,15 +142,27 @@ namespace Lucene.Net.Expressions.JS
         [Test]
         public virtual void TestCosMethod()
         {
+            //AssertEvaluatesTo("cos(0)", 1);
+            //AssertEvaluatesTo("cos(" + Math.PI / 2 + ")", 0);
+            //AssertEvaluatesTo("cos(" + -Math.PI / 2 + ")", 0);
+            //AssertEvaluatesTo("cos(" + Math.PI / 4 + ")", 0.7071068);
+            //AssertEvaluatesTo("cos(" + -Math.PI / 4 + ")", 0.7071068);
+            //AssertEvaluatesTo("cos(" + Math.PI * 2 / 3 + ")", -0.5);
+            //AssertEvaluatesTo("cos(" + -Math.PI * 2 / 3 + ")", -0.5);
+            //AssertEvaluatesTo("cos(" + Math.PI / 6 + ")", 0.8660254);
+            //AssertEvaluatesTo("cos(" + -Math.PI / 6 + ")", 0.8660254);
+
+            // LUCENENET specific - need to apply invariant culture to the string concatenation
+            // to ensure the numeric formatting is correct, otherwise it may look like the
wrong number of parameters
             AssertEvaluatesTo("cos(0)", 1);
-            AssertEvaluatesTo("cos(" + Math.PI / 2 + ")", 0);
-            AssertEvaluatesTo("cos(" + -Math.PI / 2 + ")", 0);
-            AssertEvaluatesTo("cos(" + Math.PI / 4 + ")", 0.7071068);
-            AssertEvaluatesTo("cos(" + -Math.PI / 4 + ")", 0.7071068);
-            AssertEvaluatesTo("cos(" + Math.PI * 2 / 3 + ")", -0.5);
-            AssertEvaluatesTo("cos(" + -Math.PI * 2 / 3 + ")", -0.5);
-            AssertEvaluatesTo("cos(" + Math.PI / 6 + ")", 0.8660254);
-            AssertEvaluatesTo("cos(" + -Math.PI / 6 + ")", 0.8660254);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", Math.PI
/ 2), 0);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", -Math.PI
/ 2), 0);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", Math.PI
/ 4), 0.7071068);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", -Math.PI
/ 4), 0.7071068);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", Math.PI
* 2 / 3), -0.5);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", -Math.PI
* 2 / 3), -0.5);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", Math.PI
/ 6), 0.8660254);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "cos({0})", -Math.PI
/ 6), 0.8660254);
         }
 
         [Test]
@@ -199,7 +212,10 @@ namespace Lucene.Net.Expressions.JS
         public virtual void TestLnMethod()
         {
             AssertEvaluatesTo("ln(0)", double.NegativeInfinity);
-            AssertEvaluatesTo("ln(" + Math.E + ")", 1);
+
+            // LUCENENET specific - need to apply invariant culture to the string concatenation
+            // to ensure the numeric formatting is correct, otherwise it may look like the
wrong number of parameters
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "ln({0})", Math.E),
1);
             AssertEvaluatesTo("ln(-1)", double.NaN);
             AssertEvaluatesTo("ln(1)", 0);
             AssertEvaluatesTo("ln(0.5)", -0.69314718056);
@@ -266,15 +282,27 @@ namespace Lucene.Net.Expressions.JS
         [Test]
         public virtual void TestSinMethod()
         {
+            //AssertEvaluatesTo("sin(0)", 0);
+            //AssertEvaluatesTo("sin(" + Math.PI / 2 + ")", 1);
+            //AssertEvaluatesTo("sin(" + -Math.PI / 2 + ")", -1);
+            //AssertEvaluatesTo("sin(" + Math.PI / 4 + ")", 0.7071068);
+            //AssertEvaluatesTo("sin(" + -Math.PI / 4 + ")", -0.7071068);
+            //AssertEvaluatesTo("sin(" + Math.PI * 2 / 3 + ")", 0.8660254);
+            //AssertEvaluatesTo("sin(" + -Math.PI * 2 / 3 + ")", -0.8660254);
+            //AssertEvaluatesTo("sin(" + Math.PI / 6 + ")", 0.5);
+            //AssertEvaluatesTo("sin(" + -Math.PI / 6 + ")", -0.5);
+
+            // LUCENENET specific - need to apply invariant culture to the string concatenation
+            // to ensure the numeric formatting is correct, otherwise it may look like the
wrong number of parameters
             AssertEvaluatesTo("sin(0)", 0);
-            AssertEvaluatesTo("sin(" + Math.PI / 2 + ")", 1);
-            AssertEvaluatesTo("sin(" + -Math.PI / 2 + ")", -1);
-            AssertEvaluatesTo("sin(" + Math.PI / 4 + ")", 0.7071068);
-            AssertEvaluatesTo("sin(" + -Math.PI / 4 + ")", -0.7071068);
-            AssertEvaluatesTo("sin(" + Math.PI * 2 / 3 + ")", 0.8660254);
-            AssertEvaluatesTo("sin(" + -Math.PI * 2 / 3 + ")", -0.8660254);
-            AssertEvaluatesTo("sin(" + Math.PI / 6 + ")", 0.5);
-            AssertEvaluatesTo("sin(" + -Math.PI / 6 + ")", -0.5);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", Math.PI
/ 2), 1);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", -Math.PI
/ 2), - 1);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", Math.PI
/ 4), 0.7071068);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", -Math.PI
/ 4), -0.7071068);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", Math.PI
* 2 / 3), 0.8660254);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", -Math.PI
* 2 / 3), - 0.8660254);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", Math.PI
/ 6), 0.5);
+            AssertEvaluatesTo(string.Format(CultureInfo.InvariantCulture, "sin({0})", -Math.PI
/ 6), -0.5);
         }
 
         [Test]


Mime
View raw message