function assertEqual(expected, got, tolerance, message, rejector) {
  if (Array.isArray(expected)) {
    const length = expected.length;
    if (!Array.isArray(got) || length != got.length) {
      const error = new Error(message);
      rejector(error);
      throw error;
    }
    for (let i = 0; i < length; ++i) {
      assertEqual(expected[i], got[i], tolerance, message, rejector);
    }
    return;
  }

  got = /** @type {number} */ (got);
  if (Math.abs(expected - got) > tolerance * expected) {
    throw new Error(message);
  }
}
@param {number|Array<number>|Array<Array<number>>} expected Expected value.
@param {number|Array<number>|Array<Array<number>>} got Actual value.
@param {number} tolerance Accepted tolerance in fraction of expected between expected and got.
@param {string} message The error message.
@param {function(Error):void} rejector A function to be called with any error.