js/src/tests/ecma/Math/15.8.2.9.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 /**
michael@0 8 File Name: 15.8.2.9.js
michael@0 9 ECMA Section: 15.8.2.9 Math.floor(x)
michael@0 10 Description: return the greatest number value that is not greater
michael@0 11 than the argument and is equal to a mathematical integer.
michael@0 12 if the number is already an integer, return the number
michael@0 13 itself. special cases:
michael@0 14 - if x is NaN return NaN
michael@0 15 - if x = +0 return +0
michael@0 16 - if x = -0 return -0
michael@0 17 - if x = Infinity return Infinity
michael@0 18 - if x = -Infinity return -Infinity
michael@0 19 - if ( -1 < x < 0 ) return -0
michael@0 20 also:
michael@0 21 - the value of Math.floor(x) == -Math.ceil(-x)
michael@0 22 Author: christine@netscape.com
michael@0 23 Date: 7 july 1997
michael@0 24 */
michael@0 25
michael@0 26 var SECTION = "15.8.2.9";
michael@0 27 var VERSION = "ECMA_1";
michael@0 28 startTest();
michael@0 29 var TITLE = "Math.floor(x)";
michael@0 30
michael@0 31 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 32
michael@0 33 new TestCase( SECTION,
michael@0 34 "Math.floor.length",
michael@0 35 1,
michael@0 36 Math.floor.length );
michael@0 37
michael@0 38 new TestCase( SECTION,
michael@0 39 "Math.floor()",
michael@0 40 Number.NaN,
michael@0 41 Math.floor() );
michael@0 42
michael@0 43 new TestCase( SECTION,
michael@0 44 "Math.floor(void 0)",
michael@0 45 Number.NaN,
michael@0 46 Math.floor(void 0) );
michael@0 47
michael@0 48 new TestCase( SECTION,
michael@0 49 "Math.floor(null)",
michael@0 50 0,
michael@0 51 Math.floor(null) );
michael@0 52
michael@0 53 new TestCase( SECTION,
michael@0 54 "Math.floor(true)",
michael@0 55 1,
michael@0 56 Math.floor(true) );
michael@0 57
michael@0 58 new TestCase( SECTION,
michael@0 59 "Math.floor(false)",
michael@0 60 0,
michael@0 61 Math.floor(false) );
michael@0 62
michael@0 63 new TestCase( SECTION,
michael@0 64 "Math.floor('1.1')",
michael@0 65 1,
michael@0 66 Math.floor("1.1") );
michael@0 67
michael@0 68 new TestCase( SECTION,
michael@0 69 "Math.floor('-1.1')",
michael@0 70 -2,
michael@0 71 Math.floor("-1.1") );
michael@0 72
michael@0 73 new TestCase( SECTION,
michael@0 74 "Math.floor('0.1')",
michael@0 75 0,
michael@0 76 Math.floor("0.1") );
michael@0 77
michael@0 78 new TestCase( SECTION,
michael@0 79 "Math.floor('-0.1')",
michael@0 80 -1,
michael@0 81 Math.floor("-0.1") );
michael@0 82
michael@0 83 new TestCase( SECTION,
michael@0 84 "Math.floor(NaN)",
michael@0 85 Number.NaN,
michael@0 86 Math.floor(Number.NaN) );
michael@0 87
michael@0 88 new TestCase( SECTION,
michael@0 89 "Math.floor(NaN)==-Math.ceil(-NaN)",
michael@0 90 false,
michael@0 91 Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) );
michael@0 92
michael@0 93 new TestCase( SECTION,
michael@0 94 "Math.floor(0)",
michael@0 95 0,
michael@0 96 Math.floor(0) );
michael@0 97
michael@0 98 new TestCase( SECTION,
michael@0 99 "Math.floor(0)==-Math.ceil(-0)",
michael@0 100 true,
michael@0 101 Math.floor(0) == -Math.ceil(-0) );
michael@0 102
michael@0 103 new TestCase( SECTION,
michael@0 104 "Math.floor(-0)",
michael@0 105 -0,
michael@0 106 Math.floor(-0) );
michael@0 107
michael@0 108 new TestCase( SECTION,
michael@0 109 "Infinity/Math.floor(-0)",
michael@0 110 -Infinity,
michael@0 111 Infinity/Math.floor(-0) );
michael@0 112
michael@0 113 new TestCase( SECTION,
michael@0 114 "Math.floor(-0)==-Math.ceil(0)",
michael@0 115 true,
michael@0 116 Math.floor(-0)== -Math.ceil(0) );
michael@0 117
michael@0 118 new TestCase( SECTION,
michael@0 119 "Math.floor(Infinity)",
michael@0 120 Number.POSITIVE_INFINITY,
michael@0 121 Math.floor(Number.POSITIVE_INFINITY) );
michael@0 122
michael@0 123 new TestCase( SECTION,
michael@0 124 "Math.floor(Infinity)==-Math.ceil(-Infinity)",
michael@0 125 true,
michael@0 126 Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) );
michael@0 127
michael@0 128 new TestCase( SECTION,
michael@0 129 "Math.floor(-Infinity)",
michael@0 130 Number.NEGATIVE_INFINITY,
michael@0 131 Math.floor(Number.NEGATIVE_INFINITY) );
michael@0 132
michael@0 133 new TestCase( SECTION,
michael@0 134 "Math.floor(-Infinity)==-Math.ceil(Infinity)",
michael@0 135 true,
michael@0 136 Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) );
michael@0 137
michael@0 138 new TestCase( SECTION,
michael@0 139 "Math.floor(0.0000001)",
michael@0 140 0,
michael@0 141 Math.floor(0.0000001) );
michael@0 142
michael@0 143 new TestCase( SECTION,
michael@0 144 "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true,
michael@0 145 Math.floor(0.0000001)==-Math.ceil(-0.0000001) );
michael@0 146
michael@0 147 new TestCase( SECTION,
michael@0 148 "Math.floor(-0.0000001)",
michael@0 149 -1,
michael@0 150 Math.floor(-0.0000001) );
michael@0 151
michael@0 152 new TestCase( SECTION,
michael@0 153 "Math.floor(0.0000001)==-Math.ceil(0.0000001)",
michael@0 154 true,
michael@0 155 Math.floor(-0.0000001)==-Math.ceil(0.0000001) );
michael@0 156
michael@0 157 test();

mercurial