1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Regress/regress-329383.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 329383; 1.11 +var summary = 'Math copysign issues'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 +printBugNumber(BUGNUMBER); 1.16 +printStatus (summary); 1.17 + 1.18 +var inputs = [ 1.19 + -Infinity, 1.20 + -10.01, 1.21 + -9.01, 1.22 + -8.01, 1.23 + -7.01, 1.24 + -6.01, 1.25 + -5.01, 1.26 + -4.01, 1.27 + -Math.PI, 1.28 + -3.01, 1.29 + -2.01, 1.30 + -1.01, 1.31 + -0.5, 1.32 + -0.49, 1.33 + -0.01, 1.34 + -0, 1.35 + 0, 1.36 + +0, 1.37 + 0.01, 1.38 + 0.49, 1.39 + 0.50, 1.40 + 0, 1.41 + 1.01, 1.42 + 2.01, 1.43 + 3.01, 1.44 + Math.PI, 1.45 + 4.01, 1.46 + 5.01, 1.47 + 6.01, 1.48 + 7.01, 1.49 + 8.01, 1.50 + 9.01, 1.51 + 10.01, 1.52 + Infinity 1.53 + ]; 1.54 + 1.55 +var iinput; 1.56 + 1.57 +for (iinput = 0; iinput < inputs.length; iinput++) 1.58 +{ 1.59 + var input = inputs[iinput]; 1.60 + reportCompare(Math.round(input), 1.61 + emulateRound(input), 1.62 + summary + ': Math.round(' + input + ')'); 1.63 +} 1.64 + 1.65 +reportCompare(isNaN(Math.round(NaN)), 1.66 + isNaN(emulateRound(NaN)), 1.67 + summary + ': Math.round(' + input + ')'); 1.68 + 1.69 +function emulateRound(x) 1.70 +{ 1.71 + if (!isFinite(x) || x === 0) return x 1.72 + if (-0.5 <= x && x < 0) return -0 1.73 + return Math.floor(x + 0.5) 1.74 + } 1.75 + 1.76 +var z; 1.77 + 1.78 +z = Math.min(-0, 0); 1.79 + 1.80 +reportCompare(-Math.PI, Math.atan2(z, z), summary + ': Math.atan2(-0, -0)'); 1.81 +reportCompare(-Infinity, 1/z, summary + ': 1/-0'); 1.82 + 1.83 +z = Math.max(-0, 0); 1.84 + 1.85 +reportCompare(0, Math.atan2(z, z), summary + ': Math.atan2(0, 0)'); 1.86 +reportCompare(Infinity, 1/z, summary + ': 1/0');