JSAbstractOperations { static Double ToInteger(Object arg) { Double number = ToNumber(arg); if (number.isNaN()) { return 0.0; } if (number.isInfinite()) { return number; } return java.lang.Math.signum(number) * java.lang.Math.floor(java.lang.Math.abs(number)); }   static final BigInteger UINT_MAX_VALUE; static final Double UINT_MAX_VALUE_D; static final BigInteger SINT_MAX_VALUE; static final BigInteger USHORT_MAX_VALUE; }
@Test public void testToInteger01() { assertEquals(0.0, ToInteger(NaN), 0.0); assertEquals(0.0, ToInteger("x"), 0.0); assertEquals(0.0, ToInteger(+0), 0.0); assertEquals(0.0, ToInteger(-0), 0.0); }
@Test public void testToInteger02() { assertEquals(6, ToInteger(6.54321), 0.0); assertEquals(-6, ToInteger(-6.54321), 0.0); assertEquals(654, ToInteger(6.54321e2), 0.0); assertEquals(-654, ToInteger(-6.54321e2), 0.0); assertEquals(6, ToInteger(0.654321e1), 0.0); assertEquals(-6, ToInteger(-0.654321e1), 0.0); assertEquals(1, ToInteger(true), 0.0); assertEquals(0, ToInteger(false), 0.0); assertEquals(1.23e15, ToInteger(1.23e15), 0.0); assertEquals(-1.23e15, ToInteger(-1.23e15), 0.0); assertEquals(0, ToInteger(1.23e-15), 0.0); assertEquals(-0, ToInteger(-1.23e-15), 0.0); }
@Test public void testToInteger03() { assertEquals(Double.POSITIVE_INFINITY, ToInteger(Double.POSITIVE_INFINITY), 0.0); assertEquals(Double.NEGATIVE_INFINITY, ToInteger(Double.NEGATIVE_INFINITY), 0.0); assertEquals(0.0, ToInteger(0.0), 0.0); assertEquals(0.0, ToInteger(0.0), 0.0); assertEquals(-0.0, ToInteger(-0.0), 0.0); }