Debian Codegraph @

js/src/tests/test262/language/statements/function/S13_A17_T2.js

raw
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 info: |
6 Function call cannot appear in the program before the FunctionExpression
7 appears
8 es5id: 13_A17_T2
9 description: >
10 Trying to call a function before the FunctionExpression appears
11 and then using the FunctionExpression one more time
12 ---*/
13
14 //////////////////////////////////////////////////////////////////////////////
15 //CHECK#1
16 try{
17 var __result = __func();
18 throw new Test262Error("#1: var __result = __func() lead to throwing exception");
19 } catch(e) {
20 if ((e instanceof TypeError) !== true) {
21 throw new Test262Error('#1.2: func should throw a TypeError Actual: ' + (e));
22 }
23 }
24 //
25 //////////////////////////////////////////////////////////////////////////////
26
27 // now we reach the __func overwriting by new expression
28 var __func = function __func(){return "ONE";};
29
30 //////////////////////////////////////////////////////////////////////////////
31 //CHECK#2
32 var __result = __func();
33 if (__result !== "ONE") {
34 throw new Test262Error('#2: __result === "ONE". Actual: __result ==='+__result);
35 }
36 //
37 //////////////////////////////////////////////////////////////////////////////
38
39 __func = function __func(){return "TWO";};
40
41 //////////////////////////////////////////////////////////////////////////////
42 //CHECK#3
43 var __result = __func();
44 if (__result !== "TWO") {
45 throw new Test262Error('#3: __result === "TWO". Actual: __result ==='+__result);
46 }
47 //
48 //////////////////////////////////////////////////////////////////////////////
49
50 reportCompare(0, 0);