Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for .NET Framework x86 Support #529

Merged
merged 9 commits into from Oct 23, 2021

Conversation

NightOwl888
Copy link
Contributor

See #269.

This fixes the following tests so they don't fail on .NET Framework x86 with optimizations enabled (without working around the problem by disabling optimizations):

Failed due to cast from float to double causing a change of value

  • Lucene.Net.Expressions.TestExpressionSorts::TestQueries()

This was fixed by adding an intermediate cast to decimal on .NET Framework and .NET Standard 2.0 only

Failed due to equality comparisons between float data type values

  • Lucene.Net.Sandbox.TestSlowFuzzyQuery::TestTieBreaker()
  • Lucene.Net.Sandbox.TestSlowFuzzyQuery::TestTokenLengthOpt()
  • Lucene.Net.Search.TestBooleanQuery::TestBS2DisjunctionNextVsAdvance()
  • Lucene.Net.Search.TestFuzzyQuery::TestTieBreaker()
  • Lucene.Net.Search.TestSearchAfter::TestQueries()
  • Lucene.Net.Search.TestTopDocsMerge::TestSort_1()
  • Lucene.Net.Search.TestTopDocsMerge::TestSort_2()

These were fixed by using the Lucene.Net.Util.NumericUtils::SingleToSortableInt32() method to compare the raw bits for equality. This change doesn't impact performance or behavior of the application as using an approximate float comparison would.

This also fixes Lucene.Net.Expressions.ExpressionComparer to use J2N.Collections.Generic.Comparer<double> to ensure we use the same floating point comparison logic as Java.

…nce(): Use Assert.AreEqual instead of Asssert.IsTrue with == to fix floating point comparison on x86 .NET Framework with optimizations enabled.
…NumericUtils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. This fixes Lucene.Net.Search.TestBooleanQuery.TestBS2DisjunctionNextVsAdvance(), Lucene.Net.Search.TestFuzzyQuery.TestTieBreaker(), and Lucene.Net.Sandbox.Queries.TestSlowFuzzyQuery.TestTieBreaker(). See apache#269.
….Util.NumericUtils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. This fixes Lucene.Net.Search.TestTopDocsMerge::TestSort_1(), Lucene.Net.Search.TestTopDocsMerge::TestSort_2(), and Lucene.Net.Search.TestSearchAfter.TestQueries(). See apache#269.
… using Lucene.Net.Util.NumericUtils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. This fixes Lucene.Net.Sandbox.Queries.TestSlowFuzzyQuery.TestTokenLengthOpt(). See apache#269.
…tils.SingleToSortableInt32() to prevent test failures on x86 .NET Framework. See apache#269.
…e floating point numbers (except in cases where we are testing for whole numbers).
…ng float to double loses precision in x86 .NET Framework. Do an intermediate cast to decimal to fix Lucene.Net.Expressions.TestExpressionSorts::TestQueries(). See apache#269.
…c.Comparer<double> to ensure we use the same comparison logic as in Java.
@NightOwl888 NightOwl888 merged commit 6632a68 into apache:master Oct 23, 2021
@NightOwl888 NightOwl888 added this to the 4.8.0-beta00015 milestone Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant