blob: f4de0242625b9e3940f1def916caa3295b2dceef [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.4_A1.1_T2</p>
<div id='console'></div>
<script>
try {
/**
* @name: S15.4_A1.1_T2;
* @section: 15.4, 11.2.1;
* @assertion: A property name P (in the form of a string value) is an array index
* if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1;
* @description: Checking for number primitive;
*/
//CHECK#1
x = [];
x[NaN] = 1;
if (x[0] !== undefined) {
testFailed('#1: x = []; x[NaN] = 1; x[0] === undefined. Actual: ' + (x[0]));
}
//CHECK#2
if (x["NaN"] !== 1) {
testFailed('#2: x = []; x[NaN] = 1; x["NaN"] === 1. Actual: ' + (x["NaN"]));
}
//CHECK#3
y = [];
y[Number.POSITIVE_INFINITY] = 1;
if (y[0] !== undefined) {
testFailed('#3: y = []; y[Number.POSITIVE_INFINITY] = 1; y[0] === undefined. Actual: ' + (y[0]));
}
//CHECK#4
if (y["Infinity"] !== 1) {
testFailed('#4: y = []; y[Number.POSITIVE_INFINITY] = 1; y["Infinity"] === 1. Actual: ' + (y["Infinity"]));
}
//CHECK#5
z = [];
z[Number.NEGATIVE_INFINITY] = 1;
if (z[0] !== undefined) {
testFailed('#5: z = []; z[Number.NEGATIVE_INFINITY] = 1; z[0] === undefined. Actual: ' + (z[0]));
}
//CHECK#6
if (z["-Infinity"] !== 1) {
testFailed('#6: z = []; z[Number.NEGATIVE_INFINITY] = 1; z["-Infinity"] === 1. Actual: ' + (z["-Infinity"]));
}
} 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>