michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * If Type(x) is primitive type and Type(y) is Object, michael@0: * return x != ToPrimitive(y) michael@0: * michael@0: * @path ch11/11.9/11.9.2/S11.9.2_A7.9.js michael@0: * @description y is object, x is primtitive michael@0: */ michael@0: michael@0: //CHECK#1 michael@0: if (({valueOf: function() {return 1}} != true) !== false) { michael@0: $ERROR('#1: ({valueOf: function() {return 1}} != true) === false'); michael@0: } michael@0: michael@0: //CHECK#2 michael@0: if (({valueOf: function() {return 1}, toString: function() {return 0}} != 1) !== false) { michael@0: $ERROR('#2: ({valueOf: function() {return 1}, toString: function() {return 0}} != 1) === false'); michael@0: } michael@0: michael@0: //CHECK#3 michael@0: if (({valueOf: function() {return 1}, toString: function() {return {}}} != "+1") !== false) { michael@0: $ERROR('#3: ({valueOf: function() {return 1}, toString: function() {return {}}} != "+1") === false'); michael@0: } michael@0: michael@0: //CHECK#4 michael@0: try { michael@0: if (({valueOf: function() {return "+1"}, toString: function() {throw "error"}} != true) !== false) { michael@0: $ERROR('#4.1: ({valueOf: function() {return "+1"}, toString: function() {throw "error"}} != true) === false'); michael@0: } michael@0: } michael@0: catch (e) { michael@0: if (e === "error") { michael@0: $ERROR('#4.2: ({valueOf: function() {return "+1"}, toString: function() {throw "error"}} != true) not throw "error"'); michael@0: } else { michael@0: $ERROR('#4.3: ({valueOf: function() {return "+1"}, toString: function() {throw "error"}} != true) not throw Error. Actual: ' + (e)); michael@0: } michael@0: } michael@0: michael@0: //CHECK#5 michael@0: if (({toString: function() {return "+1"}} != 1) !== false) { michael@0: $ERROR('#5: ({toString: function() {return "+1"}} != 1) === false'); michael@0: } michael@0: michael@0: //CHECK#6 michael@0: if (({valueOf: function() {return {}}, toString: function() {return "+1"}} != "1") !== true) { michael@0: $ERROR('#6.1: ({valueOf: function() {return {}}, toString: function() {return "+1"}} != "1") === true'); michael@0: } else { michael@0: if (({valueOf: function() {return {}}, toString: function() {return "+1"}} != "+1") !== false) { michael@0: $ERROR('#6.2: ({valueOf: function() {return {}}, toString: function() {return "+1"}} != "+1") === false'); michael@0: } michael@0: } michael@0: michael@0: //CHECK#7 michael@0: try { michael@0: ({valueOf: function() {throw "error"}, toString: function() {return 1}} != 1); michael@0: $ERROR('#7.1: ({valueOf: function() {throw "error"}, toString: function() {return 1}} != 1) throw "error". Actual: ' + (({valueOf: function() {throw "error"}, toString: function() {return 1}} != 1))); michael@0: } michael@0: catch (e) { michael@0: if (e !== "error") { michael@0: $ERROR('#7.2: ({valueOf: function() {throw "error"}, toString: function() {return 1}} != 1) throw "error". Actual: ' + (e)); michael@0: } michael@0: } michael@0: michael@0: //CHECK#8 michael@0: try { michael@0: ({valueOf: function() {return {}}, toString: function() {return {}}} != 1); michael@0: $ERROR('#8.1: ({valueOf: function() {return {}}, toString: function() {return {}}} != 1) throw TypeError. Actual: ' + (({valueOf: function() {return {}}, toString: function() {return {}}} != 1))); michael@0: } michael@0: catch (e) { michael@0: if ((e instanceof TypeError) !== true) { michael@0: $ERROR('#8.2: ({valueOf: function() {return {}}, toString: function() {return {}}} != 1) throw TypeError. Actual: ' + (e)); michael@0: } michael@0: } michael@0: