|
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 in expression is evaluated to true |
|
6 * |
|
7 * @path ch12/12.5/S12.5_A1_T2.js |
|
8 * @description Using "if/else" construction |
|
9 */ |
|
10 |
|
11 var c=0; |
|
12 ////////////////////////////////////////////////////////////////////////////// |
|
13 //CHECK#1 |
|
14 if(!(1)) |
|
15 $ERROR('#1.1: 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(!(true)) |
|
25 $ERROR('#2.1: 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(!("1")) |
|
35 $ERROR('#3.1: "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(!("A")) |
|
45 $ERROR('#4.1: "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 |