forked from deephaven/deephaven-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Remove Math.nextUp call in QueryConstants (deephaven#5747)
Math.nextUp is not presently usable in GWT, so this patch lets the JS API share QueryConstants and ensures that the MIN_FINITE values are correct, without actually initializing them via a call to Math.nextUp. Partial deephaven#188 Co-authored-by: Ryan Caudy <rcaudy@gmail.com>
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ plugins { | |
id 'java-library' | ||
id 'io.deephaven.project.register' | ||
} | ||
|
||
dependencies { | ||
testImplementation libs.junit4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
engine/query-constants/src/test/java/io/deephaven/util/QueryConstantsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.util; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class QueryConstantsTest { | ||
|
||
@Test | ||
public void testMinFiniteFloat() { | ||
final float calculated = Math.nextUp(-Float.MAX_VALUE); | ||
// noinspection SimplifiableAssertion | ||
assertTrue(calculated == QueryConstants.MIN_FINITE_FLOAT); | ||
assertEquals( | ||
Float.floatToIntBits(calculated), | ||
Float.floatToIntBits(QueryConstants.MIN_FINITE_FLOAT)); | ||
} | ||
|
||
@Test | ||
public void testMinFiniteDouble() { | ||
final double calculated = Math.nextUp(-Double.MAX_VALUE); | ||
// noinspection SimplifiableAssertion | ||
assertTrue(calculated == QueryConstants.MIN_FINITE_DOUBLE); | ||
assertEquals( | ||
Double.doubleToLongBits(calculated), | ||
Double.doubleToLongBits(QueryConstants.MIN_FINITE_DOUBLE)); | ||
} | ||
} |