Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/addition/S11.6.1_A2.2_T3.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: Operator x + y uses [[Default Value]]
6 es5id: 11.6.1_A2.2_T3
7 description: If Type(value) is Function, evaluate ToPrimitive(value, Number)
8 ---*/
9
10 //CHECK#1
11 function f1(){
12 return 0;
13 }
14 if (f1 + 1 !== f1.toString() + 1) {
15 $ERROR('#1: function f1() {return 0;}; f1 + 1 === f1.toString() + 1');
16 }
17
18 //CHECK#2
19 function f2(){
20 return 0;
21 }
22 f2.valueOf = function() {return 1;};
23 if (1 + f2 !== 1 + 1) {
24 $ERROR('#2: f1unction f2() {return 0;} f2.valueOf = function() {return 1;}; 1 + f2 === 1 + 1. Actual: ' + (1 + f2));
25 }
26
27 //CHECK#3
28 function f3(){
29 return 0;
30 }
31 f3.toString = function() {return 1;};
32 if (1 + f3 !== 1 + 1) {
33 $ERROR('#3: f1unction f3() {return 0;} f3.toString() = function() {return 1;}; 1 + f3 === 1 + 1. Actual: ' + (1 + f3));
34 }
35
36 //CHECK#4
37 function f4(){
38 return 0;
39 }
40 f4.valueOf = function() {return -1;};
41 f4.toString = function() {return 1;};
42 if (f4 + 1 !== 1 - 1) {
43 $ERROR('#4: f1unction f4() {return 0;}; f2.valueOf = function() {return -1;}; f4.toString() = function() {return 1;}; f4 + 1 === 1 - 1. Actual: ' + (f4 + 1));
44 }