|
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 * 1, true, non-empty string and others in expression is evaluated to true when using operator "new" |
|
6 * |
|
7 * @path ch12/12.5/S12.5_A1.2_T2.js |
|
8 * @description Using "if/else" construction |
|
9 */ |
|
10 |
|
11 var c=0; |
|
12 ////////////////////////////////////////////////////////////////////////////// |
|
13 //CHECK#1 |
|
14 if(!(new Number(1))) |
|
15 $ERROR('#1.1: new 1 in expression is evaluated to true'); |
|
16 else |
|
17 c++; |
|
18 if (c!=1) $ERROR('#1.2: else branch don`t execute'); |
|
19 // |
|
20 ////////////////////////////////////////////////////////////////////////////// |
|
21 |
|
22 ////////////////////////////////////////////////////////////////////////////// |
|
23 //CHECK#2 |
|
24 if(!(new Boolean(true))) |
|
25 $ERROR('#2.1: new true in expression is evaluated to true'); |
|
26 else |
|
27 c++; |
|
28 if (c!=2) $ERROR('#2.2: else branch don`t execute'); |
|
29 // |
|
30 ////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
32 ////////////////////////////////////////////////////////////////////////////// |
|
33 //CHECK#3 |
|
34 if(!(new String("1"))) |
|
35 $ERROR('#3.1: new "1" in expression is evaluated to true'); |
|
36 else |
|
37 c++; |
|
38 if (c!=3) $ERROR('#3.2: else branch don`t execute'); |
|
39 // |
|
40 ////////////////////////////////////////////////////////////////////////////// |
|
41 |
|
42 ////////////////////////////////////////////////////////////////////////////// |
|
43 //CHECK#4 |
|
44 if(!(new String("A"))) |
|
45 $ERROR('#4.1: new "A" in expression is evaluated to true'); |
|
46 else |
|
47 c++; |
|
48 if (c!=4) $ERROR('#4.2: else branch don`t execute'); |
|
49 // |
|
50 ////////////////////////////////////////////////////////////////////////////// |
|
51 |
|
52 ////////////////////////////////////////////////////////////////////////////// |
|
53 //CHECK#5 |
|
54 if(!(new Boolean(false))) |
|
55 $ERROR('#5.1: new false in expression is evaluated to true '); |
|
56 else |
|
57 c++; |
|
58 if (c!=5) $ERROR('#5.2: else branch don`t execute'); |
|
59 // |
|
60 ////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
62 ////////////////////////////////////////////////////////////////////////////// |
|
63 //CHECK#6 |
|
64 if(!(new Number(NaN))) |
|
65 $ERROR('#6.1: new NaN in expression is evaluated to true '); |
|
66 else |
|
67 c++; |
|
68 if (c!=6) $ERROR('#6.2: else branch don`t execute'); |
|
69 // |
|
70 ////////////////////////////////////////////////////////////////////////////// |
|
71 |
|
72 ////////////////////////////////////////////////////////////////////////////// |
|
73 //CHECK#7 |
|
74 if(!(new Number(null))) |
|
75 $ERROR('#7.1: new null in expression is evaluated to true '); |
|
76 else |
|
77 c++; |
|
78 if (c!=7) $ERROR('#7.2: else branch don`t execute'); |
|
79 // |
|
80 ////////////////////////////////////////////////////////////////////////////// |
|
81 |
|
82 ////////////////////////////////////////////////////////////////////////////// |
|
83 //CHECK#8 |
|
84 if(!(new String(undefined))) |
|
85 $ERROR('#8.1: new undefined in expression is evaluated to true '); |
|
86 else |
|
87 c++; |
|
88 if (c!=8) $ERROR('#8.2: else branch don`t execute'); |
|
89 // |
|
90 ////////////////////////////////////////////////////////////////////////////// |
|
91 |
|
92 ////////////////////////////////////////////////////////////////////////////// |
|
93 //CHECK#9 |
|
94 if(!(new String(""))) |
|
95 $ERROR('#9.1: new empty string in expression is evaluated to true '); |
|
96 else |
|
97 c++; |
|
98 if (c!=9) $ERROR('#9.2: else branch don`t execute'); |
|
99 // |
|
100 ////////////////////////////////////////////////////////////////////////////// |
|
101 |