Add regression tests for qualified type - #201
Conversation
c-cube
commented
Dec 1, 2021
Not sure either, what do you think @vch9 ? |
c-cube
commented
Dec 1, 2021
for reference, the generated code: |
Yes this is a bug, thank you for reporting it. I translated
Based on my last discovery, the bug is pretty much easy to fix. We can begin by having a function which create an identifier for a qualified type: letname_lg=function|Lidents -> name s
|Ldot (lg, s) -> longident_to_str lg ^"."^ name s (* Q.t becomes Q.gen *)|Lapply_ -> raise (Invalid_argument"We do not produce gen name for Lapply")Then we change the precedent creation of generator from letgen~loc?(env = TypeGen.empty)lg=let (moduleA) =Ast_builder.make loc inmatch lg with|Lidents ->
Option.value ~default:(name s |>A.evar) @@TypeGen.find_opt s env
|Ldot (lg, s) -> A.(pexp_construct (Located.mk @@Ldot (lg, name s)) None)
|Lapply (_, _) -> raise (Invalid_argument"gen received an Lapply")to letgen~loc?(env = TypeGen.empty)lg=let (moduleA) =Ast_builder.make loc inlet s = longident_to_str lg inlet name = name_lg lg inOption.value ~default:(A.evar name) @@TypeGen.find_opt s envAdding a regressing test is a good idea (I should already have done it tbh). What would be more convenient, put our trust in the compiler ? put regression tests on the generated code ?
it would not catch the difference between a Pexp_construct and a Pexp_ident. |
bobot
commented
Dec 1, 2021
Thanks for finding the erroneous |
vch9
commented
Dec 1, 2021
I also prefer your fix :) Maybe we could have a test such as moduleA=structtypea = (int [@gen QCheck.Gen.pure0])
[@@deriving qcheck]
moduleB=structtypeb = (int [@gen QCheck.Gen.pure1])
[@@deriving qcheck]
endendtypea = A.t
[@@deriving qcheck]
typeb = A.B.t
[@@deriving qcheck] with a unit (or pbt?) to test |
bobot
commented
Dec 2, 2021
Adding more tests is a good idea, you can push in the branch, but It also could go in another MR. This MR has a fix and a regresssion test. Is the falling test normal? |
vch9
commented
Dec 2, 2021
Unfortunately I can't, I'm not a QCheck's maintainer. This will be done in a follow-up MR. |
c-cube
commented
Dec 2, 2021
I don't think anyone can push onto your branch, @bobot, it's from your fork :) |
vch9
commented
Dec 2, 2021
Can't we on github allow modifications from maintainers? |
c-cube
commented
Dec 2, 2021
Maybe, but I've never understood how to push on such a branch 😅 |
bobot
commented
Dec 3, 2021
The last time I did that I believe I just added the remote of the branch author. But except for the failing test the branch is done for me, and I don't understand why the test is failing. |
vch9
commented
Dec 3, 2021
Rebase on master, #203 should fix the test. |
63e23e4 to
fac2c39Comparevch9
commented
Dec 3, 2021
LGTM, thank you for the fix :) |
vch9
commented
Dec 3, 2021
@c-cube If you also agree we could merge this |
c-cube
commented
Dec 3, 2021
let's go! |
bobot
commented
Apr 2, 2022
Is there a release planned? |
c-cube
commented
Apr 3, 2022
I kind of lost context, but I think there were just a few PRs blocking 0.19, and @jmid is going through them like a hurricane 😁 |
Qualified type are currently concatenated into a unique identifier, so it becomes a constructor:
I added the test outside
test.mlbecause string comparison doesn't show the difference (let gen = Q.genin both case). I tried to see if the bug was obvious but I haven't found anything.