Skip to content

Commit

Permalink
Update test generation and add native tests for instance typing
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemaurer committed Oct 20, 2023
1 parent b62e6c2 commit d051da2
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 5 deletions.
49 changes: 49 additions & 0 deletions ocaml/testsuite/tests/templates/basic/gen_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,57 @@ let tree_for_mode mode =
["string_monoid"; "string_monoid_no_mli"; "test_direct_access"];
]);
]);
compile "semigroup.mli";
compile "category.mli";
compile "monoid_of_semigroup.mli"
~flags:"-parameter Semigroup -as-argument-for Monoid";
(* Invoke the compiler separately on .mli and .ml just this once to make sure
things work this way as well *)
compile "monoid_of_semigroup.ml";
compile "list_element.mli" ~flags:"-as-parameter";
compile "list_monoid.mli list_monoid.ml"
~flags:"-parameter List_element -as-argument-for Monoid";
compile "monoid_utils.mli monoid_utils.ml" ~flags:"-parameter Monoid";
compile_bad_ml "bad_ref_indirect" ~flags:"";
compile_bad_ml "bad_instance_arg_name_not_found"
~flags:"-parameter List_element";
compile_bad_ml "bad_instance_arg_value_not_arg"
~flags:"-parameter List_element";
compile_bad_ml "bad_instance_arg_value_not_found"
~flags:"-parameter List_element";
compile_bad_ml "bad_ref_direct_imported" ~flags:"-parameter Semigroup";
compile "chain.mli chain.ml" ~flags:"-parameter Category";
compile "category_utils.mli category_utils.ml" ~flags:"-parameter Category";
compile "category_of_monoid.mli category_of_monoid.ml"
~flags:"-parameter Monoid -as-argument-for Category";
compile_bad_ml "bad_instance_arg_value_wrong_type"
~flags:"-parameter List_element";
compile "import.ml"
~flags:"-parameter Semigroup -parameter List_element -w -misplaced-attribute";
compile "main.mli"
~flags:"-parameter Semigroup -parameter List_element -w -misplaced-attribute";
Branch (Seq [
Act (compiler, [
"flags", "-parameter Semigroup -parameter List_element -w -misplaced-attribute -i";
"module", "main.ml";
]);
Act (!%"check-%s-output" compiler, [
"compiler_reference", "main.reference"
]);
]);
compile "main.ml";
Branch (
match mode with
| Byte -> Seq [
Act ("ocamlobjinfo", [
"program", !%"main.%s main.cmi" cmo;
]);
Act ("check-program-output", [])
]
| Native ->
(* flambda output is too noisy *)
Nop
);
]

let test_tree = Par [ tree_for_mode Byte; tree_for_mode Native ]
Expand Down
15 changes: 15 additions & 0 deletions ocaml/testsuite/tests/templates/basic/test.in.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,25 @@
readonly_files = "\
bad_arg_impl.ml bad_arg_impl.reference \
bad_arg_intf.mli bad_arg_intf.reference \
bad_instance_arg_name_not_found.ml bad_instance_arg_name_not_found.reference \
bad_instance_arg_value_not_arg.ml bad_instance_arg_value_not_arg.reference \
bad_instance_arg_value_not_found.ml bad_instance_arg_value_not_found.reference \
bad_instance_arg_value_wrong_type.ml bad_instance_arg_value_wrong_type.reference \
bad_ref_direct.ml bad_ref_direct.reference \
bad_ref_direct_imported.ml bad_ref_direct_imported.reference \
bad_ref_indirect.ml bad_ref_indirect.reference \
category.ml category.mli \
category_of_monoid.ml category_of_monoid.mli \
category_utils.ml category_utils.mli \
chain.ml chain.mli \
import.ml \
list_element.mli \
list_monoid.ml list_monoid.mli \
main.ml main.mli main.reference \
monoid.mli \
monoid_of_semigroup.ml monoid_of_semigroup.mli \
monoid_utils.ml monoid_utils.mli \
semigroup.mli \
string_monoid.ml string_monoid.mli \
test_direct_access.ml test_direct_access.reference \
"
Expand Down
145 changes: 140 additions & 5 deletions ocaml/testsuite/tests/templates/basic/test.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
(* If this is [test.ml], instead change [test.in.ml] and/or [gen_test.ml] and
re-run [gen_test.ml]. *)

(* TEST
readonly_files = "\
Expand Down Expand Up @@ -31,6 +34,7 @@ readonly_files = "\
flags = "-as-parameter"
module = "monoid.mli"
*** ocamlc.byte
flags = ""
module = "bad_ref_direct.ml"
compiler_output = "bad_ref_direct.output"
ocamlc_byte_exit_status = "2"
Expand Down Expand Up @@ -61,9 +65,13 @@ flags = ""
module = "test_direct_access.ml"
****** ocamlc.byte
flags = ""
program = "${test_build_directory}/test_direct_access.exe"
program = "${test_build_directory}/test_direct_access.bc"
module = ""
all_modules = "string_monoid.cmo string_monoid_no_mli.cmo test_direct_access.cmo"
all_modules = "\
string_monoid.cmo \
string_monoid_no_mli.cmo \
test_direct_access.cmo \
"
******* run
output = "test_direct_access.output"
******** check-program-output
Expand All @@ -76,8 +84,6 @@ module = "category.mli"
flags = "-parameter Semigroup -as-argument-for Monoid"
module = "monoid_of_semigroup.mli"
****** ocamlc.byte
(* Invoke the compiler separately on .mli and .ml just this once to make sure
things work this way as well *)
module = "monoid_of_semigroup.ml"
******* ocamlc.byte
flags = "-as-parameter"
Expand Down Expand Up @@ -146,7 +152,7 @@ module = "import.ml"
flags = "-parameter Semigroup -parameter List_element -w -misplaced-attribute"
module = "main.mli"
*************** ocamlc.byte
flags += " -i"
flags = "-parameter Semigroup -parameter List_element -w -misplaced-attribute -i"
module = "main.ml"
**************** check-ocamlc.byte-output
compiler_reference = "main.reference"
Expand All @@ -155,4 +161,133 @@ module = "main.ml"
**************** ocamlobjinfo
program = "main.cmo main.cmi"
***************** check-program-output
* setup-ocamlopt.byte-build-env
** ocamlopt.byte
flags = "-as-parameter"
module = "monoid.mli"
*** ocamlopt.byte
flags = ""
module = "bad_ref_direct.ml"
compiler_output = "bad_ref_direct.output"
ocamlopt_byte_exit_status = "2"
**** check-ocamlopt.byte-output
compiler_reference = "bad_ref_direct.reference"
*** ocamlopt.byte
flags = "-as-argument-for Monoid"
module = "bad_arg_impl.ml"
compiler_output = "bad_arg_impl.output"
ocamlopt_byte_exit_status = "2"
**** check-ocamlopt.byte-output
compiler_reference = "bad_arg_impl.reference"
*** ocamlopt.byte
flags = "-as-argument-for Monoid"
module = "bad_arg_intf.mli"
compiler_output = "bad_arg_intf.output"
ocamlopt_byte_exit_status = "2"
**** check-ocamlopt.byte-output
compiler_reference = "bad_arg_intf.reference"
*** copy
src = "string_monoid.ml"
dst = "string_monoid_no_mli.ml"
**** ocamlopt.byte
flags = "-as-argument-for Monoid"
module = "string_monoid_no_mli.ml string_monoid.mli string_monoid.ml"
***** ocamlopt.byte
flags = ""
module = "test_direct_access.ml"
****** ocamlopt.byte
flags = ""
program = "${test_build_directory}/test_direct_access.exe"
module = ""
all_modules = "\
string_monoid.cmx \
string_monoid_no_mli.cmx \
test_direct_access.cmx \
"
******* run
output = "test_direct_access.output"
******** check-program-output
reference = "test_direct_access.reference"
*** ocamlopt.byte
module = "semigroup.mli"
**** ocamlopt.byte
module = "category.mli"
***** ocamlopt.byte
flags = "-parameter Semigroup -as-argument-for Monoid"
module = "monoid_of_semigroup.mli"
****** ocamlopt.byte
module = "monoid_of_semigroup.ml"
******* ocamlopt.byte
flags = "-as-parameter"
module = "list_element.mli"
******** ocamlopt.byte
flags = "-parameter List_element -as-argument-for Monoid"
module = "list_monoid.mli list_monoid.ml"
********* ocamlopt.byte
flags = "-parameter Monoid"
module = "monoid_utils.mli monoid_utils.ml"
********** ocamlopt.byte
flags = ""
module = "bad_ref_indirect.ml"
compiler_output = "bad_ref_indirect.output"
ocamlopt_byte_exit_status = "2"
*********** check-ocamlopt.byte-output
compiler_reference = "bad_ref_indirect.reference"
********** ocamlopt.byte
flags = "-parameter List_element"
module = "bad_instance_arg_name_not_found.ml"
compiler_output = "bad_instance_arg_name_not_found.output"
ocamlopt_byte_exit_status = "2"
*********** check-ocamlopt.byte-output
compiler_reference = "bad_instance_arg_name_not_found.reference"
********** ocamlopt.byte
flags = "-parameter List_element"
module = "bad_instance_arg_value_not_arg.ml"
compiler_output = "bad_instance_arg_value_not_arg.output"
ocamlopt_byte_exit_status = "2"
*********** check-ocamlopt.byte-output
compiler_reference = "bad_instance_arg_value_not_arg.reference"
********** ocamlopt.byte
flags = "-parameter List_element"
module = "bad_instance_arg_value_not_found.ml"
compiler_output = "bad_instance_arg_value_not_found.output"
ocamlopt_byte_exit_status = "2"
*********** check-ocamlopt.byte-output
compiler_reference = "bad_instance_arg_value_not_found.reference"
********** ocamlopt.byte
flags = "-parameter Semigroup"
module = "bad_ref_direct_imported.ml"
compiler_output = "bad_ref_direct_imported.output"
ocamlopt_byte_exit_status = "2"
*********** check-ocamlopt.byte-output
compiler_reference = "bad_ref_direct_imported.reference"
********** ocamlopt.byte
flags = "-parameter Category"
module = "chain.mli chain.ml"
*********** ocamlopt.byte
flags = "-parameter Category"
module = "category_utils.mli category_utils.ml"
************ ocamlopt.byte
flags = "-parameter Monoid -as-argument-for Category"
module = "category_of_monoid.mli category_of_monoid.ml"
************* ocamlopt.byte
flags = "-parameter List_element"
module = "bad_instance_arg_value_wrong_type.ml"
compiler_output = "bad_instance_arg_value_wrong_type.output"
ocamlopt_byte_exit_status = "2"
************** check-ocamlopt.byte-output
compiler_reference = "bad_instance_arg_value_wrong_type.reference"
************* ocamlopt.byte
flags = "-parameter Semigroup -parameter List_element -w -misplaced-attribute"
module = "import.ml"
************** ocamlopt.byte
flags = "-parameter Semigroup -parameter List_element -w -misplaced-attribute"
module = "main.mli"
*************** ocamlopt.byte
flags = "-parameter Semigroup -parameter List_element -w -misplaced-attribute -i"
module = "main.ml"
**************** check-ocamlopt.byte-output
compiler_reference = "main.reference"
*************** ocamlopt.byte
module = "main.ml"
*)

0 comments on commit d051da2

Please sign in to comment.