Bug 1921963 part 1 - Use JS::ReportUncatchableException more outside the JS engine...
[gecko.git] / js / src / tests / non262 / expressions / object-literal-computed-property-evaluation.js
blobd26783d3555833c2c7b19c07788c0f567e1400f9
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
4 //-----------------------------------------------------------------------------
5 var BUGNUMBER = 1199546;
6 var summary =
7   "Convert computed property name expressions to property key before " +
8   "evaluating the property's value";
10 print(BUGNUMBER + ": " + summary);
12 /**************
13  * BEGIN TEST *
14  **************/
16 var s = "foo";
17 var convertsToS = { toString() { return s; } };
19 var o = {
20   [convertsToS]: // after ToPropertyKey becomes "foo"
21     (function() {
22       s = 'bar';
23       return 'abc'; // so we have "foo": "bar" for the first property
24      })(),
26   [convertsToS]: // |s| was set above to "bar", so after ToPropertyKey, "bar"
27     'efg' // so we have "bar": "efg" for the second property
30 assertEq(o.foo, "abc");
31 assertEq(o.bar, "efg");
33 /******************************************************************************/
35 if (typeof reportCompare === "function")
36   reportCompare(true, true);
38 print("Tests complete");