~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/ecma_5/Function/arguments-caller-callee.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Any copyright is dedicated to the Public Domain.
 
3
 * http://creativecommons.org/licenses/publicdomain/
 
4
 */
 
5
 
 
6
var gTestfile = 'arguments-caller-callee.js';
 
7
var BUGNUMBER = 514563;
 
8
var summary = "arguments.caller and arguments.callee are poison pills in ES5";
 
9
 
 
10
print(BUGNUMBER + ": " + summary);
 
11
 
 
12
/**************
 
13
 * BEGIN TEST *
 
14
 **************/
 
15
 
 
16
// behavior
 
17
 
 
18
function expectTypeError(fun)
 
19
{
 
20
  try
 
21
  {
 
22
    fun();
 
23
    throw new Error("didn't throw");
 
24
  }
 
25
  catch (e)
 
26
  {
 
27
    assertEq(e instanceof TypeError, true,
 
28
             "expected TypeError calling function" +
 
29
             ("name" in fun ? " " + fun.name : "") + ", instead got: " + e);
 
30
  }
 
31
}
 
32
 
 
33
function bar() { "use strict"; return arguments; }
 
34
expectTypeError(function barCaller() { bar().caller; });
 
35
expectTypeError(function barCallee() { bar().callee; });
 
36
 
 
37
function baz() { return arguments; }
 
38
assertEq(baz().callee, baz);
 
39
 
 
40
 
 
41
// accessor identity
 
42
 
 
43
function strictMode() { "use strict"; return arguments; }
 
44
var canonicalTTE = Object.getOwnPropertyDescriptor(strictMode(), "caller").get;
 
45
 
 
46
var args = strictMode();
 
47
 
 
48
var argsCaller = Object.getOwnPropertyDescriptor(args, "caller");
 
49
assertEq("get" in argsCaller, true);
 
50
assertEq("set" in argsCaller, true);
 
51
assertEq(argsCaller.get, canonicalTTE);
 
52
assertEq(argsCaller.set, canonicalTTE);
 
53
 
 
54
var argsCallee = Object.getOwnPropertyDescriptor(args, "callee");
 
55
assertEq("get" in argsCallee, true);
 
56
assertEq("set" in argsCallee, true);
 
57
assertEq(argsCallee.get, canonicalTTE);
 
58
assertEq(argsCallee.set, canonicalTTE);
 
59
 
 
60
 
 
61
/******************************************************************************/
 
62
 
 
63
if (typeof reportCompare === "function")
 
64
  reportCompare(true, true);
 
65
 
 
66
print("All tests passed!");