js/src/tests/ecma_5/extensions/string-literal-getter-setter-decompilation.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/licenses/publicdomain/
michael@0 3
michael@0 4 var f;
michael@0 5 try
michael@0 6 {
michael@0 7 f = eval("(function literalInside() { return { set 'c d e'(v) { } }; })");
michael@0 8 }
michael@0 9 catch (e)
michael@0 10 {
michael@0 11 assertEq(true, false,
michael@0 12 "string-literal property name in setter in object literal in " +
michael@0 13 "function statement failed to parse: " + e);
michael@0 14 }
michael@0 15
michael@0 16 var fstr = "" + f;
michael@0 17 assertEq(fstr.indexOf("set") < fstr.indexOf("c d e"), true,
michael@0 18 "should be using new-style syntax with string literal in place of " +
michael@0 19 "property identifier");
michael@0 20 assertEq(fstr.indexOf("setter") < 0, true, "using old-style syntax?");
michael@0 21
michael@0 22 var o = f();
michael@0 23 var ostr = "" + o;
michael@0 24 assertEq("c d e" in o, true, "missing the property?");
michael@0 25 assertEq("set" in Object.getOwnPropertyDescriptor(o, "c d e"), true,
michael@0 26 "'c d e' property not a setter?");
michael@0 27 // disabled because we still generate old-style syntax here (toSource
michael@0 28 // decompilation is as yet unfixed)
michael@0 29 // assertEq(ostr.indexOf("set") < ostr.indexOf("c d e"), true,
michael@0 30 // "should be using new-style syntax when getting the source of a " +
michael@0 31 // "getter/setter while decompiling an object");
michael@0 32 // assertEq(ostr.indexOf("setter") < 0, true, "using old-style syntax?");
michael@0 33
michael@0 34 reportCompare(true, true);

mercurial