Package

purescript-flarecheck

Repository
sharkdp/purescript-flarecheck
License
MIT
Uploaded by
sharkdp
Published on
2017-04-15T20:47:42Z

A library to create interactive test suites for PureScript functions.

Usage

Suppose you have written a function

substring :: Int -> Int -> String -> String
substring start end str = take (end - start) (drop start str)

that you want to test. To use FlareCheck, you simply call (the first argument is just a title for the test):

flareCheck "substring" substring

This automatically creates an interactive testing environment (see demo page for a working version) like this:

Notice how the type information is used to create appropriate input fields for Int and String. Similarly, calling

flareCheck "filter even" (filter even)

creates the following interface:

Minimal setup

  • The module that you want to test (src/MyModule.purs):
module MyModule (substring) where

import Prelude
import Data.String

substring :: Int -> Int -> String -> String
substring start end str = take (end - start) (drop start str)
  • A module which runs the tests (test/Main.purs):
module Test.Main where

import Prelude
import MyModule
import Test.FlareCheck

main = flareCheck "substring" substring
  • The compiled test module (test.js), run:
pulp build -O -I test -m Test.Main -t test.js
  • An accompanying HTML file which includes an empty element with ID tests that runs the script:
<div id="tests"></div>
<script src="test.js"></script>

See the assets folder for full HTML and CSS templates.