danr / proptest

Property-based testing a'la QuickCheck for TypeScript and JavaScript
MIT License
20 stars 5 forks source link

Pure to of #1

Closed paldepind closed 6 years ago

paldepind commented 6 years ago

It is customary to call pure for of in TypeScript/JavaScript. This is a precedence set by Fantasy Land.

This PR renames pure to of. It also adds a simple .gitignore to exclude node_modules and the compiled files.

danr commented 6 years ago

I guess I better rename then to chain too, then?

paldepind commented 6 years ago

then is problematic because then is part of the promise specification but Tree isn't a promise. Currently, if you happened to use the rose tree with promises

somePromis.then((result) => Tree.of(result));

then you'd get an error because native promises assume that everything with a then method is Promise-like. So it's best not to add a then method things that aren't promises.

On the other hand chain isn't completely appropriate either because the depth argument is passed along which, strictly speaking, isn't the correct signature for a chain method. chainWithDepth would be appropriate but it's quite verbose. I honestly don't know what is best.

danr commented 6 years ago

I renamed them to chain now and removed the depth argument (it felt a bit out of place and didn't count the number of shrinks correctly anyway)