npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fantasy-check

v0.3.2

Published

QuickCheck library for Javascript using Fantasy-Land

Downloads

3,084

Readme

Fantasy Check

Build Status Dependencies Status

General

QuickCheck is a form of automated specification testing. Instead of manually writing tests cases like so:

   assert(0 + 1 == 1);
   assert(1 + 1 == 2);
   assert(3 + 3 == 6);

We can just write the assertion algebraically and tell QuickCheck to automatically generate lots of inputs:

   λ.forAll(
       function(n) {
           return n + n == 2 * n;
       },
       [Number]
   ).fold(
       function(fail) {
           return "Failed after " + fail.tries + " tries: " + fail.inputs.toString();
       },
       "All tests passed!",
   )

Laws

Fantasy Check allows the easy testing of various laws whilst being unit testing framework agnostic.

Assuming you're using Fantasy Identities and a adapter from the adapters package with the unit testing framework.

Functors

The functor check has 2 different laws which allow you to test the mapping of tagged types. Note - it should be possible to test functions as well, by providing a map (aka compose) for the function type.

  • Identity
  • Composition
exports.law1 = functor.identity(λ)(Identity.of);
exports.law2 = functor.composition(λ)(Identity.of);

Applicative Functors

The applicative functor check has 4 different laws which allow you to test:

  • Identity
  • Composition
  • Homomorphism
  • Interchange
exports.law1 = functor.identity(λ)(Identity);
exports.law2 = functor.composition(λ)(Identity);
exports.law3 = functor.homomorphism(λ)(Identity);
exports.law4 = functor.interchange(λ)(Identity);

Monads

The monad check has 3 different laws which allow you to test:

  • Left Identity
  • Right Identity
  • Associativity
exports.law1 = functor.leftIdentity(λ)(Identity);
exports.law2 = functor.rightIdentity(λ)(Identity);
exports.law3 = functor.associativity(λ)(Identity);

Testing

Library

Fantasy Check uses nodeunit for all the tests and because of this there is currently an existing adapter in the library to help with integration between nodeunit and Fantasy Check.

Coverage

Currently Fantasy Check is using Istanbul for code coverage analysis; you can run the coverage via the following command:

This assumes that you have istanbul installed correctly.

istanbul cover nodeunit -- test/*.js

It should report that the total coverage is at 100% for the whole lib.