534 lines
34 KiB
TypeScript
Raw Normal View History

// based on http://nsz.repo.hu/git/?p=libc-test
// mostly generated from their tests using scripts/hexfloat.html
assert(Math.E == NativeMath.E); // global alias should exist
const INEXACT = 1 << 0;
const INVALID = 1 << 1;
const DIVBYZERO = 1 << 2;
const UNDERFLOW = 1 << 3;
const OVERFLOW = 1 << 4;
function check<T>(actual: T, expected: T, error: T, flags: i32): void { // TODO: is this correct? -0?
if (isNaN(expected)) {
if (!isNaN(actual)) unreachable();
} else if (actual != expected) {
if (!(flags & INEXACT) || abs<T>(actual - expected) > abs<T>(error)) unreachable();
}
}
// ================================ built-in fmod ================================
2018-03-26 03:50:06 +02:00
function test_fmod(left: f64, right: f64, expected: f64, error: f64, flags: i32): void {
check<f64>(left % right, expected, error, flags);
}
// sanity
2018-03-26 03:50:06 +02:00
test_fmod(-8.06684839057968084, 4.53566256067686879, -3.53118582990281205, 0.00000000000000000, 0);
test_fmod(4.34523984933830487, -8.88799136300345083, 4.34523984933830487, 0.00000000000000000, 0);
test_fmod(-8.38143342755524934, -2.76360733737958819, -0.0906114154164847641, 0.00000000000000000, 0);
test_fmod(-6.53167358191348413, 4.56753527684274374, -1.96413830507074039, 0.00000000000000000, 0);
test_fmod(9.26705696697258574, 4.81139208435979615, 4.45566488261278959, 0.00000000000000000, 0);
test_fmod(-6.45004555606023633, 0.662071792337673881, -0.491399425021171399, 0.00000000000000000, 0);
test_fmod(7.85889025304169664, 0.0521545267500622481, 0.0357112405323594256, 0.00000000000000000, 0);
test_fmod(-0.792054511984895959, 7.67640268511753998, -0.792054511984895959, 0.00000000000000000, 0);
test_fmod(0.615702673197924044, 2.01190257903248026, 0.615702673197924044, 0.00000000000000000, 0);
test_fmod(-0.558758682360915193, 0.0322398306026380407, -0.0106815621160685006, 0.00000000000000000, 0);
// special
2018-03-26 03:50:06 +02:00
test_fmod(0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-0.00000000000000000, 1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(0.500000000000000000, 1.00000000000000000, 0.500000000000000000, 0.00000000000000000, 0);
test_fmod(-0.500000000000000000, 1.00000000000000000, -0.500000000000000000, 0.00000000000000000, 0);
test_fmod(1.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-1.00000000000000000, 1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(1.50000000000000000, 1.00000000000000000, 0.500000000000000000, 0.00000000000000000, 0);
test_fmod(-1.50000000000000000, 1.00000000000000000, -0.500000000000000000, 0.00000000000000000, 0);
test_fmod(2.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-2.00000000000000000, 1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(Infinity, 1.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, 1.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(NaN, 1.00000000000000000, NaN, 0.00000000000000000, 0);
test_fmod(0.00000000000000000, -1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-0.00000000000000000, -1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(0.500000000000000000, -1.00000000000000000, 0.500000000000000000, 0.00000000000000000, 0);
test_fmod(-0.500000000000000000, -1.00000000000000000, -0.500000000000000000, 0.00000000000000000, 0);
test_fmod(1.00000000000000000, -1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-1.00000000000000000, -1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(1.50000000000000000, -1.00000000000000000, 0.500000000000000000, 0.00000000000000000, 0);
test_fmod(-1.50000000000000000, -1.00000000000000000, -0.500000000000000000, 0.00000000000000000, 0);
test_fmod(2.00000000000000000, -1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-2.00000000000000000, -1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(Infinity, -1.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, -1.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(NaN, -1.00000000000000000, NaN, 0.00000000000000000, 0);
test_fmod(0.00000000000000000, 0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(0.00000000000000000, -0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(0.00000000000000000, Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(0.00000000000000000, -Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_fmod(0.00000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_fmod(-0.00000000000000000, 0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-0.00000000000000000, -0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-0.00000000000000000, Infinity, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-0.00000000000000000, -Infinity, -0.00000000000000000, 0.00000000000000000, 0);
test_fmod(-0.00000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_fmod(1.00000000000000000, 0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-1.00000000000000000, 0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(Infinity, 0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, 0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(NaN, 0.00000000000000000, NaN, 0.00000000000000000, 0);
test_fmod(-1.00000000000000000, -0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(Infinity, -0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, -0.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(NaN, -0.00000000000000000, NaN, 0.00000000000000000, 0);
test_fmod(Infinity, 2.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(Infinity, -0.500000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(Infinity, NaN, NaN, 0.00000000000000000, 0);
test_fmod(-Infinity, 2.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, -0.500000000000000000, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, NaN, NaN, 0.00000000000000000, 0);
test_fmod(NaN, NaN, NaN, 0.00000000000000000, 0);
test_fmod(1.00000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_fmod(-1.00000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_fmod(1.00000000000000000, Infinity, 1.00000000000000000, 0.00000000000000000, 0);
test_fmod(-1.00000000000000000, Infinity, -1.00000000000000000, 0.00000000000000000, 0);
test_fmod(Infinity, Infinity, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, Infinity, NaN, 0.00000000000000000, INVALID);
test_fmod(1.00000000000000000, -Infinity, 1.00000000000000000, 0.00000000000000000, 0);
test_fmod(-1.00000000000000000, -Infinity, -1.00000000000000000, 0.00000000000000000, 0);
test_fmod(Infinity, -Infinity, NaN, 0.00000000000000000, INVALID);
test_fmod(-Infinity, -Infinity, NaN, 0.00000000000000000, INVALID);
test_fmod(1.75000000000000000, 0.500000000000000000, 0.250000000000000000, 0.00000000000000000, 0);
test_fmod(-1.75000000000000000, 0.500000000000000000, -0.250000000000000000, 0.00000000000000000, 0);
test_fmod(1.75000000000000000, -0.500000000000000000, 0.250000000000000000, 0.00000000000000000, 0);
test_fmod(-1.75000000000000000, -0.500000000000000000, -0.250000000000000000, 0.00000000000000000, 0);
// ================================ built-in fmodf ================================
2018-03-26 03:50:06 +02:00
function test_fmodf(left: f32, right: f32, expected: f32, error: f32, flags: i32): void {
check<f32>(left % right, expected, error, flags);
}
// sanity
2018-03-26 03:50:06 +02:00
test_fmodf(-8.066848755, 4.535662651, -3.531186104, 0.000000000, 0);
test_fmodf(4.345239639, -8.887990952, 4.345239639, 0.000000000, 0);
test_fmodf(-8.381433487, -2.763607264, -0.09061169624, 0.000000000, 0);
test_fmodf(-6.531673431, 4.567535400, -1.964138031, 0.000000000, 0);
test_fmodf(9.267057419, 4.811392307, 4.455665112, 0.000000000, 0);
test_fmodf(-6.450045586, 0.6620717645, -0.4913997054, 0.000000000, 0);
test_fmodf(7.858890057, 0.05215452611, 0.03571113944, 0.000000000, 0);
test_fmodf(-0.7920545340, 7.676402569, -0.7920545340, 0.000000000, 0);
test_fmodf(0.6157026887, 2.011902571, 0.6157026887, 0.000000000, 0);
test_fmodf(-0.5587586761, 0.03223983198, -0.01068153232, 0.000000000, 0);
// special
2018-03-26 03:50:06 +02:00
test_fmodf(0.000000000, 1.000000000, 0.000000000, 0.000000000, 0);
test_fmodf(-0.000000000, 1.000000000, -0.000000000, 0.000000000, 0);
test_fmodf(0.5000000000, 1.000000000, 0.5000000000, 0.000000000, 0);
test_fmodf(-0.5000000000, 1.000000000, -0.5000000000, 0.000000000, 0);
test_fmodf(1.000000000, 1.000000000, 0.000000000, 0.000000000, 0);
test_fmodf(-1.000000000, 1.000000000, -0.000000000, 0.000000000, 0);
test_fmodf(1.500000000, 1.000000000, 0.5000000000, 0.000000000, 0);
test_fmodf(-1.500000000, 1.000000000, -0.5000000000, 0.000000000, 0);
test_fmodf(2.000000000, 1.000000000, 0.000000000, 0.000000000, 0);
test_fmodf(-2.000000000, 1.000000000, -0.000000000, 0.000000000, 0);
test_fmodf(Infinity, 1.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, 1.000000000, NaN, 0.000000000, INVALID);
test_fmodf(NaN, 1.000000000, NaN, 0.000000000, 0);
test_fmodf(0.000000000, -1.000000000, 0.000000000, 0.000000000, 0);
test_fmodf(-0.000000000, -1.000000000, -0.000000000, 0.000000000, 0);
test_fmodf(0.5000000000, -1.000000000, 0.5000000000, 0.000000000, 0);
test_fmodf(-0.5000000000, -1.000000000, -0.5000000000, 0.000000000, 0);
test_fmodf(1.000000000, -1.000000000, 0.000000000, 0.000000000, 0);
test_fmodf(-1.000000000, -1.000000000, -0.000000000, 0.000000000, 0);
test_fmodf(1.500000000, -1.000000000, 0.5000000000, 0.000000000, 0);
test_fmodf(-1.500000000, -1.000000000, -0.5000000000, 0.000000000, 0);
test_fmodf(2.000000000, -1.000000000, 0.000000000, 0.000000000, 0);
test_fmodf(-2.000000000, -1.000000000, -0.000000000, 0.000000000, 0);
test_fmodf(Infinity, -1.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, -1.000000000, NaN, 0.000000000, INVALID);
test_fmodf(NaN, -1.000000000, NaN, 0.000000000, 0);
test_fmodf(0.000000000, 0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(0.000000000, -0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(0.000000000, Infinity, 0.000000000, 0.000000000, 0);
test_fmodf(0.000000000, -Infinity, 0.000000000, 0.000000000, 0);
test_fmodf(0.000000000, NaN, NaN, 0.000000000, 0);
test_fmodf(-0.000000000, 0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-0.000000000, -0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-0.000000000, Infinity, -0.000000000, 0.000000000, 0);
test_fmodf(-0.000000000, -Infinity, -0.000000000, 0.000000000, 0);
test_fmodf(-0.000000000, NaN, NaN, 0.000000000, 0);
test_fmodf(1.000000000, 0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-1.000000000, 0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(Infinity, 0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, 0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(NaN, 0.000000000, NaN, 0.000000000, 0);
test_fmodf(-1.000000000, -0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(Infinity, -0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, -0.000000000, NaN, 0.000000000, INVALID);
test_fmodf(NaN, -0.000000000, NaN, 0.000000000, 0);
test_fmodf(Infinity, 2.000000000, NaN, 0.000000000, INVALID);
test_fmodf(Infinity, -0.5000000000, NaN, 0.000000000, INVALID);
test_fmodf(Infinity, NaN, NaN, 0.000000000, 0);
test_fmodf(-Infinity, 2.000000000, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, -0.5000000000, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, NaN, NaN, 0.000000000, 0);
test_fmodf(NaN, NaN, NaN, 0.000000000, 0);
test_fmodf(1.000000000, NaN, NaN, 0.000000000, 0);
test_fmodf(-1.000000000, NaN, NaN, 0.000000000, 0);
test_fmodf(1.000000000, Infinity, 1.000000000, 0.000000000, 0);
test_fmodf(-1.000000000, Infinity, -1.000000000, 0.000000000, 0);
test_fmodf(Infinity, Infinity, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, Infinity, NaN, 0.000000000, INVALID);
test_fmodf(1.000000000, -Infinity, 1.000000000, 0.000000000, 0);
test_fmodf(-1.000000000, -Infinity, -1.000000000, 0.000000000, 0);
test_fmodf(Infinity, -Infinity, NaN, 0.000000000, INVALID);
test_fmodf(-Infinity, -Infinity, NaN, 0.000000000, INVALID);
test_fmodf(1.750000000, 0.5000000000, 0.2500000000, 0.000000000, 0);
test_fmodf(-1.750000000, 0.5000000000, -0.2500000000, 0.000000000, 0);
test_fmodf(1.750000000, -0.5000000000, 0.2500000000, 0.000000000, 0);
test_fmodf(-1.750000000, -0.5000000000, -0.2500000000, 0.000000000, 0);
// ================================ Math.log ================================
2018-03-26 03:50:06 +02:00
function test_log(value: f64, expected: f64, error: f64, flags: i32): void {
check<f64>(NativeMath.log(value), expected, error, flags);
check<f64>(JSMath.log(value), expected, error, flags);
}
// sanity
2018-03-26 03:50:06 +02:00
test_log(-8.06684839057968084, NaN, 0.00000000000000000, INVALID);
test_log(4.34523984933830487, 1.46908095842243225, -0.341253340244293213, INEXACT);
test_log(-8.38143342755524934, NaN, 0.00000000000000000, INVALID);
test_log(-6.53167358191348413, NaN, 0.00000000000000000, INVALID);
test_log(9.26705696697258574, 2.22646584987956153, 0.363811403512954712, INEXACT);
test_log(0.661985898099504477, -0.412511025236513673, -0.291087478399276733, INEXACT);
test_log(-0.406603922385355310, NaN, 0.00000000000000000, INVALID);
test_log(0.561759746220724110, -0.576681018319586181, -0.109831996262073517, INEXACT);
test_log(0.774152296591303690, -0.255986659126386518, -0.0579900443553924561, INEXACT);
test_log(-0.678763702639402444, NaN, 0.00000000000000000, INVALID);
// special
2018-03-26 03:50:06 +02:00
test_log(0.00000000000000000, -Infinity, 0.00000000000000000, DIVBYZERO);
test_log(-0.00000000000000000, -Infinity, 0.00000000000000000, DIVBYZERO);
test_log(-7.88860905221011805e-31, NaN, 0.00000000000000000, INVALID);
test_log(1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_log(-1.00000000000000000, NaN, 0.00000000000000000, INVALID);
test_log(Infinity, Infinity, 0.00000000000000000, 0);
test_log(-Infinity, NaN, 0.00000000000000000, INVALID);
test_log(NaN, NaN, 0.00000000000000000, 0);
// ================================ Mathf.log ================================
2018-03-26 03:50:06 +02:00
function test_logf(value: f32, expected: f32, error: f32, flags: i32): void {
check<f32>(NativeMathf.log(value), expected, error, flags);
}
// sanity
2018-03-26 03:50:06 +02:00
test_logf(0.000000000, -Infinity, 0.000000000, DIVBYZERO);
test_logf(-0.000000000, -Infinity, 0.000000000, DIVBYZERO);
test_logf(-7.888609052e-31, NaN, 0.000000000, INVALID);
test_logf(1.000000000, 0.000000000, 0.000000000, 0);
test_logf(-1.000000000, NaN, 0.000000000, INVALID);
test_logf(Infinity, Infinity, 0.000000000, 0);
test_logf(-Infinity, NaN, 0.000000000, INVALID);
test_logf(NaN, NaN, 0.000000000, 0);
// special
2018-03-26 03:50:06 +02:00
test_logf(0.000000000, -Infinity, 0.000000000, DIVBYZERO);
test_logf(-0.000000000, -Infinity, 0.000000000, DIVBYZERO);
test_logf(-7.888609052e-31, NaN, 0.000000000, INVALID);
test_logf(1.000000000, 0.000000000, 0.000000000, 0);
test_logf(-1.000000000, NaN, 0.000000000, INVALID);
test_logf(Infinity, Infinity, 0.000000000, 0);
test_logf(-Infinity, NaN, 0.000000000, INVALID);
test_logf(NaN, NaN, 0.000000000, 0);
// ================================ Math.exp ================================
2018-03-26 03:50:06 +02:00
function test_exp(value: f64, expected: f64, error: f64, flags: i32): void {
check<f64>(NativeMath.exp(value), expected, error, flags);
check<f64>(JSMath.exp(value), expected, error, flags);
}
// sanity
2018-03-26 03:50:06 +02:00
test_exp(-8.06684839057968084, 0.000313770606816174511, -0.259919732809066772, INEXACT);
test_exp(4.34523984933830487, 77.1105301711214111, -0.0279267579317092896, INEXACT);
test_exp(-8.38143342755524934, 0.000229081338491632304, -0.249743342399597168, INEXACT);
test_exp(-6.53167358191348413, 0.00145656612609315877, -0.481682240962982178, INEXACT);
test_exp(9.26705696697258574, 10583.5582455249933, 0.176967620849609375, INEXACT);
test_exp(0.661985898099504477, 1.93863845255719980, -0.496424645185470581, INEXACT);
test_exp(-0.406603922385355310, 0.665907889283802512, -0.106083184480667114, INEXACT);
test_exp(0.561759746220724110, 1.75375595186263111, -0.391621112823486328, INEXACT);
test_exp(0.774152296591303690, 2.16875288851292458, -0.299612581729888916, INEXACT);
test_exp(-0.678763702639402444, 0.507243708940284255, 0.472617387771606445, INEXACT);
// special
2018-03-26 03:50:06 +02:00
test_exp(0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_exp(-0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_exp(1.00000000000000000, 2.71828182845904509, -0.325530737638473511, INEXACT);
test_exp(-1.00000000000000000, 0.367879441171442334, 0.223896518349647522, INEXACT);
test_exp(Infinity, Infinity, 0.00000000000000000, 0);
test_exp(-Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_exp(NaN, NaN, 0.00000000000000000, 0);
test_exp(1.03972148895263650, 2.82842915587641119, 0.188030809164047241, INEXACT);
test_exp(-1.03972148895263650, 0.353553136702178472, 0.252727240324020386, INEXACT);
test_exp(1.03972101211547852, 2.82842780717661224, -0.418413937091827393, INEXACT);
test_exp(1.03972148895263672, 2.82842915587641164, -0.226183772087097168, INEXACT);
// ================================ Mathf.exp ================================
2018-03-26 03:50:06 +02:00
function test_expf(value: f32, expected: f32, error: f32, flags: i32): void {
check<f32>(NativeMathf.exp(value), expected, error, flags);
}
// sanity
2018-03-26 03:50:06 +02:00
test_expf(-8.066848755, 0.0003137704916, -0.03019333631, INEXACT);
test_expf(4.345239639, 77.11051178, -0.2875460684, INEXACT);
test_expf(-8.381433487, 0.0002290813281, 0.2237040401, INEXACT);
test_expf(-6.531673431, 0.001456566388, 0.3646970391, INEXACT);
test_expf(9.267057419, 10583.56348, 0.4596210420, INEXACT);
test_expf(0.6619858742, 1.938638449, 0.3568260968, INEXACT);
test_expf(-0.4066039324, 0.6659078598, -0.3829499185, INEXACT);
test_expf(0.5617597699, 1.753756046, 0.4435549080, INEXACT);
test_expf(0.7741522789, 2.168752909, 0.2456246912, INEXACT);
test_expf(-0.6787636876, 0.5072436929, -0.3974292278, INEXACT);
// special
2018-03-26 03:50:06 +02:00
test_expf(0.000000000, 1.000000000, 0.000000000, 0);
test_expf(-0.000000000, 1.000000000, 0.000000000, 0);
test_expf(1.000000000, 2.718281746, -0.3462330997, INEXACT);
test_expf(-1.000000000, 0.3678794503, 0.3070148528, INEXACT);
test_expf(Infinity, Infinity, 0.000000000, 0);
test_expf(-Infinity, 0.000000000, 0.000000000, 0);
test_expf(NaN, NaN, 0.000000000, 0);
test_expf(88.72283173, 3.402798519e+38, -0.09067153931, INEXACT);
test_expf(88.72283936, Infinity, 0.000000000, INEXACT|OVERFLOW);
test_expf(-103.9720764, 1.401298464e-45, 0.4999996722, INEXACT|UNDERFLOW);
test_expf(-103.9720840, 0.000000000, -0.4999965131, INEXACT|UNDERFLOW);
test_expf(0.3465735614, 1.414213538, 0.1392242163, INEXACT);
test_expf(0.3465735912, 1.414213538, -0.2143291682, INEXACT);
test_expf(0.3465736210, 1.414213657, 0.4321174324, INEXACT);
// ================================ Math.pow ================================
function test_pow(left: f64, right: f64, expected: f64, error: f64, flags: i32): void {
check<f64>(NativeMath.pow(left, right), expected, error, flags);
2018-03-26 03:50:06 +02:00
}
// sanity
test_pow(-8.06684839057968084, 4.53566256067686879, NaN, 0.00000000000000000, INVALID);
test_pow(4.34523984933830487, -8.88799136300345083, 0.00000213471188255872853, 0.325016021728515625, INEXACT);
test_pow(-8.38143342755524934, -2.76360733737958819, NaN, 0.00000000000000000, INVALID);
test_pow(-6.53167358191348413, 4.56753527684274374, NaN, 0.00000000000000000, INVALID);
test_pow(9.26705696697258574, 4.81139208435979615, 44909.2994151296589, -0.266590803861618042, INEXACT);
test_pow(-6.45004555606023633, 0.662071792337673881, NaN, 0.00000000000000000, INVALID);
test_pow(7.85889025304169664, 0.0521545267500622481, 1.11351774134586523, -0.371686071157455444, INEXACT);
test_pow(-0.792054511984895959, 7.67640268511753998, NaN, 0.00000000000000000, INVALID);
test_pow(0.615702673197924044, 2.01190257903248026, 0.376907735213801831, 0.324733018875122070, INEXACT);
test_pow(-0.558758682360915193, 0.0322398306026380407, NaN, 0.00000000000000000, INVALID);
// special
test_pow(0.00000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_pow(0.00000000000000000, Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(0.00000000000000000, 3.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(0.00000000000000000, 2.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(0.00000000000000000, 0.500000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(0.00000000000000000, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(0.00000000000000000, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(0.00000000000000000, -0.500000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(0.00000000000000000, -1.00000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(0.00000000000000000, -2.00000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(0.00000000000000000, -3.00000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(0.00000000000000000, -4.00000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(0.00000000000000000, -Infinity, Infinity, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, 3.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, 2.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, 1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, 0.500000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.00000000000000000, -0.500000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(-0.00000000000000000, -1.00000000000000000, -Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(-0.00000000000000000, -2.00000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(-0.00000000000000000, -3.00000000000000000, -Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(-0.00000000000000000, -4.00000000000000000, Infinity, 0.00000000000000000, DIVBYZERO);
test_pow(-0.00000000000000000, -Infinity, Infinity, 0.00000000000000000, 0);
test_pow(NaN, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(Infinity, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-Infinity, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.500000000000000000, 0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(NaN, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(Infinity, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-Infinity, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.500000000000000000, -0.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, Infinity, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, -Infinity, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, 2.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, -1.00000000000000000, -1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, -2.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, -3.00000000000000000, -1.00000000000000000, 0.00000000000000000, 0);
test_pow(-1.00000000000000000, 0.500000000000000000, NaN, 0.00000000000000000, INVALID);
test_pow(1.00000000000000000, NaN, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, Infinity, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, -Infinity, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, 3.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, 0.500000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, -0.500000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(1.00000000000000000, -3.00000000000000000, 1.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.500000000000000000, 0.500000000000000000, NaN, 0.00000000000000000, INVALID);
test_pow(-0.500000000000000000, 1.50000000000000000, NaN, 0.00000000000000000, INVALID);
test_pow(-0.500000000000000000, 2.00000000000000000, 0.250000000000000000, 0.00000000000000000, 0);
test_pow(-0.500000000000000000, 3.00000000000000000, -0.125000000000000000, 0.00000000000000000, 0);
test_pow(-0.500000000000000000, Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(-0.500000000000000000, -Infinity, Infinity, 0.00000000000000000, 0);
test_pow(-0.500000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_pow(0.500000000000000000, Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(0.500000000000000000, -Infinity, Infinity, 0.00000000000000000, 0);
test_pow(0.500000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_pow(1.50000000000000000, Infinity, Infinity, 0.00000000000000000, 0);
test_pow(1.50000000000000000, -Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(1.50000000000000000, NaN, NaN, 0.00000000000000000, 0);
test_pow(Infinity, NaN, NaN, 0.00000000000000000, 0);
test_pow(Infinity, Infinity, Infinity, 0.00000000000000000, 0);
test_pow(Infinity, -Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(Infinity, 3.00000000000000000, Infinity, 0.00000000000000000, 0);
test_pow(Infinity, 2.00000000000000000, Infinity, 0.00000000000000000, 0);
test_pow(Infinity, 1.00000000000000000, Infinity, 0.00000000000000000, 0);
test_pow(Infinity, 0.500000000000000000, Infinity, 0.00000000000000000, 0);
test_pow(Infinity, -0.500000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(Infinity, -1.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(Infinity, -2.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(-Infinity, NaN, NaN, 0.00000000000000000, 0);
test_pow(-Infinity, Infinity, Infinity, 0.00000000000000000, 0);
test_pow(-Infinity, -Infinity, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(-Infinity, 3.00000000000000000, -Infinity, 0.00000000000000000, 0);
test_pow(-Infinity, 2.00000000000000000, Infinity, 0.00000000000000000, 0);
test_pow(-Infinity, 1.00000000000000000, -Infinity, 0.00000000000000000, 0);
test_pow(-Infinity, 0.500000000000000000, Infinity, 0.00000000000000000, 0);
test_pow(-Infinity, -0.500000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(-Infinity, -1.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0);
test_pow(-Infinity, -2.00000000000000000, 0.00000000000000000, 0.00000000000000000, 0);
test_pow(NaN, 1.00000000000000000, NaN, 0.00000000000000000, 0);
test_pow(NaN, -1.00000000000000000, NaN, 0.00000000000000000, 0);
test_pow(-2.00000000000000000, 1.00000000000000000, -2.00000000000000000, 0.00000000000000000, 0);
test_pow(-2.00000000000000000, -1.00000000000000000, -0.500000000000000000, 0.00000000000000000, 0);
// ================================ Mathf.pow ================================
function test_powf(left: f32, right: f32, expected: f32, error: f32, flags: i32): void {
check<f32>(NativeMathf.pow(left, right), expected, error, flags);
2018-03-26 03:50:06 +02:00
}
// sanity
test_powf(-8.066848755, 4.535662651, NaN, 0.000000000, INVALID);
test_powf(4.345239639, -8.887990952, 0.000002134714123, 0.1436440796, INEXACT);
test_powf(-8.381433487, -2.763607264, NaN, 0.000000000, INVALID);
test_powf(-6.531673431, 4.567535400, NaN, 0.000000000, INVALID);
test_powf(9.267057419, 4.811392307, 44909.33203, -0.05356409028, INEXACT);
test_powf(-6.450045586, 0.6620717645, NaN, 0.000000000, INVALID);
test_powf(7.858890057, 0.05215452611, 1.113517761, 0.1912208945, INEXACT);
test_powf(-0.7920545340, 7.676402569, NaN, 0.000000000, INVALID);
test_powf(0.6157026887, 2.011902571, 0.3769077659, 0.3371490538, INEXACT);
test_powf(-0.5587586761, 0.03223983198, NaN, 0.000000000, INVALID);
// special
test_powf(0.000000000, NaN, NaN, 0.000000000, 0);
test_powf(0.000000000, Infinity, 0.000000000, 0.000000000, 0);
test_powf(0.000000000, 3.000000000, 0.000000000, 0.000000000, 0);
test_powf(0.000000000, 2.000000000, 0.000000000, 0.000000000, 0);
test_powf(0.000000000, 1.000000000, 0.000000000, 0.000000000, 0);
test_powf(0.000000000, 0.5000000000, 0.000000000, 0.000000000, 0);
test_powf(0.000000000, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(0.000000000, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(0.000000000, -0.5000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(0.000000000, -1.000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(0.000000000, -2.000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(0.000000000, -3.000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(0.000000000, -4.000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(0.000000000, -Infinity, Infinity, 0.000000000, 0);
test_powf(-0.000000000, NaN, NaN, 0.000000000, 0);
test_powf(-0.000000000, Infinity, 0.000000000, 0.000000000, 0);
test_powf(-0.000000000, 3.000000000, -0.000000000, 0.000000000, 0);
test_powf(-0.000000000, 2.000000000, 0.000000000, 0.000000000, 0);
test_powf(-0.000000000, 1.000000000, -0.000000000, 0.000000000, 0);
test_powf(-0.000000000, 0.5000000000, 0.000000000, 0.000000000, 0);
test_powf(-0.000000000, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-0.000000000, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-0.000000000, -0.5000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(-0.000000000, -1.000000000, -Infinity, 0.000000000, DIVBYZERO);
test_powf(-0.000000000, -2.000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(-0.000000000, -3.000000000, -Infinity, 0.000000000, DIVBYZERO);
test_powf(-0.000000000, -4.000000000, Infinity, 0.000000000, DIVBYZERO);
test_powf(-0.000000000, -Infinity, Infinity, 0.000000000, 0);
test_powf(NaN, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(Infinity, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-Infinity, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-1.000000000, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-0.5000000000, 0.000000000, 1.000000000, 0.000000000, 0);
test_powf(NaN, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(Infinity, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-Infinity, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-1.000000000, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-0.5000000000, -0.000000000, 1.000000000, 0.000000000, 0);
test_powf(-1.000000000, NaN, NaN, 0.000000000, 0);
test_powf(-1.000000000, Infinity, 1.000000000, 0.000000000, 0);
test_powf(-1.000000000, -Infinity, 1.000000000, 0.000000000, 0);
test_powf(-1.000000000, 2.000000000, 1.000000000, 0.000000000, 0);
test_powf(-1.000000000, -1.000000000, -1.000000000, 0.000000000, 0);
test_powf(-1.000000000, -2.000000000, 1.000000000, 0.000000000, 0);
test_powf(-1.000000000, -3.000000000, -1.000000000, 0.000000000, 0);
test_powf(-1.000000000, 0.5000000000, NaN, 0.000000000, INVALID);
test_powf(1.000000000, NaN, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, Infinity, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, -Infinity, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, 3.000000000, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, 0.5000000000, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, -0.5000000000, 1.000000000, 0.000000000, 0);
test_powf(1.000000000, -3.000000000, 1.000000000, 0.000000000, 0);
test_powf(-0.5000000000, 0.5000000000, NaN, 0.000000000, INVALID);
test_powf(-0.5000000000, 1.500000000, NaN, 0.000000000, INVALID);
test_powf(-0.5000000000, 2.000000000, 0.2500000000, 0.000000000, 0);
test_powf(-0.5000000000, 3.000000000, -0.1250000000, 0.000000000, 0);
test_powf(-0.5000000000, Infinity, 0.000000000, 0.000000000, 0);
test_powf(-0.5000000000, -Infinity, Infinity, 0.000000000, 0);
test_powf(-0.5000000000, NaN, NaN, 0.000000000, 0);
test_powf(0.5000000000, Infinity, 0.000000000, 0.000000000, 0);
test_powf(0.5000000000, -Infinity, Infinity, 0.000000000, 0);
test_powf(0.5000000000, NaN, NaN, 0.000000000, 0);
test_powf(1.500000000, Infinity, Infinity, 0.000000000, 0);
test_powf(1.500000000, -Infinity, 0.000000000, 0.000000000, 0);
test_powf(1.500000000, NaN, NaN, 0.000000000, 0);
test_powf(Infinity, NaN, NaN, 0.000000000, 0);
test_powf(Infinity, Infinity, Infinity, 0.000000000, 0);
test_powf(Infinity, -Infinity, 0.000000000, 0.000000000, 0);
test_powf(Infinity, 3.000000000, Infinity, 0.000000000, 0);
test_powf(Infinity, 2.000000000, Infinity, 0.000000000, 0);
test_powf(Infinity, 1.000000000, Infinity, 0.000000000, 0);
test_powf(Infinity, 0.5000000000, Infinity, 0.000000000, 0);
test_powf(Infinity, -0.5000000000, 0.000000000, 0.000000000, 0);
test_powf(Infinity, -1.000000000, 0.000000000, 0.000000000, 0);
test_powf(Infinity, -2.000000000, 0.000000000, 0.000000000, 0);
test_powf(-Infinity, NaN, NaN, 0.000000000, 0);
test_powf(-Infinity, Infinity, Infinity, 0.000000000, 0);
test_powf(-Infinity, -Infinity, 0.000000000, 0.000000000, 0);
test_powf(-Infinity, 3.000000000, -Infinity, 0.000000000, 0);
test_powf(-Infinity, 2.000000000, Infinity, 0.000000000, 0);
test_powf(-Infinity, 1.000000000, -Infinity, 0.000000000, 0);
test_powf(-Infinity, 0.5000000000, Infinity, 0.000000000, 0);
test_powf(-Infinity, -0.5000000000, 0.000000000, 0.000000000, 0);
test_powf(-Infinity, -1.000000000, -0.000000000, 0.000000000, 0);
test_powf(-Infinity, -2.000000000, 0.000000000, 0.000000000, 0);
test_powf(NaN, 1.000000000, NaN, 0.000000000, 0);
test_powf(NaN, -1.000000000, NaN, 0.000000000, 0);
test_powf(-2.000000000, 1.000000000, -2.000000000, 0.000000000, 0);
test_powf(-2.000000000, -1.000000000, -0.5000000000, 0.000000000, 0);