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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | //----------------------------------------------------------------------------- |
michael@0 | 7 | var BUGNUMBER = 329383; |
michael@0 | 8 | var summary = 'Math copysign issues'; |
michael@0 | 9 | var actual = ''; |
michael@0 | 10 | var expect = ''; |
michael@0 | 11 | |
michael@0 | 12 | printBugNumber(BUGNUMBER); |
michael@0 | 13 | printStatus (summary); |
michael@0 | 14 | |
michael@0 | 15 | var inputs = [ |
michael@0 | 16 | -Infinity, |
michael@0 | 17 | -10.01, |
michael@0 | 18 | -9.01, |
michael@0 | 19 | -8.01, |
michael@0 | 20 | -7.01, |
michael@0 | 21 | -6.01, |
michael@0 | 22 | -5.01, |
michael@0 | 23 | -4.01, |
michael@0 | 24 | -Math.PI, |
michael@0 | 25 | -3.01, |
michael@0 | 26 | -2.01, |
michael@0 | 27 | -1.01, |
michael@0 | 28 | -0.5, |
michael@0 | 29 | -0.49, |
michael@0 | 30 | -0.01, |
michael@0 | 31 | -0, |
michael@0 | 32 | 0, |
michael@0 | 33 | +0, |
michael@0 | 34 | 0.01, |
michael@0 | 35 | 0.49, |
michael@0 | 36 | 0.50, |
michael@0 | 37 | 0, |
michael@0 | 38 | 1.01, |
michael@0 | 39 | 2.01, |
michael@0 | 40 | 3.01, |
michael@0 | 41 | Math.PI, |
michael@0 | 42 | 4.01, |
michael@0 | 43 | 5.01, |
michael@0 | 44 | 6.01, |
michael@0 | 45 | 7.01, |
michael@0 | 46 | 8.01, |
michael@0 | 47 | 9.01, |
michael@0 | 48 | 10.01, |
michael@0 | 49 | Infinity |
michael@0 | 50 | ]; |
michael@0 | 51 | |
michael@0 | 52 | var iinput; |
michael@0 | 53 | |
michael@0 | 54 | for (iinput = 0; iinput < inputs.length; iinput++) |
michael@0 | 55 | { |
michael@0 | 56 | var input = inputs[iinput]; |
michael@0 | 57 | reportCompare(Math.round(input), |
michael@0 | 58 | emulateRound(input), |
michael@0 | 59 | summary + ': Math.round(' + input + ')'); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | reportCompare(isNaN(Math.round(NaN)), |
michael@0 | 63 | isNaN(emulateRound(NaN)), |
michael@0 | 64 | summary + ': Math.round(' + input + ')'); |
michael@0 | 65 | |
michael@0 | 66 | function emulateRound(x) |
michael@0 | 67 | { |
michael@0 | 68 | if (!isFinite(x) || x === 0) return x |
michael@0 | 69 | if (-0.5 <= x && x < 0) return -0 |
michael@0 | 70 | return Math.floor(x + 0.5) |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | var z; |
michael@0 | 74 | |
michael@0 | 75 | z = Math.min(-0, 0); |
michael@0 | 76 | |
michael@0 | 77 | reportCompare(-Math.PI, Math.atan2(z, z), summary + ': Math.atan2(-0, -0)'); |
michael@0 | 78 | reportCompare(-Infinity, 1/z, summary + ': 1/-0'); |
michael@0 | 79 | |
michael@0 | 80 | z = Math.max(-0, 0); |
michael@0 | 81 | |
michael@0 | 82 | reportCompare(0, Math.atan2(z, z), summary + ': Math.atan2(0, 0)'); |
michael@0 | 83 | reportCompare(Infinity, 1/z, summary + ': 1/0'); |