S11.4.6_A2.1_T1.js (914B)
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 uses GetValue 6 es5id: 11.4.6_A2.1_T1 7 description: Either Type(x) is not Reference or GetBase(x) is not null 8 ---*/ 9 10 //CHECK#1 11 if (+1 !== 1) { 12 throw new Test262Error('#1: +1 === 1. Actual: ' + (+1)); 13 } 14 15 //CHECK#2 16 if (+(+1) !== 1) { 17 throw new Test262Error('#2: +(+1) === -1. Actual: ' + (+(+1))); 18 } 19 20 //CHECK#3 21 var x = 1; 22 if (+x !== 1) { 23 throw new Test262Error('#3: var x = +1; -x === 1. Actual: ' + (-x)); 24 } 25 26 //CHECK#4 27 var x = 1; 28 if (+(+x) !== 1) { 29 throw new Test262Error('#4: var x = 1; +(+x) === 1. Actual: ' + (+(+x))); 30 } 31 32 //CHECK#5 33 var object = new Object(); 34 object.prop = 1; 35 if (+object.prop !== 1) { 36 throw new Test262Error('#5: var object = new Object(); object.prop = 1; +object.prop === 1. Actual: ' + (+object.prop)); 37 } 38 39 reportCompare(0, 0);