Skip to content

Instantly share code, notes, and snippets.

@gilligan

gilligan/add.js Secret

Created December 10, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilligan/0e4ac7fb3ecc8b6e2141 to your computer and use it in GitHub Desktop.
Save gilligan/0e4ac7fb3ecc8b6e2141 to your computer and use it in GitHub Desktop.
var R = require('..');
var eq = require('./shared/eq');
var jsc = require("jsverify");
describe('add', function() {
it('adds together two numbers', function() {
eq(R.add(3, 7), 10);
});
it('is curried', function() {
var incr = R.add(1);
eq(incr(42), 43);
});
describe('properties', function () {
jsc.property("commutative", "integer", "integer", function (a, b) {
return R.add(a,b) === R.add(b,a);
});
jsc.property("associative", "integer", "integer", "integer", function (a, b, c) {
return R.add(a, R.add(b, c)) === R.add(R.add(a, b), c);
});
jsc.property("unit element", "integer" , function (a) {
return R.add(a, 0) === a;
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment