summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/extensions/function-definition-with.js
blob: 2277ad45fc364eb9a9a10384d3389e227c99b885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// |reftest| skip-if(!xulRuntime.shell) -- needs evaluate()
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

//-----------------------------------------------------------------------------
var BUGNUMBER = 577325;
var summary = 'Implement the ES5 algorithm for processing function statements';

print(BUGNUMBER + ": " + summary);

/**************
 * BEGIN TEST *
 **************/

var called, obj;

function inFile1() { return "in file"; }
called = false;
obj = { set inFile1(v) { called = true; } };
with (obj) {
  function inFile1() { return "in file in with"; };
}
assertEq(inFile1(), "in file in with");
assertEq("set" in Object.getOwnPropertyDescriptor(obj, "inFile1"), true);
assertEq(called, false);

evaluate("function notInFile1() { return 'not in file'; }");
called = false;
obj = { set notInFile1(v) { called = true; return "not in file 2"; } };
with (obj) {
  function notInFile1() { return "not in file in with"; };
}
assertEq(notInFile1(), "not in file in with");
assertEq("set" in Object.getOwnPropertyDescriptor(obj, "notInFile1"), true);
assertEq(called, false);

function inFile2() { return "in file 1"; }
called = false;
obj =
  Object.defineProperty({}, "inFile2",
                        { value: 42, configurable: false, enumerable: false });
with (obj) {
  function inFile2() { return "in file 2"; };
}
assertEq(inFile2(), "in file 2");
assertEq(obj.inFile2, 42);


/******************************************************************************/

if (typeof reportCompare === "function")
  reportCompare(true, true);

print("All tests passed!");