2005-08-19 Florian Gross <flgr@ccan.de>
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma / Math / 15.8.2.11.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39 /**
40    File Name:          15.8.2.11.js
41    ECMA Section:       15.8.2.11 Math.max(x, y)
42    Description:        return the smaller of the two arguments.
43    special cases:
44    - if x is NaN or y is NaN   return NaN
45    - if x < y                  return x
46    - if y > x                  return y
47    - if x is +0 and y is +0    return +0
48    - if x is +0 and y is -0    return -0
49    - if x is -0 and y is +0    return -0
50    - if x is -0 and y is -0    return -0
51    Author:             christine@netscape.com
52    Date:               7 july 1997
53 */
54
55 var SECTION = "15.8.2.11";
56 var VERSION = "ECMA_1";
57 startTest();
58 var TITLE   = "Math.max(x, y)";
59 var BUGNUMBER="76439";
60
61 writeHeaderToLog( SECTION + " "+ TITLE);
62
63 new TestCase( SECTION,
64               "Math.max.length",
65               2,
66               Math.max.length );
67
68 new TestCase( SECTION,
69               "Math.max()",
70               -Infinity,
71               Math.max() );
72
73 new TestCase( SECTION,
74               "Math.max(void 0, 1)",
75               Number.NaN,
76               Math.max( void 0, 1 ) );
77
78 new TestCase( SECTION,
79               "Math.max(void 0, void 0)",
80               Number.NaN,
81               Math.max( void 0, void 0 ) );
82
83 new TestCase( SECTION,
84               "Math.max(null, 1)",
85               1,
86               Math.max( null, 1 ) );
87
88 new TestCase( SECTION,
89               "Math.max(-1, null)",
90               0,
91               Math.max( -1, null ) );
92
93 new TestCase( SECTION,
94               "Math.max(true, false)",
95               1,
96               Math.max(true,false) );
97
98 new TestCase( SECTION,
99               "Math.max('-99','99')",
100               99,
101               Math.max( "-99","99") );
102
103 new TestCase( SECTION,
104               "Math.max(NaN, Infinity)",
105               Number.NaN,
106               Math.max(Number.NaN,Number.POSITIVE_INFINITY) );
107
108 new TestCase( SECTION,
109               "Math.max(NaN, 0)",
110               Number.NaN,
111               Math.max(Number.NaN, 0) );
112
113 new TestCase( SECTION,
114               "Math.max('a string', 0)",
115               Number.NaN,
116               Math.max("a string", 0) );
117
118 new TestCase( SECTION,
119               "Math.max(NaN, 1)",
120               Number.NaN,
121               Math.max(Number.NaN,1) );
122
123 new TestCase( SECTION,
124               "Math.max('a string',Infinity)", 
125               Number.NaN,
126               Math.max("a string", Number.POSITIVE_INFINITY) );
127
128 new TestCase( SECTION,
129               "Math.max(Infinity, NaN)",
130               Number.NaN,
131               Math.max( Number.POSITIVE_INFINITY, Number.NaN) );
132
133 new TestCase( SECTION,
134               "Math.max(NaN, NaN)",
135               Number.NaN,
136               Math.max(Number.NaN, Number.NaN) );
137
138 new TestCase( SECTION,
139               "Math.max(0,NaN)",
140               Number.NaN,
141               Math.max(0,Number.NaN) );
142
143 new TestCase( SECTION,
144               "Math.max(1, NaN)",
145               Number.NaN,
146               Math.max(1, Number.NaN) );
147
148 new TestCase( SECTION,
149               "Math.max(0,0)",
150               0,
151               Math.max(0,0) );
152
153 new TestCase( SECTION,
154               "Math.max(0,-0)",
155               0,
156               Math.max(0,-0) );
157
158 new TestCase( SECTION,
159               "Math.max(-0,0)",
160               0,
161               Math.max(-0,0) );
162
163 new TestCase( SECTION,
164               "Math.max(-0,-0)",
165               -0,
166               Math.max(-0,-0) );
167
168 new TestCase( SECTION,
169               "Infinity/Math.max(-0,-0)",
170               -Infinity,
171               Infinity/Math.max(-0,-0) );
172
173 new TestCase( SECTION,
174               "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY,
175               Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) );
176
177 new TestCase( SECTION,
178               "Math.max(Infinity, Infinity)",
179               Number.POSITIVE_INFINITY,
180               Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) );
181
182 new TestCase( SECTION,
183               "Math.max(-Infinity,-Infinity)",
184               Number.NEGATIVE_INFINITY,
185               Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) );
186
187 new TestCase( SECTION,
188               "Math.max(1,.99999999999999)",
189               1,
190               Math.max(1,.99999999999999) );
191
192 new TestCase( SECTION,
193               "Math.max(-1,-.99999999999999)",
194               -.99999999999999,
195               Math.max(-1,-.99999999999999) );
196
197 test();