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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/extensions/function-definition-with.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +// |reftest| skip-if(!xulRuntime.shell) -- needs evaluate()
     1.5 +/*
     1.6 + * Any copyright is dedicated to the Public Domain.
     1.7 + * http://creativecommons.org/licenses/publicdomain/
     1.8 + */
     1.9 +
    1.10 +//-----------------------------------------------------------------------------
    1.11 +var BUGNUMBER = 577325;
    1.12 +var summary = 'Implement the ES5 algorithm for processing function statements';
    1.13 +
    1.14 +print(BUGNUMBER + ": " + summary);
    1.15 +
    1.16 +/**************
    1.17 + * BEGIN TEST *
    1.18 + **************/
    1.19 +
    1.20 +var called, obj;
    1.21 +
    1.22 +function inFile1() { return "in file"; }
    1.23 +called = false;
    1.24 +obj = { set inFile1(v) { called = true; } };
    1.25 +with (obj)
    1.26 +  function inFile1() { return "in file in with"; };
    1.27 +assertEq(inFile1(), "in file in with");
    1.28 +assertEq("set" in Object.getOwnPropertyDescriptor(obj, "inFile1"), true);
    1.29 +assertEq(called, false);
    1.30 +
    1.31 +evaluate("function notInFile1() { return 'not in file'; }");
    1.32 +called = false;
    1.33 +obj = { set notInFile1(v) { called = true; return "not in file 2"; } };
    1.34 +with (obj)
    1.35 +  function notInFile1() { return "not in file in with"; };
    1.36 +assertEq(notInFile1(), "not in file in with");
    1.37 +assertEq("set" in Object.getOwnPropertyDescriptor(obj, "notInFile1"), true);
    1.38 +assertEq(called, false);
    1.39 +
    1.40 +function inFile2() { return "in file 1"; }
    1.41 +called = false;
    1.42 +obj =
    1.43 +  Object.defineProperty({}, "inFile2",
    1.44 +                        { value: 42, configurable: false, enumerable: false });
    1.45 +with (obj)
    1.46 +  function inFile2() { return "in file 2"; };
    1.47 +assertEq(inFile2(), "in file 2");
    1.48 +assertEq(obj.inFile2, 42);
    1.49 +
    1.50 +
    1.51 +/******************************************************************************/
    1.52 +
    1.53 +if (typeof reportCompare === "function")
    1.54 +  reportCompare(true, true);
    1.55 +
    1.56 +print("All tests passed!");

mercurial