fp-ts-quickcheck
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -76,4 +76,9 @@ import { Applicative1 } from "fp-ts/lib/Applicative"; | ||
*/ | ||
export declare function int(options: Partial<Record<"min" | "max", number>>): Arbitrary<number>; | ||
export declare function int(options?: Partial<Record<"min" | "max", number>>): Arbitrary<number>; | ||
/** | ||
* @category Constructors | ||
*/ | ||
export declare function float(options?: Partial<Record<"min" | "max", number>>): Arbitrary<number>; | ||
export declare type StringParams = Partial<Record<"from" | "to", string>>; | ||
/** | ||
* @summary | ||
@@ -84,10 +89,31 @@ * Generate a single character string. | ||
*/ | ||
export declare const character: (options?: Partial<Record<"from" | "to", string>>) => Arbitrary<string>; | ||
export declare const character: (options?: StringParams) => Arbitrary<string>; | ||
/** | ||
* @category Constructors | ||
*/ | ||
export declare const string: (options?: Partial<Record<"from" | "to", string>>) => Arbitrary<string>; | ||
export declare const string: (options?: StringParams) => Arbitrary<string>; | ||
/** | ||
* Allow generating arbitraries of `T` or `null`. | ||
* | ||
* @category Combinators | ||
*/ | ||
export declare const nullable: <T>(arbitrary: Arbitrary<T>) => Arbitrary<T | null>; | ||
/** | ||
* Creates an arbitrary as a struct that optionally defines properties. | ||
* | ||
* @category Combinators | ||
*/ | ||
export declare function partial<T extends Record<string, unknown>>(arbitraries: { | ||
[P in keyof T]: Arbitrary<T[P]>; | ||
}): Arbitrary<Partial<T>>; | ||
/** | ||
* Allows use of an arbitrary that is used after the current arbitrary is defined. | ||
* Useful for recursive patterns. | ||
* | ||
* @category Combinators | ||
* @example | ||
* const y = AR.lazy(() => x) | ||
* const x = AR.of(constVoid()) | ||
* // now y can use x without it being unreachable code | ||
*/ | ||
export declare function lazy<A>(lazy: Lazy<Arbitrary<A>>): Arbitrary<A>; | ||
@@ -111,3 +137,3 @@ /** | ||
/** | ||
* Generates an array with a fixed size, then each has the random contents.s | ||
* Generates an array with a fixed size, then each has the random contents. | ||
* @category Combinators | ||
@@ -151,6 +177,3 @@ */ | ||
*/ | ||
export declare const number: Arbitrary<number>; | ||
/** | ||
* @category Primitives | ||
*/ | ||
export declare const boolean: Arbitrary<boolean>; | ||
export declare function stringNonempty(options?: StringParams): Arbitrary<string>; |
@@ -39,3 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.boolean = exports.number = exports.toGen = exports.union = exports.struct = exports.tuple = exports.mutable = exports.readonly = exports.vector = exports.array = exports.filter = exports.lazy = exports.string = exports.character = exports.int = exports.fromGen = exports.Chain = exports.Applicative = exports.Apply = exports.Functor = exports.Pointed = exports.chain = exports.ap = exports.map = exports.of = exports.URI = void 0; | ||
exports.stringNonempty = exports.boolean = exports.toGen = exports.union = exports.struct = exports.tuple = exports.mutable = exports.readonly = exports.vector = exports.array = exports.filter = exports.lazy = exports.partial = exports.nullable = exports.string = exports.character = exports.float = exports.int = exports.fromGen = exports.Chain = exports.Applicative = exports.Apply = exports.Functor = exports.Pointed = exports.chain = exports.ap = exports.map = exports.of = exports.URI = void 0; | ||
/** | ||
@@ -122,2 +122,9 @@ * The `Arbitrary` typeclass represents a value that can be generated and shrunk. | ||
/** | ||
* @category Constructors | ||
*/ | ||
function float(options) { | ||
return { arbitrary: modules_1.generator.float(options) }; | ||
} | ||
exports.float = float; | ||
/** | ||
* @summary | ||
@@ -135,4 +142,31 @@ * Generate a single character string. | ||
/** | ||
* Allow generating arbitraries of `T` or `null`. | ||
* | ||
* @category Combinators | ||
*/ | ||
var nullable = function (arbitrary) { return union(arbitrary, (0, exports.of)(null)); }; | ||
exports.nullable = nullable; | ||
/** | ||
* Creates an arbitrary as a struct that optionally defines properties. | ||
* | ||
* @category Combinators | ||
*/ | ||
function partial(arbitraries) { | ||
return { | ||
arbitrary: (0, function_1.pipe)(fp_ts_2.state.get(), fp_ts_2.state.map(function (s) { | ||
return (0, function_1.pipe)(arbitraries, fp_ts_1.readonlyRecord.fromRecord, fp_ts_1.readonlyRecord.map((0, function_1.flow)(exports.nullable, toGen, fp_ts_2.state.evaluate(s))), fp_ts_1.readonlyRecord.filterMap(fp_ts_1.option.fromNullable), function (a) { return (0, function_1.unsafeCoerce)(a); }); | ||
})), | ||
}; | ||
} | ||
exports.partial = partial; | ||
/** | ||
* Allows use of an arbitrary that is used after the current arbitrary is defined. | ||
* Useful for recursive patterns. | ||
* | ||
* @category Combinators | ||
* @example | ||
* const y = AR.lazy(() => x) | ||
* const x = AR.of(constVoid()) | ||
* // now y can use x without it being unreachable code | ||
*/ | ||
function lazy(lazy) { | ||
@@ -163,3 +197,3 @@ return { arbitrary: function (s) { return lazy().arbitrary(s); } }; | ||
/** | ||
* Generates an array with a fixed size, then each has the random contents.s | ||
* Generates an array with a fixed size, then each has the random contents. | ||
* @category Combinators | ||
@@ -228,13 +262,8 @@ */ | ||
*/ | ||
exports.number = { | ||
arbitrary: modules_1.generator.int({ | ||
min: Number.MAX_SAFE_INTEGER, | ||
max: Number.MAX_SAFE_INTEGER, | ||
}), | ||
}; | ||
/** | ||
* @category Primitives | ||
*/ | ||
exports.boolean = { | ||
arbitrary: modules_1.generator.boolean, | ||
}; | ||
function stringNonempty(options) { | ||
return (0, function_1.pipe)((0, exports.string)(options), filter(function (string) { return string.length > 0; })); | ||
} | ||
exports.stringNonempty = stringNonempty; |
@@ -5,1 +5,2 @@ export * as state from "./state"; | ||
export * as stateTask from "./state-task"; | ||
export * as io from "./io"; |
@@ -22,3 +22,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stateTask = exports.task = exports.stateT = exports.state = void 0; | ||
exports.io = exports.stateTask = exports.task = exports.stateT = exports.state = void 0; | ||
exports.state = __importStar(require("./state")); | ||
@@ -28,1 +28,2 @@ exports.stateT = __importStar(require("./stateT")); | ||
exports.stateTask = __importStar(require("./state-task")); | ||
exports.io = __importStar(require("./io")); |
import { task as T } from "fp-ts"; | ||
import { ChainRec1 } from "fp-ts/lib/ChainRec"; | ||
import { MonadRecIO1 } from "../monad-rec-io"; | ||
export * from "fp-ts/Task"; | ||
export declare const ChainRec: ChainRec1<T.URI>; | ||
export declare const MonadRecIO: MonadRecIO1<T.URI>; |
@@ -24,3 +24,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ChainRec = void 0; | ||
exports.MonadRecIO = exports.ChainRec = void 0; | ||
var fp_ts_1 = require("fp-ts"); | ||
@@ -30,1 +30,2 @@ var utils_1 = require("../../utils"); | ||
exports.ChainRec = __assign(__assign({}, fp_ts_1.task.Chain), { chainRec: function (fa, f) { return (0, utils_1.tailRecM)(fp_ts_1.task.Monad)(f)(fp_ts_1.task.of(fa)); } }); | ||
exports.MonadRecIO = __assign(__assign(__assign({}, exports.ChainRec), fp_ts_1.task.FromIO), fp_ts_1.task.Pointed); |
export * as iterable from "./iterable"; | ||
export * as generator from "./generator"; | ||
export * as lcg from "./lcg"; | ||
export * as monadRecIO from "./monad-rec-io"; |
@@ -22,5 +22,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lcg = exports.generator = exports.iterable = void 0; | ||
exports.monadRecIO = exports.lcg = exports.generator = exports.iterable = void 0; | ||
exports.iterable = __importStar(require("./iterable")); | ||
exports.generator = __importStar(require("./generator")); | ||
exports.lcg = __importStar(require("./lcg")); | ||
exports.monadRecIO = __importStar(require("./monad-rec-io")); |
@@ -10,14 +10,2 @@ /** | ||
*/ | ||
import { io as IO } from "fp-ts"; | ||
import { task as T } from "../modules/fp-ts"; | ||
export interface QuickCheckOptions { | ||
readonly initialSeed: number; | ||
readonly count: number; | ||
readonly size: number; | ||
} | ||
export declare type InitialQuickCheckOptions = Partial<QuickCheckOptions>; | ||
export declare const defaults: QuickCheckOptions; | ||
export declare const assertIO: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => void, options?: Partial<QuickCheckOptions> | undefined) => IO.IO<void>; | ||
export declare const unsafeAssertSync: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => void, options?: Partial<QuickCheckOptions> | undefined) => void; | ||
export declare const assertTask: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => import("../testable").Assertion, options?: Partial<QuickCheckOptions> | undefined) => T.Task<void>; | ||
export declare const unsafeAssertAsync: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => import("../testable").Assertion, options?: Partial<QuickCheckOptions> | undefined) => Promise<void>; | ||
export { sync, async, io, task, quickcheckOptionsDefault, mk } from "./assert"; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unsafeAssertAsync = exports.assertTask = exports.unsafeAssertSync = exports.assertIO = exports.defaults = void 0; | ||
/** | ||
@@ -24,23 +11,10 @@ * @summary | ||
*/ | ||
var fp_ts_1 = require("fp-ts"); | ||
var function_1 = require("fp-ts/lib/function"); | ||
var fp_ts_2 = require("../modules/fp-ts"); | ||
var testable_1 = require("../testable"); | ||
var make_assert_1 = require("./make-assert"); | ||
exports.defaults = { | ||
count: 100, | ||
initialSeed: 100, | ||
size: 10, | ||
}; | ||
exports.assertIO = (0, make_assert_1.makeAssert)({ | ||
Testable: testable_1.assertionSync, | ||
MonadRecIO: __assign(__assign(__assign({}, fp_ts_1.io.ChainRec), fp_ts_1.io.FromIO), fp_ts_1.io.Pointed), | ||
defaults: exports.defaults, | ||
}); | ||
exports.unsafeAssertSync = (0, function_1.flow)(exports.assertIO, function (io) { return io(); }); | ||
exports.assertTask = (0, make_assert_1.makeAssert)({ | ||
MonadRecIO: __assign(__assign(__assign({}, fp_ts_2.task.ChainRec), fp_ts_2.task.FromIO), fp_ts_2.task.Pointed), | ||
Testable: testable_1.assertion, | ||
defaults: exports.defaults, | ||
}); | ||
exports.unsafeAssertAsync = (0, function_1.flow)(exports.assertTask, function (a) { return a(); }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mk = exports.quickcheckOptionsDefault = exports.task = exports.io = exports.async = exports.sync = void 0; | ||
var assert_1 = require("./assert"); | ||
Object.defineProperty(exports, "sync", { enumerable: true, get: function () { return assert_1.sync; } }); | ||
Object.defineProperty(exports, "async", { enumerable: true, get: function () { return assert_1.async; } }); | ||
Object.defineProperty(exports, "io", { enumerable: true, get: function () { return assert_1.io; } }); | ||
Object.defineProperty(exports, "task", { enumerable: true, get: function () { return assert_1.task; } }); | ||
Object.defineProperty(exports, "quickcheckOptionsDefault", { enumerable: true, get: function () { return assert_1.quickcheckOptionsDefault; } }); | ||
Object.defineProperty(exports, "mk", { enumerable: true, get: function () { return assert_1.mk; } }); |
import { URIS } from "fp-ts/HKT"; | ||
import { Monad, Monad1 } from "fp-ts/lib/Monad"; | ||
import * as ls from "../loopstate"; | ||
import * as ls from "./loopstate"; | ||
import { stateT as ST } from "../modules/fp-ts"; | ||
@@ -5,0 +5,0 @@ import { TestOptions, TestOptions1 } from "./test"; |
@@ -36,3 +36,3 @@ "use strict"; | ||
var function_1 = require("fp-ts/lib/function"); | ||
var ls = __importStar(require("../loopstate")); | ||
var ls = __importStar(require("./loopstate")); | ||
var fp_ts_2 = require("../modules/fp-ts"); | ||
@@ -39,0 +39,0 @@ var test_1 = require("./test"); |
import { HKT, Kind, URIS } from "fp-ts/HKT"; | ||
import { ChainRec, ChainRec1 } from "fp-ts/lib/ChainRec"; | ||
import { Pointed, Pointed1 } from "fp-ts/lib/Pointed"; | ||
import { QuickCheckOptions } from "."; | ||
import * as ls from "../loopstate"; | ||
import { QuickCheckOptions } from "./assert"; | ||
import * as ls from "./loopstate"; | ||
import { LoopOptions, LoopOptions1 } from "./loop"; | ||
@@ -7,0 +7,0 @@ export interface TestsOptions<F, I, A> extends LoopOptions<F, I, A>, QuickCheckOptions { |
@@ -48,3 +48,3 @@ "use strict"; | ||
var function_1 = require("fp-ts/lib/function"); | ||
var ls = __importStar(require("../loopstate")); | ||
var ls = __importStar(require("./loopstate")); | ||
var fp_ts_2 = require("../modules/fp-ts"); | ||
@@ -51,0 +51,0 @@ var loop_1 = require("./loop"); |
import { identity as I, io as IO, option as O, task as T } from "fp-ts"; | ||
import { HKT, Kind, URIS } from "fp-ts/HKT"; | ||
import { HKT, Kind, Kind2, URIS, URIS2 } from "fp-ts/HKT"; | ||
export declare type Result = O.Option<unknown>; | ||
@@ -10,2 +10,5 @@ export interface Testable<F, A> { | ||
} | ||
export interface Testable2<F extends URIS2, E, A> { | ||
readonly test: <I>(value: I) => (property: (value: I) => A) => Kind2<F, E, Result>; | ||
} | ||
export declare const boolean: Testable1<I.URI, boolean>; | ||
@@ -12,0 +15,0 @@ export declare const assertionSync: Testable1<IO.URI, void>; |
@@ -76,4 +76,9 @@ import { Applicative1 } from "fp-ts/lib/Applicative"; | ||
*/ | ||
export declare function int(options: Partial<Record<"min" | "max", number>>): Arbitrary<number>; | ||
export declare function int(options?: Partial<Record<"min" | "max", number>>): Arbitrary<number>; | ||
/** | ||
* @category Constructors | ||
*/ | ||
export declare function float(options?: Partial<Record<"min" | "max", number>>): Arbitrary<number>; | ||
export declare type StringParams = Partial<Record<"from" | "to", string>>; | ||
/** | ||
* @summary | ||
@@ -84,10 +89,31 @@ * Generate a single character string. | ||
*/ | ||
export declare const character: (options?: Partial<Record<"from" | "to", string>>) => Arbitrary<string>; | ||
export declare const character: (options?: StringParams) => Arbitrary<string>; | ||
/** | ||
* @category Constructors | ||
*/ | ||
export declare const string: (options?: Partial<Record<"from" | "to", string>>) => Arbitrary<string>; | ||
export declare const string: (options?: StringParams) => Arbitrary<string>; | ||
/** | ||
* Allow generating arbitraries of `T` or `null`. | ||
* | ||
* @category Combinators | ||
*/ | ||
export declare const nullable: <T>(arbitrary: Arbitrary<T>) => Arbitrary<T | null>; | ||
/** | ||
* Creates an arbitrary as a struct that optionally defines properties. | ||
* | ||
* @category Combinators | ||
*/ | ||
export declare function partial<T extends Record<string, unknown>>(arbitraries: { | ||
[P in keyof T]: Arbitrary<T[P]>; | ||
}): Arbitrary<Partial<T>>; | ||
/** | ||
* Allows use of an arbitrary that is used after the current arbitrary is defined. | ||
* Useful for recursive patterns. | ||
* | ||
* @category Combinators | ||
* @example | ||
* const y = AR.lazy(() => x) | ||
* const x = AR.of(constVoid()) | ||
* // now y can use x without it being unreachable code | ||
*/ | ||
export declare function lazy<A>(lazy: Lazy<Arbitrary<A>>): Arbitrary<A>; | ||
@@ -111,3 +137,3 @@ /** | ||
/** | ||
* Generates an array with a fixed size, then each has the random contents.s | ||
* Generates an array with a fixed size, then each has the random contents. | ||
* @category Combinators | ||
@@ -151,6 +177,3 @@ */ | ||
*/ | ||
export declare const number: Arbitrary<number>; | ||
/** | ||
* @category Primitives | ||
*/ | ||
export declare const boolean: Arbitrary<boolean>; | ||
export declare function stringNonempty(options?: StringParams): Arbitrary<string>; |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import { either as E, nonEmptyArray as NEA } from "fp-ts"; | ||
import { either as E, nonEmptyArray as NEA, option as O, readonlyRecord as RC, } from "fp-ts"; | ||
import { sequenceS, sequenceT } from "fp-ts/lib/Apply"; | ||
@@ -77,2 +77,8 @@ import { flow, identity, pipe, unsafeCoerce } from "fp-ts/lib/function"; | ||
/** | ||
* @category Constructors | ||
*/ | ||
export function float(options) { | ||
return { arbitrary: gen.float(options) }; | ||
} | ||
/** | ||
* @summary | ||
@@ -90,4 +96,27 @@ * Generate a single character string. | ||
/** | ||
* Allow generating arbitraries of `T` or `null`. | ||
* | ||
* @category Combinators | ||
*/ | ||
export const nullable = (arbitrary) => union(arbitrary, of(null)); | ||
/** | ||
* Creates an arbitrary as a struct that optionally defines properties. | ||
* | ||
* @category Combinators | ||
*/ | ||
export function partial(arbitraries) { | ||
return { | ||
arbitrary: pipe(S.get(), S.map((s) => pipe(arbitraries, RC.fromRecord, RC.map(flow(nullable, toGen, S.evaluate(s))), RC.filterMap(O.fromNullable), (a) => unsafeCoerce(a)))), | ||
}; | ||
} | ||
/** | ||
* Allows use of an arbitrary that is used after the current arbitrary is defined. | ||
* Useful for recursive patterns. | ||
* | ||
* @category Combinators | ||
* @example | ||
* const y = AR.lazy(() => x) | ||
* const x = AR.of(constVoid()) | ||
* // now y can use x without it being unreachable code | ||
*/ | ||
export function lazy(lazy) { | ||
@@ -113,3 +142,3 @@ return { arbitrary: (s) => lazy().arbitrary(s) }; | ||
/** | ||
* Generates an array with a fixed size, then each has the random contents.s | ||
* Generates an array with a fixed size, then each has the random contents. | ||
* @category Combinators | ||
@@ -165,13 +194,7 @@ */ | ||
*/ | ||
export const number = { | ||
arbitrary: gen.int({ | ||
min: Number.MAX_SAFE_INTEGER, | ||
max: Number.MAX_SAFE_INTEGER, | ||
}), | ||
}; | ||
/** | ||
* @category Primitives | ||
*/ | ||
export const boolean = { | ||
arbitrary: gen.boolean, | ||
}; | ||
export function stringNonempty(options) { | ||
return pipe(string(options), filter((string) => string.length > 0)); | ||
} |
@@ -5,1 +5,2 @@ export * as state from "./state"; | ||
export * as stateTask from "./state-task"; | ||
export * as io from "./io"; |
@@ -9,1 +9,3 @@ import * as state_1 from "./state"; | ||
export { stateTask_1 as stateTask }; | ||
import * as io_1 from "./io"; | ||
export { io_1 as io }; |
import { task as T } from "fp-ts"; | ||
import { ChainRec1 } from "fp-ts/lib/ChainRec"; | ||
import { MonadRecIO1 } from "../monad-rec-io"; | ||
export * from "fp-ts/Task"; | ||
export declare const ChainRec: ChainRec1<T.URI>; | ||
export declare const MonadRecIO: MonadRecIO1<T.URI>; |
@@ -5,1 +5,2 @@ import { task as T } from "fp-ts"; | ||
export const ChainRec = Object.assign(Object.assign({}, T.Chain), { chainRec: (fa, f) => tailRecM(T.Monad)(f)(T.of(fa)) }); | ||
export const MonadRecIO = Object.assign(Object.assign(Object.assign({}, ChainRec), T.FromIO), T.Pointed); |
export * as iterable from "./iterable"; | ||
export * as generator from "./generator"; | ||
export * as lcg from "./lcg"; | ||
export * as monadRecIO from "./monad-rec-io"; |
@@ -7,1 +7,3 @@ import * as iterable_1 from "./iterable"; | ||
export { lcg_1 as lcg }; | ||
import * as monadRecIO_1 from "./monad-rec-io"; | ||
export { monadRecIO_1 as monadRecIO }; |
@@ -10,14 +10,2 @@ /** | ||
*/ | ||
import { io as IO } from "fp-ts"; | ||
import { task as T } from "../modules/fp-ts"; | ||
export interface QuickCheckOptions { | ||
readonly initialSeed: number; | ||
readonly count: number; | ||
readonly size: number; | ||
} | ||
export declare type InitialQuickCheckOptions = Partial<QuickCheckOptions>; | ||
export declare const defaults: QuickCheckOptions; | ||
export declare const assertIO: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => void, options?: Partial<QuickCheckOptions> | undefined) => IO.IO<void>; | ||
export declare const unsafeAssertSync: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => void, options?: Partial<QuickCheckOptions> | undefined) => void; | ||
export declare const assertTask: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => import("../testable").Assertion, options?: Partial<QuickCheckOptions> | undefined) => T.Task<void>; | ||
export declare const unsafeAssertAsync: <I>(arbitrary: import("../arbitrary").Arbitrary<I>, property: (value: I) => import("../testable").Assertion, options?: Partial<QuickCheckOptions> | undefined) => Promise<void>; | ||
export { sync, async, io, task, quickcheckOptionsDefault, mk } from "./assert"; |
@@ -10,23 +10,2 @@ /** | ||
*/ | ||
import { io as IO } from "fp-ts"; | ||
import { flow } from "fp-ts/lib/function"; | ||
import { task as T } from "../modules/fp-ts"; | ||
import { assertion, assertionSync } from "../testable"; | ||
import { makeAssert } from "./make-assert"; | ||
export const defaults = { | ||
count: 100, | ||
initialSeed: 100, | ||
size: 10, | ||
}; | ||
export const assertIO = makeAssert({ | ||
Testable: assertionSync, | ||
MonadRecIO: Object.assign(Object.assign(Object.assign({}, IO.ChainRec), IO.FromIO), IO.Pointed), | ||
defaults, | ||
}); | ||
export const unsafeAssertSync = flow(assertIO, (io) => io()); | ||
export const assertTask = makeAssert({ | ||
MonadRecIO: Object.assign(Object.assign(Object.assign({}, T.ChainRec), T.FromIO), T.Pointed), | ||
Testable: assertion, | ||
defaults, | ||
}); | ||
export const unsafeAssertAsync = flow(assertTask, (a) => a()); | ||
export { sync, async, io, task, quickcheckOptionsDefault, mk } from "./assert"; |
import { URIS } from "fp-ts/HKT"; | ||
import { Monad, Monad1 } from "fp-ts/lib/Monad"; | ||
import * as ls from "../loopstate"; | ||
import * as ls from "./loopstate"; | ||
import { stateT as ST } from "../modules/fp-ts"; | ||
@@ -5,0 +5,0 @@ import { TestOptions, TestOptions1 } from "./test"; |
@@ -14,3 +14,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { pipe } from "fp-ts/lib/function"; | ||
import * as ls from "../loopstate"; | ||
import * as ls from "./loopstate"; | ||
import { state as S, stateT as ST } from "../modules/fp-ts"; | ||
@@ -17,0 +17,0 @@ import { test } from "./test"; |
import { HKT, Kind, URIS } from "fp-ts/HKT"; | ||
import { ChainRec, ChainRec1 } from "fp-ts/lib/ChainRec"; | ||
import { Pointed, Pointed1 } from "fp-ts/lib/Pointed"; | ||
import { QuickCheckOptions } from "."; | ||
import * as ls from "../loopstate"; | ||
import { QuickCheckOptions } from "./assert"; | ||
import * as ls from "./loopstate"; | ||
import { LoopOptions, LoopOptions1 } from "./loop"; | ||
@@ -7,0 +7,0 @@ export interface TestsOptions<F, I, A> extends LoopOptions<F, I, A>, QuickCheckOptions { |
@@ -15,3 +15,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
import { constVoid, identity, pipe } from "fp-ts/lib/function"; | ||
import * as ls from "../loopstate"; | ||
import * as ls from "./loopstate"; | ||
import { stateT as ST } from "../modules/fp-ts"; | ||
@@ -18,0 +18,0 @@ import { loop } from "./loop"; |
import { identity as I, io as IO, option as O, task as T } from "fp-ts"; | ||
import { HKT, Kind, URIS } from "fp-ts/HKT"; | ||
import { HKT, Kind, Kind2, URIS, URIS2 } from "fp-ts/HKT"; | ||
export declare type Result = O.Option<unknown>; | ||
@@ -10,2 +10,5 @@ export interface Testable<F, A> { | ||
} | ||
export interface Testable2<F extends URIS2, E, A> { | ||
readonly test: <I>(value: I) => (property: (value: I) => A) => Kind2<F, E, Result>; | ||
} | ||
export declare const boolean: Testable1<I.URI, boolean>; | ||
@@ -12,0 +15,0 @@ export declare const assertionSync: Testable1<IO.URI, void>; |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/fp-ts-quickcheck", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"files": [ | ||
@@ -17,3 +17,2 @@ "dist" | ||
"@typescript-eslint/parser": "^5.14.0", | ||
"docs-ts": "^0.6.10", | ||
"eslint": "^8.11.0", | ||
@@ -24,4 +23,7 @@ "eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-unused-imports": "^2.0.0", | ||
"fast-check": "^2.17.0", | ||
"jest": "^27.2.2", | ||
"jest-runner-eslint": "^1.0.0", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.5.1", | ||
@@ -32,2 +34,3 @@ "standard-version": "^9.3.2", | ||
"tsutils": "^3.21.0", | ||
"typedoc": "^0.22.15", | ||
"typescript": "^4.5.5" | ||
@@ -47,5 +50,6 @@ }, | ||
"test": "jest", | ||
"docs": "docs-ts" | ||
"docs": "typedoc --out docs src/index.ts", | ||
"version": "standard-version" | ||
}, | ||
"readme": "# fp-ts-test\n\nfp-ts port of Haskell's QuickCheck.\n\n> **NOTE**\n> Please note that shrinking is not yet available.\n> Purescript did the same, so this should be enough to get you started.\n> When shrinking is available, it will be transparently added as major release.\n\n## Features\n\n- [x] Purely functional implementation.\n- [x] Compatible - Easily integrates into existing testing frameworks.\n- [x] Polymorphic - Create custom assert functions using fp-ts typeclass instances.\n- [x] Extensible - Simply add compatibilty assertions for data structures\n\n## Installation\n\n```sh\nyarn add -D fp-ts-test\n```\n\n## Quick Start\n\nGrab your favourite test library, in this case `jest`, and put the assertion call of this library into the test caller.\n\n```ts\n// main.ts\nexport function subtract(x: number, y: number) {\n return x - y\n}\n\n// main.spec.ts\nimport { quickcheck as qc, arbitrary as AT } from \"fp-ts-test\"\nimport { expect, it, describe } from \"@jest/globals\"\n\nimport { pipe } from \"fp-ts/function\"\n\nimport { subtract } from \"./main\"\n\ndescribe(subtract, () => {\n const numnum = AT.tuple(AT.number, AT.number)\n\n it(\n \"should always be smaller than the first argument\",\n // returns a thunk by default, because `qc.assert` throws\n qc.assertIO(numnum, ([x, y]) => x > subract(x, y)),\n )\n\n it(\n \"should matter which order the arguments are passed\",\n // returns a thunk by default, because `qc.assert` throws\n qc.assertIO(numnum, ([x, y]) => subtract(y, x) !== subract(x, y)),\n )\n})\n```\n" | ||
} |
158357
90
3936
21