| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
var gTestfile = '15.7.4.6-1.js'; |
| 17 |
var UBound = 0; |
| 18 |
var BUGNUMBER = '(none)'; |
| 19 |
var summary = 'Testing Number.prototype.toExponential(fractionDigits)'; |
| 20 |
var cnIsRangeError = 'instanceof RangeError'; |
| 21 |
var cnNotRangeError = 'NOT instanceof RangeError'; |
| 22 |
var cnNoErrorCaught = 'NO ERROR CAUGHT...'; |
| 23 |
var status = ''; |
| 24 |
var statusitems = []; |
| 25 |
var actual = ''; |
| 26 |
var actualvalues = []; |
| 27 |
var expect= ''; |
| 28 |
var expectedvalues = []; |
| 29 |
var testNum = 77.1234; |
| 30 |
|
| 31 |
|
| 32 |
status = 'Section A of test: no error intended!'; |
| 33 |
actual = testNum.toExponential(4); |
| 34 |
expect = '7.7123e+1'; |
| 35 |
captureThis(); |
| 36 |
|
| 37 |
status = 'Section B of test: Infinity.toExponential() with out-of-range fractionDigits'; |
| 38 |
actual = Number.POSITIVE_INFINITY.toExponential(-3); |
| 39 |
expect = 'Infinity'; |
| 40 |
captureThis(); |
| 41 |
|
| 42 |
status = 'Section C of test: -Infinity.toExponential() with out-of-range fractionDigits'; |
| 43 |
actual = Number.NEGATIVE_INFINITY.toExponential(-3); |
| 44 |
expect = '-Infinity'; |
| 45 |
captureThis(); |
| 46 |
|
| 47 |
status = 'Section D of test: NaN.toExponential() with out-of-range fractionDigits'; |
| 48 |
actual = Number.NaN.toExponential(-3); |
| 49 |
expect = 'NaN'; |
| 50 |
captureThis(); |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
test(); |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
function captureThis() |
| 80 |
{ |
| 81 |
statusitems[UBound] = status; |
| 82 |
actualvalues[UBound] = actual; |
| 83 |
expectedvalues[UBound] = expect; |
| 84 |
UBound++; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
function test() |
| 89 |
{ |
| 90 |
enterFunc ('test'); |
| 91 |
printBugNumber(BUGNUMBER); |
| 92 |
printStatus (summary); |
| 93 |
|
| 94 |
for (var i = 0; i < UBound; i++) |
| 95 |
{ |
| 96 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 97 |
} |
| 98 |
|
| 99 |
exitFunc ('test'); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
function catchError(sEval) |
| 104 |
{ |
| 105 |
try {eval(sEval);} |
| 106 |
catch(e) {return isRangeError(e);} |
| 107 |
return cnNoErrorCaught; |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
function isRangeError(obj) |
| 112 |
{ |
| 113 |
if (obj instanceof RangeError) |
| 114 |
return cnIsRangeError; |
| 115 |
return cnNotRangeError; |
| 116 |
} |