js/src/tests/ecma/Math/15.8.2.11.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Math/15.8.2.11.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,166 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 +   File Name:          15.8.2.11.js
    1.12 +   ECMA Section:       15.8.2.11 Math.max(x, y)
    1.13 +   Description:        return the smaller of the two arguments.
    1.14 +   special cases:
    1.15 +   - if x is NaN or y is NaN   return NaN
    1.16 +   - if x < y                  return x
    1.17 +   - if y > x                  return y
    1.18 +   - if x is +0 and y is +0    return +0
    1.19 +   - if x is +0 and y is -0    return -0
    1.20 +   - if x is -0 and y is +0    return -0
    1.21 +   - if x is -0 and y is -0    return -0
    1.22 +   Author:             christine@netscape.com
    1.23 +   Date:               7 july 1997
    1.24 +*/
    1.25 +
    1.26 +var SECTION = "15.8.2.11";
    1.27 +var VERSION = "ECMA_1";
    1.28 +var TITLE   = "Math.max(x, y)";
    1.29 +var BUGNUMBER="76439";
    1.30 +
    1.31 +startTest();
    1.32 +
    1.33 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.34 +
    1.35 +new TestCase( SECTION,
    1.36 +	      "Math.max.length",
    1.37 +	      2,
    1.38 +	      Math.max.length );
    1.39 +
    1.40 +new TestCase( SECTION,
    1.41 +	      "Math.max()",
    1.42 +	      -Infinity,
    1.43 +	      Math.max() );
    1.44 +
    1.45 +new TestCase( SECTION,
    1.46 +	      "Math.max(void 0, 1)",
    1.47 +	      Number.NaN,
    1.48 +	      Math.max( void 0, 1 ) );
    1.49 +
    1.50 +new TestCase( SECTION,
    1.51 +	      "Math.max(void 0, void 0)",
    1.52 +	      Number.NaN,
    1.53 +	      Math.max( void 0, void 0 ) );
    1.54 +
    1.55 +new TestCase( SECTION,
    1.56 +	      "Math.max(null, 1)",
    1.57 +	      1,
    1.58 +	      Math.max( null, 1 ) );
    1.59 +
    1.60 +new TestCase( SECTION,
    1.61 +	      "Math.max(-1, null)",
    1.62 +	      0,
    1.63 +	      Math.max( -1, null ) );
    1.64 +
    1.65 +new TestCase( SECTION,
    1.66 +	      "Math.max(true, false)",
    1.67 +	      1,
    1.68 +	      Math.max(true,false) );
    1.69 +
    1.70 +new TestCase( SECTION,
    1.71 +	      "Math.max('-99','99')",
    1.72 +	      99,
    1.73 +	      Math.max( "-99","99") );
    1.74 +
    1.75 +new TestCase( SECTION,
    1.76 +	      "Math.max(NaN, Infinity)",
    1.77 +	      Number.NaN,
    1.78 +	      Math.max(Number.NaN,Number.POSITIVE_INFINITY) );
    1.79 +
    1.80 +new TestCase( SECTION,
    1.81 +	      "Math.max(NaN, 0)",
    1.82 +	      Number.NaN,
    1.83 +	      Math.max(Number.NaN, 0) );
    1.84 +
    1.85 +new TestCase( SECTION,
    1.86 +	      "Math.max('a string', 0)",
    1.87 +	      Number.NaN,
    1.88 +	      Math.max("a string", 0) );
    1.89 +
    1.90 +new TestCase( SECTION,
    1.91 +	      "Math.max(NaN, 1)",
    1.92 +	      Number.NaN,
    1.93 +	      Math.max(Number.NaN,1) );
    1.94 +
    1.95 +new TestCase( SECTION,
    1.96 +	      "Math.max('a string',Infinity)",
    1.97 +	      Number.NaN,
    1.98 +	      Math.max("a string", Number.POSITIVE_INFINITY) );
    1.99 +
   1.100 +new TestCase( SECTION,
   1.101 +	      "Math.max(Infinity, NaN)",
   1.102 +	      Number.NaN,
   1.103 +	      Math.max( Number.POSITIVE_INFINITY, Number.NaN) );
   1.104 +
   1.105 +new TestCase( SECTION,
   1.106 +	      "Math.max(NaN, NaN)",
   1.107 +	      Number.NaN,
   1.108 +	      Math.max(Number.NaN, Number.NaN) );
   1.109 +
   1.110 +new TestCase( SECTION,
   1.111 +	      "Math.max(0,NaN)",
   1.112 +	      Number.NaN,
   1.113 +	      Math.max(0,Number.NaN) );
   1.114 +
   1.115 +new TestCase( SECTION,
   1.116 +	      "Math.max(1, NaN)",
   1.117 +	      Number.NaN,
   1.118 +	      Math.max(1, Number.NaN) );
   1.119 +
   1.120 +new TestCase( SECTION,
   1.121 +	      "Math.max(0,0)",
   1.122 +              0,
   1.123 +	      Math.max(0,0) );
   1.124 +
   1.125 +new TestCase( SECTION,
   1.126 +	      "Math.max(0,-0)",
   1.127 +	      0,
   1.128 +	      Math.max(0,-0) );
   1.129 +
   1.130 +new TestCase( SECTION,
   1.131 +	      "Math.max(-0,0)",
   1.132 +	      0,
   1.133 +	      Math.max(-0,0) );
   1.134 +
   1.135 +new TestCase( SECTION,
   1.136 +	      "Math.max(-0,-0)",
   1.137 +	      -0,
   1.138 +	      Math.max(-0,-0) );
   1.139 +
   1.140 +new TestCase( SECTION,
   1.141 +	      "Infinity/Math.max(-0,-0)",
   1.142 +	      -Infinity,
   1.143 +	      Infinity/Math.max(-0,-0) );
   1.144 +
   1.145 +new TestCase( SECTION,
   1.146 +	      "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY,
   1.147 +	      Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) );
   1.148 +
   1.149 +new TestCase( SECTION,
   1.150 +	      "Math.max(Infinity, Infinity)",
   1.151 +	      Number.POSITIVE_INFINITY,
   1.152 +	      Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) );
   1.153 +
   1.154 +new TestCase( SECTION,
   1.155 +	      "Math.max(-Infinity,-Infinity)",
   1.156 +	      Number.NEGATIVE_INFINITY,
   1.157 +	      Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) );
   1.158 +
   1.159 +new TestCase( SECTION,
   1.160 +	      "Math.max(1,.99999999999999)",
   1.161 +	      1,
   1.162 +	      Math.max(1,.99999999999999) );
   1.163 +
   1.164 +new TestCase( SECTION,
   1.165 +	      "Math.max(-1,-.99999999999999)",
   1.166 +	      -.99999999999999,
   1.167 +	      Math.max(-1,-.99999999999999) );
   1.168 +
   1.169 +test();

mercurial