it('should generate points in the specified radius range', () => {
    fc.assert(
      fc.property(
        validDimensions(),
        validRadiusRange(),
        prn<any>(fc.oneof(jsf32(), mulberry32(), sfc32(), splitmix32())), // eslint-disable-line @typescript-eslint/no-explicit-any
        (dimensions, radiusRange, seed) => {
          const { min = 0, max = 1 } = radiusRange
          const [min2, max2] = [min * min, max * max]
          const generator = nShell(dimensions, radiusRange)
          const [, vector] = generator.run(seed)
          expect(vector.length).toBe(Math.floor(dimensions))
          const mag2 = magnitudeSquared(vector)
          // fuzzy floating point operations mean that the magnitude may be slightly outside the expected range
          if (mag2 < min2) {
            // this is acceptable, but only if the magnitude is very close to the boundary
            expect(mag2).toBeCloseTo(min2)
          } else if (mag2 > max2) {
            expect(mag2).toBeCloseTo(max2)
          } else {
            expect(mag2).toBeGreaterThanOrEqual(min * min)
            expect(mag2).toBeLessThanOrEqual(max * max)
          }
        },
      ),
    )
  })

Summary: The test ensures that the points generated by `nShell` have magnitudes within the specified squared radius range, allowing for slight floating point imprecision near the boundaries.


unknown

it('should always return a generator of points which are always at least config.radius apart from one another', () => {
      fc.assert(
        fc.property(
          blueNoiseConfig(2),
          prn<any>(fc.oneof(jsf32(), mulberry32(), sfc32(), splitmix32())), // eslint-disable-line @typescript-eslint/no-explicit-any
          (config, seed) => {
            const generator = blueNoise(config)
            const [, points] = generator.run(seed)
            for (let i = 0; i < points.length; i++) {
              for (let j = i + 1; j < points.length; j++) {
                const dist = distanceSquared(points[i], points[j])
                const radiusSquared = config.radius ** 2
                if (dist < radiusSquared) {
                  expect(dist).toBeCloseTo(radiusSquared)
                } else {
                  expect(dist).toBeGreaterThanOrEqual(radiusSquared)
                }
              }
            }
          },
        ),
      )
    })

Summary: A generator produces points that are always at least `config.radius` apart in a two-dimensional space.


it('should generate a valid list of variations', () => {
      fc.assert(
        fc.property(optionLists(), optionLists => {
          const varied = cartesianProduct(optionLists)
          expect(varied).toBeInstanceOf(Array)
          expect(varied.length).toBe(
            optionLists.reduce((acc, optionList) => acc * optionList.length, 1),
          )
          expect(
            varied.every(vector => vector.length === optionLists.length),
          ).toBe(true)
          optionLists.forEach((optionList, i) => {
            optionList.forEach(option => {
              expect(varied.some(vector => vector[i] === option)).toBeTruthy()
            })
          })
        }),
      )
    })

Summary: `cartesianProduct` generates an array of variations with a length equal to the product of the lengths of the input arrays, ensuring each variation vector has the same length as the input arrays, and that every element from the input arrays appears in the corresponding position of some variation.


it('should be able to rebuild before given only the diff', () => {
    fc.assert(
      fc.property(diffArb, (diff) => {
        // Arrange
        const before = beforeFromDiff(diff);
        const after = afterFromDiff(diff);

        // Act
        const computedDiff = textDiffer(before, after);

        // Assert
        expect(beforeFromDiff(computedDiff)).toEqual(before);
      })
    );
  })

Summary: Reconstructing the original sequence before changes using only the diff should produce a result that matches the initial 'before' sequence.


it('should compute the diff having the maximal number of unchanged lines', () => {
    fc.assert(
      fc.property(diffArb, (diff) => {
        // Arrange
        const before = beforeFromDiff(diff);
        const after = afterFromDiff(diff);

        // Act
        const computedDiff = textDiffer(before, after);

        // Assert
        expect(countUnchangedLines(computedDiff)).toBeGreaterThanOrEqual(countUnchangedLines(diff));
      })
    );
  })

Summary: `textDiffer` should produce a diff with a number of unchanged lines that is greater than or equal to the original count from the given diff.


it('should group selected tabs together', () => {
    fc.assert(
      fc.property(tabsWithSelectionArb, ({ tabs, selectedTabs, movePosition }) => {
        // Arrange / Act
        const newTabs = reorderTabs(tabs, selectedTabs, movePosition);

        // Assert
        const startMovedSelection = newTabs.indexOf(selectedTabs[0]);
        expect(newTabs.slice(startMovedSelection, startMovedSelection + selectedTabs.length)).toEqual(selectedTabs);
      })
    );
  })

Summary: Reordered tabs should contain the selected tabs grouped together at the specified position.


it('should predict the right podium', () => {
    fc.assert(
      fc.property(tupleN(fc.nat(), 25), (speeds) => {
        // Arrange
        const compareParticipants = (pa: number, pb: number) => {
          if (speeds[pa] !== speeds[pb]) return speeds[pb] - speeds[pa];
          else return pa - pb;
        };
        const runRace = (...participants: RaceParticipants): RaceParticipants => {
          return participants.sort(compareParticipants);
        };

        // Act
        const podium = racePodium(runRace);

        // Assert
        const rankedParticipants = [...Array(25)].map((_, i) => i).sort(compareParticipants);
        const expectedPodium = rankedParticipants.slice(0, 3);
        expect(podium).toEqual(expectedPodium);
      })
    );
  })

Summary: The function `racePodium` should return the top three participants with the highest speeds from an array of 25 participants sorted by their racing performance.


it('should build an ordered path of tracks whenever a path from start to end exists', () => {
    fc.assert(
      fc.property(orientedGraphArbitrary, ({ knownPath, tracks, stations }) => {
        // Arrange
        const departure = knownPath[0];
        const destination = knownPath[knownPath.length - 1];

        // Act
        const shortestPath = metroRoute(departure, destination, stations, tracks);

        // Assert
        for (let index = 1; index < shortestPath.length; ++index) {
          expect(shortestPath[index].from).toBe(shortestPath[index - 1].to);
        }
      })
    );
  })

Summary: The test ensures that if a path from start to end exists in an oriented graph, the `metroRoute` function returns an ordered path of tracks.


it('should be able to find a path shorther or equal to the one we come up with', () => {
    fc.assert(
      fc.property(orientedGraphArbitrary, ({ knownPath, knownPathTracks, tracks, stations }) => {
        // Arrange
        const departure = knownPath[0];
        const destination = knownPath[knownPath.length - 1];

        // Act
        const shortestPath = metroRoute(departure, destination, stations, tracks);

        // Assert
        const distanceKnownPath = knownPathTracks.reduce((acc, e) => acc + e.length, 0);
        const distanceShortestPath = shortestPath.reduce((acc, e) => acc + e.length, 0);
        expect(distanceShortestPath).toBeLessThanOrEqual(distanceKnownPath);
      })
    );
  })

Summary: The `metroRoute` function finds a path that is shorter or equal in length to a provided known path between two stations in an oriented graph.


it('should keep all the tasks for the schedule plan', () => {
    fc.assert(
      fc.property(tasksArbitrary(), (tasks) => {
        // Arrange / Act
        const schedule = christmasFactorySchedule(tasks);

        // Assert
        expect(schedule).toHaveLength(tasks.length);
        expect(schedule.map((t) => t.taskId)).toContainAllValues(tasks.map((t) => t.taskId));
      })
    );
  })

Summary: The test checks that the `christmasFactorySchedule` maintains all tasks in the schedule and ensures that the task IDs in the schedule match the original task set.


it('should not extend or reduce the duration of tasks', () => {
    fc.assert(
      fc.property(tasksArbitrary(), (tasks) => {
        // Arrange / Act
        const schedule = christmasFactorySchedule(tasks);

        // Assert
        for (const scheduledTask of schedule) {
          const task = tasks.find((t) => t.taskId === scheduledTask.taskId);
          expect(scheduledTask.finish - scheduledTask.start).toBe(task.estimatedTime);
        }
      })
    );
  })

Summary: The duration of tasks in the `christmasFactorySchedule` should match their estimated times from the input tasks.


it('should not start any task before all its dependencies ended', () => {
    fc.assert(
      fc.property(tasksArbitrary(), (tasks) => {
        // Arrange / Act
        const schedule = christmasFactorySchedule(tasks);

        // Assert
        for (const scheduledTask of schedule) {
          const dependencies = tasks.find((t) => t.taskId === scheduledTask.taskId)!.dependsOnTasks;
          for (const depTaskId of dependencies) {
            const depScheduledTask = schedule.find((s) => s.taskId === depTaskId);
            expect(scheduledTask.start).toBeGreaterThanOrEqual(depScheduledTask.finish);
          }
        }
      })
    );
  })

Summary: Scheduled tasks should not start until all their dependencies have finished.


it('should start tasks as soon as possible', () => {
    fc.assert(
      fc.property(tasksArbitrary(), (tasks) => {
        // Arrange / Act
        const schedule = christmasFactorySchedule(tasks);

        // Assert
        for (const scheduledTask of schedule) {
          const dependencies = tasks.find((t) => t.taskId === scheduledTask.taskId)!.dependsOnTasks;
          const finishTimeDependencies = dependencies.map((depTaskId) => {
            const depScheduledTask = schedule.find((s) => s.taskId === depTaskId);
            return depScheduledTask.finish;
          });
          const expectedStart = finishTimeDependencies.length !== 0 ? Math.max(...finishTimeDependencies) : 0;
          expect(scheduledTask.start).toBe(expectedStart);
        }
      })
    );
  })

Summary: Tasks are scheduled to start as soon as their dependencies are completed.


it('should not detect any cycle in a non-looping linked list', () => {
    fc.assert(
      fc.property(
        fc.letrec((tie) => ({
          node: fc.record({
            value: fc.integer(),
            next: fc.option(tie('node') as fc.Arbitrary<LinkedList>, { nil: undefined, depthFactor: 1 }),
          }),
        })).node,
        (linkedList) => {
          // Arrange / Act
          const cycleDetected = detectCycleInLinkedList(linkedList);

          // Assert
          expect(cycleDetected).toBe(false);
        }
      )
    );
  })

Summary: In a non-looping linked list, `detectCycleInLinkedList` should return false.


it('should detect a cycle in a looping linked list', () => {
    fc.assert(
      fc.property(fc.array(fc.integer(), { minLength: 1 }), (nodes) => {
        // Arrange
        const lastNode: LinkedList = { value: nodes[0], next: undefined };
        const linkedList = nodes.slice(1).reduce((acc, n) => ({ value: n, next: acc }), lastNode);
        lastNode.next = linkedList;

        // Act
        const cycleDetected = detectCycleInLinkedList(linkedList);

        // Assert
        expect(cycleDetected).toBe(true);
      })
    );
  })

Summary: Detects a cycle in a linked list that loops back to form a circular structure.


it('should compute the return the minimal number of changes to mutate before into after', () => {
    fc.assert(
      fc.property(changeArb, (changes) => {
        // Arrange
        const before = beforeFromChanges(changes);
        const after = afterFromChanges(changes);

        // Act
        const numChanges = minimalNumberOfChangesToBeOther(before, after);

        // Assert
        expect(numChanges).toBeLessThanOrEqual(countRequestedOperations(changes));
      })
    );
  })

Summary: The number of changes required to mutate a `before` string into an `after` string should be less than or equal to the number of requested operations in the provided changes.


it('should be independent of the ordering of the arguments', () => {
    fc.assert(
      fc.property(changeArb, (changes) => {
        // Arrange
        const before = beforeFromChanges(changes);
        const after = afterFromChanges(changes);

        // Act
        const numChanges = minimalNumberOfChangesToBeOther(before, after);
        const numChangesReversed = minimalNumberOfChangesToBeOther(after, before);

        // Assert
        expect(numChangesReversed).toBe(numChanges);
      })
    );
  })

Summary: The test checks that the result of `minimalNumberOfChangesToBeOther` is the same regardless of the order of the arguments.


it('should reject any expression not containing an even number of signs', () => {
    fc.assert(
      fc.property(
        fc.array(
          fc.tuple(fc.constantFrom('(', '[', '{', ')', ']', '}'), fc.constantFrom('(', '[', '{', ')', ']', '}'))
        ),
        fc.constantFrom('(', '[', '{', ')', ']', '}'),
        (evenNumParentheses, extraParenthesis) => {
          const invalidExpression = [...evenNumParentheses.flat(), extraParenthesis].join('');
          expect(validParentheses(invalidExpression)).toBe(false);
        }
      )
    );
  })

Summary: The property checks that any expression containing an odd number of parentheses or brackets is recognized as invalid by `validParentheses`.


it('should reject any expression not having the same number of openings and closings', () => {
    fc.assert(
      fc.property(
        wellParenthesedStringArbitrary,
        fc.constantFrom('(', '[', '{', ')', ']', '}'),
        fc.nat().noShrink(),
        (expression, extra, seed) => {
          const position = seed % (expression.length + 1);
          const invalidExpression = expression.substring(0, position) + extra + expression.substring(position);
          expect(validParentheses(invalidExpression)).toBe(false);
        }
      )
    );
  })

Summary: Expressions with mismatched numbers of opening and closing parentheses should be invalid according to `validParentheses`.


it('should reject any expression with at least one reversed openings and closings', () => {
    fc.assert(
      fc.property(reversedParenthesedStringArbitrary, (expression) => {
        expect(validParentheses(expression)).toBe(false);
      })
    );
  })

Summary: Expressions with at least one pair of reversed parentheses are rejected as invalid.


it('should reject any expression with non-matching openings and closings', () => {
    fc.assert(
      fc.property(nonMatchingEndParenthesedStringArbitrary, (expression) => {
        expect(validParentheses(expression)).toBe(false);
      })
    );
  })

Summary: Expressions with non-matching opening and closing parentheses should return false when evaluated by `validParentheses`.


it('should simplify any fraction to a fraction having the same result', () => {
    fc.assert(
      fc.property(
        fc.integer(),
        fc.integer().filter((n) => n !== 0),
        (numerator, denominator) => {
          const fSource = { numerator, denominator };
          const fOut = simplifyFraction(fSource);
          expect(fOut.numerator / fOut.denominator).toEqual(fSource.numerator / fSource.denominator);
        }
      )
    );
  })

Summary: The `simplifyFraction` function reduces a fraction to its simplest form while maintaining the same numerical value as the original fraction.


it('should always return a simplified fraction having a positive denominator', () => {
    fc.assert(
      fc.property(
        fc.integer(),
        fc.integer().filter((n) => n !== 0),
        (numerator, denominator) => {
          const fSource = { numerator, denominator };
          const fOut = simplifyFraction(fSource);
          expect(fOut.denominator).toBeGreaterThan(0);
        }
      )
    );
  })

Summary: The function `simplifyFraction` returns a simplified fraction with a positive denominator.


it('should only produce integer values for the numerator and denominator', () => {
    fc.assert(
      fc.property(
        fc.integer(),
        fc.integer().filter((n) => n !== 0),
        (numerator, denominator) => {
          const fSource = { numerator, denominator };
          const fOut = simplifyFraction(fSource);
          expect(fOut.numerator).toSatisfy(Number.isInteger);
          expect(fOut.denominator).toSatisfy(Number.isInteger);
        }
      )
    );
  })

Summary: The `simplifyFraction` function should return a fraction where both the numerator and denominator are integers.


it('should simplify fractions to simpler form whenever possible', () => {
    fc.assert(
      fc.property(
        fc.integer(),
        fc.integer().filter((n) => n !== 0),
        fc.integer({ min: 1 }),
        (smallNumerator, smallDenominator, factor) => {
          fc.pre(Math.abs(smallNumerator * factor) <= Number.MAX_SAFE_INTEGER);
          fc.pre(Math.abs(smallDenominator * factor) <= Number.MAX_SAFE_INTEGER);

          const fSource = { numerator: smallNumerator * factor, denominator: smallDenominator * factor };
          const fOut = simplifyFraction(fSource);

          expect(Math.abs(fOut.numerator)).toBeLessThanOrEqual(Math.abs(smallNumerator));
          expect(Math.abs(fOut.denominator)).toBeLessThanOrEqual(Math.abs(smallDenominator));
        }
      )
    );
  })

Summary: The function `simplifyFraction` simplifies fractions so that the absolute values of the numerator and denominator do not exceed those of the original scaled values.


it('should only print Fizz when divisible by 3 but not by 5', () => {
    fc.assert(
      fc.property(
        fc.oneof(
          fc
            .nat()
            .map((n) => n * 5 + 1)
            .map((n) => n * 3),
          fc
            .nat()
            .map((n) => n * 5 + 2)
            .map((n) => n * 3),
          fc
            .nat()
            .map((n) => n * 5 + 3)
            .map((n) => n * 3),
          fc
            .nat()
            .map((n) => n * 5 + 4)
            .map((n) => n * 3)
        ),
        (n) => {
          expect(fizzbuzz(n)).toBe('Fizz');
        }
      )
    );
  })

Summary: `fizzbuzz` should return "Fizz" for numbers divisible by 3 but not by 5.


it('should print Buzz whenever divisible by 5', () => {
    fc.assert(
      fc.property(
        fc.nat().map((n) => n * 5),
        (n) => {
          expect(fizzbuzz(n)).toContain('Buzz');
        }
      )
    );
  })

Summary: `fizzbuzz` includes 'Buzz' in its output for numbers divisible by 5.


it('should not print Buzz when not divisible by 5', () => {
    fc.assert(
      fc.property(
        fc.oneof(
          fc.nat().map((n) => n * 5 + 1),
          fc.nat().map((n) => n * 5 + 2),
          fc.nat().map((n) => n * 5 + 3),
          fc.nat().map((n) => n * 5 + 4)
        ),
        (n) => {
          expect(fizzbuzz(n)).not.toContain('Buzz');
        }
      )
    );
  })

Summary: `fizzbuzz` output should not include 'Buzz' for numbers not divisible by 5.


it('should only print Buzz when divisible by 5 but not by 3', () => {
    fc.assert(
      fc.property(
        fc.oneof(
          fc
            .nat()
            .map((n) => n * 3 + 1)
            .map((n) => n * 5),
          fc
            .nat()
            .map((n) => n * 3 + 2)
            .map((n) => n * 5)
        ),
        (n) => {
          expect(fizzbuzz(n)).toBe('Buzz');
        }
      )
    );
  })

Summary: `fizzbuzz` should return 'Buzz' for numbers divisible by 5 but not divisible by 3.


it('should print Fizz Buzz whenever divisible by 3 and 5', () => {
    fc.assert(
      fc.property(
        fc
          .nat()
          .map((n) => n * 3)
          .map((n) => n * 5),
        (n) => {
          expect(fizzbuzz(n)).toBe('Fizz Buzz');
        }
      )
    );
  })

Summary: `fizzbuzz` returns "Fizz Buzz" for numbers divisible by both 3 and 5.


it('should print the value itself when not divisible by 3 and not divisible by 5', () => {
    fc.assert(
      fc.property(
        fc.oneof(
          fc.nat().map((n) => n * 15 + 1),
          fc.nat().map((n) => n * 15 + 2),
          fc.nat().map((n) => n * 15 + 4), // +3 would be divisible by 3
          fc.nat().map((n) => n * 15 + 7), // +5 would be divisible by 5, +6 would be divisible by 3
          fc.nat().map((n) => n * 15 + 8), // +9 would be divisible by 3, +10 would be divisible by 5
          fc.nat().map((n) => n * 15 + 11),
          fc.nat().map((n) => n * 15 + 13), // +12 would be divisible by 3
          fc.nat().map((n) => n * 15 + 14)
        ),
        (n) => {
          expect(fizzbuzz(n)).toBe(String(n));
        }
      )
    );
  })

Summary: The `fizzbuzz` function outputs the number itself when it is not divisible by 3 or 5.


it('should produce an array such that the product equals the input', () => {
    fc.assert(
      fc.property(fc.nat(MAX_INPUT), (n) => {
        const factors = decomposeIntoPrimes(n);
        const productOfFactors = factors.reduce((a, b) => a * b, 1);
        return productOfFactors === n;
      })
    );
  })

Summary: The output array from `decomposeIntoPrimes` should multiply to the input number.


it('should compute the same factors as to the concatenation of the one of a and b for a times b', () => {
    fc.assert(
      fc.property(fc.integer(2, MAX_INPUT), fc.integer(2, MAX_INPUT), (a, b) => {
        const factorsA = decomposeIntoPrimes(a);
        const factorsB = decomposeIntoPrimes(b);
        const factorsAB = decomposeIntoPrimes(a * b);
        const reorder = (arr: number[]) => [...arr].sort((a, b) => a - b);
        expect(reorder(factorsAB)).toEqual(reorder([...factorsA, ...factorsB]));
      })
    );
  })

Summary: The concatenated prime factors of integers `a` and `b` should match the prime factors of their product `a * b`, when both are ordered.


it('should be equal to the sum of fibo(n-1) and fibo(n-2)', () => {
    fc.assert(
      fc.property(fc.integer(2, MaxN), (n) => {
        expect(fibonacci(n)).toBe(fibonacci(n - 1) + fibonacci(n - 2));
      })
    );
  })

Summary: The Fibonacci number at position `n` should equal the sum of Fibonacci numbers at positions `n-1` and `n-2`.


it('should fulfill fibo(p)*fibo(q+1)+fibo(p-1)*fibo(q) = fibo(p+q)', () => {
    fc.assert(
      fc.property(fc.integer(1, MaxN), fc.integer(0, MaxN), (p, q) => {
        expect(fibonacci(p + q)).toBe(fibonacci(p) * fibonacci(q + 1) + fibonacci(p - 1) * fibonacci(q));
      })
    );
  })

Summary: For any integers \( p \) and \( q \), the relation \( \text{fibonacci}(p) \times \text{fibonacci}(q+1) + \text{fibonacci}(p-1) \times \text{fibonacci}(q) = \text{fibonacci}(p+q) \) holds.


it('should fulfill fibo(2p-1) = fibo²(p-1)+fibo²(p)', () => {
    // Special case of the property above
    fc.assert(
      fc.property(fc.integer(1, MaxN), (p) => {
        expect(fibonacci(2 * p - 1)).toBe(fibonacci(p - 1) * fibonacci(p - 1) + fibonacci(p) * fibonacci(p));
      })
    );
  })

Summary: The Fibonacci sequence property where \(\text{fibo}(2p-1)\) is equal to \(\text{fibo}(p-1)^2 + \text{fibo}(p)^2\) should hold for integers \(p\) within a specified range.


it('should fulfill Catalan identity', () => {
    fc.assert(
      fc.property(fc.integer(0, MaxN), fc.integer(0, MaxN), (a, b) => {
        const [p, q] = a < b ? [b, a] : [a, b];
        const sign = (p - q) % 2 === 0 ? 1n : -1n; // (-1)^(p-q)
        expect(fibonacci(p) * fibonacci(p) - fibonacci(p - q) * fibonacci(p + q)).toBe(
          sign * fibonacci(q) * fibonacci(q)
        );
      })
    );
  })

Summary: The product identity of Fibonacci numbers should satisfy the Catalan identity for given integer inputs \(a\) and \(b\).


it('should fulfill Cassini identity', () => {
    fc.assert(
      fc.property(fc.integer(1, MaxN), fc.integer(0, MaxN), (p) => {
        const sign = p % 2 === 0 ? 1n : -1n; // (-1)^p
        expect(fibonacci(p + 1) * fibonacci(p - 1) - fibonacci(p) * fibonacci(p)).toBe(sign);
      })
    );
  })

Summary: The Cassini identity should hold for Fibonacci numbers, verifying that the expression \( F(p+1) \times F(p-1) - F(p)^2 \) equals \((-1)^p\).


it('should fulfill gcd(fibo(a), fibo(b)) = fibo(gcd(a,b))', () => {
    fc.assert(
      fc.property(fc.integer(1, MaxN), fc.integer(1, MaxN), (a, b) => {
        const gcdAB = Number(gcd(BigInt(a), BigInt(b)));
        expect(gcd(fibonacci(a), fibonacci(b))).toBe(fibonacci(gcdAB));
      })
    );
  })

Summary: The test ensures that the greatest common divisor of Fibonacci numbers `fibo(a)` and `fibo(b)` is equal to the Fibonacci number at the position of the greatest common divisor of `a` and `b`.


it('should only return messages built from words coming from the set of words', () => {
    fc.assert(
      fc.property(
        fc.set(wordArb, { minLength: 1 }).chain((words) =>
          fc.record({
            words: fc.shuffledSubarray(words), // we potentially remove words from the dictionary to cover no match case
            originalMessage: fc.array(fc.constantFrom(...words)).map((items) => items.join(' ')),
          })
        ),
        ({ words, originalMessage }) => {
          const spacelessMessage = originalMessage.replace(/\s/g, '');
          const combinations = respace(spacelessMessage, words);
          for (const combination of combinations) {
            if (combination.length !== 0) {
              expect(words).toIncludeAnyMembers(combination.split(' '));
            }
          }
        }
      )
    );
  })

Summary: Returned messages from `respace` should be composed of words from the provided set.


it('should have the same length as source', () => {
    fc.assert(
      fc.property(fc.array(fc.integer()), (data) => {
        expect(sorted(data)).toHaveLength(data.length);
      })
    );
  })

Summary: The `sorted` function retains the same length as the source array of integers.


it('should have exactly the same number of occurences as source for each item', () => {
    fc.assert(
      fc.property(fc.array(fc.integer()), (data) => {
        const sortedData = sorted(data);
        expect(countEach(sortedData)).toEqual(countEach(data));
      })
    );
  })

Summary: Sorted arrays maintain the same number of occurrences for each item as the source array.


it('should produce an ordered array', () => {
    fc.assert(
      fc.property(fc.array(fc.integer()), (data) => {
        const sortedData = sorted(data);
        for (let idx = 1; idx < sortedData.length; ++idx) {
          expect(sortedData[idx - 1]).toBeLessThanOrEqual(sortedData[idx]);
        }
      })
    );
  })

Summary: The function `sorted` should produce an array where each element is less than or equal to the next.


test("Repeat n times", () => {
    fc.assert(
      fc.property(fc.nat({ max: 10 }), (n) => {
        const increment = (i: number) => i + 1;
        return repeat<number>(n)(increment)(0) === n;
      }),
    );
  })

Summary: The `repeat` function applies the `increment` function `n` times starting from 0, resulting in the value `n`.


test("n-length range", () => {
    fc.assert(
      fc.property(fc.nat({ max: 100 }), (n) => {
        const suite = range(n);
        const reversedSuite = [...suite].reverse();
        return suite.reduce(sum, 0) + reversedSuite.reduce(sum, 0) === n * (n + 1);
      }),
    );
  })

Summary: A range of length `n` has elements that, when summed with their reverse, equal `n * (n + 1)`.


test("exact values", () => {
    fc.assert(
      fc.property(fc.nat({ max: 100 }), (n) => {
        const suite = range(n);
        return range(n).every((i) => suite[i - 1] === i);
      }),
    );
  })

Summary: The `range` function should generate an array where each element matches its 1-based index.


it("migrates every key", () => {
			fc.assert(
				fc.property(
					fc.dictionary(fc.string(), fc.array(fc.string(), { minLength: 1 })),
					x => {
						const y = f(x)
						return R.keys(x).every(z => y.has(z))
					},
				),
			)
		})

Summary: The function `f` ensures that every key from a dictionary is present in the resulting `URLSearchParams`.


it("migrates every key", () => {
			fc.assert(
				fc.property(fc.array(fc.tuple(fc.string(), fc.string())), xs => {
					const y = f(xs)
					return xs.map(T.fst).every(z => y.has(z))
				}),
			)
		})

Summary: Every key from the input array of string tuples should exist in the results of function `f`.


it("never throws", () => {
			fc.assert(
				fc.property(fc.array(fc.tuple(fc.string(), fc.string())), x => {
					f(x)
				}),
			)
		})

Summary: The function `f` should handle arrays of string tuples without throwing an exception.


it("is always retrievable", () => {
			fc.assert(
				fc.property(fc.string(), fc.string(), (k, v) =>
					expect(pipe(f(k)(v), lookupFirst(k))).toEqual(O.some(v)),
				),
			)
		})

Summary: Retrieving a value from a `URLSearchParams` with a given key should always return the expected value.


it("never throws", () => {
			fc.assert(
				fc.property(fc.string(), fc.string(), (k, v) => {
					f(k)(v)
				}),
			)
		})

Summary: The function `f` should not throw an exception when applied with any pair of strings as arguments.


it("always increases the size of the dataset", () => {
			fc.assert(
				fc.property(arb, fc.string(), fc.string(), (xs, k, v) =>
					expect(toString(f(k)(v)(xs)).length).toBeGreaterThan(
						toString(xs).length,
					),
				),
			)
		})

Summary: The function `toString(f(k)(v)(xs))` applied to a dataset always results in a longer string than the original dataset `toString(xs)`.


it("never increases the size of the dataset", () => {
			fc.assert(
				fc.property(arb, fc.string(), (xs, k) =>
					expect(toString(f(k)(xs)).length).toBeLessThanOrEqual(
						toString(xs).length,
					),
				),
			)
		})

Summary: The function `f(k)` applied to `xs` should produce a result whose string representation is no longer than the original `xs`.


it("returns all keys", () => {
			expect(f(new URLSearchParams())).toEqual([])
			expect(f(new URLSearchParams("a=1&b=2&a=3"))).toEqual(["a", "b", "a"])

			fc.assert(
				fc.property(fc.array(fc.string()), ks => {
					const xs = pipe(ks, A.map(withSnd("foo")))

					expect(f(new URLSearchParams(xs))).toEqual(ks)
				}),
			)
		})

Summary: Extracts all keys from a `URLSearchParams` object, including duplicates.


it("returns all values", () => {
			expect(f(new URLSearchParams())).toEqual([])
			expect(f(new URLSearchParams("a=1&b=2&a=3"))).toEqual(["1", "2", "3"])

			fc.assert(
				fc.property(fc.array(fc.string()), vs => {
					const xs = pipe(vs, A.map(withFst("foo")))

					expect(f(new URLSearchParams(xs))).toEqual(vs)
				}),
			)
		})

Summary: The function should return all values from a `URLSearchParams` object, maintaining the correct order and content.


it("is equivalent to the size of the total number of potentially duplicative keys", () => {
			expect(f(new URLSearchParams())).toBe(0)
			expect(f(new URLSearchParams("a=1&b=2&a=3"))).toBe(3)

			fc.assert(
				fc.property(fc.array(fc.string()), ks => {
					const xs = pipe(ks, A.map(withSnd("foo")))
					const ys = new URLSearchParams(xs)

					expect(f(ys)).toEqual(A.size(ks))
					expect(f(ys)).toEqual(A.size(keys(ys)))
				}),
			)
		})

Summary: The function `f` applied to a `URLSearchParams` object should return a value equivalent to the count of the total potentially duplicative keys.


it("is infallible", () => {
			fc.assert(fc.property(mapArb, xs => isURLSearchParams(f(xs))))
		})

Summary: `isURLSearchParams` should always return true for the output of function `f` applied to `xs`.


it("always keeps phony base", () => {
			fc.assert(
				fc.property(fc.oneof(fc.string(), fc.webPath()), x =>
					expect((f(x) as unknown as URL).origin).toBe(phonyBase),
				),
				{ numRuns: 10000 },
			)
		})

Summary: Ensures that the `origin` of the URL resulting from function `f` is always `phonyBase`, regardless of the input string or web path.


it("never throws", () => {
			fc.assert(
				fc.property(fc.string(), x => {
					f(x)
				}),
			)
		})

Summary: The function `f` should not throw an exception for any string input.


it("setPathname =<< getPathname = setPathname (getPathname x) x = id", () => {
			fc.assert(
				fc.property(fc.string().map(fromPathname), x =>
					expect(pipe(getPathname, Fn.chain(setPathname), apply(x))).toEqual(x),
				),
			)
		})

Summary: Setting and then getting a pathname using `setPathname` and `getPathname` on a given value should return the original value, demonstrating identity.


it("is the dual of toSnd", () => {
			fc.assert(
				fc.property(nonMaxNumber, n =>
					expect(g(n)).toEqual(pipe(n, toSnd(increment), swap)),
				),
			)
		})

Summary: Function `g` should produce the same result as applying `toSnd` with `increment` to a number, then swapping the tuple elements.


it("maps both sides", () => {
			const g = O.some

			fc.assert(
				fc.property(fc.string(), fc.string(), (l, r) =>
					expect(f(g)([l, r])).toEqual([g(l), g(r)]),
				),
			)
		})

Summary: The function `f` should map a given operation `g` to both elements of a tuple, resulting in a tuple where each element has `g` applied.


it("does not modify the number at all", () => {
			fc.assert(
				fc.property(
					fc.oneof(fc.integer(), fc.float({ noNaN: true })),
					n => n === Number(f(n)),
				),
			)
		})

Summary: Verifies that applying function `f` to a number returns the number unchanged.


it("retracts succ", () => {
				const f = flow(E.pred, O.chain(E.succ), O.chain(E.pred))
				const g = E.pred

				fc.assert(
					fc.property(fc.tuple(fc.boolean(), fc.boolean()), x =>
						expect(f(x)).toEqual(g(x)),
					),
				)
			})

Summary: Verifies that applying the function `f`, which involves chaining `E.pred` and `E.succ` with `O.chain`, produces the same result as the function `g`, which directly applies `E.pred`, for any tuple of booleans.


it("returns whole string for number that's too large", () => {
			fc.assert(
				fc.property(
					fc.string(),
					fc.integer({ min: 0, max: Number.MAX_SAFE_INTEGER }),
					(x, n) => f(x.length + n)(x) === x,
				),
			)
		})

Summary: When the integer input is larger than or equal to the string length, the function `f` should return the whole string unchanged.


it("returns empty string for non-positive number", () => {
			fc.assert(
				fc.property(
					fc.integer({ max: 0 }),
					fc.string(),
					(n, x) => f(n)(x) === "",
				),
			)
		})

Summary: Function `f` returns an empty string when given a non-positive integer and any string.


it("does not throw with non-global regex", () => {
			fc.assert(
				fc.property(fc.string(), x => {
					f(/x/)(x)
				}),
			)
		})

Summary: Function `f` should not throw an error when applied with a non-global regex on any string.


it("prepends", () => {
			expect(f("")("")).toBe("")
			expect(f("x")("")).toBe("x")
			expect(f("")("x")).toBe("x")
			expect(f("x")("yz")).toBe("xyz")

			fc.assert(
				fc.property(
					fc.string(),
					fc.string(),
					(x, y) =>
						f(x)(y).length === x.length + y.length &&
						f(y)(x).length === x.length + y.length,
				),
			)
		})

Summary: The function `f(x)(y)` should prepend `x` to `y`, and `f(y)(x)` should prepend `y` to `x`, with both resulting strings maintaining a length equal to the sum of the lengths of `x` and `y`.


it("unprepends if present", () => {
			expect(f("x")("xy")).toBe("y")
			expect(f("x")("xx")).toBe("x")

			fc.assert(
				fc.property(fc.string(), fc.string(), (x, y) => f(x)(x + y) === y),
			)
		})

Summary: `f(x)(x + y)` should return `y`, effectively removing `x` from the beginning if present.


it("appends", () => {
			expect(f("")("")).toBe("")
			expect(f("x")("")).toBe("x")
			expect(f("")("x")).toBe("x")
			expect(f("z")("xy")).toBe("xyz")

			fc.assert(
				fc.property(
					fc.string(),
					fc.string(),
					(x, y) =>
						f(x)(y).length === x.length + y.length &&
						f(y)(x).length === x.length + y.length,
				),
			)
		})

Summary: The function `f` appends two strings and maintains the commutative property regarding their combined length.


it("unappends if present", () => {
			expect(f("y")("xy")).toBe("x")
			expect(f("x")("xx")).toBe("x")

			fc.assert(
				fc.property(fc.string(), fc.string(), (x, y) => f(x)(y + x) === y),
			)
		})

Summary: The function `f` removes the specified string `x` from the end of string `y` if present.


it("always returns a string", () => {
			fc.assert(
				fc.property(fc.oneof(fc.integer(), fc.float()), flow(f, S.isString)),
			)
		})

Summary: Function `f` should always return a string when given an integer or float.


it("drops specified number of characters", () => {
			expect(f(2)("abc")).toBe("c")

			fc.assert(
				fc.property(
					fc.string(),
					fc.integer({ min: 0, max: Number.MAX_SAFE_INTEGER }),
					(x, n) => f(n)(x).length === max(N.Ord)(0, x.length - n),
				),
			)
		})

Summary: A function `f(n)` should return a string with a length equal to the original string minus `n`, only if `n` is less than or equal to the string's length; otherwise, it returns an empty string.


it("returns identity on constFalse", () => {
			fc.assert(fc.property(fc.string(), x => f(constFalse)(x) === x))
		})

Summary: Function `f` applied to `constFalse` should return the input string unchanged.


it("returns identity for non-positive number", () => {
			expect(f(-1)("abc")).toBe("abc")

			fc.assert(
				fc.property(
					fc.string(),
					fc.integer({ max: 0 }),
					(x, n) => f(n)(x) === x,
				),
			)
		})

Summary: The function `f(n)` returns the input string unchanged for non-positive integer values of `n`.


it("returns last character of non-empty string", () => {
			fc.assert(
				fc.property(fc.string({ minLength: 1, maxLength: 100 }), x =>
					expect(f(x)).toEqual(O.some(x[x.length - 1])),
				),
			)
		})

Summary: `f` returns the last character of a non-empty string as an `O.some` value.


it("returns empty string for string with one character", () => {
			fc.assert(
				fc.property(fc.string({ minLength: 1, maxLength: 1 }), x =>
					expect(f(x)).toEqual(O.some("")),
				),
			)
		})

Summary: `f` should return an empty string wrapped in `O.some` for any single-character string.


it("returns string one character smaller", () => {
			fc.assert(
				fc.property(fc.string({ minLength: 1, maxLength: 100 }), x =>
					pipe(
						f(x),
						O.exists(y => y.length === x.length - 1),
					),
				),
			)
		})

Summary: Verifies that applying function `f` to a string results in an output string that is one character shorter than the input.


it("constTrue returns empty string", () => {
			fc.assert(
				fc.property(fc.string(), x => expect(f(constTrue)(x)).toEqual("")),
			)
		})

Summary: `constTrue` returns an empty string for any input string passed through the function `f`.


it("constFalse returns original string", () => {
			fc.assert(
				fc.property(fc.string(), x => expect(f(constFalse)(x)).toEqual(x)),
			)
		})

Summary: `constFalse` applied in function `f` should return the original string.


it("returns input string on constTrue", () => {
			fc.assert(fc.property(fc.string(), x => f(constTrue)(x) === x))
		})

Summary: Applying the `f` function with `constTrue` should return the input string unchanged.


it("returns empty string on constFalse", () => {
			fc.assert(fc.property(fc.string(), x => f(constFalse)(x) === ""))
		})

Summary: The function `f` returns an empty string when `constFalse` is applied to any string input.


Summary: Function `f` returns the input string when applied with `constTrue`.


it('"joining" results in the same string', () => {
			fc.assert(
				fc.property(
					fc.integer(),
					fc.string(),
					(index, str) => splitAt(index)(str).join("") === str,
				),
			)
		})

Summary: Splitting a string at any index and then rejoining the segments results in the original string.


it("does not modify string given empty prefix", () => {
			fc.assert(fc.property(fc.string(), x => f("")(x) === x))
		})

Summary: Applying an empty prefix to a string does not modify the string.


it("does not modify string given empty suffix", () => {
			fc.assert(fc.property(fc.string(), x => f("")(x) === x))
		})

Summary: A string remains unchanged when an empty suffix is applied.


it("cannot find anything in empty object", () => {
			fc.assert(fc.property(fc.string(), x => O.isNone(f({})(x))))
		})

Summary: `f` applied to an empty object should always result in `O.isNone` being true for any string input.


it("is the inverse of filter", () => {
			fc.assert(
				fc.property(fc.dictionary(fc.string(), fc.integer()), xs =>
					expect(pipe(xs, R.filter(p), f)).toEqual({}),
				),
			)
		})

Summary: Applying `filter` with predicate `p` to a dictionary and then applying function `f` results in an empty object.


it("has every unique transformed value as a key", () => {
			const g = fromNumber
			const h: (x: Record<string, number>) => Array<string> = flow(
				values,
				A.uniq(N.Eq),
				A.map(g),
			)

			fc.assert(
				fc.property(fc.dictionary(fc.string(), fc.integer()), x =>
					pipe(x, f(g), R.keys, ks =>
						pipe(
							h(x),
							A.every(k => A.elem(S.Eq)(k)(ks)),
						),
					),
				),
			)
		})

Summary: Each unique value transformed by `fromNumber` in an object should be present as a key after processing with function `f`.


Summary: Every unique transformed value from the record values should exist as a key in the output.


it("is the inverse of filter", () => {
			fc.assert(
				fc.property(fc.dictionary(fc.string(), fc.integer()), xs =>
					expect(pipe(xs, RR.filter(p), f)).toEqual({}),
				),
			)
		})

Summary: Applying `filter` to a `ReadonlyRecord` and then using function `f` on the result should yield an empty record.


it("has every unique transformed value as a key", () => {
			const g = fromNumber
			const h: (x: RR.ReadonlyRecord<string, number>) => ReadonlyArray<string> =
				flow(values, RA.uniq(N.Eq), RA.map(g))

			fc.assert(
				fc.property(fc.dictionary(fc.string(), fc.integer()), x =>
					pipe(x, f(g), RR.keys, ks =>
						pipe(
							h(x),
							RA.every(k => RA.elem(S.Eq)(k)(ks)),
						),
					),
				),
			)
		})

Summary: Every unique transformed value from a `ReadonlyRecord` of numbers should be present as a key in the resulting array.


it("returns updated array wrapped in Some if index is okay", () => {
			expect(f(0)(["x"])([])).toEqual(O.some(["x"]))
			expect(g(["x"])).toEqual(O.some(["x", "a", "b"]))
			expect(g(["x", "y"])).toEqual(O.some(["x", "a", "b", "y"]))

			fc.assert(
				fc.property(
					fc.array(fc.anything(), {
						minLength: 1,
						maxLength: 5,
					}) as fc.Arbitrary<NonEmptyArray<unknown>>,
					fc.integer({ min: 0, max: 10 }),
					(xs, i) => O.isSome(f(i)(xs)(xs)) === i <= A.size(xs),
				),
			)

			fc.assert(
				fc.property(
					fc.array(fc.string(), { minLength: 1, maxLength: 20 }),
					xs =>
						expect(pipe(g(xs), O.map(A.size))).toEqual(O.some(A.size(xs) + 2)),
				),
			)
		})

Summary: The function `f` returns an updated array wrapped in `Some` if the index is within bounds of the array, and the function `g` extends the array by adding two elements, preserving the size increase wrapped in `Some`.


it("never returns a larger array", () => {
			fc.assert(
				fc.property(fc.array(fc.integer()), xs => f(xs).length <= A.size(xs)),
			)
		})

Summary: The function `f` should return an array with a length not greater than the input array of integers.


it("never introduces new elements", () => {
			const g = A.uniq(N.Eq)

			fc.assert(
				fc.property(fc.array(fc.integer()), xs =>
					pipe(xs, f, g, A.every(elemV(N.Eq)(g(xs)))),
				),
			)
		})

Summary: The transformation through functions `f` and `g` on an array ensures no new elements are introduced, with each element still present in the result.


it("returns true for empty subarray", () => {
			fc.assert(fc.property(fc.array(fc.integer()), xs => f([])(xs)))
		})

Summary: Returns true when an empty array is identified as a subarray of any array of integers.


it("checks start of array for subarray", () => {
			expect(f([1])([1, 2, 3])).toBe(true)
			expect(f([3])([1, 2, 3])).toBe(false)

			fc.assert(
				fc.property(fc.array(fc.integer()), fc.array(fc.integer()), (xs, ys) =>
					f(xs)(A.concat(ys)(xs)),
				),
			)
		})

Summary: A subarray is verified as the starting segment of a concatenated array.


Summary: Returning true when the subarray is empty for any array `xs`.


it("checks end of array for subarray", () => {
			expect(f([3])([1, 2, 3])).toBe(true)
			expect(f([1])([1, 2, 3])).toBe(false)

			fc.assert(
				fc.property(fc.array(fc.integer()), fc.array(fc.integer()), (xs, ys) =>
					f(xs)(A.concat(xs)(ys)),
				),
			)
		})

Summary: A subarray checked at the end of an array should always match when concatenated to the original array.


it("removes numbers present in first input array", () => {
			const g = f([4, 5])

			expect(g([3, 4])).toEqual([3])
			expect(g([4, 5])).toEqual([])
			expect(g([4, 5, 6])).toEqual([6])
			expect(g([3, 4, 5, 6])).toEqual([3, 6])
			expect(g([4, 3, 4, 5, 6, 5])).toEqual([3, 6])

			fc.assert(
				fc.property(fc.array(fc.integer()), xs =>
					expect(f(xs)(xs)).toEqual(A.empty),
				),
			)
		})

Summary: Function `f` removes elements from the second array that are present in the first input array, ensuring when both inputs are the same array, the result is empty.


it("output array length is the product of input array lengths", () => {
			fc.assert(
				fc.property(
					fc.array(fc.anything()),
					fc.array(fc.anything()),
					(xs, ys) => f(xs)(ys).length === A.size(xs) * ys.length,
				),
			)
		})

Summary: The length of the output array should be the product of the lengths of the two input arrays.


it("sums non-empty input", () => {
			expect(f([25, 3, 10])).toBe(38)
			expect(f([-3, 2])).toBe(-1)
			expect(f([2.5, 3.2])).toBe(5.7)

			fc.assert(
				fc.property(
					fc.array(fc.integer()),
					xs => f(xs) === xs.reduce((acc, val) => acc + val, 0),
				),
			)
		})

Summary: The function `f` should sum the elements of an array, matching the result of using `reduce` with addition on the same array of integers.


it("calculates product of non-empty input", () => {
			expect(f([4, 2, 3])).toBe(24)
			expect(f([5])).toBe(5)
			expect(f([1.5, -5])).toBe(-7.5)

			fc.assert(
				fc.property(
					fc.array(fc.integer()),
					xs => f(xs) === xs.reduce((acc, val) => acc * val, 1),
				),
			)
		})

Summary: The function `f` should return the product of elements in a non-empty integer array, matching the result of using `reduce` with multiplication.


it("returns empty array for empty array input", () => {
			expect(f(0)([])).toEqual([])

			fc.assert(
				fc.property(fc.integer({ min: 0, max: 100 }), n => !f(n)([]).length),
			)
		})

Summary: The function returns an empty array when given an empty array, regardless of the integer input.


it("returns empty array for tuple length larger than input array length", () => {
			fc.assert(
				fc.property(
					fc.array(fc.anything()),
					xs => !f(A.size(xs) + 1)(xs).length,
				),
			)
		})

Summary: The function returns an empty array when the tuple length is larger than the input array length.


it("output length is input length - n + 1", () => {
			fc.assert(
				fc.property(
					fc.array(fc.anything()),
					fc.integer({ min: 1, max: 100 }),
					(xs, n) => f(n)(xs).length === max(N.Ord)(0, A.size(xs) - n + 1),
				),
			)
		})

Summary: The function `f(n)(xs)` should produce an output where the length is equal to the input array's length minus `n` plus one, bounded by a minimum of zero.


it("behaves identically to Array.prototype.slice", () => {
			fc.assert(
				fc.property(
					fc.array(fc.anything()),
					fc.integer(),
					fc.integer(),
					(xs, start, end) =>
						expect(f(start)(end)(xs)).toEqual(xs.slice(start, end)),
				),
			)
		})

Summary: The function behaves identically to `Array.prototype.slice` when given arrays and integer start and end indices.


it("is the inverse of filter", () => {
			fc.assert(
				fc.property(
					fc.array(fc.integer()),
					xs => A.filter(p)(xs).length + f(xs).length === A.size(xs),
				),
			)
		})

Summary: The sum of the lengths of the arrays resulting from applying a filter and its inverse function equals the original array's length.


it("returns unmodified array provided same indices (in bounds)", () => {
			const n = 10

			fc.assert(
				fc.property(
					fc.array(fc.anything(), { minLength: 1, maxLength: n }),
					fc.integer({ min: 0, max: n - 1 }),
					(xs, i) => i >= A.size(xs) || expect(f(i)(i)(xs)).toEqual(O.some(xs)),
				),
			)
		})

Summary: The function returns the original array when the same in-bounds index is used for both extraction and insertion.


it("returns None if source is out of bounds", () => {
			fc.assert(
				fc.property(fc.array(fc.anything()), xs =>
					expect(f(A.size(xs))(0)(xs)).toEqual(O.none),
				),
			)
		})

Summary: `f` returns `None` when the source array is empty or out of bounds.


it("returns the same array size", () => {
			const n = 10

			fc.assert(
				fc.property(
					fc.array(fc.anything(), { minLength: n, maxLength: n }),
					fc.integer({ min: 0, max: n - 1 }),
					fc.integer({ min: 0, max: n - 1 }),
					(xs, i, j) =>
						pipe(
							f(i)(j)(xs),
							O.exists(ys => A.size(ys) === n),
						),
				),
			)
		})

Summary: The function `f(i)(j)(xs)` retains the original array size.


Summary: The function `f` with identical start and end indices (in bounds) should return the original array wrapped in `O.some`.


it("returns None if target is out of bounds", () => {
			fc.assert(
				fc.property(fc.array(fc.anything()), xs =>
					expect(f(A.size(xs))(0)(xs)).toEqual(O.none),
				),
			)
		})

Summary: `f` returns `O.none` if the index is out of bounds for the given array.


it("moves source to target", () => {
			expect(f(0)(1)(["a", "b", "c"])).toEqual(O.some(["b", "a", "c"]))
			expect(f(1)(0)(["a", "b", "c"])).toEqual(O.some(["b", "a", "c"]))

			const n = 10

			fc.assert(
				fc.property(
					fc.array(fc.anything(), { minLength: n, maxLength: n }),
					fc.integer({ min: 0, max: n - 1 }),
					fc.integer({ min: 0, max: n - 1 }),
					(xs, i, j) => O.isSome(f(i)(j)(xs)),
				),
			)
		})

Summary: Elements at specified indices in an array can be successfully moved, ensuring the operation produces a valid result.


it("sibling indices are interchangeable", () => {
			const n = 10

			fc.assert(
				fc.property(
					fc.array(fc.anything(), { minLength: n, maxLength: n }),
					fc.integer({ min: 0, max: n - 2 }),
					(xs, i) => expect(f(i)(i + 1)(xs)).toEqual(f(i + 1)(i)(xs)),
				),
			)
		})

Summary: Sibling indices in an array can be swapped without affecting the overall result.


it("counts the same summed number as the length of the array", () => {
			// fast-check generates keys that fp-ts internals won't iterate over,
			// meaning without this the keys below won't necessarily add up.
			const filterSpecialKeys: Endomorphism<ReadonlyArray<string>> = A.chain(
				flow(k => R.singleton(k, null), R.keys),
			)

			fc.assert(
				fc.property(
					fc.array(fc.string()),
					xs =>
						pipe(xs, f(identity), values, sum) === filterSpecialKeys(xs).length,
				),
			)
		})

Summary: Verifies that the sum of array elements equals the length of the array when filtering out non-iterable keys.


it("calculates the mean", () => {
			expect(f([2, 7, 9])).toBe(6)

			fc.assert(
				fc.property(
					fc.integer({ min: 1, max: 50 }),
					fc.integer(),
					(x, y) => f(A.replicate(x, y) as ReadonlyNonEmptyArray<number>) === y,
				),
			)
		})

Summary: The mean of a replicated integer in a non-empty array should equal that integer.


it("constTrue returns original array", () => {
			fc.assert(
				fc.property(fc.array(fc.anything()), xs =>
					expect(f(constTrue)(xs)).toEqual(xs),
				),
			)
		})

Summary: `constTrue` returns the original array unchanged.


it("constFalse returns empty array", () => {
			fc.assert(
				fc.property(fc.array(fc.anything()), xs =>
					expect(f(constFalse)(xs)).toEqual([]),
				),
			)
		})

Summary: Applying `constFalse` results in an empty array when used on any array.


it("one empty input returns other input whole", () => {
			fc.assert(
				fc.property(fc.array(fc.integer()), xs =>
					expect(f(xs)([])).toEqual(xs),
				),
			)

			fc.assert(
				fc.property(fc.array(fc.integer()), xs =>
					expect(f([])(xs)).toEqual(xs),
				),
			)
		})

Summary: When one input array is empty, the function `f` returns the other input array unchanged.


it("returns the smallest value", () => {
			expect(f([3, 1, 2])).toBe(1)

			fc.assert(
				fc.property(
					fc.integer(),
					n => f([n, n + 1]) === n && f([n + 1, n]) === n,
				),
			)
		})

Summary: The function returns the smallest value from an array of integers.


it("returns the largest value", () => {
			expect(f([1, 3, 2])).toBe(3)

			fc.assert(
				fc.property(
					fc.integer(),
					n => f([n, n + 1]) === n + 1 && f([n + 1, n]) === n + 1,
				),
			)
		})

Summary: The function `f` should return the largest value from a given array of integers.


it("is identical to filter in an applicative context", () => {
			const g = A.filter
			const isEven: Predicate<number> = n => n % 2 === 0
			const isEvenIO = flow(isEven, IO.of)

			fc.assert(
				fc.property(fc.array(fc.integer()), xs =>
					expect(f(isEvenIO)(xs)()).toEqual(g(isEven)(xs)),
				),
			)
		})

Summary: `f` applied to `isEvenIO` should produce the same result as `filter` applied to `isEven` for arrays of integers.


it("extracts expected TaskEither right from a ReaderTaskEither", async () => {
			type Env = { dependency: string }
			const env: Env = { dependency: "dependency " }
			await fc.assert(
				fc.asyncProperty(fc.integer(), async _ => {
					const rte: RTE.ReaderTaskEither<Env, never, number> = pipe(
						E.right(_),
						RTE.fromEither,
					)
					const extractedRight = pipe(rte, runReaderTaskEither(env))()
					await expect(extractedRight).resolves.toStrictEqual(E.right(_))
				}),
			)
		})

Summary: Extracting the expected `TaskEither` right value from a `ReaderTaskEither` should match the original `Either` right value when run with a given environment.


it("extracts expected Either right from a ReaderEither", () => {
			type Env = { dependency: string }
			const env: Env = { dependency: "dependency " }
			fc.assert(
				fc.property(fc.integer(), _ => {
					const re: RE.ReaderEither<Env, never, number> = pipe(
						E.right(_),
						RE.fromEither,
					)
					const extractedRight = pipe(re, runReaderEither(env))
					expect(extractedRight).toStrictEqual(E.right(_))
				}),
			)
		})

Summary: Extracting an `Either` right value from a `ReaderEither` with a given environment yields the expected result.


it("returns array of input size minus one", () => {
			fc.assert(
				fc.property(fc.array(fc.anything(), { minLength: 2 }), xs =>
					expect(
						pipe(
							xs as NonEmptyArray<unknown>,
							f,
							IO.map(flow(snd, A.size)),
							execute,
						),
					).toEqual(pipe(xs, A.size, decrement)),
				),
			)
		})

Summary: Verifies that applying the function `f` to a non-empty array results in an array whose size is one less than the original array.


it("wraps provided value in Some given a None", () => {
			fc.assert(
				fc.property(fc.string(), x => expect(f(x)(O.none)).toEqual(O.some(x))),
			)
		})

Summary: The function `f` wraps a provided string value in `Some` when given `None`.


it("returns None given a Some containing an equivalent value", () => {
			fc.assert(
				fc.property(fc.string(), x => expect(f(x)(O.some(x))).toEqual(O.none)),
			)
		})

Summary: Returns `None` when given a `Some` containing the same value generated by `f`.


it("unwraps Some", () => {
			fc.assert(fc.property(fc.string(), x => pipe(x, O.some, f) === x))
		})

Summary: The function `f` unwraps the value from `O.some`, returning the original string.


it("returns identity on argument on true condition", () => {
			fc.assert(
				fc.property(arbOption(fc.string()), x =>
					expect(f(true)(constant(x))).toEqual(x),
				),
			)
		})

Summary: The function `f(true)` returns the input `Option` unmodified when using `constant(x)`.


it("returns true for any other number", () => {
			fc.assert(fc.property(fc.integer(), f))
		})

Summary: Function `f` returns true for any integer input.


it("returns some(3) for '3.3'", () => {
			expect(f("3.3")).toStrictEqual(O.some(3))
			fc.assert(
				fc.property(fc.integer(), x =>
					expect(f(fromNumber(x))).toStrictEqual(O.some(x)),
				),
			)
		})

Summary: The function `f` should return `O.some(3)` when given the string "3.3", and for any integer input, it should return that integer wrapped in `O.some`.


it("returns some(3) for '3'", () => {
			expect(f("3")).toStrictEqual(O.some(3))
			fc.assert(
				fc.property(fc.integer(), x =>
					expect(f(fromNumber(x))).toStrictEqual(O.some(x)),
				),
			)
		})

Summary: `f` returns `some(x)` for string representations of integers, including "3" and any generated integer converted to a string.


it("returns some(3.3) for '3.3'", () => {
			expect(f("3.3")).toStrictEqual(O.some(3.3))
			fc.assert(
				fc.property(fc.integer(), x =>
					expect(f(fromNumber(x))).toStrictEqual(O.some(x)),
				),
			)
		})

Summary: The function `f` returns `O.some(x)` when converting integers to their string representation and then back to numbers.


it("returns some for floating point number", () => {
			expect(f("3.3")).toStrictEqual(O.some(3.3))

			// Negative zero isn't reversible below via `fromNumber`.
			const isNegativeZero: Predicate<number> = n => Object.is(n, -0)
			expect(f("0")).toStrictEqual(O.some(0))
			expect(f("-0")).toStrictEqual(O.some(-0))

			fc.assert(
				fc.property(
					fc.float({ noNaN: true }).filter(Pred.not(isNegativeZero)),
					x => expect(f(fromNumber(x))).toStrictEqual(O.some(x)),
				),
			)
		})

Summary: For a given string representation of a floating point number, the function should return an `Option` containing the number, except for negative zero which is handled separately.


Summary: `f` returns `O.some(3)` for the string "3" and `O.some(x)` for any integer `x` converted to a string using `fromNumber`.


it("is reversible", () => {
			fc.assert(fc.property(fc.integer(), n => f(f(n)) === n))
		})

Summary: The property should hold that applying the function `f` twice to an integer returns the original integer.


it("returns identity on non-Infinity", () => {
			fc.assert(
				fc.property(
					fc.integer({
						min: Number.MIN_SAFE_INTEGER,
						max: Number.MAX_SAFE_INTEGER,
					}),
					x => f(x) === x,
				),
			)
		})

Summary: Function `f` should return the same integer input when the input is within the range of safe integers and not infinity.


it("returns true for any number above zero", () => {
			expect(f(0.000001)).toBe(true)
			expect(f(42)).toBe(true)
			expect(f(Number.POSITIVE_INFINITY)).toBe(true)

			fc.assert(fc.property(fc.integer({ min: 1 }), f))
		})

Summary: The function `f` returns true for any number greater than zero.


it("retracts pred", () => {
				const g = flow(
					EnumInt.pred,
					O.chain(EnumInt.succ),
					O.chain(EnumInt.pred),
				)
				const h = EnumInt.pred

				fc.assert(fc.property(fc.integer(), n => expect(g(n)).toEqual(h(n))))
			})

Summary: A number processed through `EnumInt.pred`, `EnumInt.succ`, and `EnumInt.pred` should equal the result of applying `EnumInt.pred` once.


it("retracts succ", () => {
				const g = flow(
					EnumInt.succ,
					O.chain(EnumInt.pred),
					O.chain(EnumInt.succ),
				)
				const h = EnumInt.succ

				fc.assert(fc.property(fc.integer(), n => expect(g(n)).toEqual(h(n))))
			})

Summary: Applying `EnumInt.succ`, then `EnumInt.pred`, and `EnumInt.succ` again should yield the same result as a single `EnumInt.succ` on an integer.


it("maintains newtype contract", () => {
			fc.assert(fc.property(fc.integer(), flow(f, isValid)))
		})

Summary: The test ensures that applying the function `f` to integers results in values that satisfy the `isValid` condition, maintaining the newtype contract.


it("is equivalent to lifted Str.append", () => {
			fc.assert(
				fc.property(
					fc.string(),
					arb,
					(x, y) =>
						Str.append(x)(unNonEmptyString(y)) === unNonEmptyString(f(x)(y)),
				),
			)
		})

Summary: `Str.append` applied to a string and an unwrapped non-empty string is equivalent to the unwrapped result of applying function `f` to the same arguments.


it("maintains newtype contract", () => {
			fc.assert(fc.property(fc.string(), arb, (x, y) => pipe(y, f(x), isValid)))
		})

Summary: Verifies that applying function `f` on a string `x` and `arb` value `y` upholds the `isValid` condition.


it("maintains newtype contract", () => {
			fc.assert(fc.property(arb, flow(f, isValid)))
		})

Summary: The function `flow(f, isValid)` should maintain the newtype contract for arbitrary values.


Summary: The property ensures that applying a function `f` to an arbitrary input maintains the newtype contract by producing a valid result according to `isValid`.


it("is equivalent to lifted Str.reverse", () => {
			fc.assert(
				fc.property(
					arb,
					x => Str.reverse(unNonEmptyString(x)) === unNonEmptyString(f(x)),
				),
			)
		})

Summary: Verifies that applying the function `f` to a non-empty string results in a reversed string equivalent to directly reversing it with `Str.reverse`.


Summary: The property ensures that applying `f` to a value generated by `arb` results in a `NonEmptyString` that satisfies `isValid`.


it("is equivalent to lifted Str.size", () => {
			fc.assert(fc.property(arb, x => _size(unNonEmptyString(x)) === f(x)))
		})

Summary: `_size` function applied to `unNonEmptyString(x)` should be equivalent to the function `f(x)` for all inputs generated by `arb`.


it("is equivalent to lifted Str.includes", () => {
			fc.assert(
				fc.property(
					arb,
					fc.string(),
					(haystack, needle) =>
						_includes(needle)(unNonEmptyString(haystack)) ===
						f(needle)(haystack),
				),
			)
		})

Summary: `_includes` and `f` should produce equivalent results when checking for the presence of a string `needle` in a `haystack`.


it("is equivalent to a lifted endomorphism", () => {
			const g: Endomorphism<number> = multiply(2)

			fc.assert(fc.property(fc.integer(), n => f(g)(mkNum(n)) === mkNum(g(n))))
		})

Summary: The test checks that applying a lifted endomorphism `f(g)` to a number wrapped in `mkNum` is equivalent to applying the endomorphism `g` directly to the number and then wrapping the result with `mkNum`.


it("unwraps per provided Foldable instance", () => {
			fc.assert(fc.property(fc.string(), x => pipe(x, O.some, f) === x))
			fc.assert(fc.property(fc.string(), x => pipe(x, E.right, g) === x))
		})

Summary: Unwrapping operations with `Foldable` instances should return the original string for both `Option` and `Either` contexts.


Summary: Verifies that wrapping a string in an `Option` or `Either` and then applying the functions `f` or `g` respectively returns the original string.


it("returns identity element on true condition", () => {
			fc.assert(
				fc.property(fc.string(), x => f(true)(constant(x)) === S.Monoid.empty),
			)
		})

Summary: Function `f` returns the identity element of `S.Monoid` when the condition is true.


it("returns identity on argument on true condition", () => {
			fc.assert(fc.property(fc.string(), x => f(true)(constant(x)) === x))
		})

Summary: When the condition is true, the function returns the identity of the argument.


it("fails when stringification does not return a string", () => {
			const e = TypeError("Stringify output not a string")
			expect(f(identity)(undefined)).toEqual(E.left(e))

			fc.assert(
				fc.property(
					fc.anything(),
					flow(f(identity), E.fold(constTrue, isString)),
				),
			)
		})

Summary: JSON stringification should return a string; if not, it results in a `TypeError`.


it("fails when stringification does not return a string", () => {
			expect(f(undefined)).toEqual(O.none)

			fc.assert(
				fc.property(fc.anything(), flow(f, O.fold(constTrue, isString))),
			)
		})

Summary: `f` function should return a string when applied to any value; otherwise, it should return `O.none`.


it("parses valid JSON", () => {
			expect(f(identity)('{"a":1,"b":["two"]}')).toEqual(
				E.right({ a: 1, b: ["two"] }),
			)

			fc.assert(
				fc.property(
					fc.oneof(fc.string(), fc.integer(), fc.boolean(), fc.constant(null)),
					flow(stringifyPrimitiveUnwrapped, f(identity), E.isRight),
				),
			)
		})

Summary: Parsing valid JSON should result in an `E.right` outcome for various primitive values.


it("parses valid JSON", () => {
			expect(f('{"a":1,"b":["two"]}')).toEqual(O.some({ a: 1, b: ["two"] }))

			fc.assert(
				fc.property(
					fc.oneof(fc.string(), fc.integer(), fc.boolean(), fc.constant(null)),
					flow(stringifyPrimitiveUnwrapped, f, O.isSome),
				),
			)
		})

Summary: `f` correctly parses strings containing valid JSON, including primitives, into an `O.some` value.


it("always runs the effect on const true predicate", () => {
			fc.assert(
				fc.property(fc.integer({ min: 0, max: 99 }), x => {
					let n = 0
					const g: IO<void> = () => {
						n++
					}
					const h = f(constTrue)(g)

					for (let i = 0; i < x; i++) h()
					return n === x
				}),
			)
		})

Summary: The property verifies that when an effect is composed with a constant true predicate, the effect runs exactly as many times as called.


it("never runs the effect on const false predicate", () => {
			fc.assert(
				fc.property(fc.integer({ min: 0, max: 99 }), x => {
					let n = 0
					const g: IO<void> = () => {
						n++
					}
					const h = f(constFalse)(g)

					for (let i = 0; i < x; i++) h()
					return n === 0
				}),
			)
		})

Summary: The function `f` should not execute the effect `g` any number of times if the predicate `constFalse` is used, ensuring `n` remains zero.


it("runs the effect whenever the predicate passes", () => {
			fc.assert(
				fc.property(fc.integer({ min: 0, max: 99 }), x => {
					let n = 0
					const g: IO<void> = () => {
						n++
					}
					const h = f(n => n % 2 === 0)(g)

					for (let i = 0; i < x; i++) h()
					return n === Math.floor(x / 2)
				}),
			)
		})

Summary: The function runs an effect only when a predicate, checking if a number is even, passes and increments a counter accordingly.


it("gets the value", () => {
			fc.assert(
				fc.property(fc.anything(), x =>
					expect(x).toEqual(pipe(x, IO.of, execute)),
				),
			)
		})

Summary: The property ensures that applying `IO.of` and then `execute` on any value returns the original value.


it("identity", () => {
				fc.assert(
					fc.property(fc.anything(), fc.anything(), (x, y) => {
						const left = pipe(F.of(x), F.map(identity), apply(y))
						const right = pipe(F.of(x), identity, apply(y))

						expect(left).toEqual(right)
					}),
				)
			})

Summary: Applying the `identity` function within a pipeline should yield the same result as directly applying `identity`, when both are followed by an `apply` operation with the same value.


it("composition", () => {
				fc.assert(
					fc.property(
						fc.integer(),
						fc.integer(),
						fc.integer(),
						fc.anything(),
						(x, y, z, zz) => {
							const f = add(y)
							const g = multiply(z)

							const left = pipe(F.of(x), F.map(flow(f, g)), apply(zz))
							const right = pipe(F.of(x), F.map(f), F.map(g), apply(zz))

							return expect(left).toEqual(right)
						},
					),
				)
			})

Summary: Function composition should produce equivalent outcomes when mapped through a sequence and then applied.


it("identity", () => {
				fc.assert(
					fc.property(fc.anything(), fc.anything(), (x, y) => {
						const left = pipe(F.of(identity), F.ap(F.of(x)), apply(y))
						const right = pipe(F.of(x), apply(y))

						return expect(left).toEqual(right)
					}),
				)
			})

Summary: `F.of(identity)` applied to `F.ap(F.of(x))` and `apply(y)` should produce the same result as `F.of(x)` applied with `apply(y)`.


it("left identity", () => {
				fc.assert(
					fc.property(fc.integer(), fc.integer(), fc.anything(), (x, y, z) => {
						const f = flow(add(y), F.of)

						const left = pipe(F.of(x), F.chain(f), apply(z))
						const right = pipe(f(x), apply(z))

						return expect(left).toEqual(right)
					}),
				)
			})

Summary: The property should hold that applying a function `f` to a monadic value using `left` and `right` transformations results in equivalent outcomes.


it("right identity", () => {
				fc.assert(
					fc.property(fc.anything(), fc.anything(), (x, y) => {
						const left = pipe(F.of(x), F.chain(F.of), apply(y))
						const right = pipe(F.of(x), apply(y))

						return expect(left).toEqual(right)
					}),
				)
			})

Summary: The operation `apply(y)` on `pipe(F.of(x), F.chain(F.of))` should yield the same result as `pipe(F.of(x))` when `apply(y)` is also applied, ensuring right identity.


it("calls the method with arguments on the object", () => {
			fc.assert(
				fc.property(
					fc.string({ minLength: 5, maxLength: 5 }),
					x => f<string>()("padStart")([8, "."])(x) === `...${x}`,
				),
			)
		})

Summary: The method `padStart` is called with specified arguments on a string, resulting in a string prefixed with three dots and the original string.


it("always returns the same output provided same input", () => {
			const g = f(N.Eq)(add(5))

			expect(g(2)).toBe(7)
			expect(g(3)).toBe(8)
			expect(g(2)).toBe(7)

			fc.assert(fc.property(fc.integer(), n => g(n) === n + 5))
		})

Summary: The function `g`, derived from `f(N.Eq)(add(5))`, consistently returns the same output for identical integer inputs, specifically outputting the input plus 5.


it("calls all provided functions and returns their outputs in order", () => {
			fc.assert(
				fc.property(fc.string(), x =>
					expect(
						fork([
							S.append("!"),
							identity,
							S.append("?"),
							A.of,
							S.prepend("."),
						])(x),
					).toEqual([`${x}!`, x, `${x}?`, [x], `.${x}`]),
				),
			)
			expect(f)
		})

Summary: Calling multiple functions on a string should return their outputs in a specified order.


it("calls all provided functions and outputs the resulting tuple to the converging function", () => {
			fc.assert(
				fc.property(
					fc.string(),
					x =>
						f(join(" "))([S.append("!"), identity, S.prepend("?")])(x) ===
						`${x}! ${x} ?${x}`,
				),
			)
		})

Summary: The result of applying multiple functions to a string should form a tuple that, when joined and passed to a converging function, matches the expected formatted output.


it("returns identity on empty array", () => {
			fc.assert(fc.property(fc.anything(), x => expect(f([])(x)).toEqual(x)))
		})

Summary: `f` applied to an empty array should return the identity function for any input `x`.


it("returns identity on array of None", () => {
			fc.assert(
				fc.property(fc.anything(), fc.array(fc.constant(O.none)), (x, gs) =>
					expect(f(gs)(x)).toEqual(x),
				),
			)
		})

Summary: `f` applied to an array of `None` values should return the input `x` unchanged.


it("applies the function the specified number of times", () => {
			expect(f(3)).toBe(5)

			fc.assert(
				fc.property(fc.integer({ min: 1, max: 50 }), n => f(n) === n + 2),
			)
		})

Summary: A function applied a specified number of times should return the input value incremented by 2.


it("can reimplement range", () => {
			const g = curry2(NEA.range)

			fc.assert(
				fc.property(validPair, ([x, y]) => expect(f(x)(y)).toEqual(g(x)(y))),
			)
		})

Summary: Reimplementing the `range` function should produce the same results as `NEA.range` for a valid pair of numbers.


it("never throws", () => {
			fc.assert(
				fc.property(triple, ([x, y, z]) => {
					f(x)(y)(z)
				}),
			)
		})

Summary: The function `f` should not throw errors when applied sequentially to elements of a triple.


it("can reimplement range", () => {
			const g =
				(start: number) =>
				(end: number): NonEmptyArray<number> =>
					f(start)(start + 1)(end)
			const h = curry2(NEA.range)

			expect(g(-1)(0)).toEqual([-1, 0])
			expect(h(-1)(0)).toEqual([-1, 0])
			fc.assert(
				fc.property(validPair, ([x, y]) => expect(g(x)(y)).toEqual(h(x)(y))),
			)
		})

Summary: Reimplementing a range function (`g`) should produce the same output as the `curry2` version of the `NEA.range` function (`h`) for valid number pairs.


it("never throws in succ or pred", () => {
			fc.assert(
				fc.property(
					fc.array(fc.string(), { maxLength: 100 }),
					fc.string(),
					(xs, y) => {
						const E = f(Str.Ord)(xs as NonEmptyArray<string>)

						E.succ(y)
						E.pred(y)
					},
				),
			)
		})

Summary: Calling `succ` or `pred` on an enumeration mapping of strings should not throw an error.


it("output A.size is input A.size - n + 1", () => {
			fc.assert(
				fc.property(
					fc.array(fc.anything()),
					fc.integer({ min: 1, max: 100 }),
					(xs, n) => f(n)(xs).length === max(N.Ord)(0, A.size(xs) - n + 1),
				),
			)
		})

Summary: The length of the output array should be the size of the input array minus \( n \) plus 1, but not less than zero.


it("returns identity on identity input", () => {
			fc.assert(
				fc.property(fc.string(), x => {
					expect(f(identity)(E.left(x))).toEqual(E.left(x))
					expect(f(identity)(E.right(x))).toEqual(E.right(x))
				}),
			)
		})

Summary: Applying `f` with an identity function to either `E.left` or `E.right` returns the input as is.


it("logs string message and shown value", () => {
			fc.assert(
				fc.property(fc.string(), fc.string(), (x, y) => {
					const spy = jest
						.spyOn(global.console, "log")
						.mockImplementation(constVoid)
					f(x)(y)
					expect(console.log).toHaveBeenCalledTimes(1)
					expect(console.log).toHaveBeenCalledWith(x, Str.Show.show(y))
					spy.mockRestore()
				}),
			)
		})

Summary: Logs a string message and a value's string representation using `console.log` exactly once.


it("returns provided value by reference", () => {
			fc.assert(
				fc.property(fc.string(), x => {
					const spy = jest
						.spyOn(global.console, "log")
						.mockImplementation(constVoid)
					expect(f("")(x)).toBe(x)
					spy.mockRestore()
				}),
			)
		})

Summary: The function `f` should return the input string by reference, ensuring the output is the same instance as the input.


it("returns true for any date", () => {
			expect(f(new Date())).toBe(true)
			expect(f(new Date("invalid"))).toBe(true)

			fc.assert(fc.property(fc.date(), isDate))
		})

Summary: The function `f` consistently returns true for any given date, including invalid ones, and `isDate` should return true for all generated dates.


it("wraps date constructor and validates", () => {
			expect(f(Number.NEGATIVE_INFINITY)).toEqual(O.none)
			expect(f(Number.POSITIVE_INFINITY)).toEqual(O.none)
			expect(f("invalid")).toEqual(O.none)

			fc.assert(
				fc.property(dateMillisInt, x =>
					expect(f(x)).toEqual(O.some(new Date(x))),
				),
			)
		})

Summary: The function `f` returns `O.none` for invalid date inputs and `O.some(new Date(x))` for valid date milliseconds.


it("creates date using underlying number", () => {
			fc.assert(
				fc.property(dateMillisInt, n =>
					expect(f(mkMilliseconds(n)).toISOString()).toBe(
						new Date(n).toISOString(),
					),
				),
			)
		})

Summary: Creating a date from milliseconds results in the same ISO string representation as directly using the number to create a date.


it("joins", () => {
			expect(f([])).toBe("")
			expect(f(["x"])).toBe("x")
			expect(f(["x", "yz"])).toBe("x,yz")

			fc.assert(
				fc.property(fc.array(fc.string()), xs => {
					const countDelims = flow(
						split(""),
						RA.filter(c => c === delim),
						RA.size,
					)

					const countDelimsA = flow(RA.map(countDelims), concatAll(N.MonoidSum))

					return (
						countDelims(f(xs)) ===
						countDelimsA(xs) + max(N.Ord)(0, A.size(xs) - 1)
					)
				}),
			)
		})

Summary: The function `f` joins an array of strings with delimiters such that the number of delimiters in the result matches the expected count based on the input array's elements and length.


it("output array A.size is the product of input array A.sizes", () => {
			fc.assert(
				fc.property(
					fc.array(fc.anything()),
					fc.array(fc.anything()),
					(xs, ys) => f(xs)(ys).length === A.size(xs) * ys.length,
				),
			)
		})

Summary: The length of the output array should be the product of the sizes of two input arrays.


it("calculates the median", () => {
			expect(f([2, 9, 7])).toBe(7)
			expect(f([7, 2, 10, 9])).toBe(8)

			fc.assert(
				fc.property(
					fc.integer({ min: 1, max: 50 }),
					fc.integer(),
					(x, y) => f(A.replicate(x, y) as NonEmptyArray<number>) === y,
				),
			)
		})

Summary: Calculates the median of an array and verifies that the median of a non-empty array of identical integers equals the repeated integer.


it("does not reuse the input reference/object", () => {
			fc.assert(
				fc.property(fc.array(fc.anything()), xs => {
					const ys = f(xs)

					expect(xs).toBe(xs)
					expect(xs).not.toBe(ys)
				}),
			)
		})

Summary: Function `f` returns a new array object instead of reusing the input array reference.


it('returns exactly what it was given', () => {
        fc.assert(
          fc.property(fc.anything(), (anything) => {
            assert.strictEqual(Table.schema(anything as any), anything);
          }),
        );
      })

Summary: `Table.schema` should return the exact input it receives.


it('should return true for valid IPv4 addresses', () => {
        fc.assert(
          fc.property(fc.mixedCase(fc.ipV4()), (ip) => {
            assert.ok(DataAPIInet.isIPv4(ip));
          }),
        );
      })

Summary: `DataAPIInet.isIPv4` returns true for valid IPv4 addresses with varying case inputs.


it('should return true for valid IPv6 addresses', () => {
        fc.assert(
          fc.property(fc.mixedCase(fc.ipV6()), (ip) => {
            assert.ok(DataAPIInet.isIPv6(ip));
          }),
        );
      })

Summary: `DataAPIInet.isIPv6` should return true for valid IPv6 addresses with mixed casing.


it('should return false for valid IPv6 addresses', () => {
        fc.assert(
          fc.property(fc.string(), (ip) => {
            fc.pre(tryCatchErrSync(() => new URL(`https://[${ip}]`)) !== undefined);
            assert.ok(!DataAPIInet.isIPv4(ip));
          }), {
            examples: [['a'], ['a'.repeat(100)]],
          },
        );
      })

Summary: `DataAPIInet.isIPv4` returns false for valid IPv6 addresses.


it('should not populate unpopulated fields', () => {
      fc.assert(
        fc.property(arbs.tableDefinitionAndRow(), ([schema]) => {
          const resp = serdes.deserialize({}, {
            status: { projectionSchema: schema },
          });
          assert.deepStrictEqual(resp, {});
        }),
      );
    })

Summary: Deserialization should not populate unpopulated fields in response when given an empty input and a schema.


it('should allow force creation of invalid values', () => {
      for (const version of [4, 6, undefined] as const) {
        fc.assert(
          fc.property(fc.anything(), (ip) => {
            if (ip !== null && (typeof ip === 'string' || typeof ip === 'object' && 'toLowerCase' in ip && typeof ip.toLowerCase === 'function')) {
              assert.doesNotThrow(() => new DataAPIInet(ip as any, version, false));
            } else {
              assert.throws(() => new DataAPIInet(ip as any, version, false), TypeError);
            }
          }), {
            examples: [[{ toLowerCase: () => 3 }]],
          },
        );
      }
    })

Summary: Creating a `DataAPIInet` object with any input should not throw an error if the input is a string or an object with a `toLowerCase` function, but should throw a `TypeError` for other types.


it('should return false for valid IPv6 addresses', () => {
        fc.assert(
          fc.property(fc.string(), (ip) => {
            fc.pre(tryCatchErrSync(() => new URL(`https://[${ip}]`)) !== undefined);
            assert.ok(!DataAPIInet.isIPv6(ip));
          }), {
            examples: [['a'], ['a'.repeat(100)]],
          },
        );
      })

Summary: `DataAPIInet.isIPv6` returns false for valid IPv6 addresses.


it("copies the array contents", () => {
			fc.assert(
				fc.property(fc.array(fc.anything()), xs => expect(f(xs)).toEqual(xs)),
			)
		})

Summary: The function `f` should produce an exact copy of the contents of any given array.


it("returns These Left for only Either Lefts", () => {
			fc.assert(
				fc.property(fc.array(fc.anything(), { minLength: 1 }), xs => {
					const ys = pipe(xs as NonEmptyArray<unknown>, NEA.map(E.left))

					expect(f(ys)).toEqual(T.left(xs))
				}),
			)
		})

Summary: The function `f` converts a non-empty array of `Either Left` values into a `These Left` containing the original array.


it("returns These Right for only Either Rights", () => {
			fc.assert(
				fc.property(fc.array(fc.anything(), { minLength: 1 }), xs => {
					const ys = pipe(xs as NonEmptyArray<unknown>, NEA.map(E.right))

					expect(f(ys)).toEqual(T.right(xs))
				}),
			)
		})

Summary: `f` returns `These Right` when applied to a non-empty array of `Either Rights`.


it("returns constant empty on all-empty input", () => {
			fc.assert(
				fc.property(fc.anything(), x =>
					expect(
						f([constant(O.none), constant(O.none), constant(O.none)])(
							constant(x),
						),
					).toEqual(O.none),
				),
			)
		})

Summary: For an input array of constant `O.none` functions, the output of `f` should also be `O.none` regardless of the provided argument.


test('presents a starting state', () => {
      fc.assert(
        fc.property(fc.string(), value => {
          const tseq = new TSeq('p1');
          tseq.splice(0, 0, value);
          expect(tseq.toString()).toBe(value);
        })
      );
    })

Summary: `TSeq` initialized and spliced with a string at the start index should convert to that string.


test('process group converges with forced sync', () => {
      const numProcs = 3;
      fc.assert(
        fc.property(
          fc.commands([
            TSeqProcessGroupSpliceCommand.arbitrary(numProcs),
            TSeqProcessGroupForceSyncCommand.arbitrary()
          ], {
            size: '+1' // good coverage, <1sec runtime
          }),
          arbitraryProcessIds(numProcs),
          TSeqProcessGroupCommand.runModel
        )
      );
    })

Summary: The `TSeqProcessGroup` achieves convergence through forced synchronization when executing sequences of splice and sync commands across multiple processes.


test.each([
      [false, false],
      [true, false],
      [false, true],
      [true, true]
    ])('process group converges with partial deliveries', (fuse, redeliver) => {
      const numProcs = 3;
      fc.assert(
        fc.property(
          fc.commands([
            TSeqProcessGroupSpliceCommand.arbitrary(numProcs),
            TSeqProcessGroupDeliverCommand.arbitrary(numProcs, fuse, redeliver),
            TSeqProcessGroupCheckConvergedCommand.arbitrary()
          ], {
            size: '+1' // good coverage, <1sec runtime
          }),
          arbitraryProcessIds(numProcs),
          TSeqProcessGroupCommand.runModel
        )
      );
    })

Summary: The test checks that a `TSeqProcessGroup` converges correctly despite partial deliveries, based on a combination of process commands and configurations with different `fuse` and `redeliver` settings.


test('diff applies', () => {
    fc.assert(
      fc.property(
        fc.array(fc.nat({ max: 5 }), { maxLength: 4 }),
        fc.array(fc.nat({ max: 5 }), { maxLength: 4 }),
        (olds, news) => {
          const { deletes, inserts } = SubjectPropertyValues
            .for({ '@list': news }, '@list')
            .diff(olds);
          // New items must be expressed as slots
          slotify(<List>inserts);
          const regen = SubjectPropertyValues
            .for({ '@list': [...olds] }, '@list')
            .update(deletes, inserts).values();
          expect(regen).toEqual(news);
        }
      ),
      { ignoreEqualValues: true }
    );
  })

Summary: The test verifies that updating a list by diffing old and new lists, converting new items to slots, and then regenerating the list, results in a list that matches the new list.


assertArbitrary = (arbitrary: fc.Arbitrary<any>, checks: FilterFunction[], result: boolean): void => {
  fc.assert(
    fc.property(arbitrary, (value) => {
      checks.forEach((check) => {
        expect(check(value)).toBe(result);
      });
      // TypeScript 2.7.2 does not work well with fast-check type definitions
    }) as any,
  );
}

Summary: The function verifies that, for a given arbitrary value, each check in a list of filter functions consistently returns the specified boolean result.


it('null/undefined should be valid values for any type', () => {
    const isEvent = typeCheckFor<AWSSNSEvent>();

    const validArbitrary: fc.Arbitrary<AWSSNSEvent> = oneOf(
      eventArbitrary(),
      fc.constantFrom<AWSSNSEvent>({ Records: null }, { Records: undefined }, null, undefined),
      // Without strict null checks TypeScript is kinda useless - if in this case "Records"
      // is null or undefined the check should return true. But that is the case
      // for virtually any type - numbers, strings, booleans etc all have undefined "Records" property!
      oneOf<any>(fc.string(), numeric(), fc.boolean(), fc.bigInt(), fc.func(fc.anything())) as fc.Arbitrary<any>,
    );
    const invalidArbitrary = oneOf<any>(
      eventArbitrary().map((event) => ({
        ...event,
        Records: {},
      })),
      eventArbitrary()
        .map((event) => ({
          ...event,
          Records: event.Records.map((record) => ({
            ...record,
            Sns: {
              ...record.Sns,
              TopicArn: 7,
            },
          })),
        }))
        .filter((event) => event.Records.length > 0),
    );

    fc.assert(
      fc.property(validArbitrary, (event: AWSSNSEvent): void => {
        expect(isEvent(event)).toBeTruthy();
        expect(isA<AWSSNSEvent>(event)).toBeTruthy();
      }) as any,
    );

    fc.assert(
      fc.property(invalidArbitrary, (notAnEvent: any): void => {
        expect(isEvent(notAnEvent)).toBeFalsy();
        expect(isA<AWSSNSEvent>(notAnEvent)).toBeFalsy();
      }) as any,
    );
  })

Summary: `AWSSNSEvent` should allow null or undefined values for any type, validating them as true, while invalid structures should be recognized as false.


Summary: Null or undefined values should be considered valid for any type, while specific malformed structures should be recognized as invalid by type checks.


test('recovering after same-type circular structure check', () => {
      const circularArbitrary = fc
        .integer(0, 50)
        .map<[TypeReference1, TypeReference1]>((n) => createLinkedList(n, true));

      // We check the valid arbitrary on a finer-grained level than the invalid one
      fc.assert(
        fc.property(circularArbitrary, ([head, tail]) => {
          expect(() => typeCheckFor<TypeReference1>()(head)).toThrow(circularTypeError);
          expect(() => isA<TypeReference1>(head)).toThrow(circularTypeError);

          head.next = undefined;
          expect(typeCheckFor<TypeReference1>()(head)).toBeTruthy();
          expect(isA<TypeReference1>(head)).toBeTruthy();

          head.next = tail;
          expect(() => typeCheckFor<TypeReference1>()(head)).toThrow(circularTypeError);
          expect(() => isA<TypeReference1>(head)).toThrow(circularTypeError);
        }) as any,
      );
    })

Summary: `typeCheckFor` and `isA` throw an error for a circular reference structure, but pass validation when the circular link is removed.


test('alternating-type circular structure should throw an error', () => {
      const circularArbitrary = fc.integer(0, 100).map<TypeReference1>((n) => createLinkedList(n, true)[0]);

      // We check the valid arbitrary on a finer-grained level than the invalid one
      fc.assert(
        fc.property(circularArbitrary, (value) => {
          expect(() => typeCheckFor<TypeReference1>()(value)).toThrow(circularTypeError);
          expect(() => isA<TypeReference1>(value)).toThrow(circularTypeError);

          expect(() => typeCheckFor<TypeReference2>()(value.next)).toThrow(circularTypeError);
          expect(() => isA<TypeReference2>(value.next)).toThrow(circularTypeError);
        }) as any,
      );
    })

Summary: An alternating-type circular structure should throw an error during type checks with `typeCheckFor` and `isA`.


test('recovering after same-type circular structure check', () => {
      const circularArbitrary = fc
        .integer(0, 50)
        .map<[TypeReference1, TypeReference2]>((n) => createLinkedList(n, true));

      // We check the valid arbitrary on a finer-grained level than the invalid one
      fc.assert(
        fc.property(circularArbitrary, ([head, tail]) => {
          expect(() => typeCheckFor<TypeReference1>()(head)).toThrow(circularTypeError);
          expect(() => isA<TypeReference1>(head)).toThrow(circularTypeError);

          tail.following = undefined;
          expect(typeCheckFor<TypeReference1>()(head)).toBeTruthy();
          expect(isA<TypeReference1>(head)).toBeTruthy();

          tail.following = head;
          expect(() => typeCheckFor<TypeReference1>()(head)).toThrow(circularTypeError);
          expect(() => isA<TypeReference1>(head)).toThrow(circularTypeError);
        }) as any,
      );
    })

Summary: Ensures that after detecting a same-type circular structure causing a type error, removing the circularity temporarily allows successful type-checking, but reinstating it leads to the error again.


it('null/undefined should not be valid values for any type', () => {
    const isEvent = typeCheckFor<AWSSNSEvent>();

    const validArbitrary: fc.Arbitrary<AWSSNSEvent> = oneOf(eventArbitrary());
    const invalidArbitrary = oneOf<any>(
      eventArbitrary().map((event) => ({
        ...event,
        Records: {},
      })),
      fc.constantFrom({ Records: null }, { Records: undefined }, null, undefined),
      // Without strict null checks TypeScript is kinda useless - if in this case "Records"
      // is null or undefined the check should return true. But that is the case
      // for virtually any type - numbers, strings, booleans etc all have undefined "Records" property!
      oneOf<any>(fc.string(), numeric(), fc.boolean(), fc.bigInt(), fc.func(fc.anything())) as fc.Arbitrary<any>,
      eventArbitrary()
        .map((event) => ({
          ...event,
          Records: event.Records.map((record) => ({
            ...record,
            Sns: {
              ...record.Sns,
              TopicArn: 7,
            },
          })),
        }))
        .filter((event) => event.Records.length > 0),
    );

    fc.assert(
      fc.property(validArbitrary, (event: AWSSNSEvent): void => {
        expect(isEvent(event)).toBeTruthy();
        expect(isA<AWSSNSEvent>(event)).toBeTruthy();
      }),
    );

    fc.assert(
      fc.property(invalidArbitrary, (notAnEvent: any): void => {
        expect(isEvent(notAnEvent)).toBeFalsy();
        expect(isA<AWSSNSEvent>(notAnEvent)).toBeFalsy();
      }),
    );
  })

Summary: Null or undefined should not be valid for any type, specifically in the context of `AWSSNSEvent`, by ensuring `isEvent` and `isA<AWSSNSEvent>` return false for invalid data, and true for valid data.


Summary: `AWSSNSEvent` rejects null and undefined as valid values across different scenarios, ensuring strict type validation.


it('should trap from a query method', async () => {
            const actor = await getCanisterActor<Actor>('canister');

            await fc.assert(
                fc.asyncProperty(
                    fc.string({
                        maxLength: 500,
                        size: 'max'
                    }),
                    async (message) => {
                        const expectedErrorMessage = new RegExp(
                            `Call failed:\\s*Canister: ${canisterId}\\s*Method: queryTrap \\(query\\)\\s*"Status": "rejected"\\s*"Code": "CanisterError"\\s*"Message": "Error from Canister ${canisterId}: Canister called \`ic0.trap\` with message: 'trap proptest message:`
                        );
                        await expect(actor.queryTrap(message)).rejects.toThrow(
                            expectedErrorMessage
                        );
                        await expect(actor.queryTrap(message)).rejects.toThrow(
                            message.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
                        );
                    }
                ),
                defaultPropTestParams()
            );
        })

Summary: The query method `queryTrap` should reject calls by trapping with the expected error message, including the user-provided message string.


it('should trap from an update method', async () => {
            const actor = await getCanisterActor<Actor>('canister');

            await fc.assert(
                fc.asyncProperty(
                    fc.string({
                        maxLength: 500,
                        size: 'max'
                    }),
                    async (message) => {
                        const expectedErrorMessage = new RegExp(
                            `Call failed:\\s*Canister: ${canisterId}\\s*Method: updateTrap \\(update\\)\\s*"Request ID": "[a-f0-9]{64}"\\s*"Error code": "IC0503"\\s*"Reject code": "5"\\s*"Reject message": "Error from Canister ${canisterId}: Canister called \`ic0.trap\` with message: 'trap proptest message:`
                        );
                        await expect(actor.updateTrap(message)).rejects.toThrow(
                            expectedErrorMessage
                        );
                        await expect(actor.updateTrap(message)).rejects.toThrow(
                            message.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
                        );
                    }
                ),
                defaultPropTestParams()
            );
        })

Summary: An update method in the actor should consistently cause a trap with an expected error message and reject the operation correctly when invoked with various string messages.


it('should trap from inspectMessage', async () => {
            const actor = await getCanisterActor<Actor>('canister');

            await fc.assert(
                fc.asyncProperty(
                    fc.string({
                        maxLength: 500,
                        size: 'max'
                    }),
                    async (message) => {
                        const expectedErrorMessage = new RegExp(
                            `Call failed:\\s*Canister: ${canisterId}\\s*Method: inspectMessageTrap \\(update\\)\\s*"Request ID": "[a-f0-9]{64}"\\s*"Error code": "IC0503"\\s*"Reject code": "5"\\s*"Reject message": "Error from Canister ${canisterId}: Canister called \`ic0.trap\` with message: 'trap proptest message:`
                        );
                        await expect(
                            actor.inspectMessageTrap(message)
                        ).rejects.toThrow(expectedErrorMessage);
                        await expect(
                            actor.inspectMessageTrap(message)
                        ).rejects.toThrow(
                            message.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
                        );
                    }
                ),
                defaultPropTestParams()
            );
        })

Summary: `inspectMessageTrap` method should throw an error, trapping messages that match the expected error pattern, including the specific message content.


it('should return time from an update method', async () => {
            const actor = await getCanisterActor<Actor>('canister');

            await fc.assert(
                fc.asyncProperty(fc.constant(undefined), async () => {
                    const testTimeBefore = new Date().getTime() - 2_000;
                    const canisterTime0 = nanoSecondsToMilliseconds(
                        await actor.updateTime()
                    );
                    const canisterTime1 = nanoSecondsToMilliseconds(
                        await actor.updateTime()
                    );
                    const testTimeAfter = new Date().getTime();

                    expect(canisterTime0).toBeLessThan(canisterTime1);

                    expect(canisterTime0).toBeGreaterThanOrEqual(
                        testTimeBefore
                    );
                    expect(canisterTime1).toBeGreaterThanOrEqual(
                        testTimeBefore
                    );

                    expect(canisterTime0).toBeLessThan(testTimeAfter);
                    expect(canisterTime1).toBeLessThanOrEqual(testTimeAfter);
                }),
                defaultPropTestParams()
            );
        })

Summary: The property ensures that the `updateTime` method returns increasing time values within a valid range when converted from nanoseconds to milliseconds.


it('should return time from inspectMessage', async () => {
            const actor = await getCanisterActor<Actor>('canister');

            await fc.assert(
                fc.asyncProperty(fc.constant(undefined), async () => {
                    const testTimeBefore = new Date().getTime() - 2_000;

                    const inspectMessageTime0 = nanoSecondsToMilliseconds(
                        await getInspectMessageTime(actor)
                    );
                    const inspectMessageTime1 = nanoSecondsToMilliseconds(
                        await getInspectMessageTime(actor)
                    );

                    const testTimeAfter = new Date().getTime();

                    expect(inspectMessageTime0).toBeLessThanOrEqual(
                        inspectMessageTime1
                    );

                    expect(inspectMessageTime0).toBeGreaterThanOrEqual(
                        testTimeBefore
                    );
                    expect(inspectMessageTime0).toBeLessThan(testTimeAfter);

                    expect(inspectMessageTime1).toBeGreaterThanOrEqual(
                        testTimeBefore
                    );
                    expect(inspectMessageTime1).toBeLessThanOrEqual(
                        testTimeAfter
                    );
                }),
                defaultPropTestParams()
            );
        })

Summary: The property should hold that `inspectMessageTime` converted to milliseconds is non-decreasing and falls within the expected time bounds before and after invocation.