You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2021/10/23 23:49:09 UTC

[lucenenet] 01/09: BUG: Lucene.Net.Search.TestBooleanQuery::TestBS2DisjunctionNextVsAdvance(): Use Assert.AreEqual instead of Asssert.IsTrue with == to fix floating point comparison on x86 .NET Framework with optimizations enabled.

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

commit b02fb28d3b025afc8d9a4dcd51dd321c06db2951
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sat Oct 23 02:27:53 2021 +0700

    BUG: Lucene.Net.Search.TestBooleanQuery::TestBS2DisjunctionNextVsAdvance(): Use Assert.AreEqual instead of Asssert.IsTrue with == to fix floating point comparison on x86 .NET Framework with optimizations enabled.
---
 src/Lucene.Net.Tests/Search/TestBooleanQuery.cs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs
index a511922..5d6cef3 100644
--- a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs
+++ b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs
@@ -213,9 +213,6 @@ namespace Lucene.Net.Search
         }
 
         [Test]
-#if NETFRAMEWORK
-        [AwaitsFix(BugUrl = "https://github.com/apache/lucenenet/issues/269")] // LUCENENET TODO: this test fails on x86 on .NET Framework in Release mode only
-#endif
         public virtual void TestBS2DisjunctionNextVsAdvance()
         {
             Directory d = NewDirectory();
@@ -337,8 +334,10 @@ namespace Lucene.Net.Search
                         {
                             ScoreDoc hit = hits[nextUpto];
                             Assert.AreEqual(hit.Doc, nextDoc);
+
+                            // LUCENENET: For some weird reason, on x86 in .NET Framework (optimizations enabled), using == (as they did in Lucene) doesn't work with optimizations enabled, but using AreEqual with epsilon of 0f does.
                             // Test for precise float equality:
-                            Assert.IsTrue(hit.Score == scorer.GetScore(), "doc " + hit.Doc + " has wrong score: expected=" + hit.Score + " actual=" + scorer.GetScore());
+                            Assert.AreEqual(hit.Score, scorer.GetScore(), 0f, "doc " + hit.Doc + " has wrong score: expected=" + hit.Score + " actual=" + scorer.GetScore());
                         }
                         upto = nextUpto;
                     }