leebyron / testcheck-js

Generative testing for JavaScript

Home Page:http://leebyron.com/testcheck-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gen.array(gen.any) takes super long

jethrolarson opened this issue · comments

Single test (using mocha-testcheck) that takes gen.array(gen.any) never completes. Mocha times out the browser locks up. Are these not safe to use together?

It would be helpful if you could provide a more complete failing test case.

The following test seems to complete in <5ms

time node -p "var {gen, sample} = require('testcheck'); sample(gen.array(gen.any));"

[ [],
  [],
  [ [ [Array] ] ],
  [ [ [Object], [Object] ] ],
  [ {}, {}, [ false ] ],
  [ [ [Object] ], { '9Q': [Object], Y4w: [] } ],
  [ { d: [] } ],
  [ { '4': [Object], Nie: {} }, [], [ [Array] ], {}, { QI: [] } ],
  [ { '1': [Array] },
    { mH: [Object], j: [Object] },
    [ [Array], {} ],
    [ [Array] ],
    { FI: [Array], Tn: [] } ],
  [ {}, { '6E': 6 }, {}, {}, { YX9: [Object], BA: {} } ] ]
node -p   0.19s user 0.04s system 108% cpu 0.215 total

Note that gen.any produces values which may include nested arrays and objects. Objects are particularly expensive to generate since the key strings are randomly generated as well.

Maybe it's something to do with mocha. I'll see if I still have that branch somewhere

I'm going to close this issue for now - but feel free to re-open if you come across a reproducible case we can look at together.