Debian Codegraph @

rhino/testsrc/jstests/688458.jstest

raw
1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 // https://bugzilla.mozilla.org/show_bug.cgi?id=688458
6
7 var x = {NEGATIVE_INFINITY: 1, POSITIVE_INFINITY: 1};
8 var count1 = 0;
9 var count2 = 0;
10 var n = 100000;
11 var running = true;
12
13 new java.lang.Thread(function() {
14 while (running) {
15 x = {NEGATIVE_INFINITY: 1, POSITIVE_INFINITY: 1};
16 for (var i = 0; i < 16; i++) x["i" + i] = i;
17 }
18 }).start();
19
20 // Test for original read bug first
21 for(var k = 0; k < n; k++) {
22 if (!x.POSITIVE_INFINITY || !x.NEGATIVE_INFINITY)
23 count1++;
24 }
25
26 // Now test for write bug introduced by first fix
27 for(var k = 0; k < n; k++) {
28 var M = x.k;
29 if (M && M != k - 1)
30 count2++;
31 x.k = k;
32 }
33
34 running = false;
35
36 if (count1 > 0 || count2 > 0) {
37 throw new Error(count1 + " read bugs, " + count2 + " write bugs");
38 }
39
40 "success";