js/src/tests/ecma_5/strict/this-for-function-expression-recursion.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:65b97914ba98
1 /*
2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/licenses/publicdomain/
4 */
5
6 var gTestfile = 'this-for-function-expression-recursion.js';
7 var BUGNUMBER = 611276;
8 var summary = "JSOP_CALLEE should push undefined, not null, for this";
9
10 print(BUGNUMBER + ": " + summary);
11
12 /**************
13 * BEGIN TEST *
14 **************/
15
16 // Calling a named function expression (not function statement) uses the
17 // JSOP_CALLEE opcode. This opcode pushes its own |this|, distinct from the
18 // normal call path; verify that that |this| value is properly |undefined|.
19
20 var calleeThisFun =
21 function calleeThisFun(recurring)
22 {
23 if (recurring)
24 return this;
25 return calleeThisFun(true);
26 };
27 assertEq(calleeThisFun(false), this);
28
29 var calleeThisStrictFun =
30 function calleeThisStrictFun(recurring)
31 {
32 "use strict";
33 if (recurring)
34 return this;
35 return calleeThisStrictFun(true);
36 };
37 assertEq(calleeThisStrictFun(false), undefined);
38
39 /******************************************************************************/
40
41 if (typeof reportCompare === "function")
42 reportCompare(true, true);
43
44 print("All tests passed!");

mercurial