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 Object and Type(y) is primitive type, michael@0: * return ToPrimitive(x) != y michael@0: * michael@0: * @path ch11/11.9/11.9.2/S11.9.2_A7.8.js michael@0: * @description x is object, y is primtitive michael@0: */ michael@0: michael@0: //CHECK#1 michael@0: if ((true != {valueOf: function() {return 1}}) !== false) { michael@0: $ERROR('#1: (true != {valueOf: function() {return 1}}) === false'); michael@0: } michael@0: michael@0: //CHECK#2 michael@0: if ((1 != {valueOf: function() {return 1}, toString: function() {return 0}}) !== false) { michael@0: $ERROR('#2: (1 != {valueOf: function() {return 1}, toString: function() {return 0}}) === false'); michael@0: } michael@0: michael@0: //CHECK#3 michael@0: if (("+1" != {valueOf: function() {return 1}, toString: function() {return {}}}) !== false) { michael@0: $ERROR('#3: ("+1" != {valueOf: function() {return 1}, toString: function() {return {}}}) === false'); michael@0: } michael@0: michael@0: //CHECK#4 michael@0: try { michael@0: if ((true != {valueOf: function() {return "+1"}, toString: function() {throw "error"}}) !== false) { michael@0: $ERROR('#4.1: (true != {valueOf: function() {return "+1"}, toString: function() {throw "error"}}) === false'); michael@0: } michael@0: } michael@0: catch (e) { michael@0: if (e === "error") { michael@0: $ERROR('#4.2: (true != {valueOf: function() {return "+1"}, toString: function() {throw "error"}}) not throw "error"'); michael@0: } else { michael@0: $ERROR('#4.3: (true != {valueOf: function() {return "+1"}, toString: function() {throw "error"}}) not throw Error. Actual: ' + (e)); michael@0: } michael@0: } michael@0: michael@0: //CHECK#5 michael@0: if ((1 != {toString: function() {return "+1"}}) !== false) { michael@0: $ERROR('#5: (1 != {toString: function() {return "+1"}}) === false'); michael@0: } michael@0: michael@0: //CHECK#6 michael@0: if (("1" != {valueOf: function() {return {}}, toString: function() {return "+1"}}) !== true) { michael@0: $ERROR('#6.1: ("1" != {valueOf: function() {return {}}, toString: function() {return "+1"}}) === true'); michael@0: } else { michael@0: if (("+1" != {valueOf: function() {return {}}, toString: function() {return "+1"}}) !== false) { michael@0: $ERROR('#6.2: ("+1" != {valueOf: function() {return {}}, toString: function() {return "+1"}}) === false'); michael@0: } michael@0: } michael@0: michael@0: //CHECK#7 michael@0: try { michael@0: (1 != {valueOf: function() {throw "error"}, toString: function() {return 1}}); michael@0: $ERROR('#7: (1 != {valueOf: function() {throw "error"}, toString: function() {return 1}}) throw "error"'); michael@0: } michael@0: catch (e) { michael@0: if (e !== "error") { michael@0: $ERROR('#7: (1 != {valueOf: function() {throw "error"}, toString: function() {return 1}}) throw "error"'); michael@0: } michael@0: } michael@0: michael@0: //CHECK#8 michael@0: try { michael@0: (1 != {valueOf: function() {return {}}, toString: function() {return {}}}); michael@0: $ERROR('#8: (1 != {valueOf: function() {return {}}, toString: function() {return {}}}) throw TypeError'); michael@0: } michael@0: catch (e) { michael@0: if ((e instanceof TypeError) !== true) { michael@0: $ERROR('#8: (1 != {valueOf: function() {return {}}, toString: function() {return {}}}) throw TypeError'); michael@0: } michael@0: } michael@0: