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