Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / ecma_5 / Expressions / 11.1.5-01.js
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
3
4 //-----------------------------------------------------------------------------
5 var BUGNUMBER = 520696;
6 var summary =
7   'Implement support for string literals as names for properties defined ' +
8   'using ES5 get/set syntax';
9
10 print(BUGNUMBER + ": " + summary);
11
12
13 var o;
14
15 o = { get "a b c"() { return 17; } };
16 assertEq("get" in Object.getOwnPropertyDescriptor(o, "a b c"), true);
17
18 o = eval('({ get "a b c"() { return 17; } })');
19 assertEq("get" in Object.getOwnPropertyDescriptor(o, "a b c"), true);
20
21 var f = eval("(function literalInside() { return { set 'c d e'(q) { } }; })");
22 f = function literalInside() { return { set 'c d e'(q) { } }; };
23
24 function checkO()
25 {
26   assertEq(3.141592654 in o, true, "fractional-named property isn't in object");
27   assertEq(10000 in o, true, "exponential-named property is in object");
28   assertEq(0xdeadbeef in o, true, "hex-named property is in object");
29   assertEq("Infinity" in o, true, "numeric index stringified correctly");
30 }
31
32 o = eval('({ 3.141592654: "pi", 1e4: 17, 0xdeadbeef: "hex", 1e3000: "Infinity" })');
33 checkO();
34 o = { 3.141592654: "pi", 1e4: 17, 0xdeadbeef: "hex", 1e3000: "Infinity" };
35 checkO();
36
37 reportCompare(true, true);