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
| // 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) |
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') | |
| const Chance = require('chance') | |
| const chance = new Chance() | |
| chance.mixin({ | |
| user: () => ({ | |
| first: chance.first(), | |
| last: chance.last(), | |
| email: chance.email() | |
| }) | |
| }) |
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 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()) |
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
| 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)) |
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 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 | |
| } |
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
| test('addition is commutative', (t) => { | |
| t.plan(1) | |
| t.equal(jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a), true) | |
| }) |
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
| describe('Maths', () => { | |
| it('addition is commutative', () => { | |
| expect(jsc.checkForall(jsc.integer, jsc.integer, (a, b) => a + b === b + a)).toBeTrue() | |
| }) | |
| }) |
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
| // 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 |
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
| 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) | |
| }) | |
| }) |
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
| // 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) |