Skip to content

Instantly share code, notes, and snippets.

View MattMcFarland's full-sized avatar

Matt McFarland MattMcFarland

  • Software Engineer
  • Dayton, OH
View GitHub Profile
// lets test our user here:
const checkOptions = {
rngState: '074e9b5f037a8c21d6',
tests: 2
}
// lets test our user here:
jsc.check(jsc.forall(jsc.integer, arbUser, (a, user) => {
console.log({a, user})
return true
}), checkOptions)
@MattMcFarland
MattMcFarland / chance random and js verify.js
Created March 15, 2017 00:11
chance random and js verify
const jsc = require('jsverify')
const Chance = require('chance')
const chance = new Chance()
chance.mixin({
user: () => ({
first: chance.first(),
last: chance.last(),
email: chance.email()
})
})
@MattMcFarland
MattMcFarland / chance random user.js
Created March 15, 2017 00:10
chance random user.js
const Chance = require('chance')
const chance = new Chance()
chance.mixin({
user: () => ({
first: chance.first(),
last: chance.last(),
email: chance.email()
})
});
console.log('here is a random user!', chance.user())
jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a)
// is the same as
jsc.check(jsc.forall(jsc.integer, jsc.integer, (a, b) => a + b === b + a))
@MattMcFarland
MattMcFarland / jsc options.js
Last active March 15, 2017 07:16
jsc options
const options = {
tests: 5, // test count to run, default 100
size: 50, // maximum size of generated values, default 50
quiet: false, // do not console.log if true
rngState: '074e9b5f037a8c21d6', // state string for the rng
}
@MattMcFarland
MattMcFarland / jsverify and tape.js
Last active March 15, 2017 07:03
js verify with tape
test('addition is commutative', (t) => {
t.plan(1)
t.equal(jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a), true)
})
@MattMcFarland
MattMcFarland / jsverify jasmine.js
Last active October 29, 2018 14:44
js verify with jasmine
describe('Maths', () => {
it('addition is commutative', () => {
expect(jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a)).toBeTrue()
})
})
@MattMcFarland
MattMcFarland / with chai.js
Created March 15, 2017 00:07
js verify with chai
// using should:
jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a).should.be.true
// using expect:
expect(jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a)).to.be.true
@MattMcFarland
MattMcFarland / with mocha.js
Last active March 10, 2018 19:47
jsverify with mocha
describe('Maths', () => {
it('addition is commutative', () => {
jsc.assertForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a)
// same as:
assert(jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a) === true)
})
})
@MattMcFarland
MattMcFarland / jsvNode.js
Created March 15, 2017 00:05
jsverify with node
// node assertion library
assert(jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a) === true)
// same as:
jsc.assertForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a)