This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git


The following commit(s) were added to refs/heads/master by this push:
     new 610e18f  Lucene.Net.Tests.Expressions: Minor formatting and comment 
changes (See #259)
610e18f is described below

commit 610e18f079a1c9dba2387fe9d8daa9abe3c98484
Author: Ron Clabo <[email protected]>
AuthorDate: Wed Feb 24 19:23:58 2021 -0500

    Lucene.Net.Tests.Expressions: Minor formatting and comment changes (See 
#259)
    
    * Reviewed code and cleaned it up a bit
    
    * Cleaned up my formatting a bit more and updated the editorconfig to 
default to using spaces not tabs.
    
    * One more comments
---
 .editorconfig                                      |  2 +
 .../JS/TestCustomFunctions.cs                      | 54 +++++------------
 .../JS/TestJavascriptCompiler.cs                   | 67 ++++++++++++----------
 .../JS/TestJavascriptOperations.cs                 | 14 ++---
 .../TestDemoExpressions.cs                         |  8 +--
 .../TestExpressionRescorer.cs                      | 16 +++++-
 .../TestExpressionSortField.cs                     | 13 +++++
 .../TestExpressionSorts.cs                         |  6 +-
 .../TestExpressionValueSource.cs                   | 22 +++++--
 9 files changed, 112 insertions(+), 90 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 2f625c2..8be8b5e 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -11,6 +11,8 @@ indent_size = 4
 
 # C# files
 [*.cs]
+indent_style = space
+indent_size = 4
 
 #### Core EditorConfig Options ####
 
diff --git a/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs 
b/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs
index 8cfcd24..055926d 100644
--- a/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs
+++ b/src/Lucene.Net.Tests.Expressions/JS/TestCustomFunctions.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Support;
+using Lucene.Net.Support;
 using Lucene.Net.Util;
 using NUnit.Framework;
 using System;
@@ -56,10 +56,7 @@ namespace Lucene.Net.Expressions.JS
             Assert.AreEqual(Math.Sqrt(20), expr.Evaluate(0, null), DELTA);
         }
 
-        public static double ZeroArgMethod()
-        {
-            return 5;
-        }
+        public static double ZeroArgMethod() => 5;
 
         /// <summary>tests a method with no arguments</summary>
         [Test]
@@ -71,10 +68,7 @@ namespace Lucene.Net.Expressions.JS
             Assert.AreEqual(5, expr.Evaluate(0, null), DELTA);
         }
 
-        public static double OneArgMethod(double arg1)
-        {
-            return 3 + arg1;
-        }
+        public static double OneArgMethod(double arg1) => 3 + arg1; 
 
         /// <summary>tests a method with one arguments</summary>
         [Test]
@@ -86,18 +80,14 @@ namespace Lucene.Net.Expressions.JS
             Assert.AreEqual(6, expr.Evaluate(0, null), DELTA);
         }
 
-        public static double ThreeArgMethod(double arg1, double arg2, double 
arg3)
-        {
-            return arg1 + arg2 + arg3;
-        }
+        public static double ThreeArgMethod(double arg1, double arg2, double 
arg3) => arg1 + arg2 + arg3;
 
         /// <summary>tests a method with three arguments</summary>
         [Test]
         public virtual void TestThreeArgMethod()
         {
             IDictionary<string, MethodInfo> functions = new Dictionary<string, 
MethodInfo>();
-            functions["foo"] = GetType().GetMethod("ThreeArgMethod", new []{ 
typeof(double), typeof(
-                double), typeof(double)});
+            functions["foo"] = GetType().GetMethod("ThreeArgMethod", new []{ 
typeof(double), typeof(double), typeof(double)});
             var expr = JavascriptCompiler.Compile("foo(3, 4, 5)", functions);
             Assert.AreEqual(12, expr.Evaluate(0, null), DELTA);
         }
@@ -113,10 +103,7 @@ namespace Lucene.Net.Expressions.JS
             Assert.AreEqual(11, expr.Evaluate(0, null), DELTA);
         }
 
-        public static string BogusReturnType()
-        {
-            return "bogus!";
-        }
+        public static string BogusReturnType() => "bogus!"; 
 
         /// <summary>wrong return type: must be double</summary>
         [Test]
@@ -135,10 +122,7 @@ namespace Lucene.Net.Expressions.JS
             }
         }
 
-        public static double BogusParameterType(string s)
-        {
-            return 0;
-        }
+        public static double BogusParameterType(string s) => 0; 
 
         /// <summary>wrong param type: must be doubles</summary>
         [Test]
@@ -153,15 +137,11 @@ namespace Lucene.Net.Expressions.JS
             }
             catch (ArgumentException e)
             {
-                Assert.IsTrue(e.Message.Contains("must take only double 
parameters"
-                    ));
+                Assert.IsTrue(e.Message.Contains("must take only double 
parameters"));
             }
         }
 
-        public virtual double NonStaticMethod()
-        {
-            return 0;
-        }
+        public virtual double NonStaticMethod() => 0; 
 
         /// <summary>wrong modifiers: must be static</summary>
         [Test]
@@ -180,10 +160,7 @@ namespace Lucene.Net.Expressions.JS
             }
         }
 
-        internal static double NonPublicMethod()
-        {
-            return 0;
-        }
+        internal static double NonPublicMethod() => 0;
 
         /// <summary>wrong modifiers: must be public</summary>
         [Test]
@@ -205,10 +182,7 @@ namespace Lucene.Net.Expressions.JS
 
         internal class NestedNotPublic
         {
-            public static double Method()
-            {
-                return 0;
-            }
+            public static double Method() => 0;
         }
 
         /// <summary>wrong class modifiers: class containing method is not 
public</summary>
@@ -228,6 +202,9 @@ namespace Lucene.Net.Expressions.JS
             }
         }
 
+
+        //LUCENENET: testClassLoader() was not ported.  (May not apply to 
Lucene.Net)
+        
         
         internal static string MESSAGE = "This should not happen but it 
happens";
 
@@ -240,7 +217,7 @@ namespace Lucene.Net.Expressions.JS
         }
 
         /// <summary>the method throws an exception.</summary>
-        /// <remarks>the method throws an exception. We should check the stack 
trace that it contains the source code of the expression as file name.
+        /// <remarks>We should check the stack trace that it contains the 
source code of the expression as file name.
         ///    </remarks>
         [Test]
         public virtual void TestThrowingException()
@@ -265,7 +242,6 @@ namespace Lucene.Net.Expressions.JS
         }
 
         /// <summary>test that namespaces work with custom 
expressions.</summary>
-        /// <remarks>test that namespaces work with custom 
expressions.</remarks>
         [Test]
         public virtual void TestNamespaces()
         {
diff --git a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs 
b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs
index a133d58..a72441d 100644
--- a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs
+++ b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptCompiler.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Util;
+using Lucene.Net.Util;
 using NUnit.Framework;
 using System;
 using Assert = Lucene.Net.TestFramework.Assert;
@@ -40,7 +40,6 @@ namespace Lucene.Net.Expressions.JS
             
Assert.IsNotNull(JavascriptCompiler.Compile("object0.object1.valid1"));
         }
 
-        //TODO: change all exceptions to ParseExceptions
         [Test]
         public virtual void TestInvalidNamespaces()
         {
@@ -49,39 +48,42 @@ namespace Lucene.Net.Expressions.JS
                 JavascriptCompiler.Compile("object.0invalid");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                //expected
             }
-            //expected
+
             try
             {
                 JavascriptCompiler.Compile("0.invalid");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                //expected
             }
-            //expected
+
             try
             {
                 JavascriptCompiler.Compile("object..invalid");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                //expected
             }
-            //expected
+
             try
             {
                 JavascriptCompiler.Compile(".invalid");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                //expected
             }
         }
 
-        //expected
         [Test]
         public virtual void TestInvalidCompiles()
         {
@@ -90,44 +92,48 @@ namespace Lucene.Net.Expressions.JS
                 JavascriptCompiler.Compile("100 100");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                               // expected
             }
-            // expected exception
             try
             {
                 JavascriptCompiler.Compile("7*/-8");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                // expected
             }
-            // expected exception
+
             try
             {
                 JavascriptCompiler.Compile("0y1234");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                // expected
             }
-            // expected exception
+            
             try
             {
                 JavascriptCompiler.Compile("500EE");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                // expected
             }
-            // expected exception
+            
             try
             {
                 JavascriptCompiler.Compile("500.5EE");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                // expected
             }
         }
 
@@ -139,30 +145,32 @@ namespace Lucene.Net.Expressions.JS
                 JavascriptCompiler.Compile(string.Empty);
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                // expected
             }
-            // expected exception
+            
             try
             {
                 JavascriptCompiler.Compile("()");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                // expected
             }
-            // expected exception
+            
             try
             {
                 JavascriptCompiler.Compile("   \r\n   \n \t");
                 Assert.Fail();
             }
-            catch (Exception)
+            catch (InvalidOperationException)
             {
+                // expected
             }
         }
 
-        // expected exception
         [Test]
         public virtual void TestNull()
         {
@@ -173,10 +181,10 @@ namespace Lucene.Net.Expressions.JS
             }
             catch (ArgumentNullException)
             {
+                // expected
             }
         }
 
-        // expected exception
         [Test]
         public virtual void TestWrongArity()
         {
@@ -187,9 +195,9 @@ namespace Lucene.Net.Expressions.JS
             }
             catch (ArgumentException expected)
             {
-                Assert.IsTrue(expected.Message.Contains("arguments for method 
call"
-                    ));
+                Assert.IsTrue(expected.Message.Contains("arguments for method 
call"));
             }
+
             try
             {
                 JavascriptCompiler.Compile("tan(1, 1)");
@@ -197,8 +205,7 @@ namespace Lucene.Net.Expressions.JS
             }
             catch (ArgumentException expected)
             {
-                Assert.IsTrue(expected.Message.Contains("arguments for method 
call"
-                    ));
+                Assert.IsTrue(expected.Message.Contains("arguments for method 
call"));
             }
         }
     }
diff --git a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptOperations.cs 
b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptOperations.cs
index 520a627..2422201 100644
--- a/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptOperations.cs
+++ b/src/Lucene.Net.Tests.Expressions/JS/TestJavascriptOperations.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Util;
+using Lucene.Net.Util;
 using NUnit.Framework;
 using Assert = Lucene.Net.TestFramework.Assert;
 
@@ -361,10 +361,10 @@ namespace Lucene.Net.Expressions.JS
             AssertEvaluatesTo("0x1", 1);
             AssertEvaluatesTo("0xF", 15);
             AssertEvaluatesTo("0x1234ABCDEF", 78193085935L);
-            AssertEvaluatesTo("1 << 0x1", 1 << (0x1));
-            AssertEvaluatesTo("1 << 0xA", 1 << (0xA));
-            AssertEvaluatesTo("0x1 << 2", unchecked((int)(0x1)) << 2);
-            AssertEvaluatesTo("0xA << 2", unchecked((int)(0xA)) << 2);
+            AssertEvaluatesTo("1 << 0x1", 1 << 0x1);
+            AssertEvaluatesTo("1 << 0xA", 1 << 0xA);
+            AssertEvaluatesTo("0x1 << 2", 0x1 << 2);
+            AssertEvaluatesTo("0xA << 2", 0xA << 2);
         }
 
         [Test]
@@ -373,7 +373,7 @@ namespace Lucene.Net.Expressions.JS
             AssertEvaluatesTo("0X0", 0);
             AssertEvaluatesTo("0X1", 1);
             AssertEvaluatesTo("0XF", 15);
-            AssertEvaluatesTo("0X1234ABCDEF", 78193085935L);
+            AssertEvaluatesTo("0X1234ABCDEF", 78193085935L);  
         }
 
         [Test]
@@ -382,7 +382,7 @@ namespace Lucene.Net.Expressions.JS
             AssertEvaluatesTo("00", 0);
             AssertEvaluatesTo("01", 1);
             AssertEvaluatesTo("010", 8);
-            AssertEvaluatesTo("0123456777", 21913087);
+            AssertEvaluatesTo("0123456777", 21913087);  // LUCENENET Comment: 
Javascript octal value via leading 0, compared with decimal value.
             AssertEvaluatesTo("1 << 01", 1 << 0x1);
             AssertEvaluatesTo("1 << 010", 1 << 0x8);
             AssertEvaluatesTo("01 << 2", 0x1 << 2);
diff --git a/src/Lucene.Net.Tests.Expressions/TestDemoExpressions.cs 
b/src/Lucene.Net.Tests.Expressions/TestDemoExpressions.cs
index 958b557..1b21659 100644
--- a/src/Lucene.Net.Tests.Expressions/TestDemoExpressions.cs
+++ b/src/Lucene.Net.Tests.Expressions/TestDemoExpressions.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Documents;
+using Lucene.Net.Documents;
 using Lucene.Net.Expressions.JS;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
@@ -173,11 +173,11 @@ namespace Lucene.Net.Expressions
             DoTestLotsOfBindings(byte.MaxValue - 1);
             DoTestLotsOfBindings(byte.MaxValue);
             DoTestLotsOfBindings(byte.MaxValue + 1);
+            // TODO: ideally we'd test > Short.MAX_VALUE too, but compilation 
is currently recursive.
+            // so if we want to test such huge expressions, we need to instead 
change parser to use an explicit Stack
         }
 
-        // TODO: ideally we'd test > Short.MAX_VALUE too, but compilation is 
currently recursive.
-        // so if we want to test such huge expressions, we need to instead 
change parser to use an explicit Stack
-        /// <exception cref="Exception"></exception>
+        
         private void DoTestLotsOfBindings(int n)
         {
             SimpleBindings bindings = new SimpleBindings();
diff --git a/src/Lucene.Net.Tests.Expressions/TestExpressionRescorer.cs 
b/src/Lucene.Net.Tests.Expressions/TestExpressionRescorer.cs
index c1c43f4..07b66e2 100644
--- a/src/Lucene.Net.Tests.Expressions/TestExpressionRescorer.cs
+++ b/src/Lucene.Net.Tests.Expressions/TestExpressionRescorer.cs
@@ -1,4 +1,4 @@
-using Lucene.Net.Documents;
+using Lucene.Net.Documents;
 using Lucene.Net.Expressions.JS;
 using Lucene.Net.Index;
 using Lucene.Net.Search;
@@ -52,6 +52,7 @@ namespace Lucene.Net.Expressions
                 new NumericDocValuesField("popularity", 5)
             };
             iw.AddDocument(doc);
+
             doc = new Document
             {
                 NewStringField("id", "2", Field.Store.YES),
@@ -60,6 +61,7 @@ namespace Lucene.Net.Expressions
                 new NumericDocValuesField("popularity", 20)
             };
             iw.AddDocument(doc);
+
             doc = new Document
             {
                 NewStringField("id", "3", Field.Store.YES),
@@ -67,6 +69,7 @@ namespace Lucene.Net.Expressions
                 new NumericDocValuesField("popularity", 2)
             };
             iw.AddDocument(doc);
+
             reader = iw.GetReader();
             searcher = new IndexSearcher(reader);
             iw.Dispose();
@@ -86,27 +89,36 @@ namespace Lucene.Net.Expressions
             // create a sort field and sort by it (reverse order)
             Query query = new TermQuery(new Term("body", "contents"));
             IndexReader r = searcher.IndexReader;
+
             // Just first pass query
             TopDocs hits = searcher.Search(query, 10);
             Assert.AreEqual(3, hits.TotalHits);
             Assert.AreEqual("3", r.Document(hits.ScoreDocs[0].Doc).Get("id"));
             Assert.AreEqual("1", r.Document(hits.ScoreDocs[1].Doc).Get("id"));
             Assert.AreEqual("2", r.Document(hits.ScoreDocs[2].Doc).Get("id"));
+
             // Now, rescore:
+
             Expression e = JavascriptCompiler.Compile("sqrt(_score) + 
ln(popularity)");
             SimpleBindings bindings = new SimpleBindings();
             bindings.Add(new SortField("popularity", SortFieldType.INT32));
             bindings.Add(new SortField("_score", SortFieldType.SCORE));
             Rescorer rescorer = e.GetRescorer(bindings);
+
             hits = rescorer.Rescore(searcher, hits, 10);
             Assert.AreEqual(3, hits.TotalHits);
             Assert.AreEqual("2", r.Document(hits.ScoreDocs[0].Doc).Get("id"));
             Assert.AreEqual("1", r.Document(hits.ScoreDocs[1].Doc).Get("id"));
             Assert.AreEqual("3", r.Document(hits.ScoreDocs[2].Doc).Get("id"));
-            string expl = rescorer.Explain(searcher, searcher.Explain(query, 
hits.ScoreDocs[0].Doc), hits.ScoreDocs[0].Doc).ToString();
+
+            string expl = rescorer.Explain(searcher, 
+                                           searcher.Explain(query, 
hits.ScoreDocs[0].Doc), 
+                                           hits.ScoreDocs[0].Doc).ToString();
+
             // Confirm the explanation breaks out the individual
             // variables:
             Assert.IsTrue(expl.Contains("= variable \"popularity\""));
+
             // Confirm the explanation includes first pass details:
             Assert.IsTrue(expl.Contains("= first pass score"));
             Assert.IsTrue(expl.Contains("body:contents in"));
diff --git a/src/Lucene.Net.Tests.Expressions/TestExpressionSortField.cs 
b/src/Lucene.Net.Tests.Expressions/TestExpressionSortField.cs
index 8bcf0b0..5078cfb 100644
--- a/src/Lucene.Net.Tests.Expressions/TestExpressionSortField.cs
+++ b/src/Lucene.Net.Tests.Expressions/TestExpressionSortField.cs
@@ -40,25 +40,33 @@ namespace Lucene.Net.Expressions
         public virtual void TestEquals()
         {
             Expression expr = JavascriptCompiler.Compile("sqrt(_score) + 
ln(popularity)");
+
             SimpleBindings bindings = new SimpleBindings();
             bindings.Add(new SortField("_score", SortFieldType.SCORE));
             bindings.Add(new SortField("popularity", SortFieldType.INT32));
+
             SimpleBindings otherBindings = new SimpleBindings();
             otherBindings.Add(new SortField("_score", SortFieldType.INT64));
             otherBindings.Add(new SortField("popularity", 
SortFieldType.INT32));
+
             SortField sf1 = expr.GetSortField(bindings, true);
+
             // different order
             SortField sf2 = expr.GetSortField(bindings, false);
             Assert.IsFalse(sf1.Equals(sf2));
+
             // different bindings
             sf2 = expr.GetSortField(otherBindings, true);
             Assert.IsFalse(sf1.Equals(sf2));
+
             // different expression
             Expression other = JavascriptCompiler.Compile("popularity/2");
             sf2 = other.GetSortField(bindings, true);
             Assert.IsFalse(sf1.Equals(sf2));
+
             // null
             Assert.IsFalse(sf1.Equals(null));
+
             // same instance:
             Assert.AreEqual(sf1, sf1);
         }
@@ -73,18 +81,22 @@ namespace Lucene.Net.Expressions
             Expression exprB = JavascriptCompiler.Compile("0");
             // field
             Expression exprC = JavascriptCompiler.Compile("intfield");
+
             // score + constant
             Expression exprD = JavascriptCompiler.Compile("_score + 0");
             // field + constant
             Expression exprE = JavascriptCompiler.Compile("intfield + 0");
+
             // expression + constant (score ref'd)
             Expression exprF = JavascriptCompiler.Compile("a + 0");
             // expression + constant
             Expression exprG = JavascriptCompiler.Compile("e + 0");
+
             // several variables (score ref'd)
             Expression exprH = JavascriptCompiler.Compile("b / c + e * g - 
sqrt(f)");
             // several variables
             Expression exprI = JavascriptCompiler.Compile("b / c + e * g");
+
             bindings.Add(new SortField("_score", SortFieldType.SCORE));
             bindings.Add(new SortField("intfield", SortFieldType.INT32));
             bindings.Add("a", exprA);
@@ -96,6 +108,7 @@ namespace Lucene.Net.Expressions
             bindings.Add("g", exprG);
             bindings.Add("h", exprH);
             bindings.Add("i", exprI);
+
             Assert.IsTrue(exprA.GetSortField(bindings, true).NeedsScores);
             Assert.IsFalse(exprB.GetSortField(bindings, true).NeedsScores);
             Assert.IsFalse(exprC.GetSortField(bindings, true).NeedsScores);
diff --git a/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs 
b/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs
index 2ec8ec8..a18c030 100644
--- a/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs
+++ b/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs
@@ -32,10 +32,8 @@ namespace Lucene.Net.Expressions
     /// Tests some basic expressions against different queries,
     /// and fieldcache/docvalues fields against an equivalent sort.
     /// </summary>
-    /// <remarks>
-    /// Tests some basic expressions against different queries,
-    /// and fieldcache/docvalues fields against an equivalent sort.
-    /// </remarks>
+
+
     [SuppressCodecs("Lucene3x")]
     public class TestExpressionSorts : LuceneTestCase
     {
diff --git a/src/Lucene.Net.Tests.Expressions/TestExpressionValueSource.cs 
b/src/Lucene.Net.Tests.Expressions/TestExpressionValueSource.cs
index bdf7788..77b59ab 100644
--- a/src/Lucene.Net.Tests.Expressions/TestExpressionValueSource.cs
+++ b/src/Lucene.Net.Tests.Expressions/TestExpressionValueSource.cs
@@ -46,6 +46,7 @@ namespace Lucene.Net.Expressions
                 (Random));
             iwc.SetMergePolicy(NewLogMergePolicy());
             var iw = new RandomIndexWriter(Random, dir, iwc);
+
             var doc = new Document
             {
                 NewStringField("id", "1", Field.Store.YES),
@@ -53,14 +54,15 @@ namespace Lucene.Net.Expressions
                 new NumericDocValuesField("popularity", 5)
             };
             iw.AddDocument(doc);
+
             doc = new Document
             {
                 NewStringField("id", "2", Field.Store.YES),
-                NewTextField("body", "another document with different 
contents", Field.Store
-                    .NO),
+                NewTextField("body", "another document with different 
contents", Field.Store.NO),
                 new NumericDocValuesField("popularity", 20)
             };
             iw.AddDocument(doc);
+
             doc = new Document
             {
                 NewStringField("id", "3", Field.Store.YES),
@@ -69,6 +71,7 @@ namespace Lucene.Net.Expressions
             };
             iw.AddDocument(doc);
             iw.ForceMerge(1);
+
             reader = iw.GetReader();
             iw.Dispose();
         }
@@ -88,9 +91,11 @@ namespace Lucene.Net.Expressions
             SimpleBindings bindings = new SimpleBindings();
             bindings.Add(new SortField("popularity", SortFieldType.INT64));
             ValueSource vs = expr.GetValueSource(bindings);
+
             Assert.AreEqual(1, reader.Leaves.Count);
             AtomicReaderContext leaf = reader.Leaves[0];
             FunctionValues values = vs.GetValues(new Dictionary<string, 
object>(), leaf);
+
             Assert.AreEqual(10, values.DoubleVal(0), 0);
             Assert.AreEqual(10, values.SingleVal(0), 0);
             Assert.AreEqual(10, values.Int64Val(0));
@@ -99,6 +104,7 @@ namespace Lucene.Net.Expressions
             Assert.AreEqual((byte)10, values.ByteVal(0));
             Assert.AreEqual("10", values.StrVal(0));
             Assert.AreEqual(System.Convert.ToDouble(10), values.ObjectVal(0));
+
             Assert.AreEqual(40, values.DoubleVal(1), 0);
             Assert.AreEqual(40, values.SingleVal(1), 0);
             Assert.AreEqual(40, values.Int64Val(1));
@@ -107,6 +113,7 @@ namespace Lucene.Net.Expressions
             Assert.AreEqual((byte)40, values.ByteVal(1));
             Assert.AreEqual("40", values.StrVal(1));
             Assert.AreEqual(System.Convert.ToDouble(40), values.ObjectVal(1));
+
             Assert.AreEqual(4, values.DoubleVal(2), 0);
             Assert.AreEqual(4, values.SingleVal(2), 0);
             Assert.AreEqual(4, values.Int64Val(2));
@@ -124,17 +131,19 @@ namespace Lucene.Net.Expressions
             SimpleBindings bindings = new SimpleBindings();
             bindings.Add(new SortField("popularity", SortFieldType.INT64));
             ValueSource vs = expr.GetValueSource(bindings);
+
             Assert.AreEqual(1, reader.Leaves.Count);
             AtomicReaderContext leaf = reader.Leaves[0];
             FunctionValues values = vs.GetValues(new Dictionary<string, 
object>(), leaf);
+
             // everything
-            ValueSourceScorer scorer = values.GetRangeScorer(leaf.Reader, "4"
-                , "40", true, true);
+            ValueSourceScorer scorer = values.GetRangeScorer(leaf.Reader, "4", 
"40", true, true);
             Assert.AreEqual(-1, scorer.DocID);
             Assert.AreEqual(0, scorer.NextDoc());
             Assert.AreEqual(1, scorer.NextDoc());
             Assert.AreEqual(2, scorer.NextDoc());
             Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, scorer.NextDoc());
+
             // just the first doc
             scorer = values.GetRangeScorer(leaf.Reader, "4", "40", false, 
false);
             Assert.AreEqual(-1, scorer.DocID);
@@ -146,9 +155,11 @@ namespace Lucene.Net.Expressions
         public virtual void TestEquals()
         {
             Expression expr = JavascriptCompiler.Compile("sqrt(a) + ln(b)");
+
             SimpleBindings bindings = new SimpleBindings();
             bindings.Add(new SortField("a", SortFieldType.INT32));
             bindings.Add(new SortField("b", SortFieldType.INT32));
+
             ValueSource vs1 = expr.GetValueSource(bindings);
             // same instance
             Assert.AreEqual(vs1, vs1);
@@ -156,16 +167,19 @@ namespace Lucene.Net.Expressions
             Assert.IsFalse(vs1.Equals(null));
             // other object
             Assert.IsFalse(vs1.Equals("foobar"));
+
             // same bindings and expression instances
             ValueSource vs2 = expr.GetValueSource(bindings);
             Assert.AreEqual(vs1.GetHashCode(), vs2.GetHashCode());
             Assert.AreEqual(vs1, vs2);
+
             // equiv bindings (different instance)
             SimpleBindings bindings2 = new SimpleBindings();
             bindings2.Add(new SortField("a", SortFieldType.INT32));
             bindings2.Add(new SortField("b", SortFieldType.INT32));
             ValueSource vs3 = expr.GetValueSource(bindings2);
             Assert.AreEqual(vs1, vs3);
+
             // different bindings (same names, different types)
             SimpleBindings bindings3 = new SimpleBindings();
             bindings3.Add(new SortField("a", SortFieldType.INT64));

Reply via email to