-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(melange): show wrong require for private impl of public virtual lib
Signed-off-by: Antonio Nuno Monteiro <[email protected]>
- Loading branch information
1 parent
56b10d8
commit 324de2e
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
test/blackbox-tests/test-cases/melange/virtual-lib-private-impl.t
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,74 @@ | ||
Test virtual libraries where the virtual implementation is a public library | ||
|
||
$ mkdir -p vlib js_impl test | ||
$ cat > dune-project <<EOF | ||
> (lang dune 3.13) | ||
> (using melange 0.1) | ||
> (package (name the_lib)) | ||
> (package (name concrete_lib)) | ||
> EOF | ||
$ cat > vlib/dune <<EOF | ||
> (library | ||
> (name the_lib) | ||
> (modes melange native) | ||
> (public_name the_lib) | ||
> (virtual_modules virt)) | ||
> EOF | ||
$ cat > vlib/the_lib.mli <<EOF | ||
> module Time : sig | ||
> val gettimeofday : unit -> float | ||
> end | ||
> EOF | ||
$ cat > vlib/the_lib.ml <<EOF | ||
> module Time = struct | ||
> let gettimeofday () = Virt.gettimeofday () | ||
> end | ||
> EOF | ||
$ cat > vlib/virt.mli <<EOF | ||
> val gettimeofday : unit -> float | ||
> EOF | ||
$ cat > js_impl/dune <<EOF | ||
> (library | ||
> (name timeJs) | ||
> ;(public_name concrete_lib) | ||
> (implements the_lib) | ||
> (modes melange) | ||
> (preprocess (pps melange.ppx))) | ||
> EOF | ||
$ cat > js_impl/virt.ml <<EOF | ||
> let gettimeofday : unit -> float = fun () -> 42. | ||
> EOF | ||
$ cat > test/dune <<EOF | ||
> (melange.emit | ||
> (target output) | ||
> (libraries the_lib timeJs) | ||
> (emit_stdlib false)) | ||
> EOF | ||
$ dune build @melange | ||
$ ls _build/default/test/output | ||
js_impl | ||
node_modules | ||
test | ||
$ cat _build/default/test/output/node_modules/the_lib/the_lib.js | ||
// Generated by Melange | ||
'use strict'; | ||
const Curry = require("melange.js/curry.js"); | ||
const The_lib__Virt = require("js_impl/virt.js"); | ||
function gettimeofday(param) { | ||
return Curry._1(The_lib__Virt.gettimeofday, undefined); | ||
} | ||
const Time = { | ||
gettimeofday: gettimeofday | ||
}; | ||
exports.Time = Time; | ||
/* The_lib__Virt Not a pure module */ | ||