ocaml-sf / learn-ocaml

A Web Application for Learning OCaml
https://ocaml-sf.org/learn-ocaml/
MIT License
304 stars 66 forks source link

fix(grading): avoid failing on sampling arrays with unique elements #568

Closed AltGr closed 1 year ago

AltGr commented 1 year ago

Closes https://github.com/ocaml-sf/learn-ocaml-corpus/issues/39

The sampler was attempting to generate N distinct elements by restarting the provided sampler an arbitrary number of times (100). It would fail if the domain is to small: now it might still return duplicates in this case, which is better than failing for our use-cases.

AltGr commented 1 year ago

Tests fail because of an incompatibility with asak 0.4 (was expecting 0.3), there should be an upper bound. This is unrelated to this PR.

The solution would be to merge #481 first ; adding the version constraint now would generate conflicts on the other PRs that actually work.

erikmd commented 1 year ago

Hi @AltGr,

Tests fail because of an incompatibility with asak 0.4 (was expecting 0.3), there should be an upper bound. This is unrelated to this PR.

Indeed, but the missing upper bound also prevents master to build (and to do any release), so I merged #570

Feel free to rebase this PR #568 on master now, and you'll be able to integrate it at the time you see fit.