tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Math.hypot_ToNumberErr.js (922B)


      1 // Copyright (c) 2021 Richard Gibson. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6  Math.hypot should coerce all arguments before inspecting them.
      7 esid: sec-math.hypot
      8 info: |
      9  1. Let _coerced_ be a new empty List.
     10  2. For each element _arg_ of _args_, do
     11    a. Let _n_ be ? ToNumber(_arg_).
     12    b. Append _n_ to _coerced_.
     13  3. For each element _number_ of _coerced_, do
     14 ---*/
     15 
     16 var counter = 0;
     17 
     18 assert.throws(
     19  Test262Error,
     20  function() {
     21    Math.hypot(
     22      Infinity,
     23      -Infinity,
     24      NaN,
     25      0,
     26      -0,
     27      {valueOf: function(){ throw new Test262Error(); }},
     28      {valueOf: function(){ counter++; }}
     29    );
     30  },
     31  'Math.hypot propagates an abrupt completion from coercing an argument to Number'
     32 );
     33 
     34 assert.sameValue(counter, 0,
     35    'Math.hypot aborts argument processing at the first abrupt completion');
     36 
     37 reportCompare(0, 0);