tor-browser

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

assertions.js (1291B)


      1 function assert_equal_to_array(table, expected, message) {
      2  assert_equals(table.length, expected.length, `${message}: length`);
      3  // The argument check in get() happens before the range check, and negative numbers
      4  // are illegal, hence will throw TypeError per spec.
      5  assert_throws_js(TypeError, () => table.get(-1), `${message}: table.get(-1)`);
      6  for (let i = 0; i < expected.length; ++i) {
      7    assert_equals(table.get(i), expected[i], `${message}: table.get(${i} of ${expected.length})`);
      8  }
      9  assert_throws_js(RangeError, () => table.get(expected.length),
     10                   `${message}: table.get(${expected.length} of ${expected.length})`);
     11  assert_throws_js(RangeError, () => table.get(expected.length + 1),
     12                   `${message}: table.get(${expected.length + 1} of ${expected.length})`);
     13 }
     14 globalThis.assert_equal_to_array = assert_equal_to_array;
     15 
     16 function assert_Table(actual, expected) {
     17  assert_equals(Object.getPrototypeOf(actual), WebAssembly.Table.prototype,
     18                "prototype");
     19  assert_true(Object.isExtensible(actual), "extensible");
     20 
     21  assert_equals(actual.length, expected.length, "length");
     22  for (let i = 0; i < expected.length; ++i) {
     23    assert_equals(actual.get(i), null, `actual.get(${i})`);
     24  }
     25 }
     26 globalThis.assert_Table = assert_Table;