From 3cd841b676cdefc981da10dde7b6e10a23fcb877 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Tue, 2 Feb 2016 14:58:34 +0000 Subject: [PATCH] Switch typing-immediate to expect tests --- .gitignore | 1 + testsuite/tests/typing-immediate/Makefile | 2 +- testsuite/tests/typing-immediate/immediate.ml | 76 +++++++++++++++++++ .../typing-immediate/immediate.ml.reference | 71 ----------------- 4 files changed, 78 insertions(+), 72 deletions(-) delete mode 100644 testsuite/tests/typing-immediate/immediate.ml.reference diff --git a/.gitignore b/.gitignore index 814905d99..41ba81571 100644 --- a/.gitignore +++ b/.gitignore @@ -225,6 +225,7 @@ /testsuite/**/*.result /testsuite/**/*.opt_result +/testsuite/**/*.corrected /testsuite/**/*.byte /testsuite/**/*.native /testsuite/**/program diff --git a/testsuite/tests/typing-immediate/Makefile b/testsuite/tests/typing-immediate/Makefile index 7fc00661c..0b15e777d 100644 --- a/testsuite/tests/typing-immediate/Makefile +++ b/testsuite/tests/typing-immediate/Makefile @@ -14,5 +14,5 @@ #************************************************************************** BASEDIR=../.. -include $(BASEDIR)/makefiles/Makefile.toplevel +include $(BASEDIR)/makefiles/Makefile.expect include $(BASEDIR)/makefiles/Makefile.common diff --git a/testsuite/tests/typing-immediate/immediate.ml b/testsuite/tests/typing-immediate/immediate.ml index 996469f96..559e2a11c 100644 --- a/testsuite/tests/typing-immediate/immediate.ml +++ b/testsuite/tests/typing-immediate/immediate.ml @@ -1,5 +1,9 @@ module type S = sig type t [@@immediate] end;; module F (M : S) : S = M;; +[%%expect{| +module type S = sig type t [@@immediate] end +module F : functor (M : S) -> S +|}];; (* VALID DECLARATIONS *) @@ -17,40 +21,74 @@ module A = struct type p = q [@@immediate] and q = int end;; +[%%expect{| +module A : + sig + type t [@@immediate] + type s = t [@@immediate] + type r = s + type p = q [@@immediate] + and q = int + end +|}];; (* Valid using with constraints *) module type X = sig type t end;; module Y = struct type t = int end;; module Z = ((Y : X with type t = int) : sig type t [@@immediate] end);; +[%%expect{| +module type X = sig type t end +module Y : sig type t = int end +module Z : sig type t [@@immediate] end +|}];; (* Valid using an explicit signature *) module M_valid : S = struct type t = int end;; module FM_valid = F (struct type t = int end);; +[%%expect{| +module M_valid : S +module FM_valid : S +|}];; (* Practical usage over modules *) module Foo : sig type t val x : t ref end = struct type t = int let x = ref 0 end;; +[%%expect{| +module Foo : sig type t val x : t ref end +|}];; module Bar : sig type t [@@immediate] val x : t ref end = struct type t = int let x = ref 0 end;; +[%%expect{| +module Bar : sig type t [@@immediate] val x : t ref end +|}];; let test f = let start = Sys.time() in f (); (Sys.time() -. start);; +[%%expect{| +val test : (unit -> 'a) -> float = +|}];; let test_foo () = for i = 0 to 100_000_000 do Foo.x := !Foo.x done;; +[%%expect{| +val test_foo : unit -> unit = +|}];; let test_bar () = for i = 0 to 100_000_000 do Bar.x := !Bar.x done;; +[%%expect{| +val test_bar : unit -> unit = +|}];; (* Uncomment these to test. Should see substantial speedup! let () = Printf.printf "No @@immediate: %fs\n" (test test_foo) @@ -63,24 +101,62 @@ let () = Printf.printf "With @@immediate: %fs\n" (test test_bar) *) module B = struct type t = string [@@immediate] end;; +[%%expect{| +Line _, characters 2-31: +Error: Types marked with the immediate attribute must be + non-pointer types like int or bool +|}];; (* Not guaranteed that t is immediate, so this is an invalid declaration *) module C = struct type t type s = t [@@immediate] end;; +[%%expect{| +Line _, characters 2-26: +Error: Types marked with the immediate attribute must be + non-pointer types like int or bool +|}];; (* Can't ascribe to an immediate type signature with a non-immediate type *) module D : sig type t [@@immediate] end = struct type t = string end;; +[%%expect{| +Line _, characters 42-70: +Error: Signature mismatch: + Modules do not match: + sig type t = string end + is not included in + sig type t [@@immediate] end + Type declarations do not match: + type t = string + is not included in + type t [@@immediate] + the first is not an immediate type. +|}];; (* Same as above but with explicit signature *) module M_invalid : S = struct type t = string end;; module FM_invalid = F (struct type t = string end);; +[%%expect{| +Line _, characters 23-49: +Error: Signature mismatch: + Modules do not match: sig type t = string end is not included in S + Type declarations do not match: + type t = string + is not included in + type t [@@immediate] + the first is not an immediate type. +|}];; (* Can't use a non-immediate type even if mutually recursive *) module E = struct type t = s [@@immediate] and s = string end;; +[%%expect{| +Line _, characters 2-26: +Error: Types marked with the immediate attribute must be + non-pointer types like int or bool +|}];; diff --git a/testsuite/tests/typing-immediate/immediate.ml.reference b/testsuite/tests/typing-immediate/immediate.ml.reference deleted file mode 100644 index d62a70614..000000000 --- a/testsuite/tests/typing-immediate/immediate.ml.reference +++ /dev/null @@ -1,71 +0,0 @@ - -# module type S = sig type t [@@immediate] end -# module F : functor (M : S) -> S -# module A : - sig - type t [@@immediate] - type s = t [@@immediate] - type r = s - type p = q [@@immediate] - and q = int - end -# module type X = sig type t end -# module Y : sig type t = int end -# module Z : sig type t [@@immediate] end -# module M_valid : S -# module FM_valid : S -# module Foo : sig type t val x : t ref end -# module Bar : sig type t [@@immediate] val x : t ref end -# val test : (unit -> 'a) -> float = -# val test_foo : unit -> unit = -# val test_bar : unit -> unit = -# * * Characters 306-335: - type t = string [@@immediate] - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error: Types marked with the immediate attribute must be - non-pointer types like int or bool -# Characters 106-130: - type s = t [@@immediate] - ^^^^^^^^^^^^^^^^^^^^^^^^ -Error: Types marked with the immediate attribute must be - non-pointer types like int or bool -# Characters 120-148: - ..........................................struct - type t = string - end.. -Error: Signature mismatch: - Modules do not match: - sig type t = string end - is not included in - sig type t [@@immediate] end - Type declarations do not match: - type t = string - is not included in - type t [@@immediate] - the first is not an immediate type. -# Characters 72-98: - module M_invalid : S = struct type t = string end;; - ^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error: Signature mismatch: - Modules do not match: sig type t = string end is not included in S - Type declarations do not match: - type t = string - is not included in - type t [@@immediate] - the first is not an immediate type. -# Characters 23-49: - module FM_invalid = F (struct type t = string end);; - ^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error: Signature mismatch: - Modules do not match: sig type t = string end is not included in S - Type declarations do not match: - type t = string - is not included in - type t [@@immediate] - the first is not an immediate type. -# Characters 85-109: - type t = s [@@immediate] - ^^^^^^^^^^^^^^^^^^^^^^^^ -Error: Types marked with the immediate attribute must be - non-pointer types like int or bool -#