aristidb / hspec Goto Github PK
View Code? Open in Web Editor NEWThis project forked from hspec/hspec
Behavior Driven Development for Haskell
License: Other
This project forked from hspec/hspec
Behavior Driven Development for Haskell
License: Other
hspec aims to be a simple, extendable, and useful tool for Behavior Driven Development in Haskell. Step 1, write descriptions and examples of your desired behavior > specs = describe "myabs" [ > it "returns the original number when given a positive input" > (myabs 1 == 1), > > it "returns a positive number when given a negative input" > (myabs (-1) == 1), > > it "returns zero when given zero" > (myabs 0 == 0) > ] Step 2, write whatever you are describing > myabs n = undefined Step 3, watch your examples fail with red text > hspec specs myabs x returns the original number when given a positive input FAILED [1] x returns a positive number when given a negative input FAILED [2] x returns zero when given zero FAILED [3] 1) myabs returns the original number when given a positive input FAILED Prelude.undefined 2) myabs returns a positive number when given a negative input FAILED Prelude.undefined 3) myabs returns zero when given zero FAILED Prelude.undefined Finished in 0.0002 seconds 3 examples, 3 failures Step 4, implement your desired behavior > myabs n = if n < 0 then negate n else n Step 5, watch your examples pass with green text > hspec specs myabs - returns the original number when given a positive input - returns a positive number when given a negative input - returns zero when given zero Finished in 0.0000 seconds 3 examples, 0 failures Here's the report of hspec's behavior: the "describe" function - takes a description of what the behavior is for - groups behaviors for what's being described the "it" function - takes a description of a desired behavior - takes an example of that behavior - can use a Bool, HUnit Test, QuickCheck property, or "pending" as an example - will treat exceptions as failures the "hspec" function - displays a header for each thing being described - displays one row for each behavior - displays a '-' for successfull examples - displays an 'x' for failed examples - displays a detailed list of failed examples - displays a '-' for pending examples - displays a '#' and an additional message for pending examples - summarizes the time it takes to finish - summarizes the number of examples and failures - outputs failed examples in red, pending in yellow, and passing in green Bool as an example - is just an expression that evaluates to a Bool HUnit TestCase as an example - is specified with the HUnit "TestCase" data constructor - is the assumed example for IO() actions - will show the failed assertion text if available (e.g. assertBool) - will show the failed assertion expected and actual values if available (e.g. assertEqual) QuickCheck property as an example - is specified with the "property" function - will show what falsified it pending as an example - is specified with the "pending" function and an explanation - accepts a message to display in the report the "hHspecWithFormat" function - can use the "silent" formatter to show no output - can use the "progress" formatter to show '..F...FF.F' style output - can use the "specdoc" formatter to show all examples (default) - can use the "failed_examples" formatter to show only failed examples quantify (an internal function) - returns an amount and a word given an amount and word - returns a singular word given the number 1 - returns a plural word given a number greater than 1 - returns a plural word given the number 0 Finished in 0.0627 seconds 33 examples, 0 failures
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.