|
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 * Function call cannot appear in the program before the FunctionExpression appears |
|
6 * |
|
7 * @path ch13/13.0/S13_A17_T1.js |
|
8 * @description Trying to call a function before the FunctionExpression appears |
|
9 */ |
|
10 |
|
11 ////////////////////////////////////////////////////////////////////////////// |
|
12 //CHECK#1 |
|
13 try{ |
|
14 var __result = __func(); |
|
15 $FAIL("#1.1: var __result = __func() lead to throwing exception"); |
|
16 } catch(e) { |
|
17 if ((e instanceof TypeError) !== true) { |
|
18 $ERROR('#1.2: func should throw a TypeError Actual: ' + (e)); |
|
19 } |
|
20 } |
|
21 // |
|
22 ////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
24 var __func = function (){return "ONE";}; |
|
25 |
|
26 ////////////////////////////////////////////////////////////////////////////// |
|
27 //CHECK#2 |
|
28 var __result = __func(); |
|
29 if (__result !== "ONE") { |
|
30 $ERROR('#2: __result === "ONE". Actual: __result ==='+__result); |
|
31 } |
|
32 // |
|
33 ////////////////////////////////////////////////////////////////////////////// |
|
34 |
|
35 __func = function (){return "TWO";}; |
|
36 |
|
37 ////////////////////////////////////////////////////////////////////////////// |
|
38 //CHECK#3 |
|
39 var __result = __func(); |
|
40 if (__result !== "TWO") { |
|
41 $ERROR('#3: __result === "TWO". Actual: __result ==='+__result); |
|
42 } |
|
43 // |
|
44 ////////////////////////////////////////////////////////////////////////////// |
|
45 |