blob: 84c4ee572c2bb5206e4153b5f929c1a5999ca130 [file] [log] [blame]
<html>
<head>
<meta charset='utf-8'>
<style>
.pass {
font-weight: bold;
color: green;
}
.fail {
font-weight: bold;
color: red;
}
</style>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function SputnikError(message)
{
this.message = message;
}
SputnikError.prototype.toString = function ()
{
return 'SputnikError: ' + this.message;
};
var sputnikException;
function testPrint(msg)
{
var span = document.createElement("span");
document.getElementById("console").appendChild(span); // insert it first so XHTML knows the namespace
span.innerHTML = msg + '<br />';
}
function escapeHTML(text)
{
return text.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;");
}
function printTestPassed(msg)
{
testPrint('<span><span class="pass">PASS</span> ' + escapeHTML(msg) + '</span>');
}
function printTestFailed(msg)
{
testPrint('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>');
}
function testFailed(msg)
{
throw new SputnikError(msg);
}
var successfullyParsed = false;
</script>
</head>
<body>
<p>S15.8.2.11_A2</p>
<div id='console'></div>
<script>
try {
/**
* @name: S15.8.2.11_A2;
* @section: 15.8.2.11;
* @assertion: If any value is NaN, the result of Math.max is NaN;
* @description: The script tests Math.max giving 1, 2 and 3 arguments to the function where at least one of the arguments is NaN
*/
// CHECK#1
if (!isNaN(Math.max(NaN)))
{
testFailed("#1: 'isNaN(Math.max(NaN)) === false");
}
// CHECK#2
vals = new Array();
vals[0] = -Infinity;
vals[1] = -0.000000000000001;
vals[2] = -0;
vals[3] = +0
vals[4] = 0.000000000000001;
vals[5] = +Infinity;
vals[6] = NaN;
valnum = 7;
args = new Array();
for (i = 0; i <= 1; i++)
{
args[i] = NaN;
for (j = 0; j < valnum; j++)
{
args[1-i] = vals[j];
if (!isNaN(Math.max(args[0], args[1])))
{
testFailed("#2: 'isNaN(Math.max(" + args[0] + ", " + args[1] + ")) === false");
}
}
}
// CHECK #3
var k = 1;
var l = 2;
for (i = 0; i <= 2; i++)
{
args[i] = NaN;
if (i === 1)
{
k = 0;
} else if (i === 2)
{
l = 1;
}
for (j = 0; j < valnum; j++)
{
for (jj = 0; jj < valnum; jj++)
{
args[k] = vals[j];
args[l] = vals[jj];
if (!isNaN(Math.max(args[0], args[1], args[2])))
{
testFailed("#3: 'isNaN(Math.max(" + args[0] + ", " + args[1] + ", " + args[2] + ")) === false");
}
}
}
}
} catch (ex) {
sputnikException = ex;
}
var successfullyParsed = true;
</script>
<script>
if (!successfullyParsed)
printTestFailed('successfullyParsed is not set');
else if (sputnikException)
printTestFailed(sputnikException);
else
printTestPassed("");
testPrint('<br /><span class="pass">TEST COMPLETE</span>');
</script>
</body>
</html>