Add tests for [%ocaml.extension_constructor <path>]
parent
ebd830b85b
commit
4af976cffe
|
@ -0,0 +1,15 @@
|
|||
#########################################################################
|
||||
# #
|
||||
# OCaml #
|
||||
# #
|
||||
# Xavier Clerc, SED, INRIA Rocquencourt #
|
||||
# #
|
||||
# Copyright 2010 Institut National de Recherche en Informatique et #
|
||||
# en Automatique. All rights reserved. This file is distributed #
|
||||
# under the terms of the Q Public License version 1.0. #
|
||||
# #
|
||||
#########################################################################
|
||||
|
||||
BASEDIR=../..
|
||||
include $(BASEDIR)/makefiles/Makefile.several
|
||||
include $(BASEDIR)/makefiles/Makefile.common
|
|
@ -0,0 +1,29 @@
|
|||
(***********************************************************************)
|
||||
(* *)
|
||||
(* OCaml *)
|
||||
(* *)
|
||||
(* Jeremie Dimino, Jane Street Europe *)
|
||||
(* *)
|
||||
(* Copyright 2015 Institut National de Recherche en Informatique et *)
|
||||
(* en Automatique. All rights reserved. This file is distributed *)
|
||||
(* under the terms of the Q Public License version 1.0. *)
|
||||
(* *)
|
||||
(***********************************************************************)
|
||||
|
||||
type t = ..
|
||||
|
||||
module M = struct
|
||||
type t += A
|
||||
type t += B of int
|
||||
end
|
||||
|
||||
type t += C
|
||||
type t += D of int * string
|
||||
|
||||
let () =
|
||||
assert (Obj.extension_constructor M.A == [%extension_constructor M.A]);
|
||||
assert (Obj.extension_constructor (M.B 42) == [%extension_constructor M.B]);
|
||||
assert (Obj.extension_constructor C == [%extension_constructor C ]);
|
||||
assert (Obj.extension_constructor (D (42, "")) == [%extension_constructor D ])
|
||||
|
||||
let () = print_endline "OK"
|
|
@ -0,0 +1 @@
|
|||
OK
|
|
@ -0,0 +1,15 @@
|
|||
#########################################################################
|
||||
# #
|
||||
# OCaml #
|
||||
# #
|
||||
# Xavier Clerc, SED, INRIA Rocquencourt #
|
||||
# #
|
||||
# Copyright 2010 Institut National de Recherche en Informatique et #
|
||||
# en Automatique. All rights reserved. This file is distributed #
|
||||
# under the terms of the Q Public License version 1.0. #
|
||||
# #
|
||||
#########################################################################
|
||||
|
||||
BASEDIR=../..
|
||||
include $(BASEDIR)/makefiles/Makefile.toplevel
|
||||
include $(BASEDIR)/makefiles/Makefile.common
|
|
@ -0,0 +1,21 @@
|
|||
(***********************************************************************)
|
||||
(* *)
|
||||
(* OCaml *)
|
||||
(* *)
|
||||
(* Jeremie Dimino, Jane Street Europe *)
|
||||
(* *)
|
||||
(* Copyright 2015 Institut National de Recherche en Informatique et *)
|
||||
(* en Automatique. All rights reserved. This file is distributed *)
|
||||
(* under the terms of the Q Public License version 1.0. *)
|
||||
(* *)
|
||||
(***********************************************************************)
|
||||
|
||||
type t = ..;;
|
||||
type t += A;;
|
||||
|
||||
[%extension_constructor A];;
|
||||
([%extension_constructor A] : extension_constructor);;
|
||||
|
||||
type extension_constructor = int;;
|
||||
|
||||
([%extension_constructor A] : extension_constructor);;
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
# type t = ..
|
||||
# type t += A
|
||||
# - : extension_constructor = <abstr>
|
||||
# - : extension_constructor = <abstr>
|
||||
# type extension_constructor = int
|
||||
# Characters 2-28:
|
||||
([%extension_constructor A] : extension_constructor);;
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Error: This expression has type extension_constructor/16
|
||||
but an expression was expected of type
|
||||
extension_constructor/1214 = int
|
||||
#
|
Loading…
Reference in New Issue