Home | History | Annotate | Download | only in mjsunit
      1 // Copyright 2015 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 var values = [true,false,null,void 0,0,0.0,-0,"",-1,-1.25,1,1.25,-2147483648,2147483648,Infinity,-Infinity,NaN];
      6 var expected = [
      7   [1,0,0,NaN,0,0,-0,0,-1,-1.25,1,1,-2147483648,1,1,-Infinity,NaN],
      8   [0,0,0,NaN,0,0,-0,0,-1,-1.25,0,0,-2147483648,0,0,-Infinity,NaN],
      9   [0,0,0,NaN,0,0,-0,0,-1,-1.25,0,0,-2147483648,0,0,-Infinity,NaN],
     10   [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN],
     11   [0,0,0,NaN,0,0,-0,0,-1,-1.25,0,0,-2147483648,0,0,-Infinity,NaN],
     12   [0,0,0,NaN,0,0,-0,0,-1,-1.25,0,0,-2147483648,0,0,-Infinity,NaN],
     13   [-0,-0,-0,NaN,-0,-0,-0,-0,-1,-1.25,-0,-0,-2147483648,-0,-0,-Infinity,NaN],
     14   [0,0,0,NaN,0,0,-0,0,-1,-1.25,0,0,-2147483648,0,0,-Infinity,NaN],
     15   [-1,-1,-1,NaN,-1,-1,-1,-1,-1,-1.25,-1,-1,-2147483648,-1,-1,-Infinity,NaN],
     16   [-1.25,-1.25,-1.25,NaN,-1.25,-1.25,-1.25,-1.25,-1.25,-1.25,-1.25,-1.25,-2147483648,-1.25,-1.25,-Infinity,NaN],
     17   [1,0,0,NaN,0,0,-0,0,-1,-1.25,1,1,-2147483648,1,1,-Infinity,NaN],
     18   [1,0,0,NaN,0,0,-0,0,-1,-1.25,1,1.25,-2147483648,1.25,1.25,-Infinity,NaN],
     19   [-2147483648,-2147483648,-2147483648,NaN,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-2147483648,-Infinity,NaN],
     20   [1,0,0,NaN,0,0,-0,0,-1,-1.25,1,1.25,-2147483648,2147483648,2147483648,-Infinity,NaN],
     21   [1,0,0,NaN,0,0,-0,0,-1,-1.25,1,1.25,-2147483648,2147483648,Infinity,-Infinity,NaN],
     22   [-Infinity,-Infinity,-Infinity,NaN,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,-Infinity,NaN],
     23   [NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN]
     24 ];
     25 var func = (function min(a,b) { return Math.min(a, b); });
     26 var left_funcs = [
     27   (function min_L0(b) { return Math.min(true, b); }),
     28   (function min_L1(b) { return Math.min(false, b); }),
     29   (function min_L2(b) { return Math.min(null, b); }),
     30   (function min_L3(b) { return Math.min(void 0, b); }),
     31   (function min_L4(b) { return Math.min(0, b); }),
     32   (function min_L5(b) { return Math.min(0.0, b); }),
     33   (function min_L6(b) { return Math.min(-0, b); }),
     34   (function min_L7(b) { return Math.min("", b); }),
     35   (function min_L8(b) { return Math.min(-1, b); }),
     36   (function min_L9(b) { return Math.min(-1.25, b); }),
     37   (function min_L10(b) { return Math.min(1, b); }),
     38   (function min_L11(b) { return Math.min(1.25, b); }),
     39   (function min_L12(b) { return Math.min(-2147483648, b); }),
     40   (function min_L13(b) { return Math.min(2147483648, b); }),
     41   (function min_L14(b) { return Math.min(Infinity, b); }),
     42   (function min_L15(b) { return Math.min(-Infinity, b); }),
     43   (function min_L16(b) { return Math.min(NaN, b); })
     44 ];
     45 var right_funcs = [
     46   (function min_R0(a) { return Math.min(a, true); }),
     47   (function min_R1(a) { return Math.min(a, false); }),
     48   (function min_R2(a) { return Math.min(a, null); }),
     49   (function min_R3(a) { return Math.min(a, void 0); }),
     50   (function min_R4(a) { return Math.min(a, 0); }),
     51   (function min_R5(a) { return Math.min(a, 0.0); }),
     52   (function min_R6(a) { return Math.min(a, -0); }),
     53   (function min_R7(a) { return Math.min(a, ""); }),
     54   (function min_R8(a) { return Math.min(a, -1); }),
     55   (function min_R9(a) { return Math.min(a, -1.25); }),
     56   (function min_R10(a) { return Math.min(a, 1); }),
     57   (function min_R11(a) { return Math.min(a, 1.25); }),
     58   (function min_R12(a) { return Math.min(a, -2147483648); }),
     59   (function min_R13(a) { return Math.min(a, 2147483648); }),
     60   (function min_R14(a) { return Math.min(a, Infinity); }),
     61   (function min_R15(a) { return Math.min(a, -Infinity); }),
     62   (function min_R16(a) { return Math.min(a, NaN); })
     63 ];
     64 function matrix() {
     65   return [
     66     [Math.min(true, true),Math.min(true, false),Math.min(true, null),Math.min(true, void 0),Math.min(true, 0),Math.min(true, 0.0),Math.min(true, -0),Math.min(true, ""),Math.min(true, -1),Math.min(true, -1.25),Math.min(true, 1),Math.min(true, 1.25),Math.min(true, -2147483648),Math.min(true, 2147483648),Math.min(true, Infinity),Math.min(true, -Infinity),Math.min(true, NaN)],
     67     [Math.min(false, true),Math.min(false, false),Math.min(false, null),Math.min(false, void 0),Math.min(false, 0),Math.min(false, 0.0),Math.min(false, -0),Math.min(false, ""),Math.min(false, -1),Math.min(false, -1.25),Math.min(false, 1),Math.min(false, 1.25),Math.min(false, -2147483648),Math.min(false, 2147483648),Math.min(false, Infinity),Math.min(false, -Infinity),Math.min(false, NaN)],
     68     [Math.min(null, true),Math.min(null, false),Math.min(null, null),Math.min(null, void 0),Math.min(null, 0),Math.min(null, 0.0),Math.min(null, -0),Math.min(null, ""),Math.min(null, -1),Math.min(null, -1.25),Math.min(null, 1),Math.min(null, 1.25),Math.min(null, -2147483648),Math.min(null, 2147483648),Math.min(null, Infinity),Math.min(null, -Infinity),Math.min(null, NaN)],
     69     [Math.min(void 0, true),Math.min(void 0, false),Math.min(void 0, null),Math.min(void 0, void 0),Math.min(void 0, 0),Math.min(void 0, 0.0),Math.min(void 0, -0),Math.min(void 0, ""),Math.min(void 0, -1),Math.min(void 0, -1.25),Math.min(void 0, 1),Math.min(void 0, 1.25),Math.min(void 0, -2147483648),Math.min(void 0, 2147483648),Math.min(void 0, Infinity),Math.min(void 0, -Infinity),Math.min(void 0, NaN)],
     70     [Math.min(0, true),Math.min(0, false),Math.min(0, null),Math.min(0, void 0),Math.min(0, 0),Math.min(0, 0.0),Math.min(0, -0),Math.min(0, ""),Math.min(0, -1),Math.min(0, -1.25),Math.min(0, 1),Math.min(0, 1.25),Math.min(0, -2147483648),Math.min(0, 2147483648),Math.min(0, Infinity),Math.min(0, -Infinity),Math.min(0, NaN)],
     71     [Math.min(0.0, true),Math.min(0.0, false),Math.min(0.0, null),Math.min(0.0, void 0),Math.min(0.0, 0),Math.min(0.0, 0.0),Math.min(0.0, -0),Math.min(0.0, ""),Math.min(0.0, -1),Math.min(0.0, -1.25),Math.min(0.0, 1),Math.min(0.0, 1.25),Math.min(0.0, -2147483648),Math.min(0.0, 2147483648),Math.min(0.0, Infinity),Math.min(0.0, -Infinity),Math.min(0.0, NaN)],
     72     [Math.min(-0, true),Math.min(-0, false),Math.min(-0, null),Math.min(-0, void 0),Math.min(-0, 0),Math.min(-0, 0.0),Math.min(-0, -0),Math.min(-0, ""),Math.min(-0, -1),Math.min(-0, -1.25),Math.min(-0, 1),Math.min(-0, 1.25),Math.min(-0, -2147483648),Math.min(-0, 2147483648),Math.min(-0, Infinity),Math.min(-0, -Infinity),Math.min(-0, NaN)],
     73     [Math.min("", true),Math.min("", false),Math.min("", null),Math.min("", void 0),Math.min("", 0),Math.min("", 0.0),Math.min("", -0),Math.min("", ""),Math.min("", -1),Math.min("", -1.25),Math.min("", 1),Math.min("", 1.25),Math.min("", -2147483648),Math.min("", 2147483648),Math.min("", Infinity),Math.min("", -Infinity),Math.min("", NaN)],
     74     [Math.min(-1, true),Math.min(-1, false),Math.min(-1, null),Math.min(-1, void 0),Math.min(-1, 0),Math.min(-1, 0.0),Math.min(-1, -0),Math.min(-1, ""),Math.min(-1, -1),Math.min(-1, -1.25),Math.min(-1, 1),Math.min(-1, 1.25),Math.min(-1, -2147483648),Math.min(-1, 2147483648),Math.min(-1, Infinity),Math.min(-1, -Infinity),Math.min(-1, NaN)],
     75     [Math.min(-1.25, true),Math.min(-1.25, false),Math.min(-1.25, null),Math.min(-1.25, void 0),Math.min(-1.25, 0),Math.min(-1.25, 0.0),Math.min(-1.25, -0),Math.min(-1.25, ""),Math.min(-1.25, -1),Math.min(-1.25, -1.25),Math.min(-1.25, 1),Math.min(-1.25, 1.25),Math.min(-1.25, -2147483648),Math.min(-1.25, 2147483648),Math.min(-1.25, Infinity),Math.min(-1.25, -Infinity),Math.min(-1.25, NaN)],
     76     [Math.min(1, true),Math.min(1, false),Math.min(1, null),Math.min(1, void 0),Math.min(1, 0),Math.min(1, 0.0),Math.min(1, -0),Math.min(1, ""),Math.min(1, -1),Math.min(1, -1.25),Math.min(1, 1),Math.min(1, 1.25),Math.min(1, -2147483648),Math.min(1, 2147483648),Math.min(1, Infinity),Math.min(1, -Infinity),Math.min(1, NaN)],
     77     [Math.min(1.25, true),Math.min(1.25, false),Math.min(1.25, null),Math.min(1.25, void 0),Math.min(1.25, 0),Math.min(1.25, 0.0),Math.min(1.25, -0),Math.min(1.25, ""),Math.min(1.25, -1),Math.min(1.25, -1.25),Math.min(1.25, 1),Math.min(1.25, 1.25),Math.min(1.25, -2147483648),Math.min(1.25, 2147483648),Math.min(1.25, Infinity),Math.min(1.25, -Infinity),Math.min(1.25, NaN)],
     78     [Math.min(-2147483648, true),Math.min(-2147483648, false),Math.min(-2147483648, null),Math.min(-2147483648, void 0),Math.min(-2147483648, 0),Math.min(-2147483648, 0.0),Math.min(-2147483648, -0),Math.min(-2147483648, ""),Math.min(-2147483648, -1),Math.min(-2147483648, -1.25),Math.min(-2147483648, 1),Math.min(-2147483648, 1.25),Math.min(-2147483648, -2147483648),Math.min(-2147483648, 2147483648),Math.min(-2147483648, Infinity),Math.min(-2147483648, -Infinity),Math.min(-2147483648, NaN)],
     79     [Math.min(2147483648, true),Math.min(2147483648, false),Math.min(2147483648, null),Math.min(2147483648, void 0),Math.min(2147483648, 0),Math.min(2147483648, 0.0),Math.min(2147483648, -0),Math.min(2147483648, ""),Math.min(2147483648, -1),Math.min(2147483648, -1.25),Math.min(2147483648, 1),Math.min(2147483648, 1.25),Math.min(2147483648, -2147483648),Math.min(2147483648, 2147483648),Math.min(2147483648, Infinity),Math.min(2147483648, -Infinity),Math.min(2147483648, NaN)],
     80     [Math.min(Infinity, true),Math.min(Infinity, false),Math.min(Infinity, null),Math.min(Infinity, void 0),Math.min(Infinity, 0),Math.min(Infinity, 0.0),Math.min(Infinity, -0),Math.min(Infinity, ""),Math.min(Infinity, -1),Math.min(Infinity, -1.25),Math.min(Infinity, 1),Math.min(Infinity, 1.25),Math.min(Infinity, -2147483648),Math.min(Infinity, 2147483648),Math.min(Infinity, Infinity),Math.min(Infinity, -Infinity),Math.min(Infinity, NaN)],
     81     [Math.min(-Infinity, true),Math.min(-Infinity, false),Math.min(-Infinity, null),Math.min(-Infinity, void 0),Math.min(-Infinity, 0),Math.min(-Infinity, 0.0),Math.min(-Infinity, -0),Math.min(-Infinity, ""),Math.min(-Infinity, -1),Math.min(-Infinity, -1.25),Math.min(-Infinity, 1),Math.min(-Infinity, 1.25),Math.min(-Infinity, -2147483648),Math.min(-Infinity, 2147483648),Math.min(-Infinity, Infinity),Math.min(-Infinity, -Infinity),Math.min(-Infinity, NaN)],
     82     [Math.min(NaN, true),Math.min(NaN, false),Math.min(NaN, null),Math.min(NaN, void 0),Math.min(NaN, 0),Math.min(NaN, 0.0),Math.min(NaN, -0),Math.min(NaN, ""),Math.min(NaN, -1),Math.min(NaN, -1.25),Math.min(NaN, 1),Math.min(NaN, 1.25),Math.min(NaN, -2147483648),Math.min(NaN, 2147483648),Math.min(NaN, Infinity),Math.min(NaN, -Infinity),Math.min(NaN, NaN)]
     83   ];
     84 }
     85 function test() {
     86   for (var i = 0; i < values.length; i++) {
     87     for (var j = 0; j < values.length; j++) {
     88       var a = values[i];
     89       var b = values[j];
     90       var x = expected[i][j];
     91       assertEquals(x, func(a,b));
     92       assertEquals(x, left_funcs[i](b));
     93       assertEquals(x, right_funcs[j](a));
     94     }
     95   }
     96 
     97   var result = matrix();
     98   for (var i = 0; i < values.length; i++) {
     99     for (var j = 0; j < values.length; j++) {
    100       assertEquals(expected[i][j], result[i][j]);
    101     }
    102   }
    103 }
    104 test();
    105 test();
    106