Integrate tcomb with property-based testing
npm install tcomb-generate

tcomb-generate convert tcomb type to jsverify arbitrary.
- Background
- Install
- Usage
- API
- Contribute
- License
Property-based testing is very awesome approach for analyze and verification program. But this approach requires the writing of generators for all datatypes in our program. This process is very time-consuming, error-prone and not DRY.
Example:
``js
import * as t from 'tcomb'
const AsteroidType = t.interface({
type: t.enums.of('asteroid'),
location: t.tuple([t.Number, t.Number, t.Number]),
mass: t.Number,
})
const AsteroidArbitrary = jsc.record({
type: jsc.constant('asteroid'),
location: jsc.tuple(jsc.number, jsc.number, jsc.number),
mass: jsc.number
})
`
But with tcomb-generate we can get AsteroidArbitrary from AsteroidType:
`js`
import { makeJsverifyArbitrary } from 'tcomb-generate'
const AsteroidType = t.interface({
type: t.enums.of('asteroid'),
location: t.tuple([t.Number, t.Number, t.Number]),
mass: t.Number,
})
const AsteroidArbitrary = makeJsverifyArbitrary(AsteroidType)
``
npm install --save tcomb-generate
- Base tcomb type and combinator
- Refinement tcomb type
- makeJsverifyArbitrary(type: Type - convert tcomb type to jsverify arbitraryaddTypeToRegistry(name: string, (x: Type
- - add new generator for type with nameaddTypeToIntersectRegistry(names: string[], generator: (x: Type
- - add new generator for custom t.intersection types. TODO examplegenerateAndCheck(rt: Type
- - run jsc.assert for property type.is(generatedData) for all generatedData obtained from makeJsverifyArbitrary(type)`. Uses for verification custom generators for custom named type. See example in tests.
PRs accepted.
If you had questions just make issue or ask them in my telegram
Small note: If editing the Readme, please conform to the standard-readme specification.
MIT © typeetfunc