blob: 713ed84b503d140a3c61c95b50043a84ac875ed8 [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.7.4.5_A1.2_D02</p>
<div id='console'></div>
<script>
try {
/**
* @name: S15.7.4.5_A1.2_D02;
* @section: 15.7.4.5;
* @assertion: If f < 0 or f > 20, throw a RangeError exception;
* @description: calling on Number object;
*/
//CHECK#2
try{
s = (new Number(1)).toFixed(-1);
testFailed('#2: (new Number(1)).toFixed(-1) should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#2: (new Number(1)).toFixed(-1) should throw RangeError, not the '+e);
}
}
//CHECK#3
try{
s = (new Number(1)).toFixed(20.1);
testFailed('#3: (new Number(1)).toFixed(20.1) should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#3: (new Number(1)).toFixed(20.1) should throw RangeError, not the '+e);
}
}
//CHECK#4
try{
s = (new Number(1)).toFixed(21);
testFailed('#4: (new Number(1)).toFixed(21) should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#4: (new Number(1)).toFixed(21) should throw RangeError, not the '+e);
}
}
//CHECK#5
try{
s = (new Number(1)).toFixed(Number.POSITIVE_INFINITY);
testFailed('#5: (new Number(1)).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#5: (new Number(1)).toFixed(Number.POSITIVE_INFINITY) should throw RangeError, not the '+e);
}
}
//CHECK#6
try{
s = (new Number(1)).toFixed(Number.NEGATIVE_INFINITY);
testFailed('#6: (new Number(1)).toFixed(Number.NEGATIVE_INFINITY) should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#6: (new Number(1)).toFixed(Number.NEGATIVE_INFINITY) should throw RangeError, not the '+e);
}
}
//CHECK#7
try{
s = (new Number(1)).toFixed("-0.1");
testFailed('#1: (new Number(1)).toFixed("-0.1") should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#1: (new Number(1)).toFixed("-0.1") should throw RangeError, not the '+e);
}
}
//CHECK#2
try{
s = (new Number(1)).toFixed("-1");
testFailed('#2: (new Number(1)).toFixed("-1") should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#2: (new Number(1)).toFixed("-1") should throw RangeError, not the '+e);
}
}
//CHECK#3
try{
s = (new Number(1)).toFixed("20.1");
testFailed('#3: (new Number(1)).toFixed("20.1") should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#3: (new Number(1)).toFixed("20.1") should throw RangeError, not the '+e);
}
}
//CHECK#4
try{
s = (new Number(1)).toFixed(21);
testFailed('#4: (new Number(1)).toFixed("21") should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#4: (new Number(1)).toFixed("21") should throw RangeError, not the '+e);
}
}
//CHECK#5
try{
s = (new Number(1)).toFixed("Infinity");
testFailed('#5: (new Number(1)).toFixed("Infinity") should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#5: (new Number(1)).toFixed("Infinity") should throw RangeError, not the '+e);
}
}
//CHECK#6
try{
s = (new Number(1)).toFixed("-Infinity");
testFailed('#6: (new Number(1)).toFixed("-Infinity") should throw RangeError, see the diagnostics tests for this section');
}
catch(e){
if(!(e instanceof RangeError)){
testFailed('#6: (new Number(1)).toFixed("-Infinity") should throw RangeError, not the '+e);
}
}
} 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>