tor-browser

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

constructor-errors.js (585B)


      1 // The Set constructor throws TypeError when passed a non-iterable argument.
      2 
      3 load(libdir + "asserts.js");
      4 
      5 var misc = [
      6    {}, {x: 1}, Math, isNaN,
      7    Object.create(null),
      8    true, 0, 3.1416,
      9    new Boolean(true), new Number(0),
     10    {iterator: function () { return undefined; }},
     11    {iterator: function () { return null; }},
     12    {iterator: function () { return true; }},
     13    {iterator: function () { return 17; }},
     14 ];
     15 
     16 for (var v of misc) {
     17    assertThrowsInstanceOf(function () { new Set(v); }, TypeError);
     18    assertThrowsInstanceOf(function () { new Map(v); }, TypeError);
     19 }