Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fp-ts-quickcheck

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fp-ts-quickcheck

  • 0.1.0
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

fp-ts-test

fp-ts port of Haskell's QuickCheck.

NOTE Please note that shrinking is not yet available. Purescript did the same, so this should be enough to get you started. When shrinking is available, it will be transparently added as major release.

Features

  • Purely functional implementation.
  • Compatible - Easily integrates into existing testing frameworks.
  • Polymorphic - Create custom assert functions using fp-ts typeclass instances.
  • Extensible - Simply add compatibilty assertions for data structures

Installation

yarn add fp-ts && yarn add -D fp-ts-test

Quick Start

Grab your favourite test library, in this case jest, and put the assertion call of this library into the test caller.

// main.ts
export function subtract(x: number, y: number) {
  return x - y
}

// main.spec.ts
import { quickcheck as qc, arbitrary as AT } from "fp-ts-test"
import { expect, it, describe } from "@jest/globals"

import { pipe } from "fp-ts/function"

import { subtract } from "./main"

describe(subtract, () => {
  const arbitrary = AT.tuple(AT.number, AT.number)

  it(
    "should always be smaller than the first argument",
    pipe(
      arbitrary,
      // returns a thunk by default, because `qc.assert` throws
      qc.assert(([x, y]) => x > subract(x, y)),
    ),
  )

  it(
    "should matter which order the arguments are passed",
    pipe(
      arbitrary,
      // returns a thunk by default, because `qc.assert` throws
      qc.assert(([x, y]) => subtract(y, x) !== subract(x, y)),
    ),
  )
})

FAQs

Package last updated on 28 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc