RunKit + npm: jsverify-commands

node v8.17.0
version: 2.0.0
endpointsharetweet
Import modules
const assert = require('assert'); const jsc = require('jsverify'); const jscCommands = require('jsverify-commands');
Declare commands
function PopCommand() { this.check = (desc) => desc.numEntries > 0; this.run = function(tab, desc) { tab.pop(); --desc.numEntries; return tab.length == desc.numEntries; }; this.name = `PopCommand`; } function PushCommand(value) { this.check = (desc) => true; this.run = function(tab, desc) { tab.push(value); ++desc.numEntries; return tab.length == desc.numEntries; }; this.name = `PushCommand(${value})`; }
Fake mocha implementation (for RunKit purpose only)
const describe = (name, f) => f(); const it = async (name, f) => { try { await f(); console.log(`${name}: success`); } catch (err) { console.log(`${name}: failed with error`); console.log(err); } };
Your tests go there
describe('Array', function() { it('should confirm commands', function() { const commands = jscCommands.commands( jscCommands.command(PopCommand), jscCommands.command(PushCommand, jsc.nat)); const warmup = () => new Object({state: [], model: {numEntries: 0}}); const teardown = () => {}; const settings = { metrics: true, verbose: true }; return jscCommands.assertForall(commands, warmup, teardown, settings); }); });
Created from: https://npm.runkit.com/jsverify-commands
Loading…

no comments

    sign in to comment