Skip to content

Commit

Permalink
test(melange): add test exercising ocaml#7104
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
  • Loading branch information
anmonteiro committed Mar 1, 2023
1 parent 5de6e9f commit e4d71c4
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(executable
(name ml)
(modules ml)
(libraries vlib impl_ml))

(melange.emit
(target output)
(alias melange)
(entries mel)
(libraries vlib impl_melange)
(module_system commonjs))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 3.8)

(using melange 0.1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name impl_melange)
(modes melange)
(implements vlib))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let t = "melange"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(name impl_ml)
(implements vlib))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let t = "ml"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print_endline Virt.t
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline Virt.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Test virtual lib in an exe / melange environment

$ dune build @melange --display=short
ocamldep impl_melange/.impl_melange.objs/virt.impl.d
ocamldep vlib/.vlib.objs/shared.impl.d
ocamldep vlib/.vlib.objs/virt.intf.d
ocamldep vlib/.vlib.objs/vlib_impl.impl.d
melc vlib/.vlib.objs/melange/virt.{cmi,cmti}
melc vlib/.vlib.objs/melange/vlib_impl.{cmi,cmj,cmt}
melc vlib/.vlib.objs/melange/shared.{cmi,cmj,cmt}
melc output/vlib/vlib_impl.js
melc impl_melange/.impl_melange.objs/melange/virt.{cmj,cmt}
melc output/vlib/shared.js
melc .output.mobjs/melange/melange__Mel.{cmi,cmj,cmt}
melc output/impl_melange/virt.js
melc output/mel.js
$ output=_build/default/output/mel.js
$ test -f "$output" && node "$output"
melange

$ dune exec ./ml.exe --display=short
ocamldep impl_ml/.impl_ml.objs/virt.impl.d
ocamlc vlib/.vlib.objs/byte/virt.{cmi,cmti}
ocamlc vlib/.vlib.objs/byte/vlib_impl.{cmi,cmo,cmt}
ocamlopt vlib/.vlib.objs/native/vlib_impl.{cmx,o}
ocamlc vlib/.vlib.objs/byte/shared.{cmi,cmo,cmt}
ocamlc .ml.eobjs/byte/dune__exe__Ml.{cmi,cmti}
ocamlopt vlib/.vlib.objs/native/shared.{cmx,o}
ocamlopt impl_ml/.impl_ml.objs/native/virt.{cmx,o}
ocamlopt .ml.eobjs/native/dune__exe__Ml.{cmx,o}
ocamlopt impl_ml/impl_ml.{a,cmxa}
ocamlopt ml.exe
ml
$ ls _build/default/vlib/.vlib.objs/byte
shared.cmi
shared.cmo
shared.cmt
virt.cmi
virt.cmti
vlib_impl.cmi
vlib_impl.cmo
vlib_impl.cmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(library
(name vlib)
(wrapped false)
(modes :standard melange)
(virtual_modules virt))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let t = Vlib_impl.hello
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val t : string
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let hello = "Hello from " ^ Virt.t

0 comments on commit e4d71c4

Please sign in to comment.