/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4984407 5033578
* @summary Tests for {Math, StrictMath}.pow
* @author Joseph D. Darcy
*/
public class PowTests {
private PowTests(){}
int failures = 0;
return failures;
}
int failures = 0;
return failures;
}
int failures = 0;
return failures;
}
/*
* Test for bad negation implementation.
*/
static int testPow() {
int failures = 0;
double [][] testCases = {
{-0.0, 3.0, -0.0},
{-0.0, 4.0, 0.0},
};
}
return failures;
}
/*
* Test cross-product of different kinds of arguments.
*/
static int testCrossProduct() {
int failures = 0;
double testData[] = {
/**/ (double) -((1L<<53)+2L),
/**/ (double) -((1L<<53)),
/**/ (double) -((1L<<53)-1L),
/**/ -3.0,
/**/ -Math.E,
/**/ -2.0,
/**/ -1.0000000000000004,
/* < -1.0 */ -1.0000000000000002, // nextAfter(-1.0, -oo)
-1.0,
/* > -1.0 */ -0.9999999999999999, // nextAfter(-1.0, +oo)
/* > -1.0 */ -0.9999999999999998,
/**/ -0.5,
/**/ -1.0/3.0,
-0.0,
+0.0,
/**/ +1.0/3.0,
/**/ +0.5,
/**/ +0.9999999999999998,
/* < +1.0 */ +0.9999999999999999, // nextAfter(-1.0, +oo)
+1.0,
/* > 1.0 */ +1.0000000000000002, // nextAfter(+1.0, +oo)
/**/ +1.0000000000000004,
/**/ +2.0,
/**/ +Math.E,
/**/ +3.0,
/**/ (double) ((1L<<53)-1L),
/**/ (double) ((1L<<53)),
/**/ (double) ((1L<<53)+2L),
};
for(double x: testData) {
for(double y: testData) {
boolean testPass = false;
double actual;
// First, switch on y
} else if (y == 0.0) {
expected = 1.0;
} else if (Double.isInfinite(y) ) {
if(y > 0) { // x ^ (+oo)
expected = +0.0;
} else { // x is NaN
}
} else { // x ^ (-oo)
expected = +0.0;
} else { // x is NaN
}
} /* end Double.isInfinite(y) */
} else if (y == 1.0) {
expected = x;
assert y != 0.0;
} else if (x == Double.NEGATIVE_INFINITY) {
} else if (x == Double.POSITIVE_INFINITY) {
} else if (equivalent(x, +0.0)) {
assert y != 0.0;
} else if (equivalent(x, -0.0)) {
assert y != 0.0;
} else if( x < 0.0) {
assert y != 0.0;
continue;
} else {
// go to next iteration
continue;
}
} // y
} // x
return failures;
}
static boolean equivalent(double a, double b) {
}
static double f1(double y) {
return (intClassify(y) == 1)?
}
static double f2(double y) {
}
static double f3(double x, double y) {
switch( intClassify(y) ) {
case 0:
// break;
case 1:
// break;
case -1:
// break;
default:
throw new AssertionError("Bad classification.");
// break;
}
}
static double f3ns(double x, double y) {
switch( intClassify(y) ) {
case 0:
// break;
case 1:
// break;
case -1:
// break;
default:
throw new AssertionError("Bad classification.");
// break;
}
}
static boolean isFinite(double a) {
return (0.0*a == 0);
}
/**
* Return classification of argument: -1 for non-integers, 0 for
* even integers, 1 for odd integers.
*/
static int intClassify(double a) {
if(!isFinite(a) || // NaNs and infinities
return -1;
}
else {
// Determine if argument is an odd or even integer.
if(a+1.0 == a) { // a > maximum odd floating-point integer
return 0; // Large integers are all even
}
else { // Convert double -> long and look at low-order bit
long ell = (long) a;
}
}
}
int failures = 0;
failures += testCrossProduct();
if (failures > 0) {
+ failures + " failures.");
throw new RuntimeException();
}
}
}