{"action":"created","issue":{"url":"https://api.github.com/repos/vincent-hugot/iTeML/issues/19","labels_url":"https://api.github.com/repos/vincent-hugot/iTeML/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/vincent-hugot/iTeML/issues/19/comments","events_url":"https://api.github.com/repos/vincent-hugot/iTeML/issues/19/events","html_url":"https://github.com/vincent-hugot/iTeML/pull/19","id":106354116,"number":19,"title":"Better quickcheck","user":{"login":"c-cube","id":1274291,"avatar_url":"https://avatars.githubusercontent.com/u/1274291?v=3","gravatar_id":"","url":"https://api.github.com/users/c-cube","html_url":"https://github.com/c-cube","followers_url":"https://api.github.com/users/c-cube/followers","following_url":"https://api.github.com/users/c-cube/following{/other_user}","gists_url":"https://api.github.com/users/c-cube/gists{/gist_id}","starred_url":"https://api.github.com/users/c-cube/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-cube/subscriptions","organizations_url":"https://api.github.com/users/c-cube/orgs","repos_url":"https://api.github.com/users/c-cube/repos","events_url":"https://api.github.com/users/c-cube/events{/privacy}","received_events_url":"https://api.github.com/users/c-cube/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-14T14:26:34Z","updated_at":"2015-09-14T20:59:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/vincent-hugot/iTeML/pulls/19","html_url":"https://github.com/vincent-hugot/iTeML/pull/19","diff_url":"https://github.com/vincent-hugot/iTeML/pull/19.diff","patch_url":"https://github.com/vincent-hugot/iTeML/pull/19.patch"},"body":"First draft of how to improve the quickcheck part. In particular:\r\n\r\n- make it easier to define one's own generators (exposing `Gen` combinators)\r\n- define shrinking and link `small` to the extended generator intsance\r\n- use more readable names\r\n- use shrinking in `laws` and `laws_exn` if available\r\n- make `==>` different in that a failed precondition will generate a new test case (up to a limit)\r\n\r\nOther things I want to do:\r\n- expose the random seed at the beginning and allow to re-run tests with a given seed\r\n- a `-verbose` mode that prints statistics on random tests (number of failed preconditions, etc.)\r\n- improve documentation\r\n\r\nThings I would like to do but probably won't:\r\n- allow nested comments in some blocks"},"comment":{"url":"https://api.github.com/repos/vincent-hugot/iTeML/issues/comments/140204315","html_url":"https://github.com/vincent-hugot/iTeML/pull/19#issuecomment-140204315","issue_url":"https://api.github.com/repos/vincent-hugot/iTeML/issues/19","id":140204315,"user":{"login":"gasche","id":426238,"avatar_url":"https://avatars.githubusercontent.com/u/426238?v=3","gravatar_id":"","url":"https://api.github.com/users/gasche","html_url":"https://github.com/gasche","followers_url":"https://api.github.com/users/gasche/followers","following_url":"https://api.github.com/users/gasche/following{/other_user}","gists_url":"https://api.github.com/users/gasche/gists{/gist_id}","starred_url":"https://api.github.com/users/gasche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gasche/subscriptions","organizations_url":"https://api.github.com/users/gasche/orgs","repos_url":"https://api.github.com/users/gasche/repos","events_url":"https://api.github.com/users/gasche/events{/privacy}","received_events_url":"https://api.github.com/users/gasche/received_events","type":"User","site_admin":false},"created_at":"2015-09-14T20:59:07Z","updated_at":"2015-09-14T20:59:07Z","body":"To my knowledge Batteries does not rely much on advanced quickcheck feature (we do have about a hundred random tests, but they most just have a generator on the left and a predicate on the right). There is exactly one use of `==>`, to perform [a case distinction](https://github.com/ocaml-batteries-team/batteries-included/blob/bf20650765d5af749306b3429ee3adee97ff6ba8/src/batInt.ml#L161-L167):\r\n\r\n```ocaml\r\n(*$Q mid\r\n  (Q.pair Q.int Q.int) (fun (a,b) -> \\\r\n    let m = mid a b in \\\r\n    a <= b ==> (a <= m && m <= b && abs ((m-a) - (b-m)) <= 1) && \\\r\n    b < a ==> (b <= m && m <= a && abs ((m-b) - (a-m)) <= 1))\r\n*)\r\n```\r\n\r\nand this could easily be rewritten in another way.\r\n\r\nI have always thought, however, that \"inserting blobs of code for testing purposes\" and \"being a good {unit,random} test library\" were separate purposes that could easily become separate small projects used together (just as we use `ounit` for the nice-report-generation-whatever part). In fact when I wrote [random-generator](https://github.com/gasche/random-generator) I also had in mind that a QuickCheck library could be build on top of it, with a nice separation of concepts between \"generating random structures\" and \"orchestrating a reasonably safe coverage from a random generator\".\r\n\r\nSo my two cents would be: it may be time to have `quickcheck.{ml,mli}` become its own separate projects, that people that don't particularly care about extraction from comments could rally around and use. I wouldn't mind switching the Batteries random tests to that if it can provide buy-in and motivation -- and if it integrates nicely with iTeML, of course. "}}