js/src/tests/ecma_5/extensions/string-literal-getter-setter-decompilation.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/string-literal-getter-setter-decompilation.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +// Any copyright is dedicated to the Public Domain.
     1.5 +// http://creativecommons.org/licenses/publicdomain/
     1.6 +
     1.7 +var f;
     1.8 +try
     1.9 +{
    1.10 +  f = eval("(function literalInside() { return { set 'c d e'(v) { } }; })");
    1.11 +}
    1.12 +catch (e)
    1.13 +{
    1.14 +  assertEq(true, false,
    1.15 +           "string-literal property name in setter in object literal in " +
    1.16 +           "function statement failed to parse: " + e);
    1.17 +}
    1.18 +
    1.19 +var fstr = "" + f;
    1.20 +assertEq(fstr.indexOf("set") < fstr.indexOf("c d e"), true,
    1.21 +         "should be using new-style syntax with string literal in place of " +
    1.22 +         "property identifier");
    1.23 +assertEq(fstr.indexOf("setter") < 0, true, "using old-style syntax?");
    1.24 +
    1.25 +var o = f();
    1.26 +var ostr = "" + o;
    1.27 +assertEq("c d e" in o, true, "missing the property?");
    1.28 +assertEq("set" in Object.getOwnPropertyDescriptor(o, "c d e"), true,
    1.29 +         "'c d e' property not a setter?");
    1.30 +// disabled because we still generate old-style syntax here (toSource
    1.31 +// decompilation is as yet unfixed)
    1.32 +// assertEq(ostr.indexOf("set") < ostr.indexOf("c d e"), true,
    1.33 +//         "should be using new-style syntax when getting the source of a " +
    1.34 +//         "getter/setter while decompiling an object");
    1.35 +// assertEq(ostr.indexOf("setter") < 0, true, "using old-style syntax?");
    1.36 +
    1.37 +reportCompare(true, true);

mercurial