bkaestner / codewars-rules

Arbitrary rules by an arbitrary Codewars warrior. THIS REPOSITORY IS LOOKING FOR A NEW MAINTAINER
https://bkaestner.github.io/codewars-rules/
Other
12 stars 5 forks source link

Should `node-quickcheck` get included? #25

Closed bkaestner closed 8 years ago

bkaestner commented 8 years ago

So, the quickcheck package has been available for some time. There was a small bug, but other than that it seems rather reasonable.

However, I'm not sure whether one should include it into the document. It's a competitor to randomAssertEquals, but I'm not sure how often that one gets used. Both can be created in terms of the other:

var randomAssertEquals = function(generator, userSol, refSol){
  var property = function(values){
    Test.assertEquals(userSol.apply(this,values), refSol.apply(this,values));
  }
  return forAll(property, generator);
}
// ------------------------------------------
var forAll = function(property){
  var generators = Array.prototype.slice.call(arguments, 1);
  var generator = function(){ return generators.map(f => f()); }
  var const_true = function(){ return true;}
  return randomAssertEquals (generator, property, const_true, 100);
}

Both solutions have advantages and disadvantages.