Debian Codegraph @

js/src/tests/non262/object/regress-465476.js

raw
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 465476;
8 var summary = '"-0" and "0" are distinct properties.';
9 var actual = '';
10 var expect = '';
11
12
13 //-----------------------------------------------------------------------------
14 test();
15 //-----------------------------------------------------------------------------
16
17 function test()
18 {
19 printBugNumber(BUGNUMBER);
20 printStatus (summary);
21
22 var x = { "0": 3, "-0": 7 };
23
24 expect = actual = 'No Exception';
25
26 try
27 {
28 if (!("0" in x))
29 throw "0 not in x";
30 if (!("-0" in x))
31 throw "-0 not in x";
32 delete x[0];
33 if ("0" in x)
34 throw "0 in x after delete";
35 if (!("-0" in x))
36 throw "-0 removed from x after unassociated delete";
37 delete x["-0"];
38 if ("-0" in x)
39 throw "-0 in x after delete";
40 x[0] = 3;
41 if (!("0" in x))
42 throw "0 not in x after insertion of 0 property";
43 if ("-0" in x)
44 throw "-0 in x after insertion of 0 property";
45 x["-0"] = 7;
46 if (!("-0" in x))
47 throw "-0 not in x after reinsertion";
48
49 var props = [];
50 for (var i in x)
51 props.push(i);
52 if (props.length !== 2)
53 throw "not all props found!";
54 }
55 catch(ex)
56 {
57 actual = ex + '';
58 }
59 reportCompare(expect, actual, summary);
60 }