Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-329383.js

raw symbols SCIP
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/. */
5
6 var gTestfile = 'regress-329383.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 329383;
9 var summary = 'Math copysign issues';
10 var actual = '';
11 var expect = '';
12
13 printBugNumber(BUGNUMBER);
14 printStatus (summary);
15
16 var inputs = [
17 -Infinity,
18 -10.01,
19 -9.01,
20 -8.01,
21 -7.01,
22 -6.01,
23 -5.01,
24 -4.01,
25 -Math.PI,
26 -3.01,
27 -2.01,
28 -1.01,
29 -0.5,
30 -0.49,
31 -0.01,
32 -0,
33 0,
34 +0,
35 0.01,
36 0.49,
37 0.50,
38 0,
39 1.01,
40 2.01,
41 3.01,
42 Math.PI,
43 4.01,
44 5.01,
45 6.01,
46 7.01,
47 8.01,
48 9.01,
49 10.01,
50 Infinity
51 ];
52
53 var iinput;
54
55 for (iinput = 0; iinput < inputs.length; iinput++)
56 {
57 var input = inputs[iinput];
58 reportCompare(Math.round(input),
59 emulateRound(input),
60 summary + ': Math.round(' + input + ')');
61 }
62
63 reportCompare(isNaN(Math.round(NaN)),
64 isNaN(emulateRound(NaN)),
65 summary + ': Math.round(' + input + ')');
66
67 function emulateRound(x)
68 {
69 if (!isFinite(x) || x === 0) return x
70 if (-0.5 <= x && x < 0) return -0
71 return Math.floor(x + 0.5)
72 }
73
74 var z;
75
76 z = Math.min(-0, 0);
77
78 reportCompare(-Math.PI, Math.atan2(z, z), summary + ': Math.atan2(-0, -0)');
79 reportCompare(-Infinity, 1/z, summary + ': 1/-0');
80
81 z = Math.max(-0, 0);
82
83 reportCompare(0, Math.atan2(z, z), summary + ': Math.atan2(0, 0)');
84 reportCompare(Infinity, 1/z, summary + ': 1/0');