1 <p>This page tests whether primitive conversions during equality tests properly
2 throw exceptions. If the test passes, you'll see a series of PASS messages below.
5 <pre id=
"console"></pre>
10 document
.getElementById("console").appendChild(document
.createTextNode(s
+ "\n"));
13 function shouldThrow(expression
, exception
, didCorrectlyThrow
)
15 if (didCorrectlyThrow
)
16 log("PASS: " + expression
+ " should throw a " + exception
+ ", and did.");
18 log("FAIL: " + expression
+ " should throw a " + exception
+ ", but didn't.");
21 if (window
.testRunner
)
22 testRunner
.dumpAsText();
26 return { }; // should throw, because this is not a primitive value
29 toString: function() {
30 return { }; // should throw, because this is not a primitive value
34 shouldThrow("o == 'a'", "type error", (function() { try { o
== 'a'; return false; } catch(e
) { return e
instanceof TypeError
; } })());
35 shouldThrow("o != 'a'", "type error", (function() { try { o
!= 'a'; return false; } catch(e
) { return e
instanceof TypeError
; } })());
36 shouldThrow("o == 0", "type error", (function() { try { o
== 'a'; return false; } catch(e
) { return e
instanceof TypeError
; } })());
37 shouldThrow("o != 0", "type error", (function() { try { o
!= 'a'; return false; } catch(e
) { return e
instanceof TypeError
; } })());