it("should agree with interchangeMap", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          result(
            task(fc.anything(), fc.anything()),
            task(fc.anything(), fc.anything()),
          ),
          interchangeDefinition,
        ),
      );
    })

Summary: The test checks that the `result` function aligns with the `interchangeDefinition` for asynchronous tasks using arbitrary input values.


unknown

it("should extract the value from Fail", () => {
      expect.assertions(100);

      fc.assert(fc.property(fc.anything(), fc.anything(), extractFailFromFail));
    })

Summary: `extractFailFromFail` should consistently extract the value from any given `Fail`.


it("should return the default value for Okay", () => {
      expect.assertions(100);

      fc.assert(fc.property(fc.anything(), fc.anything(), extractFailFromOkay));
    })

Summary: `extractFailFromOkay` returns the default value for `Okay`.


it("should agree with extractOkay", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          result(fc.anything(), fc.anything()),
          fc.anything(),
          extractMapOkayDefinition,
        ),
      );
    })

Summary: The test checks that the `result` function agrees with the behavior defined by `extractMapOkayDefinition`. [I AM UNSURE]


it("should agree with extractFail", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          result(fc.anything(), fc.anything()),
          fc.anything(),
          extractMapFailDefinition,
        ),
      );
    })

Summary: The property ensures that the behavior of a function or process is consistent with `extractFail` when applied to results generated from arbitrary values.


it("should agree with Task.okay and Task.fail", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          result(fc.anything(), fc.anything()),
          toTaskEquivalence,
        ),
      );
    })

Summary: `toTaskEquivalence` ensures that the behavior of a `result` matches `Task.okay` and `Task.fail` across various inputs.


it("should agree with okayValues and failValues", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(result(fc.anything(), fc.anything()), valuesDefinition),
      );
    })

Summary: The property should align the outcomes with `okayValues` and `failValues` based on the `result` function evaluated with arbitrary inputs and `valuesDefinition`.


it("should agree with effect", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          result(fc.anything(), fc.anything()),
          fc.func(fc.anything()),
          effectMapDefinition,
        ),
      );
    })

Summary: The property ensures consistency between the `result` function and `effectMapDefinition`.


it("should be equivalent to multiple flatMap calls", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          result(fc.integer({ min: 1 }), fc.anything()),
          fc.constant(isPowerOfTwo),
          fc.constant((n: number) => new Okay(hotpo(n))),
          fc.func(result(fc.anything(), fc.anything())),
          fromGeneratorEquivalence,
        ),
      );
    })

Summary: The property tests the equivalence between multiple `flatMap` calls and the `fromGeneratorEquivalence` function when applied to a `result` with specific transformations.


it("should throw the value when the generator yields Fail", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          result(fc.anything(), fc.anything()),
          result(fc.anything(), fc.anything()),
          fromGeneratorThrow,
        ),
      );
    })

Summary: The test checks that the `fromGeneratorThrow` function throws an error when the generator yields a `Fail` value.


it("should return Fail when the generator throws an Exception", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          result(fc.anything(), fc.anything()),
          fc.anything(),
          fromGeneratorCatch,
        ),
      );
    })

Summary: When the generator throws an exception, `fromGeneratorCatch` should return `Fail`.


it("should agree with Pair.of", () => {
      expect.assertions(100);

      fc.assert(fc.property(fc.anything(), fromDefinition));
    })

Summary: The property verifies that the function `fromDefinition` agrees with `Pair.of` across a wide range of arbitrary inputs.


it("should return a pair of the value and undefined", () => {
      expect.assertions(100);

      fc.assert(fc.property(fc.anything(), fstDefinition));
    })

Summary: The test checks that `fstDefinition` returns a pair consisting of the given value and `undefined` for any input.


it("should return a pair of undefined and the value", () => {
      expect.assertions(100);

      fc.assert(fc.property(fc.anything(), sndDefinition));
    })

Summary: The `sndDefinition` function returns a pair consisting of `undefined` and the provided value.


it("should fold the Pair", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          fc.anything(),
          fc.anything(),
          fc.func(fc.anything()),
          foldEquivalence,
        ),
      );
    })

Summary: Folding a `Pair` with a function should maintain equivalence as defined by `foldEquivalence`.


it("should preserve identity morphisms", () => {
      expect.assertions(100);

      fc.assert(fc.property(pair(fc.anything(), fc.anything()), mapIdentity));
    })

Summary: Identity morphisms are preserved in `pair` constructions when mapped through `mapIdentity`.


it("should fail to cast non-objects", () => {
      expect.assertions(101);
      const property = (input: unknown) => {
        expect(castObject(input)).toStrictEqual({
          status: "failure",
          expected: "object",
          actual: input
        });
      };
      fc.assert(
        fc.property(
          fc.anything().filter((input) => typeof input !== "object"),
          property
        )
      );
      // eslint-disable-next-line unicorn/no-null -- testing null
      property(null);
    })

Summary: Casting non-object inputs should result in a failure status, expecting an object but receiving the actual input type instead.


it("should preserve identity morphisms", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(pair(fc.anything(), fc.anything()), mapFstIdentity),
      );
    })

Summary: The test checks that applying an identity morphism to the first element of a pair does not alter the pair.


it("should preserve identity morphisms", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(pair(fc.anything(), fc.anything()), mapSndIdentity),
      );
    })

Summary: The test verifies that applying the identity morphism to the second element of a pair preserves the pair's structure.


it("should agree with mapFst", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.anything(),
          replaceFstDefinition,
        ),
      );
    })

Summary: The property ensures that the behavior of the function under test is consistent with `mapFst`, evaluated over randomly generated pairs and values.


it("should agree with mapSnd", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.anything(),
          replaceSndDefinition,
        ),
      );
    })

Summary: The `replaceSndDefinition` applied to pairs should produce results that align with using `mapSnd`.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(pair(fc.anything(), fc.anything()), andLeftIdentity),
      );
    })

Summary: The property should demonstrate that `andLeftIdentity` maintains a left identity for pairs of any values.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(pair(fc.anything(), fc.anything()), andRightIdentity),
      );
    })

Summary: The property validates that a pair satisfies the right identity condition through the `andRightIdentity` function.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          pair(fc.anything(), fc.anything()),
          pair(fc.anything(), fc.anything()),
          andAssociativity,
        ),
      );
    })

Summary: Associativity is tested for pairs of arbitrary values by verifying that `andAssociativity` holds true for combinations of three pairs.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), text),
          fc.constant(new Text("")),
          andFstLeftIdentity,
        ),
      );
    })

Summary: The property asserts that `andFstLeftIdentity` holds true when pairing any value with an empty `Text`.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), text),
          fc.constant(new Text("")),
          andFstRightIdentity,
        ),
      );
    })

Summary: The `andFstRightIdentity` function should maintain the right identity when combining a pair of any value with an empty `Text` object.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), text),
          pair(fc.anything(), text),
          pair(fc.anything(), text),
          andFstAssociativity,
        ),
      );
    })

Summary: The function `andFstAssociativity` should hold the associativity property across pairs of elements.


it("should agree with andFst", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), text),
          pair(fc.anything(), text),
          andThenFstDefinition,
        ),
      );
    })

Summary: The property ensures that the behavior of a pair function is consistent with the `andFst` function using arbitrary pairs of values.


it("should agree with andFst", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), text),
          pair(fc.anything(), text),
          andWhenFstDefinition,
        ),
      );
    })

Summary: The test verifies that the behavior of two paired elements agrees with the `andFst` function according to `andWhenFstDefinition`.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, fc.anything()),
          fc.constant(new Text("")),
          andSndLeftIdentity,
        ),
      );
    })

Summary: `andSndLeftIdentity` function should demonstrate left identity when applied to a pair of text and any value, along with an empty `Text`.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, fc.anything()),
          fc.constant(new Text("")),
          andSndRightIdentity,
        ),
      );
    })

Summary: The test checks that applying `andSndRightIdentity` on a pair with an empty `Text` object as the right element results in the original pair.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, fc.anything()),
          pair(text, fc.anything()),
          pair(text, fc.anything()),
          andSndAssociativity,
        ),
      );
    })

Summary: The `andSndAssociativity` function should hold associativity for operations on pairs.


it("should agree with andSnd", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, fc.anything()),
          pair(text, fc.anything()),
          andWhenSndDefinition,
        ),
      );
    })

Summary: Agreement between two pairs and `andSnd` function based on their definitions holds consistently.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          fc.anything(),
          fc.constant(new Text("")),
          fc.func(pair(fc.anything(), text)),
          flatMapFstLeftIdentity,
        ),
      );
    })

Summary: `flatMapFstLeftIdentity` maintains a left identity property with randomly generated inputs of various types, using constant empty text and a function applied to paired elements.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), text),
          fc.constant(new Text("")),
          flatMapFstRightIdentity,
        ),
      );
    })

Summary: The `flatMapFstRightIdentity` function should maintain a right identity when combined with a `pair` of any value and a `Text` object.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), text),
          fc.func(pair(fc.anything(), text)),
          fc.func(pair(fc.anything(), text)),
          flatMapFstAssociativity,
        ),
      );
    })

Summary: The test ensures the associativity property holds for a function involving pairs and transformations applied to them.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          fc.constant(new Text("")),
          fc.anything(),
          fc.func(pair(text, fc.anything())),
          flatMapSndLeftIdentity,
        ),
      );
    })

Summary: The `flatMapSndLeftIdentity` function results in a mapping where the left identity property holds for a `Text` object and any other value.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, fc.anything()),
          fc.constant(new Text("")),
          flatMapSndRightIdentity,
        ),
      );
    })

Summary: The `flatMapSndRightIdentity` applied to a pair with a constant empty `Text` results in preserving the original pair.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, fc.anything()),
          fc.func(pair(text, fc.anything())),
          fc.func(pair(text, fc.anything())),
          flatMapSndAssociativity,
        ),
      );
    })

Summary: The function `flatMapSndAssociativity` applied on pairs and functions should demonstrate associativity.


it("should agree with flatMapFst", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(pair(fc.anything(), text), text),
          flattenFstDefinition,
        ),
      );
    })

Summary: `flattenFst` for a pair of pairs should behave consistently with `flatMapFst`.


it("should agree with flatMapSnd", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, pair(text, fc.anything())),
          flattenSndDefinition,
        ),
      );
    })

Summary: The test checks that the behavior of a pair transformation agrees with the `flatMapSnd` function across multiple inputs.


it("should be equivalent to multiple flatMapFst calls", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.integer({ min: 1 }), text),
          fc.constant(new Text("")),
          fc.func(text).map((f) => (n: number) => new Pair(collatz(n), f(n))),
          flatMapFstUntilEquivalence,
        ),
      );
    })

Summary: `flatMapFstUntilEquivalence` produces results equivalent to multiple `flatMapFst` calls on integer-text pairs.


it("should be equivalent to multiple flatMapSnd calls", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(text, fc.integer({ min: 1 })),
          fc.constant(new Text("")),
          fc.func(text).map((f) => (n: number) => new Pair(f(n), collatz(n))),
          flatMapSndUntilEquivalence,
        ),
      );
    })

Summary: `flatMapSndUntilEquivalence` should produce results equivalent to multiple `flatMapSnd` calls when applied to pairs of text and integers.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(fc.anything()),
          extendMapFstLeftIdentity,
        ),
      );
    })

Summary: `extendMapFstLeftIdentity` should maintain the left identity property when applied to pairs and functions.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          extendMapFstRightIdentity,
        ),
      );
    })

Summary: The function `extendMapFstRightIdentity` should demonstrate a right identity property when applied to a pair of arbitrary values.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(fc.anything()),
          fc.func(fc.anything()),
          extendMapFstAssociativity,
        ),
      );
    })

Summary: The property verifies the associative behavior of the `extendMapFstAssociativity` function when applied to pairs and functions.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(fc.anything()),
          extendMapSndLeftIdentity,
        ),
      );
    })

Summary: The function `extendMapSndLeftIdentity` maintains a left identity property when applied to pairs and functions over arbitrary values.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          extendMapSndRightIdentity,
        ),
      );
    })

Summary: `extendMapSndRightIdentity` verifies that extending a pair's second element with a right identity does not change the pair.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(fc.anything()),
          fc.func(fc.anything()),
          extendMapSndAssociativity,
        ),
      );
    })

Summary: `extendMapSndAssociativity` maintains associativity for `pair` operations using two functions.


it("should agree with extendMapFst", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(pair(fc.anything(), fc.anything()), extendFstDefinition),
      );
    })

Summary: `extendMapFst` should produce results consistent with `extendFstDefinition` when applied to pairs of arbitrary values.


it("should agree with extendMapSnd", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(pair(fc.anything(), fc.anything()), extendSndDefinition),
      );
    })

Summary: The function `extendMapSnd` should be consistent with the behavior defined in `extendSndDefinition` for a pair of arbitrary values.


it("should be its own inverse", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(pair(fc.anything(), fc.anything()), commuteInverse),
      );
    })

Summary: `commuteInverse` applied to a `pair` of any values should be its own inverse.


it("should agree with andMapOption", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(option(fc.anything())),
          andMapFstOptionDefinition,
        ),
      );
    })

Summary: The function `andMapOption` should behave consistently with `andMapFstOptionDefinition` for pairs generated with arbitrary values and a function mapping to options.


it("should agree with andMapOption", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(option(fc.anything()), option(fc.anything())),
          andOptionDefinition,
        ),
      );
    })

Summary: The property ensures that the behavior of pairing two optional values agrees with `andMapOption`.


it("should agree with andMapOption", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(option(fc.anything()), fc.anything()),
          andFstOptionDefinition,
        ),
      );
    })

Summary: The function verifies that `pair` with options agrees with `andMapOption` by using `andFstOptionDefinition`.


it("should agree with andMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(result(fc.anything(), fc.anything())),
          andMapFstResultDefinition,
        ),
      );
    })

Summary: The test checks for consistency between a `pair` function and `andMapResult` using a mapping function, ensuring their behavior aligns.


it("should agree with andMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(result(fc.anything(), fc.anything())),
          andMapSndResultDefinition,
        ),
      );
    })

Summary: The property should agree between a function applied to a pair of values and the `andMapResult`, using the second value and a result-generating function.


it("should agree with andMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(
            result(fc.anything(), fc.anything()),
            result(fc.anything(), fc.anything()),
          ),
          andResultDefinition,
        ),
      );
    })

Summary: The property checks that an operation using pairs of results is consistent with the behavior defined by `andResultDefinition`.


it("should agree with andMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(result(fc.anything(), fc.anything()), fc.anything()),
          andFstResultDefinition,
        ),
      );
    })

Summary: `pair` applied with `result` on various data types should produce outcomes that match those defined by `andFstResultDefinition`.


it("should agree with andMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), result(fc.anything(), fc.anything())),
          andSndResultDefinition,
        ),
      );
    })

Summary: The test ensures consistency between the results of `andMapResult` and a function defined by `andSndResultDefinition` when applied to pairs of arbitrary values and result objects.


it("should agree with orMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(result(fc.anything(), fc.anything())),
          orMapFstResultDefinition,
        ),
      );
    })

Summary: The function being tested should produce results consistent with `orMapResult` when given pairs and a function.


it("should agree with orMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(result(fc.anything(), fc.anything())),
          orMapSndResultDefinition,
        ),
      );
    })

Summary: The test checks that operations involving pairs and functions yield results consistent with `orMapSndResultDefinition`.


it("should agree with orMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(
            result(fc.anything(), fc.anything()),
            result(fc.anything(), fc.anything()),
          ),
          orResultDefinition,
        ),
      );
    })

Summary: The test checks that the `orMapResult` function behaves consistently with the `orResultDefinition` for pairs of result values.


it("should agree with orMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(result(fc.anything(), fc.anything()), fc.anything()),
          orFstResultDefinition,
        ),
      );
    })

Summary: The function being tested should behave consistently with `orMapResult` when applied to pairs containing result objects.


it("should agree with orMapResult", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), result(fc.anything(), fc.anything())),
          orSndResultDefinition,
        ),
      );
    })

Summary: The outcome of `orMapResult` should match the behavior defined by `orSndResultDefinition` for a pair consisting of any value and a result.


it("should agree with andMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(fc.anything(), fc.anything()),
          fc.func(task(fc.anything(), fc.anything())),
          andMapFstTaskDefinition,
        ),
      );
    })

Summary: `andMapFstTaskDefinition` should produce results consistent with `andMapTask` when applied to pairs and functions involving asynchronous tasks.


it("should agree with andMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(fc.anything(), fc.anything()),
          fc.func(task(fc.anything(), fc.anything())),
          andMapSndTaskDefinition,
        ),
      );
    })

Summary: The property ensures that `andMapSndTaskDefinition` behaves consistently with `andMapTask` when applied to pairs and tasks.


it("should agree with andMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(
            task(fc.anything(), fc.anything()),
            task(fc.anything(), fc.anything()),
          ),
          andTaskDefinition,
        ),
      );
    })

Summary: The property ensures that paired tasks produced by `pair` conform to the behavior defined by `andTaskDefinition`.


it("should agree with andMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(task(fc.anything(), fc.anything()), fc.anything()),
          andFstTaskDefinition,
        ),
      );
    })

Summary: The result of applying `andFstTaskDefinition` to a pair and an additional element should be consistent with `andMapTask`.


test('should verify phone numbers', () =>
      fc.assert(
        fc.property(fc.oneof(mobilePhone(), residentialPhone()), (phone) =>
          isPhoneNumber(phone)
        )
      ))

Summary: Verifies that numbers generated as mobile or residential phones are recognized as valid phone numbers by the `isPhoneNumber` function.


it("should agree with andMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(fc.anything(), task(fc.anything(), fc.anything())),
          andSndTaskDefinition,
        ),
      );
    })

Summary: The function `andSndTaskDefinition` should produce consistent results when applied to paired values and tasks, in agreement with `andMapTask`.


it("should agree with orMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(fc.anything(), fc.anything()),
          fc.func(task(fc.anything(), fc.anything())),
          orMapFstTaskDefinition,
        ),
      );
    })

Summary: The property should agree with the behavior of `orMapTask` when using `orMapFstTaskDefinition` with pairs and tasks.


it("should agree with orMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(fc.anything(), fc.anything()),
          fc.func(task(fc.anything(), fc.anything())),
          orMapSndTaskDefinition,
        ),
      );
    })

Summary: The `pair` function output should agree with the `orMapTask` behavior when applied with `orMapSndTaskDefinition`.


it("should agree with orMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(
            task(fc.anything(), fc.anything()),
            task(fc.anything(), fc.anything()),
          ),
          orTaskDefinition,
        ),
      );
    })

Summary: The test verifies that the output of the paired tasks is consistent with the output of `orMapTask` when given the same task definitions.


it("should agree with orMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(task(fc.anything(), fc.anything()), fc.anything()),
          orFstTaskDefinition,
        ),
      );
    })

Summary: The test verifies that the function behavior is consistent with `orMapTask` when applied to pairs of tasks generated with arbitrary values.


it("should agree with orMapTask", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(fc.anything(), task(fc.anything(), fc.anything())),
          orSndTaskDefinition,
        ),
      );
    })

Summary: The function being tested should produce consistent results with `orMapTask` when applied to a pair of arbitrary values and a task.


it("should agree with distributeMap", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(pair(fc.anything(), fc.anything())),
          distributeMapFstDefinition,
        ),
      );
    })

Summary: `distributeMapFstDefinition` applied to pairs and functions should yield consistent results as expected by `distributeMap`.


it("should agree with distributeMap", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), fc.anything()),
          fc.func(pair(fc.anything(), fc.anything())),
          distributeMapSndDefinition,
        ),
      );
    })

Summary: The test verifies that the behavior of a function used with `distributeMapSndDefinition` is consistent with the `distributeMap` function when applied to pairs of arbitrary values.


it("should agree with distributeMap", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(
            pair(fc.anything(), fc.anything()),
            pair(fc.anything(), fc.anything()),
          ),
          distributeDefinition,
        ),
      );
    })

Summary: The test checks that the behavior of an operation on paired elements aligns with the expected result defined by `distributeDefinition`.


it("should agree with distributeMap", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(pair(fc.anything(), fc.anything()), fc.anything()),
          distributeFstDefinition,
        ),
      );
    })

Summary: The `distributeFstDefinition` should agree with results generated from applying it to nested pairs of arbitrary values.


it("should agree with distributeMap", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), pair(fc.anything(), fc.anything())),
          distributeSndDefinition,
        ),
      );
    })

Summary: The property ensures that the behavior of `distributeSndDefinition` on pairs agrees with the expected distribution logic for nested pairs.


it("should agree with exchangeSnd", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(pair(fc.anything(), fc.anything()), fc.anything()),
          exchangeMapSndDefinition,
        ),
      );
    })

Summary: `exchangeMapSndDefinition` should produce results consistent with `exchangeSnd` when applied to pairs.


it("should agree with associateLeft", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), pair(fc.anything(), fc.anything())),
          associateMapLeftDefinition,
        ),
      );
    })

Summary: The output from applying an associative mapping function on nested pairs should match the expected result defined by `associateMapLeftDefinition`.


it("should be its own inverse", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(pair(fc.anything(), fc.anything()), fc.anything()),
          exchangeSndInverse,
        ),
      );
    })

Summary: The `exchangeSndInverse` function should return the original input when applied to pairs nested within pairs.


it("should be the inverse of associateRight", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(pair(fc.anything(), fc.anything()), fc.anything()),
          associateLeftInverse,
        ),
      );
    })

Summary: Associating left and right with `associateRight` should result in an inverse pair.


it("should agree with exchangeFst", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), pair(fc.anything(), fc.anything())),
          exchangeMapFstDefinition,
        ),
      );
    })

Summary: The property should hold that `exchangeFst` is consistent with `exchangeMapFstDefinition` for pairs with arbitrary elements.


it("should agree with associateRight", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(pair(fc.anything(), fc.anything()), fc.anything()),
          associateMapRightDefinition,
        ),
      );
    })

Summary: The property ensures that the operation performed by `associateRight` aligns with `associateMapRightDefinition` when applied to nested pairs with arbitrary values.


it("should be its own inverse", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), pair(fc.anything(), fc.anything())),
          exchangeFstInverse,
        ),
      );
    })

Summary: The `exchangeFstInverse` function should be its own inverse when applied to pairs of arbitrary values.


it("should be the inverse of associateLeft", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), pair(fc.anything(), fc.anything())),
          associateRightInverse,
        ),
      );
    })

Summary: The result of `associateRightInverse` applied to a pair should be the inverse of `associateLeft`.


it("should agree with distributeOkay", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), result(fc.anything(), fc.anything())),
          distributeMapOkayDefinition,
        ),
      );
    })

Summary: The agreement between the `pair` operation and `distributeOkay` is validated using `distributeMapOkayDefinition` for randomly generated input.


it("should be inverted by Result#collectSnd", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(fc.anything(), result(fc.anything(), fc.anything())),
          distributeOkayInverse,
        ),
      );
    })

Summary: `Result#collectSnd` inverts the operation performed by `distributeOkayInverse` on a pair containing any values and a result.


it("should agree with distributeFail", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(result(fc.anything(), fc.anything()), fc.anything()),
          distributeMapFailDefinition,
        ),
      );
    })

Summary: The test checks that a pair of results and an arbitrary value satisfies the `distributeMapFailDefinition`.


it("should be inverted by Result#collectFst", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          pair(result(fc.anything(), fc.anything()), fc.anything()),
          distributeFailInverse,
        ),
      );
    })

Summary: `Result#collectFst` inverts the distribution of a paired result generated with `distributeFailInverse`.


it("should agree with scatterMapOkay", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(fc.anything(), task(fc.anything(), fc.anything())),
          scatterOkayDefinition,
        ),
      );
    })

Summary: The function being tested should be consistent with `scatterMapOkay` when applied to pairs containing a value and a task.


it("should agree with scatterMapFail", async () => {
      expect.assertions(100);

      await fc.assert(
        fc.asyncProperty(
          pair(task(fc.anything(), fc.anything()), fc.anything()),
          scatterFailDefinition,
        ),
      );
    })

Summary: The test ensures that the `scatterMapFail` function behaves consistently with the `scatterFailDefinition` when applied to pairs of tasks and arbitrary values.


it("should return the values of the pair", () => {
      expect.assertions(100);

      fc.assert(fc.property(fc.anything(), fc.anything(), valuesDefinition));
    })

Summary: Calling the `valuesDefinition` should correctly handle two arbitrary values and return them as a pair.


it("should agree with effect", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          fc.constant(new Text("")),
          pair(fc.anything(), text),
          fc.func(fc.anything()),
          effectMapDefinition,
        ),
      );
    })

Summary: The property ensures that a constructed pair with various elements, functions, and an effect map definition maintains agreement with the `effect`.


it("should be equivalent to multiple flatMapFst calls", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          fc.constant(new Text("")),
          pair(fc.integer({ min: 1 }), text),
          fc.constant(isPowerOfTwo),
          fc.func(text).map((f) => (n: number) => new Pair(hotpo(n), f(n))),
          fc.func(pair(fc.anything(), text)),
          fromGeneratorEquivalence,
        ),
      );
    })

Summary: The equivalence between combining operations using a specific transformation method and using multiple `flatMapFst` calls is verified.


it("should agree with isNotLess", () => {
      expect.assertions(100);

      fc.assert(fc.property(ordering, isLessDefinition));
    })

Summary: The test ensures that the `ordering` function's output agrees with the behavior defined by `isLessDefinition`.


it("should agree with isNotMore", () => {
      expect.assertions(100);

      fc.assert(fc.property(ordering, isMoreDefinition));
    })

Summary: The test confirms that the behavior of an ordering function agrees with the `isNotMore` definition across generated inputs fifty times.


it("should be reflexive", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, isSameReflexivity));
      })

Summary: The function `isSameReflexivity` returns true when a value is equal to itself.


it("should be symmetric", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, isSameSymmetry));
      })

Summary: The property ensures that `isSameSymmetry` is symmetric for two values.


it("should be transitive", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, value, isSameTransitivity));
      })

Summary: The `isSameTransitivity` function should hold transitivity for three given values.


it("should respect function extensionality", () => {
        expect.assertions(100);

        fc.assert(
          fc.property(
            value,
            value,
            fc.func(fc.anything()),
            isSameExtensionality,
          ),
        );
      })

Summary: `isSameExtensionality` verifies that two values, when applied to identical functions, produce equal results, respecting function extensionality.


it("should agree with isSame", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, isNotSameDefinition));
      })

Summary: The property verifies that when two values satisfy `isNotSameDefinition`, they do not satisfy `isSame`.


it("should be transitive", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, value, isLessTransitive));
      })

Summary: `isLessTransitive` confirms that the transitive property holds among three values generated for testing.


it("should be the dual of isMore", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, isLessDuality));
      })

Summary: The property should hold that `isLessDuality` demonstrates the dual relationship between two values when compared using `isMore`.


it("should agree with isMore or isSame", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, isNotLessDefinition));
      })

Summary: The property should agree with the `isMore` or `isSame` conditions as defined in `isNotLessDefinition` when comparing two values.


it("should be irreflexive", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, isMoreIrreflexivity));
      })

Summary: The function `isMoreIrreflexivity` should return false for any given `value` when tested for irreflexivity.


it("should be transitive", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, value, isMoreTransitive));
      })

Summary: isMoreTransitive should hold true for any three given values, demonstrating the transitive property.


it("should be the dual of isLess", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, isMoreDuality));
      })

Summary: `isMoreDuality` consistently returns the dual of `isLess` for a pair of values.


it("should agree with isLess or isSame", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, isNotMoreDefinition));
      })

Summary: `isNotMoreDefinition` should consistently agree with `isLess` or `isSame` across multiple `value` pairs.


it("should agree with isSame", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, compareIsSame));
      })

Summary: The property ensures that the `compareIsSame` function agrees with the concept defined by `isSame` when given two values.


it("should agree with isLess", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, compareIsLess));
      })

Summary: The test ensures that the `compareIsLess` function behaves consistently with the expected ordering of two values.


it("should agree with isMore", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, compareIsMore));
      })

Summary: The `compareIsMore` function should produce consistent results with `isMore` when given pairs of values.


it("should agree with compare", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, maxDefinition));
      })

Summary: The property asserts that two `value` arguments, when compared using `maxDefinition`, consistently agree with a defined comparison logic.


it("should agree with compare", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, minDefinition));
      })

Summary: The test checks that some aspect involving two `value` inputs and `minDefinition` aligns with the behavior of a `compare` function or equivalent logic, asserting this agreement consistently across multiple instances.


it("should agree with min and max", () => {
        expect.assertions(100);

        fc.assert(fc.property(value, value, value, clampDefinition));
      })

Summary:
[I AM UNSURE]

The actual properties being tested are unclear due to the lack of details on the `value`, `clampDefinition`, and what the test assertions are verifying.


it("should convert Some to a string", () => {
      expect.assertions(100);

      fc.assert(fc.property(fc.anything(), toStringSome));
    })

Summary: The property verifies that the `toStringSome` function successfully converts various inputs into their string representations.


it("should convert None to a string", () => {
      expect.assertions(100);

      fc.assert(fc.property(none, toStringNone));
    })

Summary: `toStringNone` consistently converts `None` values to a string representation.


it("should preserve identity morphisms", () => {
      expect.assertions(100);

      fc.assert(fc.property(option(fc.anything()), mapIdentity));
    })

Summary: Identity morphisms applied to options should preserve the original content.


it("should agree with map", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(option(fc.anything()), fc.anything(), replaceDefinition),
      );
    })

Summary: The property should hold that the behavior of a function agrees with the concept of `map` when applied to options and various inputs.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(fc.property(option(fc.anything()), andLeftIdentity));
    })

Summary: The test checks the left identity property on options generated from any values.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(fc.property(option(fc.anything()), andRightIdentity));
    })

Summary: The function `andRightIdentity` should satisfy the right identity property for an `option` type across various input values.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.anything()),
          option(fc.anything()),
          option(fc.anything()),
          andAssociativity,
        ),
      );
    })

Summary: Associativity should hold for operations on three `option` values, ensuring the result remains consistent regardless of how the operations are grouped.


it("should have a right annihilator", () => {
      expect.assertions(100);

      fc.assert(fc.property(option(fc.anything()), andRightAnnihilation));
    })

Summary: The function `andRightAnnihilation` verifies the right annihilator property for options.


it("should agree with and", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.anything()),
          option(fc.anything()),
          andThenDefinition,
        ),
      );
    })

Summary: Agreement between two `option` values and `andThenDefinition`.


it("should have a left identity", () => {
      expect.assertions(100);

      fc.assert(fc.property(option(fc.anything()), orLeftIdentity));
    })

Summary: The property ensures that applying the left identity function to an option does not alter the option's behavior.


it("should have a right identity", () => {
      expect.assertions(100);

      fc.assert(fc.property(option(fc.anything()), orRightIdentity));
    })

Summary: The function `orRightIdentity` should correctly implement the right identity property for an option containing any value.


it("should be left distributive", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.anything()),
          option(fc.anything()),
          option(fc.anything()),
          orLeftDistributivity,
        ),
      );
    })

Summary: The property asserts left distributivity for options across three arbitrary values.


it("should be right distributive", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.anything()),
          option(fc.anything()),
          option(fc.anything()),
          orRightDistributivity,
        ),
      );
    })

Summary: The property should verify that the `orRightDistributivity` function maintains right distributive properties over options of any values.


it("should be associative", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.anything()),
          fc.func(option(fc.anything())),
          fc.func(option(fc.anything())),
          flatMapAssociativity,
        ),
      );
    })

Summary: Mapping functions over `option` types should satisfy associativity through `flatMapAssociativity`.


it("should be equivalent to multiple flatMap calls", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.integer({ min: 1 })),
          fc.constant(
            (n: number): Option<Result<number, number>> => new Some(collatz(n)),
          ),
          flatMapUntilEquivalence,
        ),
      );
    })

Summary: Equivalence should hold between multiple `flatMap` calls on `Option<Result<number, number>>` objects and their single-step counterparts using `flatMapUntilEquivalence`.


it("should be distributive", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.anything()),
          fc.func(fc.boolean()),
          fc.func(fc.boolean()),
          filterDistributivity,
        ),
      );
    })

Summary: The function `filterDistributivity` confirms that an `option` applied to two boolean-returning functions distributes over a general set.


it("should have an annihilating input", () => {
      expect.assertions(100);

      fc.assert(fc.property(option(fc.anything()), filterAnnihilation));
    })

Summary: The property should hold that an option applied with `filterAnnihilation` results in an annihilating input.


it("should agree with filter", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(fc.anything()),
          fc.func(fc.boolean()),
          isSomeAndDefinition,
        ),
      );
    })

Summary: The property verifies that the behavior of `option` objects is consistent with a filter function when verifying conditions using `isSomeAndDefinition`.


it("should unzip None", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(fc.func(pair(fc.anything(), fc.anything())), unzipWithNone),
      );
    })

Summary: `unzipWithNone` produces correct results when applied to functions returning `None`.


it("should unzip Some", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          fc.anything(),
          fc.func(pair(fc.anything(), fc.anything())),
          unzipWithSome,
        ),
      );
    })

Summary: `unzipWithSome` correctly handles input values and pairs generated by a function.


it("should agree with unzipWith", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(pair(fc.anything(), fc.anything())),
          unzipDefinition,
        ),
      );
    })

Summary: The function should produce consistent results with `unzipWith` when applied to option pairs.


it("should be inverted by Result#transposeMapOkay", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(result(fc.anything(), fc.anything())),
          transposeMapOkayInverse,
        ),
      );
    })

Summary: `Result#transposeMapOkay` inverts the transformation of an option wrapped result.


it("should be inverted by Result#transposeMapFail", () => {
      expect.assertions(100);

      fc.assert(
        fc.property(
          option(result(fc.anything(), fc.anything())),
          transposeMapFailInverse,
        ),
      );
    })

Summary: `Result#transposeMapFail` is inversed by the `transposeMapFailInverse` function when applied to options containing results.


it("should be an instance of Error", () => {
    expect.assertions(100);

    fc.assert(fc.property(fc.string(), exceptionError));
  })

Summary: An error produced by `exceptionError` from a given string should be an instance of `Error`.


it("should convert Double to a string", () => {
      expect.assertions(100);

      fc.assert(fc.property(double, toStringDefinition));
    })

Summary: The test checks that converting a `Double` to a string representation complies with `toStringDefinition`.


it("should convert All to a string", () => {
      expect.assertions(100);

      fc.assert(fc.property(all, allToStringDefinition));
    })

Summary: The conversion of `All` to a string should satisfy `allToStringDefinition`.


it('works', (key) => {
      fc.assert(fc.property(fc.jsonValue(), (x) => {
        assert.deepStrictEqual(jsonTryStringify(x, key), JSON.stringify(x));
      }));

      fc.assert(fc.property(fc.string(), (otherwise) => {
        assert.strictEqual(jsonTryStringify(1n, otherwise), otherwise);
      }));
    })

Summary: The test ensures that `jsonTryStringify` produces the same output as `JSON.stringify` for any JSON value, and returns the provided default string when attempting to stringify a BigInt.


Summary: `jsonTryStringify` should return results equivalent to `JSON.stringify` for JSON values and return a specified string when attempting to stringify a BigInt.


it('should find the last of a value in the array', () => {
      assert.strictEqual(findLast((x) => x === 3)([1, 2, 3, 4, 3, 5]), 3);

      fc.assert(
        fc.property(fc.array(fc.anything(), { minLength: 2 }), fc.anything(), (arr, target) => {
          const pred = (x: unknown) => x === target;

          fc.pre(arr.every(negate(pred)));
          fc.pre(!(typeof target === 'number' && isNaN(target)));

          const randIndex = ~~(Math.random() * arr.length - 1);
          arr[randIndex] = target;
          arr[randIndex + 1] = target;

          assert.strictEqual(findLast(pred)(arr), target);
        }),
      );
    })

Summary: `findLast` should return the last occurrence of a specified value in an array, even when the value is inserted consecutively within the array.


it('should append elements to the end of the array', () => {
        fc.assert(
          fc.property(fc.array(fc.array(fc.anything())), (arrays) => {
            const result = monoids.array().concat(arrays);
            assert.deepStrictEqual(result, arrays.flat());
          }),
        );
      })

Summary: `monoids.array().concat` should concatenate arrays of elements, preserving the order and structure by flattening them.


it('should prepend elements to the beginning of the array', () => {
        fc.assert(
          fc.property(fc.array(fc.array(fc.anything())), (arrays) => {
            const result = monoids.prependingArray().concat(arrays);
            assert.deepStrictEqual(result, arrays.reverse().flat());
          }),
        );
      })

Summary: The function `monoids.prependingArray().concat` should prepend arrays to produce a result equivalent to reversing and flattening the input arrays.


it('should return a single reranking api key header', () => {
    fc.assert(
      fc.property(fc.string(), (apiKey) => {
        const provider = new RerankingAPIKeyHeaderProvider(apiKey);

        assert.deepStrictEqual(provider.getHeaders(untouchable()), {
          'x-rerank-api-key': apiKey,
        });
      }),
    );
  })

Summary: `RerankingAPIKeyHeaderProvider` returns headers with a single key-value pair containing the API key.


it('should convert a string into an RerankingAPIKeyHeaderProvider', () => {
      fc.assert(
        fc.property(fc.string(), (apiKey) => {
          const provider = RerankingAPIKeyHeaderProvider.parse(apiKey);

          assert.deepStrictEqual(provider.getHeaders(untouchable()), {
            'x-rerank-api-key': apiKey,
          });
        }),
      );
    })

Summary: `RerankingAPIKeyHeaderProvider.parse` converts a string into a provider that generates headers with the key `'x-rerank-api-key'` set to the original string.


it('should throw on non-string, non-nullish', () => {
      fc.assert(
        fc.property(fc.anything().filter((x) => typeof x !== 'string' && x !== null && x !== undefined), (x) => {
          assert.throws(() => RerankingAPIKeyHeaderProvider.parse(x), TypeError);
        }),
      );
    })

Summary: `RerankingAPIKeyHeaderProvider.parse` throws a `TypeError` when given inputs that are neither strings nor nullish values.


it('should never output a standalone . or &', () => {
      const StandaloneDotRegex = /(?<!&)\.\./;
      const StandaloneAmpersandRegex =/(^|[^&])&($|[^&.])/;

      fc.assert(
        fc.property(PathSegmentsArb, (arr) => {
          const escaped = escapeFieldNames(...arr);
          assert.ok(!StandaloneDotRegex.exec(escaped));
          assert.ok(!StandaloneAmpersandRegex.exec(escaped));
        }),
      );
    })

Summary: The output of `escapeFieldNames` should not contain standalone periods (`..`) or standalone ampersands (`&`) when processing input from `PathSegmentsArb`.


it('should error if path starts with a .', () => {
      const arb = fc.string().map(s => `.${s}`);

      const prop = fc.property(arb, (invalidPath) => {
        assert.throws(() => unescapeFieldPath(invalidPath), { message: `Invalid field path '${invalidPath}'; '.' may not appear at the beginning of the path` });
      });
      fc.assert(prop);
    })

Summary: An error should be thrown if a field path starts with a dot (`.`).


it('should error if path ends with a .', () => {
      assert.doesNotThrow(() => unescapeFieldPath('&.'));

      const arb = NEStringPathSegArb.map(s => `${s}.`);

      const prop = fc.property(arb, (invalidPath) => {
        assert.throws(() => unescapeFieldPath(invalidPath), { message: `Invalid field path '${invalidPath}'; '.' may not appear at the end of the path` });
      });
      fc.assert(prop);
    })

Summary: An error is expected if `unescapeFieldPath` is called with a path ending in a dot (`.`).


it('should error if path ends with a &', () => {
      assert.doesNotThrow(() => unescapeFieldPath('&&'));

      const arb = StringPathSegArb.map(s => `${s}&`);

      const prop = fc.property(arb, (invalidPath) => {
        assert.throws(() => unescapeFieldPath(invalidPath), { message: `Invalid escape sequence in field path '${invalidPath}'; '&' may not appear at the end of the path` });
      });
      fc.assert(prop);
    })

Summary: An error is thrown if a path ends with the character '&', as invalid in a field path.


it('should error if there is a standalone &', () => {
      assert.throws(() => unescapeFieldPath('a&b.'), { message: `Invalid escape sequence in field path 'a&b.' at position 1; '&' may not appear alone (must be used as either '&&' or '&.')` });

      const arb = fc.tuple(NEStringPathSegArb, NEStringPathSegArb).map(([s1, s2]) => [s1.length, `${s1}&${s2}`] as const);

      const prop = fc.property(arb, ([errorPos, invalidPath]) => {
        assert.throws(() => unescapeFieldPath(invalidPath), { message: `Invalid escape sequence in field path '${invalidPath}' at position ${errorPos}; '&' may not appear alone (must be used as either '&&' or '&.')` });
      });
      fc.assert(prop);
    })

Summary: An exception is thrown by `unescapeFieldPath` if a standalone `&` is present in a field path, indicating an invalid escape sequence.


it('should function as a pair of adjoint functors or something idk', () => {
    const arb = PathSegmentsArb.filter(a => a.length > 0);

    fc.assert(
      fc.property(arb, (arr) => {
        const result = escapeFieldNames(...arr);

        assert.strictEqual(typeof result, 'string'); // type
        assert.strictEqual(result, escapeFieldNames(...arr)); // determinism

        const parts = unescapeFieldPath(result);

        assert.ok(Array.isArray(parts)); // type
        assert.strictEqual(parts.length, arr.length); // same num parts

        arr.forEach((original, i) => {
          const unescaped = parts[i];

          if (typeof original === 'number') {
            assert.strictEqual(unescaped, String(original)); // num is unchanged
          } else if (typeof original === 'string') {
            assert.strictEqual(unescaped, original); // each part can be individually escaped and remain the same
          }
        });
      }),
    );
  })

Summary: `escapeFieldNames` and `unescapeFieldPath` maintain type and length consistency; `escapeFieldNames` is deterministic, and numerical or string elements remain unchanged after escaping and unescaping.


it('converts non-errors into errors', () => {
        fc.assert(
          fc.property(fc.anything(), (value) => {
            fc.pre(!(value instanceof Error));

            const error = NonErrorError.asError(value);
            assert.ok(error instanceof NonErrorError);
            assert.strictEqual(error.value, value);

            try {
              assert.strictEqual(error.message, `Non-error value thrown; type='${betterTypeOf(value)}' toString='${value}' JSON.stringified='${jsonTryStringify(value, `${value}`)}'`);
            } catch (_) {
              assert.strictEqual(error.message, `Non-error value thrown; type='${betterTypeOf(value)}'`);
            }
          }),
        );
      })

Summary: Ensures that non-error values are converted to `NonErrorError` instances, preserving the original value and generating a message detailing the value's type and representation.


it('should have any error as its fixed-point', () => {
        const errorsArb = fc.oneof(
          fc.string().chain((message) => {
            return fc.constantFrom(
              new Error(message),
              new TypeError(message),
              NonErrorError.asError(new Error(message)),
              NonErrorError.asError(message),
            );
          }),
          fc.anything().map((value) => {
              return NonErrorError.asError(value);
            },
          ),
        );

        fc.assert(
          fc.property(errorsArb, (error) => {
            for (let i = 0; i < 10; i++) {
              const nextError = NonErrorError.asError(error);
              assert.strictEqual(nextError, error);
            }
          }),
        );
      })

Summary: `NonErrorError.asError` should return the original error when applied repeatedly.


it('works w/ override number', () => {
      fc.assert(
        fc.property(fc.nat(), (overrideMs) => {
          const tm = timeouts.single('generalMethodTimeoutMs', { timeout: overrideMs });
          const [timeout, mkError] = tm.advance(info(tm));

          const expectedOverrideMs = overrideMs || EffectivelyInfinity;
          assert.strictEqual(timeout, expectedOverrideMs);

          const e = mkError();
          assert.ok(e instanceof TimeoutError);
          assert.deepStrictEqual(e.info, info(tm));
          assert.deepStrictEqual(e.timeoutType, 'provided');
          assert.strictEqual(e.message, `Command timed out after ${expectedOverrideMs}ms (The timeout provided via \`{ timeout: <number> }\` timed out)`);

          assert.deepStrictEqual(tm.initial(), {
            generalMethodTimeoutMs: expectedOverrideMs,
            requestTimeoutMs: expectedOverrideMs,
          });
        }), {
          examples: [[0]],
        },
      );
    })

Summary: Timeout configuration should reflect the override number or default to `EffectivelyInfinity`, and a `TimeoutError` should be generated with accurate information when timeout occurs.


it('works w/ partial override object', () => {
      fc.assert(
        fc.property(fc.nat(), fc.nat(), (overrideDA, overrideGM) => {
          const tm = timeouts.single('databaseAdminTimeoutMs', { timeout: { generalMethodTimeoutMs: overrideGM, databaseAdminTimeoutMs: overrideDA } });
          const [timeout, mkError] = tm.advance(info(tm));

          const expectedOverrideDA = overrideDA || EffectivelyInfinity;
          const expectedOverrideMs = Math.min(Timeouts.Default.requestTimeoutMs, expectedOverrideDA);
          assert.strictEqual(timeout, expectedOverrideMs);

          const expectedOverrideField = (Timeouts.Default.requestTimeoutMs > expectedOverrideDA)
            ? 'databaseAdminTimeoutMs'
            : 'requestTimeoutMs';

          const e = mkError();
          assert.ok(e instanceof TimeoutError);
          assert.deepStrictEqual(e.info, info(tm));

          if (Timeouts.Default.requestTimeoutMs === expectedOverrideDA) {
            assert.deepStrictEqual(e.timeoutType, ['requestTimeoutMs', 'databaseAdminTimeoutMs']);
            assert.strictEqual(e.message, `Command timed out after ${expectedOverrideMs}ms (requestTimeoutMs and databaseAdminTimeoutMs simultaneously timed out)`);
          } else {
            assert.deepStrictEqual(e.timeoutType, [expectedOverrideField]);
            assert.strictEqual(e.message, `Command timed out after ${expectedOverrideMs}ms (${expectedOverrideField} timed out)`);
          }

          assert.deepStrictEqual(tm.initial(), {
            requestTimeoutMs: Timeouts.Default.requestTimeoutMs,
            databaseAdminTimeoutMs: expectedOverrideDA,
          });
        }), {
          examples: [
            [Timeouts.Default.requestTimeoutMs, arbs.one(fc.nat())],
            [0, 0],
          ],
        },
      );
    })

Summary: Verifies that a timeout configuration with partially overridden values correctly determines the effective timeout, generates the appropriate timeout error, and initializes with the expected settings.


it('works w/ full override object', () => {
      fc.assert(
        fc.property(fc.nat(), fc.nat(), fc.nat(), (overrideDA, overrideRT, overrideGM) => {
          const tm = timeouts.single('databaseAdminTimeoutMs', { timeout: { generalMethodTimeoutMs: overrideGM, requestTimeoutMs: overrideRT, databaseAdminTimeoutMs: overrideDA } });
          const [timeout, mkError] = tm.advance(info(tm));

          const expectedOverrideDA = overrideDA || EffectivelyInfinity;
          const expectedOverrideRT = overrideRT || EffectivelyInfinity;
          const expectedOverrideMs = Math.min(expectedOverrideRT, expectedOverrideDA);
          assert.strictEqual(timeout, expectedOverrideMs);

          const expectedOverrideField = (expectedOverrideRT > expectedOverrideDA)
            ? 'databaseAdminTimeoutMs'
            : 'requestTimeoutMs';

          const e = mkError();
          assert.ok(e instanceof TimeoutError);
          assert.deepStrictEqual(e.info, info(tm));

          if (expectedOverrideRT === expectedOverrideDA) {
            assert.deepStrictEqual(e.timeoutType, ['requestTimeoutMs', 'databaseAdminTimeoutMs']);
            assert.strictEqual(e.message, `Command timed out after ${expectedOverrideMs}ms (requestTimeoutMs and databaseAdminTimeoutMs simultaneously timed out)`);
          } else {
            assert.deepStrictEqual(e.timeoutType, [expectedOverrideField]);
            assert.strictEqual(e.message, `Command timed out after ${expectedOverrideMs}ms (${expectedOverrideField} timed out)`);
          }

          assert.deepStrictEqual(tm.initial(), {
            databaseAdminTimeoutMs: expectedOverrideDA,
            requestTimeoutMs: expectedOverrideRT,
          });
        }), {
          examples: [
            [123, 123, arbs.one(fc.nat())],
            [0, 0, 0],
          ],
        },
      );
    })

Summary: Verifies that the `timeouts.single` function correctly handles a full override object by evaluating timeouts and generating appropriate `TimeoutError` messages and fields, ensuring it reflects the minimum effective timeout value.


it('should set the proper initial timeout', () => {
      fc.assert(
        fc.property(fc.option(fc.nat(), { nil: undefined }), fc.option(fc.nat(), { nil: undefined }), fc.option(fc.nat(), { nil: undefined }), (overrideDA, overrideRT, overrideGM) => {
          const tm = timeouts.multipart('databaseAdminTimeoutMs', { timeout: { generalMethodTimeoutMs: overrideGM, requestTimeoutMs: overrideRT, databaseAdminTimeoutMs: overrideDA } });

          assert.deepStrictEqual(tm.initial(), {
            databaseAdminTimeoutMs: (overrideDA ?? Timeouts.Default.databaseAdminTimeoutMs) || EffectivelyInfinity,
            requestTimeoutMs: (overrideRT ?? Timeouts.Default.requestTimeoutMs) || EffectivelyInfinity,
          });
        }),
      );
    })

Summary: The initial timeout settings for a multipart function should correctly apply any specified override values or use default values, ensuring non-specified timeouts fall back to "EffectivelyInfinity" if default is undefined.


it('should return what it was given', () => {
      const timeoutTypeArb = fc.constantFrom('requestTimeoutMs', 'databaseAdminTimeoutMs');

      fc.assert(
        fc.property(fc.nat(), fc.nat(), fc.nat(), timeoutTypeArb, (overrideDA, overrideRT, advanceMS, timeoutType) => {
          const tm = timeouts.custom({ databaseAdminTimeoutMs: overrideDA, requestTimeoutMs: overrideRT }, () => [advanceMS, [timeoutType]]);

          for (let i = 0; i < 10; i++) {
            const [timeout, mkError] = tm.advance(info(tm));
            assert.strictEqual(timeout, advanceMS);

            const e = mkError();
            assert.ok(e instanceof TimeoutError);
            assert.deepStrictEqual(e.info, info(tm));
            assert.deepStrictEqual(e.timeoutType, [timeoutType]);
            assert.strictEqual(e.message, `Command timed out after ${timeoutType === 'requestTimeoutMs' ? overrideRT : overrideDA}ms (${timeoutType} timed out)`);

            assert.deepStrictEqual(tm.initial(), {
              databaseAdminTimeoutMs: overrideDA,
              requestTimeoutMs: overrideRT,
            });
          }
        }), {
          examples: [[0, 0, 0, arbs.one(timeoutTypeArb)]],
        },
      );
    })

Summary: The function `timeouts.custom` returns an advance time and constructs a `TimeoutError` object with accurately reflected timeout information and messages, ensuring consistency with the provided timeout configuration and type.


it('successfully replaces all null prototypes', () => {
      const jbi = withJbiNullProtoFix(JBI);

      assert.deepStrictEqual(Object.getPrototypeOf(JBI.parse('{ "a": 3 }')), null);
      assert.deepStrictEqual(Object.getPrototypeOf(jbi.parse('{ "a": 3 }')), Object.create(null));

      const values = [
        {},
        [],
        [{}],
        { a: 1, b: { c: BigNumber('321312312312312212121221'), d: { e: 3 } } },
        [{ a: 1, b: { c: 2, d: { e: 3 } } }],
        "hello world",
        BigNumber('12345678901234567890'),
        { a: [BigNumber('12345678901234567890213213123')] },
      ];

      for (const value of values) {
        const parsed = jbi.parse(jbi.stringify(value));
        assert.deepStrictEqual(parsed, value);
      }

      fc.assert(
        fc.property(fc.json(), (value) => {
          assert.deepStrictEqual(jbi.parse(jbi.stringify(value)), value);
        }),
      );
    })

Summary: The property ensures that the `jbi` object, with null prototype fix applied, correctly parses and stringifies various JSON values, preserving their structure and content.


it('should return false for any different arrays', () => {
      fc.assert(
        fc.property(arbs.path(), arbs.path(), (arr1, arr2) => {
          fc.pre(JSON.stringify(arr1) !== JSON.stringify(arr2));
          assert.ok(!pathArraysEqual(arr1, arr2));
        }),
      );
    })

Summary: `pathArraysEqual` returns false for any arrays that are different when serialized to strings.


it('is symmetric', () => {
      fc.assert(
        fc.property(arbs.path(), arbs.path(), (arr1, arr2) => {
          assert.strictEqual(pathArraysEqual(arr1, arr2), pathArraysEqual(arr2, arr1));
        }),
      );
    })

Summary: The symmetry property should hold such that `pathArraysEqual(arr1, arr2)` and `pathArraysEqual(arr2, arr1)` produce identical results for given path arrays.


it('behaves like pathArraysEqual if exp has no wildcard', () => {
      fc.assert(
        fc.property(pathArb, pathArb, (pattern, arr) => {
          fc.pre(!pattern.includes('*'));
          assert.strictEqual(pathMatches(pattern, arr), pathArraysEqual(arr, pattern));
        }),
      );
    })

Summary: When the pattern has no wildcard, `pathMatches` should behave identically to `pathArraysEqual`.


it("should allow wildcards to match any segment", () => {
      fc.assert(
        fc.property(pathArb, pathArb, (pattern, arr) => {
          fc.pre(pattern.length === arr.length);

          const adjustedPattern = pattern.map((p, i) => (p === arr[i] ? p : '*'));
          assert.ok(pathMatches(adjustedPattern, arr));
        }),
      );
    })

Summary: Wildcards in a pattern should match any corresponding segment in an array when both are of the same length.


it('should ignore all undefined headers', async () => {
      const rawHeadersArb = fc.array(fc.dictionary(fc.string(), fc.oneof(fc.string(), fc.constant(undefined))));
      const baseHeadersArb = arbs.record(fc.string());

      await fc.assert(
        fc.asyncProperty(rawHeadersArb, baseHeadersArb, async (rawHeaders, baseHeaders) => {
          const providers = HeadersProvider.opts.monoid.concat(
            rawHeaders.map((h) => HeadersProvider.opts.fromObj.parse(h)),
          );

          const hr = new HeadersResolver('data-api', providers, baseHeaders);
          const headers = hr.resolve();

          const expected = mergeObjsIgnoringUndefined(baseHeaders, ...rawHeaders);

          assert.ok(!(headers instanceof Promise));
          assert.deepStrictEqual(headers, expected);
        }),
      );
    })

Summary: Resolving headers should result in merging base and raw headers, ignoring any undefined values.


it('should ignore all undefined headers', async () => {
      const rawHeadersArb = fc.array(fc.dictionary(fc.string(), fc.oneof(fc.string(), fc.constant(undefined))));
      const baseHeadersArb = arbs.record(fc.string());

      await fc.assert(
        fc.asyncProperty(rawHeadersArb, baseHeadersArb, async (rawHeaders, baseHeaders) => {
          fc.pre(rawHeaders.length > 0);

          const providers = HeadersProvider.opts.monoid.concat(
            rawHeaders.map((h, i) => {
              if (Math.random() > .25 && i !== 0) {
                return HeadersProvider.opts.fromObj.parse(h);
              }

              return HeadersProvider.opts.fromObj.parse(new (class extends HeadersProvider {
                public async getHeaders() {
                  return h;
                }
              })());
            }),
          );

          const hr = new HeadersResolver('data-api', providers, baseHeaders);
          const headers = hr.resolve();

          const expected = mergeObjsIgnoringUndefined(baseHeaders, ...rawHeaders);

          assert.ok(headers instanceof Promise);
          assert.deepStrictEqual(await headers, expected);
        }),
      );
    })

Summary: `HeadersResolver` should return a promise resolving to merged headers, excluding undefined values from raw headers.


it('should extract the db id and region from valid astra endpoints', () => {
      const astraEnvArb = constantFrom('astra', 'astra-dev', 'astra-test');

      fc.assert(
        fc.property(fc.uuid(), fc.stringMatching(/^[a-z_-]+$/), astraEnvArb, (uuid, region, astraEnv) => {
          const endpoint = `https://${uuid}-${region}.apps.${astraEnv}.datastax.com`;
          assert.deepStrictEqual(extractDbComponentsFromAstraUrl(endpoint), [uuid, region]);
        }),
      );
    })

Summary: Extracting database ID and region from specified Astra endpoint URLs should return the expected components.


it('should return empty array for invalid astra endpoints', () => {
      fc.assert(
        fc.property(fc.webUrl(), (webURL) => {
          assert.deepStrictEqual(extractDbComponentsFromAstraUrl(webURL), []);
        }),
      );

      fc.assert(
        fc.property(fc.string(), (webURL) => {
          assert.deepStrictEqual(extractDbComponentsFromAstraUrl(webURL), []);
        }),
      );
    })

Summary: `extractDbComponentsFromAstraUrl` returns an empty array for any given web URL or string that is an invalid Astra endpoint.


it('should leave populated fields populated', () => {
      fc.assert(
        fc.property(arbs.tableDefinitionAndRow({ partialRow: true }), ([schema, row]) => {
          const [serializedRow] = serdes.serialize(row);

          const resp = serdes.deserialize(serializedRow, {
            status: { projectionSchema: schema },
          });

          assert.deepStrictEqual(resp, serializedRow);
        }),
      );
    })

Summary: Deserialized data should match the serialized input when populated fields are present.


it('should populate all fields', () => {
      const defaultForType = (def: StrictCreateTableColumnDefinition) => {
        switch (def.type) {
          case 'map':
            return new Map();
          case 'set':
            return new Set();
          case 'list':
            return [];
          default:
            return null;
        }
      };

      fc.assert(
        fc.property(arbs.tableDefinitionAndRow(), ([schema]) => {
          const resp = serdes.deserialize({}, {
            status: { projectionSchema: schema },
          });

          const expected = Object.fromEntries(Object.entries(schema).map(([k, v]) => [k, defaultForType(v)]));

          assert.deepStrictEqual(resp, expected);
        }),
      );
    })

Summary: Deserializing with `serdes` should populate all fields using default values based on their types according to the schema.


it('should return a single embedding api key header', () => {
    fc.assert(
      fc.property(fc.string(), (apiKey) => {
        const provider = new EmbeddingAPIKeyHeaderProvider(apiKey);

        assert.deepStrictEqual(provider.getHeaders(untouchable()), {
          'x-embedding-api-key': apiKey,
        });
      }),
    );
  })

Summary: `EmbeddingAPIKeyHeaderProvider` returns a header object containing the API key under 'x-embedding-api-key'.


it('should convert a string into an EmbeddingAPIKeyHeaderProvider', () => {
      fc.assert(
        fc.property(fc.string(), (apiKey) => {
          const provider = EmbeddingAPIKeyHeaderProvider.parse(apiKey);

          assert.deepStrictEqual(provider.getHeaders(untouchable()), {
            'x-embedding-api-key': apiKey,
          });
        }),
      );
    })

Summary: `EmbeddingAPIKeyHeaderProvider.parse` converts a string into an object that provides headers with `x-embedding-api-key` set to the given string.


it('should throw on non-string, non-nullish', () => {
      fc.assert(
        fc.property(fc.anything().filter((x) => typeof x !== 'string' && x !== null && x !== undefined), (x) => {
          assert.throws(() => EmbeddingAPIKeyHeaderProvider.parse(x), TypeError);
        }),
      );
    })

Summary: `EmbeddingAPIKeyHeaderProvider.parse` should throw a `TypeError` for inputs that are neither strings nor nullish (i.e., not null or undefined).


it('should deserialize integers into a BigInt', () => {
          fc.assert(
            fc.property(tableKeyArb, fc.integer(), (key, int) => {
              assert.deepStrictEqual(serdes.deserialize({ [key]: int }, desSchema({ [key]: { type: column } })), { [key]: BigInt(int) });
            }),
          );
        })

Summary: Deserialization of integers should result in `BigInt` values using the specified schema.


it('should deserialize strings into a BigInt', () => {
          fc.assert(
            fc.property(tableKeyArb, fc.bigInt(), (key, bigInt) => {
              assert.deepStrictEqual(serdes.deserialize({ [key]: bigInt.toString() }, desSchema({ [key]: { type: column } })), { [key]: bigInt });
            }),
          );
        })

Summary: Deserializing strings should correctly convert them into `BigInt` values based on the provided schema.


t.test('root', t => {
  fc.assert(
    fc.property(fc.integer(), fc.integer({ min: 1, max: 25 }), (n, m) => {
      if (n < 0 && m % 2 === 0) return;
      t.equal(t_root(n, m), BigIntMath.root(n, m));
    }),
    {
      examples: [
        [-7, 3],
        [7, 3],
        [15, 2],
        [22, 3]
      ]
    }
  );

  // // Identity
  // fc.assert(
  //   fc.property(fc.bigInt(1n, 2n**64n), fc.integer({ min: 1, max: 10 }), (n, m) => {
  //     t.equal(t_root(n**BigInt(m), m), n);
  //   })
  // );

  t.end();
})

Summary: `t_root` should produce the same results as `BigIntMath.root` for integers, except when `n` is negative and `m` is even.


it('should deserialize integers into a BigInt (primary key)', () => {
          fc.assert(
            fc.property(tableKeyArb, fc.integer(), (key, int) => {
              assert.deepStrictEqual(serdes.deserialize([int], desSchema({ [key]: { type: column } }), SerDesTarget.InsertedId), { [key]: BigInt(int) });
            }),
          );
        })

Summary: Deserializing integers results in mapping them to `BigInt` values using a schema with a specified primary key.


it('should deserialize strings into a BigInt (primary key)', () => {
          fc.assert(
            fc.property(tableKeyArb, fc.bigInt(), (key, bigInt) => {
              assert.deepStrictEqual(serdes.deserialize([bigInt.toString()], desSchema({ [key]: { type: column } }), SerDesTarget.InsertedId), { [key]: bigInt });
            }),
          );
        })

Summary: Deserialization of string representations into `BigInt` should correctly map to their expected primary key structure.


it('should deserialize floats as themselves', () => {
          fc.assert(
            fc.property(tableKeyArb, doubleArb, (key, float) => {
              assert.deepStrictEqual(serdes.deserialize({ [key]: float }, desSchema({ [key]: { type: column } })), { [key]: float });
            }),
          );
        })

Summary: Deserialization returns the original float value for a given schema.


it('should deserialize strings into a float', () => {
          fc.assert(
            fc.property(tableKeyArb, doubleArb, (key, float) => {
              assert.deepStrictEqual(serdes.deserialize({ [key]: float.toString() }, desSchema({ [key]: { type: column } })), { [key]: float });
            }),
          );
        })

Summary: Deserializing strings into floats should produce accurate float objects as specified by the schema.


it('should deserialize floats as themselves (primary key)', () => {
          fc.assert(
            fc.property(tableKeyArb, doubleArb, (key, float) => {
              assert.deepStrictEqual(serdes.deserialize([float], desSchema({ [key]: { type: column } }), SerDesTarget.InsertedId), { [key]: float });
            }),
          );
        })

Summary: Deserialization of floats should retain their exact values when used as primary keys.


it('should deserialize strings into a float (primary key)', () => {
          fc.assert(
            fc.property(tableKeyArb, doubleArb, (key, float) => {
              assert.deepStrictEqual(serdes.deserialize([float.toString()], desSchema({ [key]: { type: column } }), SerDesTarget.InsertedId), { [key]: float });
            }),
          );
        })

Summary: Deserializing strings into floats should result in the correct float value being mapped to the primary key.


it('should deserialize integers as themselves', () => {
          fc.assert(
            fc.property(tableKeyArb, fc.integer(), (key, int) => {
              assert.deepStrictEqual(serdes.deserialize({ [key]: int }, desSchema({ [key]: { type: column } })), { [key]: int });
            }),
          );
        })

Summary: Deserialized integers should match their original values according to the specified schema.


it('should deserialize integers as themselves (primary key)', () => {
          fc.assert(
            fc.property(tableKeyArb, fc.integer(), (key, int) => {
              assert.deepStrictEqual(serdes.deserialize([int], desSchema({ [key]: { type: column } }), SerDesTarget.InsertedId), { [key]: int });
            }),
          );
        })

Summary: Deserialization should return integers as themselves when used as a primary key.


it('should serialize blobs properly', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.blob(), (key, blob) => {
            assert.deepStrictEqual(serdes.serialize({ [key]: blob }), [{ [key]: { $binary: blob.asBase64() } }, false]);
          }),
        );
      })

Summary: Serialization of blobs correctly converts them to a base64 binary representation in the output structure.


it('should deserialize blobs properly', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.blob(), (key, blob) => {
            assert.deepStrictEqual(serdes.deserialize({ [key]: { $binary: blob.asBase64() } }, desSchema({ [key]: { type: 'blob' } })), { [key]: blob });
          }),
        );
      })

Summary: Deserialization of blobs should correctly reconstruct the original blob from a Base64-encoded binary object.


it('should deserialize blobs properly (primary key)', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.blob(), (key, blob) => {
            assert.deepStrictEqual(serdes.deserialize([blob.asBase64()], desSchema({ [key]: { type: 'blob' } }), SerDesTarget.InsertedId),  { [key]: blob });
          }),
        );
      })

Summary: Deserializing blobs as primary keys should return an object with the original blob when using the provided schema.


it('should serialize dates properly', () => {
        fc.assert(
          fc.property(tableKeyArb, dateArb, (key, date) => {
            assert.deepStrictEqual(serdes.serialize({ [key]: date }), [{ [key]: date.toString() }, false]);
          }),
        );
      })

Summary: Serialization of date objects should convert them into string representations within the serialized output.


it('should deserialize dates properly (primary key)', () => {
        fc.assert(
          fc.property(tableKeyArb, dateArb, (key, date) => {
            assert.deepStrictEqual(serdes.deserialize([date.toString()], desSchema({ [key]: { type: 'date' } }), SerDesTarget.InsertedId), { [key]: date });
          }),
        );
      })

Summary: Deserialization of date strings to the original date format should match the expected date when using a specified schema and key.


it('should deserialize inet addresses properly (primary key)', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.inet(), (key, inet) => {
            assert.deepStrictEqual(serdes.deserialize([inet.toString()], desSchema({ [key]: { type: 'inet' } }), SerDesTarget.InsertedId), { [key]: inet });
          }),
        );
      })

Summary: Deserializing an `inet` address should result in an object with the correct key-value pair matching the expected type.


it('should serialize dates properly', () => {
        fc.assert(
          fc.property(tableKeyArb, timeArb, (key, time) => {
            assert.deepStrictEqual(serdes.serialize({ [key]: time }), [{ [key]: time.toString() }, false]);
          }),
        );
      })

Summary: The `serdes.serialize` function should convert date objects to their string representations while maintaining the key-value structure.


it('should deserialize dates properly (primary key)', () => {
        fc.assert(
          fc.property(tableKeyArb, timeArb, (key, time) => {
            assert.deepStrictEqual(serdes.deserialize([time.toString()], desSchema({ [key]: { type: 'time' } }), SerDesTarget.InsertedId), { [key]: time });
          }),
        );
      })

Summary: Deserialization of dates should result in a structure where the primary key maps to the correct time value.


it('should serialize the date into the proper format', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.validDate(), (key, date) => {
            assert.deepStrictEqual(serdes.serialize({ [key]: date }), [{ [key]: date.toISOString() }, false]);
          }),
        );
      })

Summary: Serializing a date results in its conversion to the ISO string format in the output.


it('should deserialize the date properly', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.validDate(), (key, date) => {
            assert.deepStrictEqual(serdes.deserialize({ [key]: date.toISOString() }, desSchema({ [key]: { type: 'timestamp' } })), { [key]: date });
          }),
        );
      })

Summary: Deserialization of a date string using a specified schema should result in an object with the original date.


it('should deserialize vectors from { $binary }s properly', () => {
        fc.assert(
          fc.property(tableKeyArb, fc.integer({ min: 1, max: 999 }).chain(dim => fc.tuple(fc.constant(dim), arbs.vector({ dim }))), (key, [dim, vector]) => {
            assert.deepStrictEqual(serdes.deserialize({ [key]: { $binary: vector.asBase64() } }, desSchema({ [key]: { type: 'vector', dimension: dim } })), { [key]: new DataAPIVector({ $binary: vector.asBase64() }) });
          }),
        );
      })

Summary: Deserialization of vectors from binary strings should produce equivalent `DataAPIVector` objects when given dimensional schema information.


it('should deserialize vectors from number[]s properly', () => {
        fc.assert(
          fc.property(tableKeyArb, fc.integer({ min: 1, max: 9999 }).chain(dim => fc.tuple(fc.constant(dim), arbs.vector({ dim }))), (key, [dim, vector]) => {
            assert.deepStrictEqual(serdes.deserialize({ [key]: vector.asArray() }, desSchema({ [key]: { type: 'vector', dimension: dim } })), { [key]: vector });
          }),
        );
      })

Summary: Vectors deserialized from number arrays should match the expected vectors defined by the schema.


it('should serialize a map as an alist if it has >0 entries', () => {
        fc.assert(
          fc.property(tableKeyArb, anyKVsArb, (key, [keys, values]) => {
            const map = new Map(keys.map((k, i) => [k.jsRep, values[i].jsRep]));
            fc.pre(map.size > 0);

            const expectedObj = [...new Map(keys.map((k, i) => [k.jsonRep, values[i].jsonRep]))];
            fc.pre(map.size === expectedObj.length);

            const bigNumsPresent = keys.some((k) => k.jsRep instanceof BigNumber) || values.some((v) => v.jsRep instanceof BigNumber);

            assert.deepStrictEqual(serdes.serialize({ [key]: map }), [{ [key]: expectedObj }, bigNumsPresent]);
          }),
        );
      })

Summary: Serializing a map with more than zero entries should result in an associative list and indicate the presence of any `BigNumber` objects.


it('should serialize a map as an empty object if it has 0 entries', () => {
        fc.assert(
          fc.property(tableKeyArb, (key) => {
            assert.deepStrictEqual(serdes.serialize({ [key]: new Map }), [{ [key]: {} }, false]);
          }),
        );
      })

Summary: Serializing a map with zero entries should result in an empty object.


it('should serialize a normal object as an object normally', () => {
        fc.assert(
          fc.property(tableKeyArb, stringKVsArb, (key, [keys, values]) => {
            const obj = Object.fromEntries(keys.map((k, i) => [k, values[i].jsRep]));
            const expectedObj = Object.fromEntries(keys.map((k, i) => [k, values[i].jsonRep]));

            const bigNumsPresent = values.some((v) => v.jsRep instanceof BigNumber);

            assert.deepStrictEqual(serdes.serialize({ [key]: obj }), [{ [key]: expectedObj }, bigNumsPresent]);
          }),
        );
      })

Summary: Serializing an object should maintain its structure and convert properties correctly, detecting any presence of `BigNumber` instances.


it('should recurse over an object when deserializing', () => {
        fc.assert(
          fc.property(tableKeyArb, stringKVsArb, (key, [keys, values]) => {
            const seenMap = new Map(keys.map((k, i) => [k, values[i].jsonRep]));

            const codec = TableCodecs.custom({
              deserializeGuard(val, ctx) {
                if (ctx.path.length === 2) {
                  const key = ctx.path[1] as string;
                  assert.strictEqual(val, seenMap.get(key));
                  seenMap.delete(key);
                }
                return false;
              },
              deserialize: () => {
                throw new Error('Should not be called');
              },
            });

            const serdes = new TableSerDes({ ...TableSerDes.cfg.empty, codecs: [codec] });
            const schema = desSchema({ [key]: { type: 'map', valueType: values.definition.type } });

            const obj = Object.fromEntries(keys.map((k, i) => [k, values[i].jsonRep]));
            const expectMap = new Map(keys.map((k, i) => [k, values[i].jsRep]));

            assert.strictEqual(seenMap.size, expectMap.size);
            assert.deepStrictEqual(serdes.deserialize({ [key]: obj }, schema), { [key]: expectMap });
            assert.strictEqual(seenMap.size, 0);
          }),
        );
      })

Summary: Deserializing an object should involve recursion, verifying that values match expected representations at a specific depth and exhaustively processing all entries.


it('should recurse over an association list when deserializing', () => {
        fc.assert(
          fc.property(tableKeyArb, anyKVsArb, (key, [keys, values]) => {
            const seenArray = keys.map((k, i) => [k, values[i].jsonRep]);
            let i = 0;

            const codec = TableCodecs.custom({
              deserializeGuard(kv, ctx) {
                if (ctx.path.length === 2) {
                  const index = ctx.path[1] as number;
                  assert.strictEqual(index, i++);
                  assert.strictEqual(kv[0], seenArray[index][0]);
                  assert.strictEqual(kv[1], seenArray[index][1]);
                  seenArray[index] = null!;
                }
                return false;
              },
              deserialize: () => {
                throw new Error('Should not be called');
              },
            });

            const serdes = new TableSerDes({ ...TableSerDes.cfg.empty, codecs: [codec] });
            const schema = desSchema({ [key]: { type: 'map', valueType: values.definition.type } });

            const arr = keys.map((k, i) => [k, values[i].jsonRep]);
            const expectMap = new Map(keys.map((k, i) => [k, values[i].jsRep]));

            assert.strictEqual(seenArray.length, expectMap.size);
            assert.deepStrictEqual(serdes.deserialize({ [key]: arr }, schema), { [key]: expectMap });
            assert.strictEqual(seenArray.filter(Boolean).length, 0);
            assert.strictEqual(i, expectMap.size);
          }),
        );
      })

Summary: The property should hold that during deserialization, a custom codec recursively processes an association list, confirming the `deserializeGuard` correctly matches and nullifies each item in sequence according to the path context and expected values.


Summary: The `t_rem` function should produce the same remainder as the native modulus operator `%` for pairs of big integers, with `m` defaulting to `1n` if zero.


it('should serialize a set as a list', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.tableDatatypes({ scalarOnly: true }), (key, values) => {

            const jsSet = new Set(values.map((v) => v.jsRep));
            const jsonArr = [...new Set(values.map((v) => v.jsonRep))];
            fc.pre(jsSet.size === jsonArr.length);

            const bigNumsPresent = values.some((v) => v.jsRep instanceof BigNumber);

            assert.deepStrictEqual(serdes.serialize({ [key]: jsSet }), [{ [key]: jsonArr }, bigNumsPresent]);
          }),
        );
      })

Summary: Serializing a set should result in a list representation, maintaining the same length and structure, and including a flag if `BigNumber` instances are present.


it('should deserialize a list into a set', () => {
        fc.assert(
          fc.property(tableKeyArb, arbs.tableDatatypes({ scalarOnly: true }), (key, values) => {
            const seenSet = new Set(values.map((v) => v.jsonRep));
            let i = 0;

            const codec = TableCodecs.custom({
              deserializeGuard(val, ctx) {
                if (ctx.path.length === 2) {
                  assert.strictEqual(ctx.path.at(-1), i++);
                  seenSet.delete(val);
                }
                return false;
              },
              deserialize: () => {
                throw new Error('Should not be called');
              },
            });

            const serdes = new TableSerDes({ ...TableSerDes.cfg.empty, codecs: [codec] });
            const schema = desSchema({ [key]: { type: 'set', valueType: values.definition.type } });

            const arr = [...values.map((v) => v.jsonRep)];
            const expectSet = new Set(values.map((v) => v.jsRep));

            assert.strictEqual(seenSet.size, new Set(arr).size);
            assert.deepStrictEqual(serdes.deserialize({ [key]: arr }, schema), { [key]: expectSet });
            assert.strictEqual(seenSet.size, 0);
            assert.strictEqual(i, arr.length); // arr.length instead of expectSet.size because deserialization should run before set conversion
          }),
        );
      })

Summary: Deserializing a list should correctly result in a set, ensuring each element is processed and validated properly, with elements' positions being tracked and verified during the conversion.


it('should error when trying to serialize an ObjectId', () => {
      fc.assert(
        fc.property(arbs.oid(), (oid) => {
          assert.throws(() => serdes.serialize(oid), { message: /ObjectId may not be used with tables by default\..*/ });
        }),
      );
    })

Summary: An error is expected when attempting to serialize an `ObjectId`, with a message indicating that `ObjectId` cannot be used with tables by default.


it('should never mutate the input object in place', () => {
      fc.assert(
        fc.property(arbs.tableDefinitionAndRow({ requireOneOf: ['uuid', 'inet'] }), ([, row]) => { // forces usage of types which would cause the object to mutate
          const origStr = stableStringify(row);
          const [res] = serdes.serialize(row);
          const afterStr = stableStringify(row);
          const resStr = stableStringify(res);

          assert.strictEqual(origStr, afterStr);
          assert.notStrictEqual(afterStr, resStr);
        }),
      );
    })

Summary: Serialization does not mutate the input object; the original and post-serialization stringified representations are identical, while the serialized result differs.


it('should not equal a different UUID', () => {
    fc.assert(
      fc.property(fc.uuid(), fc.uuid(), (uuid1, uuid2) => {
        fc.pre(uuid1 !== uuid2);
        assert.ok(!uuid(uuid1).equals(uuid2));
        assert.ok(!uuid(uuid1).equals(uuid(uuid2)));
      }),
    );
  })

Summary: A UUID should not equal a different UUID, whether comparing directly or through a UUID object.


it('should properly construct an IPv4 address', () => {
      fc.assert(
        fc.property(fc.mixedCase(fc.ipV4()), (ip) => {
          const validate = (inet: DataAPIInet) => {
            assert.strictEqual(inet.toString(), ip.toLowerCase());
            assert.strictEqual(inet.version, 4);
          };

          validate(new DataAPIInet(ip));
          validate(new DataAPIInet(ip, 4));
          validate(new DataAPIInet(ip, 4, false));
          validate(new DataAPIInet(ip, null, false));

          validate(inet(ip));
          validate(inet(ip, 4));
        }),
      );
    })

Summary: `DataAPIInet` instances and `inet` function calls should consistently construct an IPv4 address from various input forms, ensuring the string representation is in lowercase and the version is 4.


it('should error on invalid values', () => {
      fc.assert(
        fc.property(fc.anything(), (invalid) => {
          fc.pre(!DataAPIBlob.isBlobLike(invalid));
          assert.throws(() => new DataAPIBlob(invalid as DataAPIBlobLike));
        }),
      );
    })

Summary: Constructing a `DataAPIBlob` with values not passing `isBlobLike` should throw an error.