|
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 * 0, null, undefined, false, empty string, NaN in expression is evaluated to false |
|
6 * |
|
7 * @path ch12/12.5/S12.5_A1.1_T1.js |
|
8 * @description Using "if" without "else" construction |
|
9 */ |
|
10 |
|
11 ////////////////////////////////////////////////////////////////////////////// |
|
12 //CHECK#1 |
|
13 |
|
14 if(0) |
|
15 $ERROR('#1: 0 in expression is evaluated to false '); |
|
16 // |
|
17 ////////////////////////////////////////////////////////////////////////////// |
|
18 |
|
19 ////////////////////////////////////////////////////////////////////////////// |
|
20 //CHECK#2 |
|
21 if(false) |
|
22 $ERROR('#2: false in expression is evaluated to false '); |
|
23 // |
|
24 ////////////////////////////////////////////////////////////////////////////// |
|
25 |
|
26 ////////////////////////////////////////////////////////////////////////////// |
|
27 //CHECK#3 |
|
28 if(null) |
|
29 $ERROR('#3: null in expression is evaluated to false '); |
|
30 // |
|
31 ////////////////////////////////////////////////////////////////////////////// |
|
32 |
|
33 ////////////////////////////////////////////////////////////////////////////// |
|
34 //CHECK#4 |
|
35 if(undefined) |
|
36 $ERROR('#4: undefined in expression is evaluated to false '); |
|
37 // |
|
38 ////////////////////////////////////////////////////////////////////////////// |
|
39 |
|
40 ////////////////////////////////////////////////////////////////////////////// |
|
41 //CHECK#5 |
|
42 if("") |
|
43 $ERROR('#5: empty string in expression is evaluated to false '); |
|
44 // |
|
45 ////////////////////////////////////////////////////////////////////////////// |
|
46 |
|
47 ////////////////////////////////////////////////////////////////////////////// |
|
48 //CHECK#6 |
|
49 if(NaN) |
|
50 $ERROR('#5: NaN in expression is evaluated to false '); |
|
51 // |
|
52 ////////////////////////////////////////////////////////////////////////////// |
|
53 |