Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / ecma_5 / extensions / function-definition-with.js
1 /*
2  * Any copyright is dedicated to the Public Domain.
3  * http://creativecommons.org/licenses/publicdomain/
4  */
5
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 577325;
8 var summary = 'Implement the ES5 algorithm for processing function statements';
9
10 print(BUGNUMBER + ": " + summary);
11
12 /**************
13  * BEGIN TEST *
14  **************/
15
16 var called, obj;
17
18 function inFile1() { return "in file"; }
19 called = false;
20 obj = { set inFile1(v) { called = true; } };
21 with (obj)
22   function inFile1() { return "in file in with"; };
23 assertEq(inFile1(), "in file in with");
24 assertEq("set" in Object.getOwnPropertyDescriptor(obj, "inFile1"), true);
25 assertEq(called, false);
26
27 evaluate("function notInFile1() { return 'not in file'; }");
28 called = false;
29 obj = { set notInFile1(v) { called = true; return "not in file 2"; } };
30 with (obj)
31   function notInFile1() { return "not in file in with"; };
32 assertEq(notInFile1(), "not in file in with");
33 assertEq("set" in Object.getOwnPropertyDescriptor(obj, "notInFile1"), true);
34 assertEq(called, false);
35
36 function inFile2() { return "in file 1"; }
37 called = false;
38 obj =
39   Object.defineProperty({}, "inFile2",
40                         { value: 42, configurable: false, enumerable: false });
41 with (obj)
42   function inFile2() { return "in file 2"; };
43 assertEq(inFile2(), "in file 2");
44 assertEq(obj.inFile2, 42);
45
46
47 /******************************************************************************/
48
49 if (typeof reportCompare === "function")
50   reportCompare(true, true);
51
52 print("All tests passed!");