fantasyland / fantasy-laws

Property-based tests for FL-compatible ADTs
MIT License
33 stars 4 forks source link

Asserts #8

Closed memee closed 6 years ago

memee commented 6 years ago

https://github.com/fantasyland/fantasy-laws/blob/863bdee40a17e6ad3b474e176a1536eee4b32436/src/internal/assert.js#L9

This implementation rather disables tape users from asserting in the way tape lib requires. Like having test plan: t.plan(1) where you declare the number of asserts.

Example:

var test = require('tape');

test('timing test', function (t) {
    t.plan(2); // <--- plan

    t.equal(typeof Date.now, 'function'); // <--- assert
    var start = Date.now();

    setTimeout(function () {
        t.equal(Date.now() - start, 100); // <--- assert
    }, 100);
});

No idea come to my mind that will not turn the implementation upside down. Any idea of workarounds that will help to use other test frameworks than Mocha?

davidchambers commented 6 years ago

I'm not familiar with tape, @memee. I'll be happy to consider a proposal to restructure the assertion thunks in order to improve interoperability.

safareli commented 6 years ago

I think you can just nut call the plan and use t.end() when test ends

safareli commented 6 years ago

i have actually done that and works fine https://github.com/safareli/free/blob/master/test/laws.js#L22

davidchambers commented 6 years ago

That's good to know. Thanks, Irakli. :)

safareli commented 6 years ago

You are welcome!