This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,2 @@
(library
(name x))

View file

@ -0,0 +1 @@
(lang dune 2.8)

View file

@ -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/x.cma";;
#load "$TESTCASE_ROOT/_build/default/stubs/z.cma";;
Check that C stubs work.
$ (dune top && echo "Z.f ();;") > init.mltop
$ ocaml init.mltop
Hello!

View file

@ -0,0 +1,5 @@
(library
(name z)
(foreign_stubs
(language c)
(names z_stubs)))

View file

@ -0,0 +1,4 @@
external hello : unit -> unit = "ml_hello"
let f () =
hello ()

View file

@ -0,0 +1,9 @@
#include <caml/mlvalues.h>
#include <stdio.h>
value ml_hello(value vunit)
{
printf("Hello!\n");
fflush(stdout);
return Val_unit;
}

View file

@ -0,0 +1,46 @@
Test toplevel-init-file on a tiny project
----------------------------------------------------
$ cat >dune-project <<EOF
> (lang dune 2.1)
> (name test)
> EOF
$ cat >dune <<EOF
> (library
> (name test)
> (public_name test))
> EOF
$ touch test.opam
$ cat >main.ml <<EOF
> let hello () = print_endline "hello"
> EOF
$ dune ocaml top
#directory "$TESTCASE_ROOT/_build/default/.test.objs/byte";;
#load "$TESTCASE_ROOT/_build/default/test.cma";;
$ ocaml -stdin <<EOF
> #use_output "dune ocaml top";;
> Test.Main.hello ();;
> EOF
hello
$ cat >error.ml <<EOF
> let oops () = undefined_function ()
> EOF
$ dune ocaml top
File "error.ml", line 1, characters 14-32:
1 | let oops () = undefined_function ()
^^^^^^^^^^^^^^^^^^
Error: Unbound value undefined_function
[1]
$ ocaml -stdin <<EOF
> #use_output "dune ocaml top";;
> EOF
File "error.ml", line 1, characters 14-32:
1 | let oops () = undefined_function ()
^^^^^^^^^^^^^^^^^^
Error: Unbound value undefined_function
Command exited with code 1.
[125]