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: * Operator x + y uses [[Default Value]] michael@0: * michael@0: * @path ch11/11.6/11.6.1/S11.6.1_A2.2_T3.js michael@0: * @description If Type(value) is Function, evaluate ToPrimitive(value, Number) michael@0: */ michael@0: michael@0: //CHECK#1 michael@0: function f1(){ michael@0: return 0; michael@0: } michael@0: if (f1 + 1 !== f1.toString() + 1) { michael@0: $ERROR('#1: function f1() {return 0;}; f1 + 1 === f1.toString() + 1'); michael@0: } michael@0: michael@0: //CHECK#2 michael@0: function f2(){ michael@0: return 0; michael@0: } michael@0: f2.valueOf = function() {return 1;}; michael@0: if (1 + f2 !== 1 + 1) { michael@0: $ERROR('#2: f1unction f2() {return 0;} f2.valueOf = function() {return 1;}; 1 + f2 === 1 + 1. Actual: ' + (1 + f2)); michael@0: } michael@0: michael@0: //CHECK#3 michael@0: function f3(){ michael@0: return 0; michael@0: } michael@0: f3.toString = function() {return 1;}; michael@0: if (1 + f3 !== 1 + 1) { michael@0: $ERROR('#3: f1unction f3() {return 0;} f3.toString() = function() {return 1;}; 1 + f3 === 1 + 1. Actual: ' + (1 + f3)); michael@0: } michael@0: michael@0: //CHECK#4 michael@0: function f4(){ michael@0: return 0; michael@0: } michael@0: f4.valueOf = function() {return -1;}; michael@0: f4.toString = function() {return 1;}; michael@0: if (f4 + 1 !== 1 - 1) { michael@0: $ERROR('#4: f1unction f4() {return 0;}; f2.valueOf = function() {return -1;}; f4.toString() = function() {return 1;}; f4 + 1 === 1 - 1. Actual: ' + (f4 + 1)); michael@0: } michael@0: