Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
6 //-----------------------------------------------------------------------------
7 var BUGNUMBER = 329383;
8 var summary = 'Math copysign issues';
9 var actual = '';
10 var expect = '';
12 printBugNumber(BUGNUMBER);
13 printStatus (summary);
15 var inputs = [
16 -Infinity,
17 -10.01,
18 -9.01,
19 -8.01,
20 -7.01,
21 -6.01,
22 -5.01,
23 -4.01,
24 -Math.PI,
25 -3.01,
26 -2.01,
27 -1.01,
28 -0.5,
29 -0.49,
30 -0.01,
31 -0,
32 0,
33 +0,
34 0.01,
35 0.49,
36 0.50,
37 0,
38 1.01,
39 2.01,
40 3.01,
41 Math.PI,
42 4.01,
43 5.01,
44 6.01,
45 7.01,
46 8.01,
47 9.01,
48 10.01,
49 Infinity
50 ];
52 var iinput;
54 for (iinput = 0; iinput < inputs.length; iinput++)
55 {
56 var input = inputs[iinput];
57 reportCompare(Math.round(input),
58 emulateRound(input),
59 summary + ': Math.round(' + input + ')');
60 }
62 reportCompare(isNaN(Math.round(NaN)),
63 isNaN(emulateRound(NaN)),
64 summary + ': Math.round(' + input + ')');
66 function emulateRound(x)
67 {
68 if (!isFinite(x) || x === 0) return x
69 if (-0.5 <= x && x < 0) return -0
70 return Math.floor(x + 0.5)
71 }
73 var z;
75 z = Math.min(-0, 0);
77 reportCompare(-Math.PI, Math.atan2(z, z), summary + ': Math.atan2(-0, -0)');
78 reportCompare(-Infinity, 1/z, summary + ': 1/-0');
80 z = Math.max(-0, 0);
82 reportCompare(0, Math.atan2(z, z), summary + ': Math.atan2(0, 0)');
83 reportCompare(Infinity, 1/z, summary + ': 1/0');