| <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, "&").replace(/</g, "<"); |
| } |
| |
| 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>S9.2_A6_T1</p> |
| <div id='console'></div> |
| <script> |
| try { |
| |
| /** |
| * @name: S9.2_A6_T1; |
| * @section: 9.2, 15.6.1; |
| * @assertion: Result of boolean conversion from object is true; |
| * @description: Different objects convert to Boolean by explicit transformation; |
| */ |
| |
| // CHECK#1 |
| if (Boolean(new Object()) !== true) { |
| testFailed('#1: Boolean(new Object()) === true. Actual: ' + (Boolean(new Object()))); |
| } |
| |
| // CHECK#2 |
| if (Boolean(new String("")) !== true) { |
| testFailed('#2: Boolean(new String("")) === true. Actual: ' + (Boolean(new String("")))); |
| } |
| |
| // CHECK#3 |
| if (Boolean(new String()) !== true) { |
| testFailed('#3: Boolean(new String()) === true. Actual: ' + (Boolean(new String()))); |
| } |
| |
| // CHECK#4 |
| if (Boolean(new Boolean(true)) !== true) { |
| testFailed('#4: Boolean(new Boolean(true)) === true. Actual: ' + (Boolean(new Boolean(true)))); |
| } |
| |
| // CHECK#5 |
| if (Boolean(new Boolean(false)) !== true) { |
| testFailed('#5: Boolean(new Boolean(false)) === true. Actual: ' + (Boolean(new Boolean(false)))); |
| } |
| |
| // CHECK#6 |
| if (Boolean(new Boolean()) !== true) { |
| testFailed('#6: Boolean(new Boolean()) === true. Actual: ' + (Boolean(new Boolean()))); |
| } |
| |
| // CHECK#7 |
| if (Boolean(new Array()) !== true) { |
| testFailed('#7: Boolean(new Array()) === true. Actual: ' + (Boolean(new Array()))); |
| } |
| |
| // CHECK#8 |
| if (Boolean(new Number()) !== true) { |
| testFailed('#8: Boolean(new Number()) === true. Actual: ' + (Boolean(new Number()))); |
| } |
| |
| // CHECK#9 |
| if (Boolean(new Number(-0)) !== true) { |
| testFailed('#9: Boolean(new Number(-0)) === true. Actual: ' + (Boolean(new Number(-0)))); |
| } |
| |
| // CHECK#10 |
| if (Boolean(new Number(0)) !== true) { |
| testFailed('#10: Boolean(new Number(0)) === true. Actual: ' + (Boolean(new Number(0)))); |
| } |
| |
| // CHECK#11 |
| if (Boolean(new Number()) !== true) { |
| testFailed('#11: Boolean(new Number()) === true. Actual: ' + (Boolean(new Number()))); |
| } |
| |
| // CHECK#12 |
| if (Boolean(new Number(Number.NaN)) !== true) { |
| testFailed('#12: Boolean(new Number(Number.NaN)) === true. Actual: ' + (Boolean(new Number(Number.NaN)))); |
| } |
| |
| // CHECK#13 |
| if (Boolean(new Number(-1)) !== true) { |
| testFailed('#13: Boolean(new Number(-1)) === true. Actual: ' + (Boolean(new Number(-1)))); |
| } |
| |
| // CHECK#14 |
| if (Boolean(new Number(1)) !== true) { |
| testFailed('#14: Boolean(new Number(1)) === true. Actual: ' + (Boolean(new Number(1)))); |
| } |
| |
| // CHECK#15 |
| if (Boolean(new Number(Number.POSITIVE_INFINITY)) !== true) { |
| testFailed('#15: Boolean(new Number(Number.POSITIVE_INFINITY)) === true. Actual: ' + (Boolean(new Number(Number.POSITIVE_INFINITY)))); |
| } |
| |
| // CHECK#16 |
| if (Boolean(new Number(Number.NEGATIVE_INFINITY)) !== true) { |
| testFailed('#16: Boolean(new Number(Number.NEGATIVE_INFINITY)) === true. Actual: ' + (Boolean(new Number(Number.NEGATIVE_INFINITY)))); |
| } |
| |
| // CHECK#17 |
| if (Boolean(new Function()) !== true) { |
| testFailed('#17: Boolean(new Function()) === true. Actual: ' + (Boolean(new Function()))); |
| } |
| |
| // CHECK#18 |
| if (Boolean(new Date()) !== true) { |
| testFailed('#18: Boolean(new Date()) === true. Actual: ' + (Boolean(new Date()))); |
| } |
| |
| // CHECK#19 |
| if (Boolean(new Date(0)) !== true) { |
| testFailed('#19: Boolean(new Date(0)) === true. Actual: ' + (Boolean(new Date(0)))); |
| } |
| |
| } 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> |