Last active
March 15, 2017 06:46
-
-
Save MattMcFarland/bc2b688ef324e8a9d1e1fabc5cdb538b to your computer and use it in GitHub Desktop.
A simple example using JS Verify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jsc = require('jsverify') | |
// With property based testing, we don't check for specific inputs and outputs, instead we are testing the boundaries of our code. | |
const additionIsCommutative = jsc.checkForall(jsc.integer, jsc.integer, | |
(a, b) => a + b === b + a) | |
const multiplicationIsDistributive = jsc.checkForall(jsc.integer, jsc.integer, jsc.integer, | |
(a, b, c) => a * (b + c) === a * b + a * c) | |
// log out whether or not the test passed | |
console.log({ additionIsCommutative, multiplicationIsDistributive }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment