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