All Projects → typeetfunc → runtypes-generate

typeetfunc / runtypes-generate

Licence: other
Transform runtypes type to jsverify arbitrary for generate sample of data

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to runtypes-generate

rackcheck
A property-based testing library for Racket.
Stars: ✭ 28 (-28.21%)
Mutual labels:  property-based-testing
glados
🍰 A property-based testing framework that tries to break your invariances.
Stars: ✭ 33 (-15.38%)
Mutual labels:  property-based-testing
pbt-frameworks
An overview of property-based testing functionality
Stars: ✭ 29 (-25.64%)
Mutual labels:  property-based-testing
quickcheck
Randomized testing for Prolog à la QuickCheck
Stars: ✭ 18 (-53.85%)
Mutual labels:  property-based-testing
ava-fast-check
Property based testing for AVA based on fast-check
Stars: ✭ 44 (+12.82%)
Mutual labels:  property-based-testing
kuickcheck
A property based testing framework for Kotlin
Stars: ✭ 23 (-41.03%)
Mutual labels:  property-based-testing
Rantly
Ruby Imperative Random Data Generator and Quickcheck
Stars: ✭ 241 (+517.95%)
Mutual labels:  property-based-testing
edd
Erlang Declarative Debugger
Stars: ✭ 20 (-48.72%)
Mutual labels:  property-based-testing
efftester
Effect-Driven Compiler Tester for OCaml
Stars: ✭ 37 (-5.13%)
Mutual labels:  property-based-testing
squire
The medieval language held together by twine.
Stars: ✭ 42 (+7.69%)
Mutual labels:  runtime-typechecking
quick.py
Property-based testing library for Python
Stars: ✭ 15 (-61.54%)
Mutual labels:  property-based-testing
typist-json
A simple runtime JSON type checker.
Stars: ✭ 25 (-35.9%)
Mutual labels:  runtime-typechecking
clausejs
Write contract once. Get data & function validators & conformers, an accurate & readable project contract, auto-generated API documentation, generative test coverage, plus more. A tool that enables a more predictable workflow for developing your JavaScript projects.
Stars: ✭ 29 (-25.64%)
Mutual labels:  property-based-testing
piggy
Test for spec compatibility and breaking changes.
Stars: ✭ 45 (+15.38%)
Mutual labels:  property-based-testing
python-autoclass
A python 3 library providing functions and decorators to automatically generate class code, such as constructor body or properties getters/setters along with optional support of validation contracts on the generated setters. Its objective is to reduce the amount of copy/paste code in your classes - and hence to help reducing human mistakes :).
Stars: ✭ 30 (-23.08%)
Mutual labels:  runtime-typechecking
Fuzzcheck Rs
Structure-aware, in-process, coverage-guided, evolutionary fuzzing engine for Rust functions.
Stars: ✭ 247 (+533.33%)
Mutual labels:  property-based-testing
kitimat
A library for generative, property-based testing in TypeScript and Jest.
Stars: ✭ 68 (+74.36%)
Mutual labels:  property-based-testing
jsf
Creates fake JSON files from a JSON schema
Stars: ✭ 46 (+17.95%)
Mutual labels:  property-based-testing
hypothesis-gufunc
Extension to hypothesis for testing numpy general universal functions
Stars: ✭ 32 (-17.95%)
Mutual labels:  property-based-testing
extrapolate
generalize counter-examples of property-based testing
Stars: ✭ 13 (-66.67%)
Mutual labels:  property-based-testing

Runtypes-generate

standard-readme compliant npm version

Runtypes-generate convert runtypes type to jsverify arbitrary.

Table of Contents

Background

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:

import { Number, Literal, Array, Tuple, Record } from 'runtypes'
const AsteroidType = Record({
    type: Literal('asteroid'),
    location: Tuple(Number, Number, Number),
    mass: Number,
})

const AsteroidArbitrary = jsc.record({
    type: jsc.constant('asteroid'),
    location: jsc.tuple(jsc.number, jsc.number, jsc.number),
    mass: jsc.number
})

But with runtypes-generate we can get AsteroidArbitrary from AsteroidType:

import { makeJsverifyArbitrary } from 'runtypes-generate'
const AsteroidType = Record({
    type: Literal('asteroid'),
    location: Tuple(Number, Number, Number),
    mass: Number,
})
const AsteroidArbitrary = makeJsverifyArbitrary(AsteroidType)

Install

npm install --save runtypes-generate

Usage

API

  • makeJsverifyArbitrary(type: Reflect): jsc.Arbitrary<any> - convert runtypes to jsverify arbitrary
  • addTypeToRegistry(tag: string, (x:Reflect) => jsc.Arbitrary<any>): void - add new generator for Constraint type with tag in args attribute
  • addTypeToIntersectRegistry(tags: string[], generator: (x: Reflect) => jsc.Arbitrary<any>): void) - add new generator for Intersect or custom Constraint types. TODO example
  • generateAndCheck(rt: Reflect, opts?: jsc.Options): () => void - run jsc.assert for property rt.check(generatedData) for all generatedData obtained from makeJsverifyArbitrary(rt). Uses for verification custom generators for custom Constraint type. See example in tests.

Contribute

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.

License

MIT © typeetfunc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].