Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbriais committed Oct 14, 2024
1 parent 2ee2228 commit ade4f14
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ppx-test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,15 @@
(deps test_library.cma)
(action
(echo "Successfully compile test_library")))

(rule
(targets modules.ml)
(deps modules.mli)
(action
(run gen_js_api %{deps} -o %{targets})))

(rule
(alias runtest)
(package gen_js_api)
(action
(diff expected/modules.ml modules.ml)))
24 changes: 24 additions & 0 deletions ppx-test/expected/modules.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[@@@js.dummy "!! This code has been generated by gen_js_api !!"]
[@@@ocaml.warning "-7-32-39"]
module Event =
struct
type t = Ojs.t
let rec t_of_js : Ojs.t -> t = fun (x2 : Ojs.t) -> x2
and t_to_js : t -> Ojs.t = fun (x1 : Ojs.t) -> x1
end
module Foo =
struct
module E = Event
let (foo : E.t -> string -> unit) =
fun (x4 : E.t) ->
fun (x3 : string) ->
ignore (Ojs.call (E.t_to_js x4) "foo" [|(Ojs.string_to_js x3)|])
end
module Bar =
struct
include Event
let (bar : t -> string -> unit) =
fun (x6 : t) ->
fun (x5 : string) ->
ignore (Ojs.call (t_to_js x6) "bar" [|(Ojs.string_to_js x5)|])
end
17 changes: 17 additions & 0 deletions ppx-test/modules.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module Event: sig
type t = private Ojs.t
val t_to_js: t -> Ojs.t
val t_of_js: Ojs.t -> t
end

module Foo: sig
module E = Event

val foo: E.t -> string -> unit [@@js.call]
end

module Bar: sig
include (module type of Event)

val bar: t -> string -> unit [@@js.call]
end

0 comments on commit ade4f14

Please sign in to comment.