|
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 * If ToBoolean(x) is true, return x |
|
6 * |
|
7 * @path ch11/11.11/11.11.2/S11.11.2_A4_T2.js |
|
8 * @description Type(x) and Type(y) vary between primitive number and Number object |
|
9 */ |
|
10 |
|
11 //CHECK#1 |
|
12 if ((-1 || 1) !== -1) { |
|
13 $ERROR('#1: (-1 || 1) === -1'); |
|
14 } |
|
15 |
|
16 //CHECK#2 |
|
17 if ((1 || new Number(0)) !== 1) { |
|
18 $ERROR('#2: (1 || new Number(0)) === 1'); |
|
19 } |
|
20 |
|
21 //CHECK#3 |
|
22 if ((-1 || NaN) !== -1) { |
|
23 $ERROR('#3: (-1 || NaN) === -1'); |
|
24 } |
|
25 |
|
26 //CHECK#4 |
|
27 var x = new Number(-1); |
|
28 if ((x || new Number(0)) !== x) { |
|
29 $ERROR('#4: (var x = new Number(-1); (x || new Number(-1)) === x'); |
|
30 } |
|
31 |
|
32 //CHECK#5 |
|
33 var x = new Number(NaN); |
|
34 if ((x || new Number(1)) !== x) { |
|
35 $ERROR('#5: (var x = new Number(NaN); (x || new Number(1)) === x'); |
|
36 } |
|
37 |
|
38 //CHECK#6 |
|
39 var x = new Number(0); |
|
40 if ((x || new Number(NaN)) !== x) { |
|
41 $ERROR('#6: (var x = new Number(0); (x || new Number(NaN)) === x'); |
|
42 } |
|
43 |