dom/imptests/html/js/builtins/Math.maxmin.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 function testMathMaxMin(aFun) {
     2   var test_error = { name: "test" };
     3   test(function() {
     4     assert_throws(test_error, function() {
     5       Math[aFun](NaN, {
     6         valueOf: function() {
     7           throw test_error;
     8         }
     9       });
    10     });
    11   }, "ToNumber should be called on all arguments: NaN.");
    12   test(function() {
    13     assert_throws(test_error, function() {
    14       Math[aFun](-Infinity, {
    15         valueOf: function() {
    16           throw test_error;
    17         }
    18       });
    19     });
    20   }, "ToNumber should be called on all arguments: -Infinity.");
    21   test(function() {
    22     assert_throws(test_error, function() {
    23       Math[aFun](Infinity, {
    24         valueOf: function() {
    25           throw test_error;
    26         }
    27       });
    28     });
    29   }, "ToNumber should be called on all arguments: Infinity.");
    30   test(function() {
    31     assert_throws(test_error, function() {
    32       Math[aFun]({
    33         valueOf: function() {
    34           throw test_error;
    35         }
    36       },
    37       {
    38         valueOf: function() {
    39           throw 7;
    40         }
    41       });
    42     });
    43   }, "ToNumber should be called left to right.");
    44   test(function() {
    45     assert_equals(Math[aFun]("1"), 1);
    46   }, "Should return a number.");
    47   test(function() {
    48     var expected = {
    49       "max": 0,
    50       "min": -0
    51     }
    52     assert_equals(Math[aFun](0, -0), expected[aFun]);
    53     assert_equals(Math[aFun](-0, 0), expected[aFun]);
    54     assert_equals(Math[aFun](0, 0), 0);
    55     assert_equals(Math[aFun](-0, -0), -0);
    56   }, "Should handle negative zero correctly.");
    57 }

mercurial