]> git.saurik.com Git - apple/javascriptcore.git/blame_incremental - tests/mozilla/ecma/Math/15.8.2.12.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma / Math / 15.8.2.12.js
... / ...
CommitLineData
1/* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
5 *
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
23 File Name: 15.8.2.12.js
24 ECMA Section: 15.8.2.12 Math.min(x, y)
25 Description: return the smaller of the two arguments.
26 special cases:
27 - if x is NaN or y is NaN return NaN
28 - if x < y return x
29 - if y > x return y
30 - if x is +0 and y is +0 return +0
31 - if x is +0 and y is -0 return -0
32 - if x is -0 and y is +0 return -0
33 - if x is -0 and y is -0 return -0
34 Author: christine@netscape.com
35 Date: 7 july 1997
36*/
37
38
39 var SECTION = "15.8.2.12";
40 var VERSION = "ECMA_1";
41 startTest();
42 var TITLE = "Math.min(x, y)";
43 var BUGNUMBER="76439";
44
45 writeHeaderToLog( SECTION + " "+ TITLE);
46
47 var testcases = getTestCases();
48 test();
49
50function getTestCases() {
51 var array = new Array();
52 var item = 0;
53
54 array[item++] = new TestCase( SECTION, "Math.min.length", 2, Math.min.length );
55
56 array[item++] = new TestCase( SECTION, "Math.min()", Infinity, Math.min() );
57 array[item++] = new TestCase( SECTION, "Math.min(void 0, 1)", Number.NaN, Math.min( void 0, 1 ) );
58 array[item++] = new TestCase( SECTION, "Math.min(void 0, void 0)", Number.NaN, Math.min( void 0, void 0 ) );
59 array[item++] = new TestCase( SECTION, "Math.min(null, 1)", 0, Math.min( null, 1 ) );
60 array[item++] = new TestCase( SECTION, "Math.min(-1, null)", -1, Math.min( -1, null ) );
61 array[item++] = new TestCase( SECTION, "Math.min(true, false)", 0, Math.min(true,false) );
62
63 array[item++] = new TestCase( SECTION, "Math.min('-99','99')", -99, Math.min( "-99","99") );
64
65 array[item++] = new TestCase( SECTION, "Math.min(NaN,0)", Number.NaN, Math.min(Number.NaN,0) );
66 array[item++] = new TestCase( SECTION, "Math.min(NaN,1)", Number.NaN, Math.min(Number.NaN,1) );
67 array[item++] = new TestCase( SECTION, "Math.min(NaN,-1)", Number.NaN, Math.min(Number.NaN,-1) );
68 array[item++] = new TestCase( SECTION, "Math.min(0,NaN)", Number.NaN, Math.min(0,Number.NaN) );
69 array[item++] = new TestCase( SECTION, "Math.min(1,NaN)", Number.NaN, Math.min(1,Number.NaN) );
70 array[item++] = new TestCase( SECTION, "Math.min(-1,NaN)", Number.NaN, Math.min(-1,Number.NaN) );
71 array[item++] = new TestCase( SECTION, "Math.min(NaN,NaN)", Number.NaN, Math.min(Number.NaN,Number.NaN) );
72 array[item++] = new TestCase( SECTION, "Math.min(1,1.0000000001)", 1, Math.min(1,1.0000000001) );
73 array[item++] = new TestCase( SECTION, "Math.min(1.0000000001,1)", 1, Math.min(1.0000000001,1) );
74 array[item++] = new TestCase( SECTION, "Math.min(0,0)", 0, Math.min(0,0) );
75 array[item++] = new TestCase( SECTION, "Math.min(0,-0)", -0, Math.min(0,-0) );
76 array[item++] = new TestCase( SECTION, "Math.min(-0,-0)", -0, Math.min(-0,-0) );
77
78 array[item++] = new TestCase( SECTION, "Infinity/Math.min(0,-0)", -Infinity, Infinity/Math.min(0,-0) );
79 array[item++] = new TestCase( SECTION, "Infinity/Math.min(-0,-0)", -Infinity, Infinity/Math.min(-0,-0) );
80
81
82 return ( array );
83}
84function test() {
85 for ( tc=0; tc < testcases.length; tc++ ) {
86 testcases[tc].passed = writeTestCaseResult(
87 testcases[tc].expect,
88 testcases[tc].actual,
89 testcases[tc].description +" = "+
90 testcases[tc].actual );
91
92 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
93 }
94 stopTest();
95 return ( testcases );
96}