Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
  • Loading branch information
nojb committed Mar 5, 2021
1 parent bff6281 commit 35e5ff6
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/blackbox-tests/test-cases/top.t/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(library
(name x))
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/top.t/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(lang dune 2.8)
12 changes: 12 additions & 0 deletions test/blackbox-tests/test-cases/top.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Basic check that directives are correctly emitted.
$ dune top
#directory "$TESTCASE_ROOT/_build/default/.x.objs/byte";;
#directory "$TESTCASE_ROOT/_build/default/stubs";;
#directory "$TESTCASE_ROOT/_build/default/stubs/.z.objs/byte";;
#load "$TESTCASE_ROOT/_build/default/stubs/z.cma";;
#load "$TESTCASE_ROOT/_build/default/x.cma";;

Check that C stubs work.
$ (dune top && echo "Z.f ();;") > init.mltop
$ ocaml init.mltop
Hello!
5 changes: 5 additions & 0 deletions test/blackbox-tests/test-cases/top.t/stubs/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(library
(name z)
(foreign_stubs
(language c)
(names z_stubs)))
4 changes: 4 additions & 0 deletions test/blackbox-tests/test-cases/top.t/stubs/z.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
external hello : unit -> unit = "ml_hello"

let f () =
hello ()
9 changes: 9 additions & 0 deletions test/blackbox-tests/test-cases/top.t/stubs/z_stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <caml/mlvalues.h>
#include <stdio.h>

value ml_hello(value vunit)
{
printf("Hello!\n");
fflush(stdout);
return Val_unit;
}
Empty file.

0 comments on commit 35e5ff6

Please sign in to comment.