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