js/src/tests/test262/ch13/13.0/S13_A17_T2.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:a8e990ecdbf6
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_T2.js
8 * @description Trying to call a function before the FunctionExpression appears and then using the FunctionExpression one more time
9 */
10
11 //////////////////////////////////////////////////////////////////////////////
12 //CHECK#1
13 try{
14 var __result = __func();
15 $ERROR("#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 // now we reach the __func overwriting by new expression
25 var __func = function __func(){return "ONE";};
26
27 //////////////////////////////////////////////////////////////////////////////
28 //CHECK#2
29 var __result = __func();
30 if (__result !== "ONE") {
31 $ERROR('#2: __result === "ONE". Actual: __result ==='+__result);
32 }
33 //
34 //////////////////////////////////////////////////////////////////////////////
35
36 __func = function __func(){return "TWO";};
37
38 //////////////////////////////////////////////////////////////////////////////
39 //CHECK#3
40 var __result = __func();
41 if (__result !== "TWO") {
42 $ERROR('#3: __result === "TWO". Actual: __result ==='+__result);
43 }
44 //
45 //////////////////////////////////////////////////////////////////////////////
46

mercurial