Skip to content

Commit

Permalink
Clean 1 (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz authored Jul 4, 2020
1 parent 05b54f1 commit ebb6b9e
Show file tree
Hide file tree
Showing 44 changed files with 196 additions and 196 deletions.
26 changes: 13 additions & 13 deletions prebuild/property.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const { commas, iota, txCommas } = require('./helpers.cjs');
* @param num {number}
* @param isAsync {boolean}
*/
const predicateFor = function(num, isAsync) {
const predicateFor = function (num, isAsync) {
return isAsync
? `(${commas(num, v => `t${v}:T${v}`)}) => Promise<boolean|void>`
: `(${commas(num, v => `t${v}:T${v}`)}) => (boolean|void)`;
? `(${commas(num, (v) => `t${v}:T${v}`)}) => Promise<boolean|void>`
: `(${commas(num, (v) => `t${v}:T${v}`)}) => (boolean|void)`;
};

/**
Expand All @@ -21,10 +21,10 @@ const signatureFor = (num, isAsync) => {
return `
/**
* Instantiate a new {@link ${className}}
* @param predicate Assess the success of the property. Would be considered falsy if its throws or if its output evaluates to false
* @param predicate - Assess the success of the property. Would be considered falsy if its throws or if its output evaluates to false
*/
function ${functionName}<${txCommas(num)}>(
${commas(num, v => `arb${v}:Arbitrary<T${v}>`)},
${commas(num, (v) => `arb${v}:Arbitrary<T${v}>`)},
predicate: ${predicateFor(num, isAsync)}
): ${className}<[${txCommas(num)}]>;`;
};
Expand All @@ -42,7 +42,7 @@ const generateProperty = (num, isAsync) => {
`import { genericTuple } from '../arbitrary/TupleArbitrary';`,
`import { ${className} } from './${className}.generic';`,
// declare all signatures
...iota(num).map(id => signatureFor(id + 1, isAsync)),
...iota(num).map((id) => signatureFor(id + 1, isAsync)),
// declare function
`function ${functionName}(...args: any[]): any {
if (args.length < 2) throw new Error('${functionName} expects at least two parameters');
Expand All @@ -51,7 +51,7 @@ const generateProperty = (num, isAsync) => {
return new ${className}(genericTuple(arbs), t => p(...t));
}`,
// export
`export { ${functionName} };`
`export { ${functionName} };`,
];

return blocks.join('\n');
Expand All @@ -69,13 +69,13 @@ const testBasicCall = (num, isAsync) => {
it('Should call the underlying arbitraries in ${functionName}${num}', ${kAsync} () => {
let data = null;
const p = ${functionName}(
${commas(num, v => `stubArb.single(${v * v})`)},
${kAsync} (${commas(num, v => `a${v}:number`)}) => {
data = [${commas(num, v => `a${v}`)}];
${commas(num, (v) => `stubArb.single(${v * v})`)},
${kAsync} (${commas(num, (v) => `a${v}:number`)}) => {
data = [${commas(num, (v) => `a${v}`)}];
return true;
});
expect(${kAwait} p.run(p.generate(stubRng.mutable.nocall()).value)).toBe(null);
expect(data).toEqual([${commas(num, v => `${v * v}`)}]);
expect(data).toEqual([${commas(num, (v) => `${v * v}`)}]);
});
`;
};
Expand All @@ -95,9 +95,9 @@ const generatePropertySpec = (num, isAsync) => {
// start blocks
`describe('${className}', () => {`,
// tests
...iota(num).map(id => testBasicCall(id + 1, isAsync)),
...iota(num).map((id) => testBasicCall(id + 1, isAsync)),
// end blocks
`});`
`});`,
];

return blocks.join('\n');
Expand Down
12 changes: 6 additions & 6 deletions src/check/arbitrary/ArrayArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ class ArrayArbitrary<T> extends Arbitrary<T[]> {

/**
* For arrays of values coming from `arb`
* @param arb Arbitrary used to generate the values inside the array
* @param arb - Arbitrary used to generate the values inside the array
*/
function array<T>(arb: Arbitrary<T>): Arbitrary<T[]>;
/**
* For arrays of values coming from `arb` having an upper bound size
* @param arb Arbitrary used to generate the values inside the array
* @param maxLength Upper bound of the generated array size
* @param arb - Arbitrary used to generate the values inside the array
* @param maxLength - Upper bound of the generated array size
*/
function array<T>(arb: Arbitrary<T>, maxLength: number): Arbitrary<T[]>;
/**
* For arrays of values coming from `arb` having lower and upper bound size
* @param arb Arbitrary used to generate the values inside the array
* @param minLength Lower bound of the generated array size
* @param maxLength Upper bound of the generated array size
* @param arb - Arbitrary used to generate the values inside the array
* @param minLength - Lower bound of the generated array size
* @param maxLength - Upper bound of the generated array size
*/
function array<T>(arb: Arbitrary<T>, minLength: number, maxLength: number): Arbitrary<T[]>;
function array<T>(arb: Arbitrary<T>, aLength?: number, bLength?: number): Arbitrary<T[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/check/arbitrary/AsyncSchedulerArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ function schedulerFor<TMetaData = unknown>(
* WARNING:
* If one the promises is wrongly defined it will fail - for instance asking to resolve 5 while 5 does not exist.
*
* @param customOrdering Array defining in which order the promises will be resolved.
* @param customOrdering - Array defining in which order the promises will be resolved.
* Id of the promises start at 1. 1 means first scheduled promise, 2 second scheduled promise and so on.
*/
function schedulerFor<TMetaData = unknown>(
Expand Down
10 changes: 5 additions & 5 deletions src/check/arbitrary/BigIntArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BigIntArbitrary extends ArbitraryWithShrink<bigint> {
*
* Generated values will be between -2^(n-1) (included) and 2^(n-1) (excluded)
*
* @param n Maximal number of bits of the generated bigint
* @param n - Maximal number of bits of the generated bigint
*/
function bigIntN(n: number): ArbitraryWithShrink<bigint> {
return new BigIntArbitrary(BigInt(-1) << BigInt(n - 1), (BigInt(1) << BigInt(n - 1)) - BigInt(1));
Expand All @@ -54,7 +54,7 @@ function bigIntN(n: number): ArbitraryWithShrink<bigint> {
*
* Generated values will be between 0 (included) and 2^n (excluded)
*
* @param n Maximal number of bits of the generated bigint
* @param n - Maximal number of bits of the generated bigint
*/
function bigUintN(n: number): ArbitraryWithShrink<bigint> {
return new BigIntArbitrary(BigInt(0), (BigInt(1) << BigInt(n)) - BigInt(1));
Expand All @@ -67,8 +67,8 @@ function bigInt(): ArbitraryWithShrink<bigint>;
/**
* For bigint between min (included) and max (included)
*
* @param min Lower bound for the generated integers (eg.: 0n, BigInt(Number.MIN_SAFE_INTEGER))
* @param max Upper bound for the generated integers (eg.: 2147483647n, BigInt(Number.MAX_SAFE_INTEGER))
* @param min - Lower bound for the generated integers (eg.: 0n, BigInt(Number.MIN_SAFE_INTEGER))
* @param max - Upper bound for the generated integers (eg.: 2147483647n, BigInt(Number.MAX_SAFE_INTEGER))
*/
function bigInt(min: bigint, max: bigint): ArbitraryWithShrink<bigint>;
function bigInt(min?: bigint, max?: bigint): ArbitraryWithShrink<bigint> {
Expand All @@ -81,7 +81,7 @@ function bigInt(min?: bigint, max?: bigint): ArbitraryWithShrink<bigint> {
function bigUint(): ArbitraryWithShrink<bigint>;
/**
* For positive bigint between 0 (included) and max (included)
* @param max Upper bound for the generated bigint
* @param max - Upper bound for the generated bigint
*/
function bigUint(max: bigint): ArbitraryWithShrink<bigint>;
function bigUint(max?: bigint): ArbitraryWithShrink<bigint> {
Expand Down
6 changes: 3 additions & 3 deletions src/check/arbitrary/ConstantArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConstantArbitrary<T> extends Arbitrary<T> {

/**
* For `value`
* @param value The value to produce
* @param value - The value to produce
*/
function constant<T>(value: T): Arbitrary<T> {
if (hasCloneMethod(value)) {
Expand All @@ -36,7 +36,7 @@ function constant<T>(value: T): Arbitrary<T> {

/**
* For `value`
* @param value The value to produce
* @param value - The value to produce
*/
function clonedConstant<T>(value: T): Arbitrary<T> {
if (hasCloneMethod(value)) {
Expand All @@ -51,7 +51,7 @@ function clonedConstant<T>(value: T): Arbitrary<T> {
*
* **WARNING**: It expects at least one value, otherwise it should throw
*
* @param values Constant values to be produced (all values shrink to the first one)
* @param values - Constant values to be produced (all values shrink to the first one)
*/
function constantFrom<T>(...values: T[]): Arbitrary<T> {
if (values.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/check/arbitrary/ContextArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface Context {
/**
* Log execution details during a test.
* Very helpful when troubleshooting failures
* @param data Data to be logged into the current context
* @param data - Data to be logged into the current context
*/
log(data: string): void;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/check/arbitrary/DedupArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ type TupleOf<T, N extends number> = N extends 0
* Deduplicate the values generated by `arb`
* in order to produce fully equal values
*
* @param arb Source arbitrary
* @param numValues Number of values to produce
* @param arb - Source arbitrary
* @param numValues - Number of values to produce
*/
function dedup<T, N extends number>(arb: Arbitrary<T>, numValues: N): Arbitrary<TupleOf<T, N>>;
function dedup<T>(arb: Arbitrary<T>, numValues: number): Arbitrary<T[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/check/arbitrary/DictionaryArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function toObject<T>(items: [string, T][]): { [key: string]: T } {

/**
* For dictionaries with keys produced by `keyArb` and values from `valueArb`
* @param keyArb Arbitrary used to generate the keys of the object
* @param valueArb Arbitrary used to generate the values of the object
* @param keyArb - Arbitrary used to generate the keys of the object
* @param valueArb - Arbitrary used to generate the values of the object
*/
function dictionary<T>(keyArb: Arbitrary<string>, valueArb: Arbitrary<T>): Arbitrary<Record<string, T>> {
return set(tuple(keyArb, valueArb), (t1, t2) => t1[0] === t2[0]).map(toObject);
Expand Down
12 changes: 6 additions & 6 deletions src/check/arbitrary/FloatingPointArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const floatInternal = (): Arbitrary<number> => {
function float(): Arbitrary<number>;
/**
* For floating point numbers between 0.0 (included) and max (excluded) - accuracy of `max / 2**24`
* @param max Upper bound of the generated floating point
* @param max - Upper bound of the generated floating point
*/
function float(max: number): Arbitrary<number>;
/**
* For floating point numbers between min (included) and max (excluded) - accuracy of `(max - min) / 2**24`
* @param min Lower bound of the generated floating point
* @param max Upper bound of the generated floating point
* @param min - Lower bound of the generated floating point
* @param max - Upper bound of the generated floating point
*/
function float(min: number, max: number): Arbitrary<number>;
function float(a?: number, b?: number): Arbitrary<number> {
Expand All @@ -49,13 +49,13 @@ const doubleInternal = (): Arbitrary<number> => {
function double(): Arbitrary<number>;
/**
* For floating point numbers between 0.0 (included) and max (excluded) - accuracy of `max / 2**53`
* @param max Upper bound of the generated floating point
* @param max - Upper bound of the generated floating point
*/
function double(max: number): Arbitrary<number>;
/**
* For floating point numbers between min (included) and max (excluded) - accuracy of `(max - min) / 2**53`
* @param min Lower bound of the generated floating point
* @param max Upper bound of the generated floating point
* @param min - Lower bound of the generated floating point
* @param max - Upper bound of the generated floating point
*/
function double(min: number, max: number): Arbitrary<number>;
function double(a?: number, b?: number): Arbitrary<number> {
Expand Down
2 changes: 1 addition & 1 deletion src/check/arbitrary/FrequencyArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type FrequencyArbitraryType<Ts extends WeightedArbitrary<unknown>[]> = {
*
* **WARNING**: It expects at least one (Arbitrary, weight)
*
* @param warbs (Arbitrary, weight)s that might be called to produce a value
* @param warbs - (Arbitrary, weight)s that might be called to produce a value
*/
function frequency<Ts extends WeightedArbitrary<unknown>[]>(...warbs: Ts): Arbitrary<FrequencyArbitraryType<Ts>> {
if (warbs.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/check/arbitrary/FunctionArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { tuple } from './TupleArbitrary';
/**
* For pure functions
*
* @param arb Arbitrary responsible to produce the values
* @param arb - Arbitrary responsible to produce the values
*/
export function func<TArgs extends any[], TOut>(arb: Arbitrary<TOut>): Arbitrary<(...args: TArgs) => TOut> {
return tuple(array(arb, 1, 10), integer().noShrink()).map(([outs, seed]) => {
Expand Down
8 changes: 4 additions & 4 deletions src/check/arbitrary/IntegerArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class IntegerArbitrary extends ArbitraryWithShrink<number> {
function integer(): ArbitraryWithShrink<number>;
/**
* For integers between -2147483648 (included) and max (included)
* @param max Upper bound for the generated integers (eg.: 2147483647, Number.MAX_SAFE_INTEGER)
* @param max - Upper bound for the generated integers (eg.: 2147483647, Number.MAX_SAFE_INTEGER)
*/
function integer(max: number): ArbitraryWithShrink<number>;
/**
* For integers between min (included) and max (included)
*
* @param min Lower bound for the generated integers (eg.: 0, Number.MIN_SAFE_INTEGER)
* @param max Upper bound for the generated integers (eg.: 2147483647, Number.MAX_SAFE_INTEGER)
* @param min - Lower bound for the generated integers (eg.: 0, Number.MIN_SAFE_INTEGER)
* @param max - Upper bound for the generated integers (eg.: 2147483647, Number.MAX_SAFE_INTEGER)
*/
function integer(min: number, max: number): ArbitraryWithShrink<number>;
function integer(a?: number, b?: number): ArbitraryWithShrink<number> {
Expand All @@ -77,7 +77,7 @@ function maxSafeInteger(): ArbitraryWithShrink<number> {
function nat(): ArbitraryWithShrink<number>;
/**
* For positive integers between 0 (included) and max (included)
* @param max Upper bound for the generated integers
* @param max - Upper bound for the generated integers
*/
function nat(max: number): ArbitraryWithShrink<number>;
function nat(a?: number): ArbitraryWithShrink<number> {
Expand Down
2 changes: 1 addition & 1 deletion src/check/arbitrary/LetRecArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function updateLazy(
* })); // tree is 1 / 3 of node, 2 / 3 of leaf
* ```
*
* @param builder Arbitraries builder based on themselves (through `tie`)
* @param builder - Arbitraries builder based on themselves (through `tie`)
*/
export function letrec<T>(
builder: (tie: (key: string) => Arbitrary<unknown>) => { [K in keyof T]: Arbitrary<T[K]> }
Expand Down
6 changes: 3 additions & 3 deletions src/check/arbitrary/LoremArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ const loremWord = () =>
function lorem(): Arbitrary<string>;
/**
* For lorem ipsum string of words with maximal number of words
* @param maxWordsCount Upper bound of the number of words allowed
* @param maxWordsCount - Upper bound of the number of words allowed
*/
function lorem(maxWordsCount: number): Arbitrary<string>;
/**
* For lorem ipsum string of words or sentences with maximal number of words or sentences
* @param maxWordsCount Upper bound of the number of words/sentences allowed
* @param sentencesMode If enabled, multiple sentences might be generated
* @param maxWordsCount - Upper bound of the number of words/sentences allowed
* @param sentencesMode - If enabled, multiple sentences might be generated
*/
function lorem(maxWordsCount: number, sentencesMode: boolean): Arbitrary<string>;
function lorem(maxWordsCount?: number, sentencesMode?: boolean): Arbitrary<string> {
Expand Down
2 changes: 1 addition & 1 deletion src/check/arbitrary/MapToConstantArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function computeNumChoices<T>(options: { num: number; build: (idInGroup: number)
* Generate non-contiguous ranges of values
* by mapping integer values to constant
*
* @param options Builders to be called to generate the values
* @param options - Builders to be called to generate the values
*
* @example
* ```
Expand Down
2 changes: 1 addition & 1 deletion src/check/arbitrary/MemoArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ let contextRemainingDepth = 10;
* const leaf = fc.nat;
* ```
*
* @param builder Arbitrary builder taken the maximal depth allowed as input (parameter `n`)
* @param builder - Arbitrary builder taken the maximal depth allowed as input (parameter `n`)
*/
export const memo = <T>(builder: (maxDepth: number) => Arbitrary<T>): Memo<T> => {
const previous: { [depth: number]: Arbitrary<T> } = {};
Expand Down
4 changes: 2 additions & 2 deletions src/check/arbitrary/MixedCaseArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function defaultToggleCase(rawChar: string) {
* Require bigint support.
* Under-the-hood the arbitrary relies on bigint to compute the flags that should be toggled or not.
*
* @param stringArb Arbitrary able to build string values
* @param constraints Constraints to be applied when computing upper/lower case version
* @param stringArb - Arbitrary able to build string values
* @param constraints - Constraints to be applied when computing upper/lower case version
*/
export function mixedCase(stringArb: Arbitrary<string>, constraints?: MixedCaseConstraints): Arbitrary<string> {
if (typeof BigInt === 'undefined') {
Expand Down
12 changes: 6 additions & 6 deletions src/check/arbitrary/ObjectArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function anything(): Arbitrary<unknown>;
* // - [42,42,42]...
* ```
*
* @param settings Constraints to apply when building instances
* @param settings - Constraints to apply when building instances
*/
function anything(settings: ObjectConstraints.Settings): Arbitrary<unknown>;
function anything(settings?: ObjectConstraints.Settings): Arbitrary<unknown> {
Expand All @@ -266,7 +266,7 @@ function object(): Arbitrary<Record<string, unknown>>;
* @example
* ```{} or {k: [{}, 1, 2]}```
*
* @param settings Constraints to apply when building instances
* @param settings - Constraints to apply when building instances
*/
function object(settings: ObjectConstraints.Settings): Arbitrary<Record<string, unknown>>;
function object(settings?: ObjectConstraints.Settings): Arbitrary<Record<string, unknown>> {
Expand All @@ -291,7 +291,7 @@ function jsonObject(): Arbitrary<unknown>;
*
* Keys and string values rely on {@link string}
*
* @param maxDepth Maximal depth of the generated values
* @param maxDepth - Maximal depth of the generated values
*/
function jsonObject(maxDepth: number): Arbitrary<unknown>;
function jsonObject(maxDepth?: number): Arbitrary<unknown> {
Expand All @@ -309,7 +309,7 @@ function unicodeJsonObject(): Arbitrary<unknown>;
*
* Keys and string values rely on {@link unicode}
*
* @param maxDepth Maximal depth of the generated values
* @param maxDepth - Maximal depth of the generated values
*/
function unicodeJsonObject(maxDepth: number): Arbitrary<unknown>;
function unicodeJsonObject(maxDepth?: number): Arbitrary<unknown> {
Expand All @@ -327,7 +327,7 @@ function json(): Arbitrary<string>;
*
* Keys and string values rely on {@link string}
*
* @param maxDepth Maximal depth of the generated objects
* @param maxDepth - Maximal depth of the generated objects
*/
function json(maxDepth: number): Arbitrary<string>;
function json(maxDepth?: number): Arbitrary<string> {
Expand All @@ -346,7 +346,7 @@ function unicodeJson(): Arbitrary<string>;
*
* Keys and string values rely on {@link unicode}
*
* @param maxDepth Maximal depth of the generated objects
* @param maxDepth - Maximal depth of the generated objects
*/
function unicodeJson(maxDepth: number): Arbitrary<string>;
function unicodeJson(maxDepth?: number): Arbitrary<string> {
Expand Down
Loading

0 comments on commit ebb6b9e

Please sign in to comment.