-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This tests whether it can handle the case where a varaiant consist only of zero-arg constructors. Signed-off-by: Vincent Liu <[email protected]>
- Loading branch information
1 parent
6cacde3
commit 21ccda9
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
type unit_variant = | ||
| Empty | ||
| Hollow | ||
| Vacant | ||
| Void | ||
[@@deriving rpcty] | ||
|
||
module UnitVInterface (R : Idl.RPC) = struct | ||
open R | ||
|
||
let unit_variant_p = Idl.Param.mk ~name:"unit_variant" unit_variant | ||
let int_p = Idl.Param.mk Rpc.Types.int | ||
|
||
let discard_v = | ||
R.declare | ||
"discard_v" | ||
[ "constant function taking a unit variant and discards it by returning an integer" | ||
] | ||
(unit_variant_p @-> returning int_p Idl.DefaultError.err) | ||
|
||
|
||
let implementation = | ||
implement | ||
{ Idl.Interface.name = "UnitVInterface" | ||
; namespace = Some "UnitVInterface" | ||
; description = | ||
[ "Unit variant interface which does absolutely nothing. Only used to test \ | ||
whether the pythongen code can handle variants with zero argument \ | ||
constructors." | ||
] | ||
; version = 1, 0, 0 | ||
} | ||
end | ||
|
||
module UnitVCode : sig | ||
val implementation : unit -> Codegen.Interface.t | ||
end = | ||
UnitVInterface (Codegen.Gen ()) | ||
|
||
let interfaces = | ||
Codegen.Interfaces.create | ||
~name:"unitv" | ||
~title:"Unit Variant" | ||
~description:[ "Interface for Unit variant" ] | ||
~interfaces:[ UnitVCode.implementation () ] | ||
|
||
|
||
let run () = Pythongen.of_interfaces interfaces |> Pythongen.string_of_ts |> ignore | ||
let tests = [ "test gen python on variants with zero-arg constructors", `Quick, run ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters