js/src/tests/ecma_5/extensions/function-definition-with.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial