mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 22:40:28 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
128 lines
2.6 KiB
JavaScript
128 lines
2.6 KiB
JavaScript
// Basic cases of Math.log() when the value passed are constants.
|
|
|
|
// log(NaN).
|
|
function logNaN() {
|
|
return Math.log(NaN);
|
|
}
|
|
noInline(logNaN);
|
|
|
|
function testLogNaN() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logNaN();
|
|
if (!isNaN(result))
|
|
throw "logNaN() = " + result + ", expected NaN";
|
|
}
|
|
}
|
|
testLogNaN();
|
|
|
|
|
|
// log(0).
|
|
function logZero() {
|
|
return Math.log(0);
|
|
}
|
|
noInline(logZero);
|
|
|
|
function testLogZero() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logZero();
|
|
if (result !== -Infinity)
|
|
throw "logZero() = " + result + ", expected -Infinity";
|
|
}
|
|
}
|
|
testLogZero();
|
|
|
|
|
|
// log(1).
|
|
function logOne() {
|
|
return Math.log(1);
|
|
}
|
|
noInline(logOne);
|
|
|
|
function testLogOne() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logOne();
|
|
if (result !== 0)
|
|
throw "logOne(1) = " + result + ", expected 0";
|
|
}
|
|
}
|
|
testLogOne();
|
|
|
|
|
|
// log(-1).
|
|
function logMinusOne() {
|
|
return Math.log(-1);
|
|
}
|
|
noInline(logMinusOne);
|
|
|
|
function testLogMinusOne() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logMinusOne();
|
|
if (!isNaN(result))
|
|
throw "logMinusOne() = " + result + ", expected NaN";
|
|
}
|
|
}
|
|
testLogMinusOne();
|
|
|
|
|
|
// log(Infinity).
|
|
function logInfinity() {
|
|
return Math.log(Infinity);
|
|
}
|
|
noInline(logInfinity);
|
|
|
|
function testLogInfinity() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logInfinity();
|
|
if (result !== Infinity)
|
|
throw "logInfinity() = " + result + ", expected Infinity";
|
|
}
|
|
}
|
|
testLogInfinity();
|
|
|
|
|
|
// log(-Infinity).
|
|
function logMinusInfinity() {
|
|
return Math.log(-Infinity);
|
|
}
|
|
noInline(logMinusInfinity);
|
|
|
|
function testLogMinusInfinity() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logMinusInfinity();
|
|
if (!isNaN(result))
|
|
throw "logMinusInfinity() = " + result + ", expected NaN";
|
|
}
|
|
}
|
|
testLogMinusInfinity();
|
|
|
|
|
|
// log(integer).
|
|
function logInteger() {
|
|
return Math.log(42);
|
|
}
|
|
noInline(logInteger);
|
|
|
|
function testLogInteger() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logInteger();
|
|
if (result !== 3.7376696182833684)
|
|
throw "logInteger() = " + result + ", expected 3.7376696182833684";
|
|
}
|
|
}
|
|
testLogInteger();
|
|
|
|
|
|
// log(double).
|
|
function logDouble() {
|
|
return Math.log(Math.PI);
|
|
}
|
|
noInline(logDouble);
|
|
|
|
function testLogDouble() {
|
|
for (var i = 0; i < 10000; ++i) {
|
|
var result = logDouble();
|
|
if (result !== 1.1447298858494002)
|
|
throw "logDouble() = " + result + ", expected 1.1447298858494002";
|
|
}
|
|
}
|
|
testLogDouble(); |