├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── build-mingw64.yml │ └── main.yml ├── .gitignore ├── .ocamlformat ├── .ocamlformat-ignore ├── .ocp-indent ├── CHANGES.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── HACKING.org ├── LICENSE.md ├── Makefile ├── README.md ├── bin ├── ocamlformat-rpc │ ├── dune │ ├── main.ml │ └── main.mli └── ocamlformat │ ├── dune │ ├── main.ml │ └── main.mli ├── dune ├── dune-project ├── emacs ├── dune └── ocamlformat.el ├── lib-rpc ├── dune ├── ocamlformat_rpc_lib.ml └── ocamlformat_rpc_lib.mli ├── lib ├── Assoc.ml ├── Assoc.mli ├── Ast.ml ├── Ast.mli ├── Cmt.ml ├── Cmt.mli ├── Cmts.ml ├── Cmts.mli ├── Conf.ml ├── Conf.mli ├── Config_option.ml ├── Config_option.mli ├── Docstring.ml ├── Docstring.mli ├── Exposed.ml ├── Exposed.mli ├── Extended_ast.ml ├── Extended_ast.mli ├── Fmt.ml ├── Fmt.mli ├── Fmt_ast.ml ├── Fmt_ast.mli ├── Fmt_odoc.ml ├── Fmt_odoc.mli ├── Indent.ml ├── Indent.mli ├── Literal_lexer.mli ├── Literal_lexer.mll ├── Loc_tree.ml ├── Loc_tree.mli ├── Migrate_ast.ml ├── Migrate_ast.mli ├── Multimap.ml ├── Multimap.mli ├── Non_overlapping_interval_tree.ml ├── Non_overlapping_interval_tree.mli ├── Normalize.ml ├── Normalize.mli ├── Params.ml ├── Params.mli ├── Parse_with_comments.ml ├── Parse_with_comments.mli ├── Prec.ml ├── Prec.mli ├── Source.ml ├── Source.mli ├── Std_ast.ml ├── Std_ast.mli ├── Sugar.ml ├── Sugar.mli ├── Syntax.ml ├── Syntax.mli ├── Translation_unit.ml ├── Translation_unit.mli ├── Version.ml ├── Version.mli └── dune ├── ocamlformat-help.txt ├── ocamlformat-rpc-help.txt ├── ocamlformat-rpc-lib.opam ├── ocamlformat-rpc.opam ├── ocamlformat-rpc.opam.template ├── ocamlformat.opam ├── ocamlformat.opam.template ├── test-extra └── Makefile ├── test ├── cli │ ├── bad_kind.t │ ├── check.t │ ├── conf.t │ ├── debug.t │ ├── dune │ ├── env.t │ ├── err_inplace_and_output.t │ ├── err_no_arg.t │ ├── large_string.t │ ├── max_iters.t │ ├── name.t │ ├── removed_option.t │ ├── several_files.t │ └── stdin.t ├── disabled │ ├── dir1 │ │ ├── .ocamlformat │ │ ├── .ocamlformat-ignore │ │ └── dir2 │ │ │ ├── .ocamlformat-ignore │ │ │ ├── ignore_1.ml │ │ │ └── ignore_2.ml │ └── dune ├── failing │ ├── dune │ ├── dune.inc │ ├── gen │ │ ├── dune │ │ └── gen.ml │ └── tests │ │ ├── .ocamlformat │ │ ├── comments.ml │ │ ├── comments.ml.broken-ref │ │ ├── core_failing.ml │ │ ├── core_failing.ml.broken-ref │ │ ├── core_passing.ml │ │ ├── core_passing.ml.broken-ref │ │ ├── dune-project │ │ ├── edge_cases.ml │ │ ├── edge_cases.ml.broken-ref │ │ ├── escaped_nl.ml │ │ ├── escaped_nl.ml.broken-ref │ │ ├── exprs.ml │ │ ├── exprs.ml.broken-ref │ │ ├── indent_empty.ml │ │ ├── indent_empty.ml.broken-ref │ │ ├── js_2018.ml │ │ ├── js_2018.ml.broken-ref │ │ ├── js_bench.ml │ │ ├── js_bench.ml.broken-ref │ │ ├── js_comment.ml │ │ ├── js_comment.ml.broken-ref │ │ ├── js_default.ml │ │ ├── js_default.ml.broken-ref │ │ ├── js_functor.ml │ │ ├── js_functor.ml.broken-ref │ │ ├── js_low_priority.ml │ │ ├── js_low_priority.ml.broken-ref │ │ ├── js_test.ml │ │ ├── js_test.ml.broken-ref │ │ ├── lwt.ml │ │ ├── lwt.ml.broken-ref │ │ ├── macro.ml │ │ ├── macro.ml.broken-ref │ │ ├── match_fun.ml │ │ ├── match_fun.ml.broken-ref │ │ ├── misc_2019.ml │ │ ├── misc_2019.ml.broken-ref │ │ ├── module.ml │ │ ├── module.ml.broken-ref │ │ ├── nesting.ml │ │ ├── nesting.ml.broken-ref │ │ ├── never_align.ml │ │ ├── never_align.ml.broken-ref │ │ ├── ocamldoc.ml │ │ ├── ocamldoc.ml.broken-ref │ │ ├── partial2.ml │ │ ├── partial2.ml.broken-ref │ │ ├── pattern.ml │ │ ├── pattern.ml.broken-ref │ │ ├── ppx_stritem_ext.ml │ │ ├── ppx_stritem_ext.ml.broken-ref │ │ ├── quotations2.ml │ │ ├── quotations2.ml.broken-ref │ │ ├── record_with.ml │ │ ├── record_with.ml.broken-ref │ │ ├── unit_classes.ml │ │ ├── unit_classes.ml.broken-ref │ │ ├── unit_expr.ml │ │ ├── unit_expr.ml.broken-ref │ │ ├── unit_extensions.ml │ │ ├── unit_extensions.ml.broken-ref │ │ ├── unit_lex.ml │ │ ├── unit_lex.ml.broken-ref │ │ ├── unit_modtypes.ml │ │ ├── unit_modtypes.ml.broken-ref │ │ ├── unit_typedefs.ml │ │ ├── unit_typedefs.ml.broken-ref │ │ ├── unit_types.ml │ │ ├── unit_types.ml.broken-ref │ │ ├── unit_values.ml │ │ ├── unit_values.ml.broken-ref │ │ ├── unstable_docstrings.mli │ │ ├── unstable_docstrings.mli.broken-ref │ │ ├── unstable_docstrings.mli.enabled-if │ │ ├── with_2.ml │ │ └── with_2.ml.broken-ref ├── passing │ ├── dune │ ├── dune.inc │ ├── gen │ │ ├── dune │ │ └── gen.ml │ └── tests │ │ ├── .ocamlformat │ │ ├── .ocp-indent │ │ ├── align_cases-break_all.ml.opts │ │ ├── align_cases-break_all.ml.ref │ │ ├── align_cases.ml │ │ ├── align_cases.ml.opts │ │ ├── align_infix.ml │ │ ├── align_infix.ml.opts │ │ ├── alignment.ml │ │ ├── alignment.ml.ref │ │ ├── apply.ml │ │ ├── apply_functor.ml │ │ ├── args_grouped.ml │ │ ├── args_grouped.ml.opts │ │ ├── array.ml │ │ ├── assignment_operator-op_begin_line.ml.opts │ │ ├── assignment_operator-op_begin_line.ml.ref │ │ ├── assignment_operator.ml │ │ ├── assignment_operator.ml.ref │ │ ├── attribute_and_expression.ml │ │ ├── attributes.ml │ │ ├── attributes.mli │ │ ├── attributes.mli.ref │ │ ├── binders.ml │ │ ├── break_before_in-auto.ml.opts │ │ ├── break_before_in-auto.ml.ref │ │ ├── break_before_in.ml │ │ ├── break_before_in.ml.opts │ │ ├── break_cases-align.ml.opts │ │ ├── break_cases-align.ml.ref │ │ ├── break_cases-all.ml.opts │ │ ├── break_cases-all.ml.ref │ │ ├── break_cases-closing_on_separate_line.ml.opts │ │ ├── break_cases-closing_on_separate_line.ml.ref │ │ ├── break_cases-closing_on_separate_line_leading_nested_match_parens.ml.opts │ │ ├── break_cases-closing_on_separate_line_leading_nested_match_parens.ml.ref │ │ ├── break_cases-cosl_lnmp_cmei.ml.opts │ │ ├── break_cases-cosl_lnmp_cmei.ml.ref │ │ ├── break_cases-fit_or_vertical.ml.opts │ │ ├── break_cases-fit_or_vertical.ml.ref │ │ ├── break_cases-nested.ml.opts │ │ ├── break_cases-nested.ml.ref │ │ ├── break_cases-normal_indent.ml.opts │ │ ├── break_cases-normal_indent.ml.ref │ │ ├── break_cases-toplevel.ml.opts │ │ ├── break_cases-toplevel.ml.ref │ │ ├── break_cases.ml │ │ ├── break_cases.ml.opts │ │ ├── break_cases.ml.ref │ │ ├── break_fun_decl-fit_or_vertical.ml.opts │ │ ├── break_fun_decl-fit_or_vertical.ml.ref │ │ ├── break_fun_decl-smart.ml.opts │ │ ├── break_fun_decl-smart.ml.ref │ │ ├── break_fun_decl-wrap.ml.opts │ │ ├── break_fun_decl-wrap.ml.ref │ │ ├── break_fun_decl.ml │ │ ├── break_record.ml │ │ ├── break_record.ml.opts │ │ ├── break_separators-after.ml.opts │ │ ├── break_separators-after.ml.ref │ │ ├── break_separators-after_docked.ml.opts │ │ ├── break_separators-after_docked.ml.ref │ │ ├── break_separators-after_docked_wrap.ml.opts │ │ ├── break_separators-after_docked_wrap.ml.ref │ │ ├── break_separators-after_wrap.ml.opts │ │ ├── break_separators-after_wrap.ml.ref │ │ ├── break_separators-before_docked.ml.opts │ │ ├── break_separators-before_docked.ml.ref │ │ ├── break_separators-before_docked_wrap.ml.opts │ │ ├── break_separators-before_docked_wrap.ml.ref │ │ ├── break_separators-wrap.ml.opts │ │ ├── break_separators-wrap.ml.ref │ │ ├── break_separators.ml │ │ ├── break_separators.ml.opts │ │ ├── break_sequence_before.ml │ │ ├── break_string_literals-never.ml.opts │ │ ├── break_string_literals-never.ml.ref │ │ ├── break_string_literals.ml │ │ ├── break_string_literals.ml.opts │ │ ├── break_string_literals.ml.ref │ │ ├── break_struct.ml │ │ ├── break_struct.ml.ref │ │ ├── cinaps.ml │ │ ├── cmdline_override.ml │ │ ├── cmdline_override.ml.opts │ │ ├── cmdline_override2.ml │ │ ├── cmdline_override2.ml.opts │ │ ├── coerce.ml │ │ ├── comment_breaking.ml │ │ ├── comment_header.ml │ │ ├── comment_header.ml.ref │ │ ├── comment_in_empty.ml │ │ ├── comment_in_modules.ml │ │ ├── comment_in_modules.ml.ref │ │ ├── comment_last.ml │ │ ├── comment_sparse.ml │ │ ├── comments.ml │ │ ├── comments.ml.opts │ │ ├── comments.ml.ref │ │ ├── comments_args.ml │ │ ├── comments_args.ml.opts │ │ ├── comments_args.ml.ref │ │ ├── comments_around_disabled.ml │ │ ├── comments_around_disabled.ml.ref │ │ ├── comments_in_record.ml │ │ ├── comments_in_record.ml.ref │ │ ├── compact_lists_arrays.ml │ │ ├── crlf_to_crlf.ml │ │ ├── crlf_to_crlf.ml.opts │ │ ├── crlf_to_crlf.ml.ref │ │ ├── crlf_to_lf.ml │ │ ├── crlf_to_lf.ml.opts │ │ ├── crlf_to_lf.ml.ref │ │ ├── custom_list.ml │ │ ├── dir1 │ │ ├── .ocamlformat │ │ └── dir2 │ │ │ ├── .ocamlformat │ │ │ └── print_config.ml │ │ ├── directives.mlt │ │ ├── directives.mlt.ref │ │ ├── disabled.ml │ │ ├── disabled.ml.opts │ │ ├── disambiguate.ml │ │ ├── doc_comments-after.ml.opts │ │ ├── doc_comments-after.ml.ref │ │ ├── doc_comments-before-except-val.ml.opts │ │ ├── doc_comments-before-except-val.ml.ref │ │ ├── doc_comments-before.ml.opts │ │ ├── doc_comments-before.ml.ref │ │ ├── doc_comments-no-parse-docstrings.mli.opts │ │ ├── doc_comments-no-parse-docstrings.mli.ref │ │ ├── doc_comments-no-wrap.mli.opts │ │ ├── doc_comments-no-wrap.mli.ref │ │ ├── doc_comments.ml │ │ ├── doc_comments.ml.ref │ │ ├── doc_comments.mli │ │ ├── doc_comments.mli.ref │ │ ├── doc_comments_padding.ml │ │ ├── dune-project │ │ ├── eliom_ext.eliom │ │ ├── empty.ml │ │ ├── empty_ml.ml │ │ ├── empty_mli.mli │ │ ├── empty_mlt.mlt │ │ ├── error1.ml │ │ ├── error1.ml.ref │ │ ├── error1.ml.should-fail │ │ ├── error2.ml │ │ ├── error2.ml.ref │ │ ├── error2.ml.should-fail │ │ ├── error3.ml │ │ ├── error3.ml.ref │ │ ├── error3.ml.should-fail │ │ ├── error4.ml │ │ ├── error4.ml.opts │ │ ├── error4.ml.ref │ │ ├── escaped_nl.ml │ │ ├── escaped_nl.ml.ref │ │ ├── exceptions.ml │ │ ├── exp_grouping-parens.ml.opts │ │ ├── exp_grouping-parens.ml.ref │ │ ├── exp_grouping.ml │ │ ├── exp_grouping.ml.opts │ │ ├── exp_grouping.ml.ref │ │ ├── exp_record.ml │ │ ├── expect_test.ml │ │ ├── extensions-indent.ml.opts │ │ ├── extensions-indent.ml.ref │ │ ├── extensions-indent.mli.opts │ │ ├── extensions-indent.mli.ref │ │ ├── extensions.ml │ │ ├── extensions.ml.opts │ │ ├── extensions.ml.ref │ │ ├── extensions.mli │ │ ├── field-op_begin_line.ml.opts │ │ ├── field-op_begin_line.ml.ref │ │ ├── field.ml │ │ ├── first_class_module.ml │ │ ├── floating_doc.ml │ │ ├── for_while.ml │ │ ├── format_invalid_files-0.ml.opts │ │ ├── format_invalid_files-0.ml.ref │ │ ├── format_invalid_files.ml │ │ ├── format_invalid_files.ml.opts │ │ ├── format_invalid_files.ml.ref │ │ ├── format_invalid_files_with_locations.ml │ │ ├── format_invalid_files_with_locations.ml.opts │ │ ├── format_invalid_files_with_locations.ml.ref │ │ ├── fun_decl.ml │ │ ├── fun_function.ml │ │ ├── function_indent-never.ml.opts │ │ ├── function_indent-never.ml.ref │ │ ├── function_indent.ml │ │ ├── function_indent.ml.opts │ │ ├── function_indent.ml.ref │ │ ├── functor.ml │ │ ├── funsig.ml │ │ ├── gadt.ml │ │ ├── generative.ml │ │ ├── hash_types.ml │ │ ├── holes.ml │ │ ├── holes.ml.ref │ │ ├── ifand.ml │ │ ├── ifand.ml.ref │ │ ├── index_op.ml │ │ ├── indicate_multiline_delimiters-cosl.ml.opts │ │ ├── indicate_multiline_delimiters-cosl.ml.ref │ │ ├── indicate_multiline_delimiters-space.ml.opts │ │ ├── indicate_multiline_delimiters-space.ml.ref │ │ ├── indicate_multiline_delimiters.ml │ │ ├── indicate_multiline_delimiters.ml.opts │ │ ├── infix_arg_grouping.ml │ │ ├── infix_bind-break.ml.opts │ │ ├── infix_bind-break.ml.ref │ │ ├── infix_bind-fit_or_vertical-break.ml.opts │ │ ├── infix_bind-fit_or_vertical-break.ml.ref │ │ ├── infix_bind-fit_or_vertical.ml.opts │ │ ├── infix_bind-fit_or_vertical.ml.ref │ │ ├── infix_bind.ml │ │ ├── infix_bind.ml.opts │ │ ├── infix_precedence.ml │ │ ├── infix_precedence.ml.opts │ │ ├── injectivity.ml │ │ ├── invalid.ml │ │ ├── invalid_docstring.ml │ │ ├── invalid_docstring.ml.ref │ │ ├── issue114.ml │ │ ├── issue1750.ml │ │ ├── issue289.ml │ │ ├── issue48.ml │ │ ├── issue51.ml │ │ ├── issue57.ml │ │ ├── issue60.ml │ │ ├── issue77.ml │ │ ├── issue85.ml │ │ ├── issue89.ml │ │ ├── ite-compact.ml.opts │ │ ├── ite-compact.ml.ref │ │ ├── ite-compact_closing.ml.opts │ │ ├── ite-compact_closing.ml.ref │ │ ├── ite-fit_or_vertical.ml.opts │ │ ├── ite-fit_or_vertical.ml.ref │ │ ├── ite-fit_or_vertical_closing.ml.opts │ │ ├── ite-fit_or_vertical_closing.ml.ref │ │ ├── ite-fit_or_vertical_no_indicate.ml.opts │ │ ├── ite-fit_or_vertical_no_indicate.ml.ref │ │ ├── ite-kr.ml.opts │ │ ├── ite-kr.ml.ref │ │ ├── ite-kr_closing.ml.opts │ │ ├── ite-kr_closing.ml.ref │ │ ├── ite-kw_first.ml.opts │ │ ├── ite-kw_first.ml.ref │ │ ├── ite-kw_first_closing.ml.opts │ │ ├── ite-kw_first_closing.ml.ref │ │ ├── ite-kw_first_no_indicate.ml.opts │ │ ├── ite-kw_first_no_indicate.ml.ref │ │ ├── ite-no_indicate.ml.opts │ │ ├── ite-no_indicate.ml.ref │ │ ├── ite.ml │ │ ├── ite.ml.opts │ │ ├── ite.ml.ref │ │ ├── js_args.ml │ │ ├── js_args.ml.opts │ │ ├── js_args.ml.ref │ │ ├── js_begin.ml │ │ ├── js_begin.ml.ref │ │ ├── js_bind.ml │ │ ├── js_bind.ml.ref │ │ ├── js_fun.ml │ │ ├── js_fun.ml.opts │ │ ├── js_fun.ml.ref │ │ ├── js_map.ml │ │ ├── js_map.ml.opts │ │ ├── js_map.ml.ref │ │ ├── js_pattern.ml │ │ ├── js_pattern.ml.ref │ │ ├── js_poly.ml │ │ ├── js_poly.ml.opts │ │ ├── js_poly.ml.ref │ │ ├── js_record.ml │ │ ├── js_record.ml.ref │ │ ├── js_sig.mli │ │ ├── js_sig.mli.opts │ │ ├── js_sig.mli.ref │ │ ├── js_source.ml │ │ ├── js_source.ml.ocp │ │ ├── js_source.ml.opts │ │ ├── js_source.ml.ref │ │ ├── js_syntax.ml │ │ ├── js_syntax.ml.ref │ │ ├── js_to_do.ml │ │ ├── js_to_do.ml.ref │ │ ├── js_upon.ml │ │ ├── js_upon.ml.ref │ │ ├── kw_extentions.ml │ │ ├── label_option_default_args.ml │ │ ├── label_option_default_args.ml.opts │ │ ├── label_option_default_args.ml.ref │ │ ├── labelled_args-414.ml.opts │ │ ├── labelled_args-414.ml.ref │ │ ├── labelled_args.ml │ │ ├── lazy.ml │ │ ├── let_binding-in_indent.ml.opts │ │ ├── let_binding-in_indent.ml.ref │ │ ├── let_binding-indent.ml.opts │ │ ├── let_binding-indent.ml.ref │ │ ├── let_binding.ml │ │ ├── let_binding.ml.ref │ │ ├── let_binding_spacing-double-semicolon.ml.opts │ │ ├── let_binding_spacing-double-semicolon.ml.ref │ │ ├── let_binding_spacing-sparse.ml.opts │ │ ├── let_binding_spacing-sparse.ml.ref │ │ ├── let_binding_spacing.ml │ │ ├── let_binding_spacing.ml.opts │ │ ├── let_in_constr.ml │ │ ├── let_module-sparse.ml.opts │ │ ├── let_module-sparse.ml.ref │ │ ├── let_module.ml │ │ ├── let_module.ml.opts │ │ ├── let_module.ml.ref │ │ ├── let_punning.ml │ │ ├── list-space_around.ml.opts │ │ ├── list-space_around.ml.ref │ │ ├── list.ml │ │ ├── list_and_comments.ml │ │ ├── list_and_comments.ml.ref │ │ ├── loc_stack.ml │ │ ├── loc_stack.ml.opts │ │ ├── loc_stack.ml.ref │ │ ├── locally_abtract_types.ml │ │ ├── margin_80.ml │ │ ├── margin_80.ml.opts │ │ ├── margin_80.ml.ref │ │ ├── match.ml │ │ ├── match2.ml │ │ ├── match2.ml.opts │ │ ├── match_indent-never.ml.opts │ │ ├── match_indent-never.ml.ref │ │ ├── match_indent.ml │ │ ├── match_indent.ml.opts │ │ ├── match_indent.ml.ref │ │ ├── max_indent.ml │ │ ├── max_indent.ml.opts │ │ ├── mod_type_subst.ml │ │ ├── module.ml │ │ ├── module_anonymous.ml │ │ ├── module_attributes.ml │ │ ├── module_attributes.ml.ref │ │ ├── module_item_spacing-preserve.ml.opts │ │ ├── module_item_spacing-preserve.ml.ref │ │ ├── module_item_spacing-sparse.ml.opts │ │ ├── module_item_spacing-sparse.ml.ref │ │ ├── module_item_spacing.ml │ │ ├── module_item_spacing.ml.opts │ │ ├── module_item_spacing.ml.ref │ │ ├── module_item_spacing.mli │ │ ├── module_item_spacing.mli.opts │ │ ├── module_item_spacing.mli.ref │ │ ├── module_type.ml │ │ ├── monadic_binding.ml │ │ ├── multi_index_op.ml │ │ ├── named_existentials.ml │ │ ├── need_format.ml │ │ ├── need_format.ml.opts │ │ ├── need_format.ml.ref │ │ ├── need_format.ml.should-fail │ │ ├── new.ml │ │ ├── object.ml │ │ ├── object2.ml │ │ ├── object2.ml.ref │ │ ├── object_type.ml │ │ ├── object_type.ml.ref │ │ ├── obuild.ml │ │ ├── obuild.ml.ref │ │ ├── ocp_indent_compat.ml │ │ ├── ocp_indent_options.ml │ │ ├── ocp_indent_options.ml.opts │ │ ├── ocp_indent_options.ml.ref │ │ ├── open-closing-on-separate-line.ml.opts │ │ ├── open-closing-on-separate-line.ml.ref │ │ ├── open.ml │ │ ├── open.ml.ref │ │ ├── open_types.ml │ │ ├── option.ml │ │ ├── option.ml.ref │ │ ├── override.ml │ │ ├── override.ml.ref │ │ ├── parens_tuple_patterns.ml │ │ ├── partial.ml │ │ ├── partial.ml.opts │ │ ├── partial.ml.ref │ │ ├── partial_double_quotes.ml │ │ ├── partial_double_quotes.ml.opts │ │ ├── partial_double_quotes.ml.ref │ │ ├── polytypes-default.ml.opts │ │ ├── polytypes-default.ml.ref │ │ ├── polytypes-janestreet.ml.opts │ │ ├── polytypes-janestreet.ml.ref │ │ ├── polytypes.ml │ │ ├── pre_post_extensions.ml │ │ ├── precedence.ml │ │ ├── prefix_infix.ml │ │ ├── print_config.ml │ │ ├── print_config.ml.deps │ │ ├── print_config.ml.enabled-if │ │ ├── print_config.ml.opts │ │ ├── print_config.ml.ref │ │ ├── profiles.ml │ │ ├── profiles.ml.opts │ │ ├── profiles2.ml │ │ ├── profiles2.ml.opts │ │ ├── protected_object_types.ml │ │ ├── quoted_strings.ml │ │ ├── recmod.mli │ │ ├── record-loose.ml.opts │ │ ├── record-loose.ml.ref │ │ ├── record-tight_decl.ml.opts │ │ ├── record-tight_decl.ml.ref │ │ ├── record.ml │ │ ├── record.ml.opts │ │ ├── record.ml.ref │ │ ├── record_punning.ml │ │ ├── reformat_string.ml │ │ ├── reformat_string.ml.opts │ │ ├── reformat_string.ml.ref │ │ ├── refs.ml │ │ ├── remove_extra_parens.ml │ │ ├── remove_extra_parens.ml.ref │ │ ├── revapply_ext.ml │ │ ├── send.ml │ │ ├── sequence-preserve.ml.opts │ │ ├── sequence-preserve.ml.ref │ │ ├── sequence.ml │ │ ├── sequence.ml.opts │ │ ├── sequence.ml.ref │ │ ├── shebang.ml │ │ ├── shortcut_ext_attr.ml │ │ ├── sig_value.mli │ │ ├── sig_value.mli.ref │ │ ├── single_line.mli │ │ ├── skip.ml │ │ ├── source.ml │ │ ├── source.ml.opts │ │ ├── source.ml.ref │ │ ├── str_value.ml │ │ ├── string.ml │ │ ├── string.ml.ref │ │ ├── string_array.ml │ │ ├── string_wrapping.ml │ │ ├── symbol.ml │ │ ├── tag_only.ml │ │ ├── tag_only.mli │ │ ├── try_with_or_pattern.ml │ │ ├── tuple.ml │ │ ├── tuple.ml.opts │ │ ├── tuple_less_parens.ml │ │ ├── tuple_less_parens.ml.opts │ │ ├── tuple_type_parens.ml │ │ ├── type_and_constraint.ml │ │ ├── type_annotations.ml │ │ ├── types-compact-space_around-docked.ml.opts │ │ ├── types-compact-space_around-docked.ml.ref │ │ ├── types-compact-space_around.ml.opts │ │ ├── types-compact-space_around.ml.ref │ │ ├── types-compact.ml.opts │ │ ├── types-compact.ml.ref │ │ ├── types-indent.ml.opts │ │ ├── types-indent.ml.ref │ │ ├── types-sparse-space_around.ml.opts │ │ ├── types-sparse-space_around.ml.ref │ │ ├── types-sparse.ml.opts │ │ ├── types-sparse.ml.ref │ │ ├── types.ml │ │ ├── unary.ml │ │ ├── unary.ml.ref │ │ ├── unary_hash.ml │ │ ├── unicode.ml │ │ ├── unicode.ml.opts │ │ ├── unicode.ml.ref │ │ ├── use_file.mlt │ │ ├── verbose1.ml │ │ ├── verbose1.ml.enabled-if │ │ ├── verbose1.ml.opts │ │ ├── verbose1.ml.ref │ │ ├── verbose2.ml │ │ ├── verbose2.ml.enabled-if │ │ ├── verbose2.ml.opts │ │ ├── verbose2.ml.ref │ │ ├── wrap_comments.ml │ │ ├── wrap_comments.ml.opts │ │ ├── wrap_comments.ml.ref │ │ ├── wrap_comments_break.ml │ │ ├── wrap_comments_break.ml.opts │ │ └── wrapping_functor_args.ml ├── projects │ ├── .ocamlformat │ ├── dune │ ├── enable_outside_detected_project.expected │ ├── enable_outside_detected_project │ │ ├── dune-project │ │ └── main.ml │ ├── outside_detected_project.expected │ ├── outside_detected_project │ │ ├── dune-project │ │ └── main.ml │ ├── outside_detected_project_with_name.expected │ └── outside_detected_project_with_name │ │ ├── outside_root │ │ ├── .ocamlformat │ │ ├── a.ml │ │ └── dune-project │ │ └── project_root │ │ ├── .ocamlformat │ │ └── dune-project ├── rpc │ ├── dune │ ├── rpc_test.expected │ ├── rpc_test.ml │ ├── rpc_test_fail.expected │ └── rpc_test_fail.ml └── unit │ ├── dune │ ├── test_ast.ml │ ├── test_ast.mli │ ├── test_fmt.ml │ ├── test_fmt.mli │ ├── test_indent.ml │ ├── test_indent.mli │ ├── test_literal_lexer.ml │ ├── test_literal_lexer.mli │ ├── test_translation_unit.ml │ ├── test_translation_unit.mli │ ├── test_unit.ml │ └── test_unit.mli ├── tools ├── bisect.sh ├── build-mingw64.sh ├── config.headache ├── gen_changes.sh ├── header.txt ├── ocamlformat_test_branch ├── test_branch.sh └── update_headers.sh └── vendor ├── ocaml-4.13-extended ├── ast_helper.ml ├── ast_helper.mli ├── ast_mapper.ml ├── ast_mapper.mli ├── asttypes.mli ├── docstrings.ml ├── docstrings.mli ├── dune ├── lexer.mll ├── parse.ml ├── parse.mli ├── parser.mly ├── parsetree.mli ├── pprintast.ml └── pprintast.mli ├── ocaml-4.13 ├── LICENSE ├── ast_helper.ml ├── ast_helper.mli ├── ast_mapper.ml ├── ast_mapper.mli ├── asttypes.mli ├── docstrings.ml ├── docstrings.mli ├── dune ├── lexer.mll ├── parse.ml ├── parse.mli ├── parser.mly ├── parsetree.mli ├── pprintast.ml └── pprintast.mli ├── ocaml-common ├── dune ├── location.ml ├── location.mli ├── longident.ml ├── longident.mli ├── syntaxerr.ml ├── syntaxerr.mli ├── warnings.ml └── warnings.mli ├── ocamlformat-stdlib ├── cmdliner_ext.ml ├── cmdliner_ext.mli ├── dune ├── fpath_ext.ml ├── fpath_ext.mli ├── list_ext.ml ├── list_ext.mli ├── ocamlformat_stdlib.ml ├── ocamlformat_stdlib.mli ├── string_ext.ml ├── string_ext.mli ├── warning.ml └── warning.mli ├── ocamlformat_support ├── .ocamlformat ├── LICENSE ├── README.md ├── dune ├── format_.ml └── format_.mli ├── parse-wyc ├── .ocamlformat ├── LICENSE ├── README.md ├── lib │ ├── .ocamlformat-ignore │ ├── annot.ml │ ├── annot.mli │ ├── dune │ ├── let_binding.mli │ ├── lexer.mll │ ├── merlin_recovery.ml │ ├── merlin_recovery.mli │ ├── parse_wyc.ml │ ├── parse_wyc.mli │ └── parser.mly ├── menhir-recover │ ├── Makefile │ ├── attributes.ml │ ├── dune │ ├── emitter.ml │ ├── emitter.mli │ ├── main.ml │ ├── recovery_custom.ml │ ├── recovery_intf.ml │ ├── synthesis.ml │ └── utils.ml └── test │ └── unit │ ├── dune │ ├── test_unit.ml │ └── test_unit.mli └── parser-shims ├── dune ├── parser_shims.ml └── parser_shims.mli /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: 'Bug: ...' 5 | labels: 'Kind/Bug :x:' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **How to Reproduce** 14 | Steps to reproduce the behavior: 15 | - What is the formatted file? Please try to minimize the code snippet. 16 | - What are the selected options? 17 | 18 | The option `--print-config` prints the configuration on the standard output, please put the result of this command in the report if you are not sure which option causes the issue. 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: 'Feature request: ...' 5 | labels: Kind/Feature-request 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | You could write a clear and concise description of any alternative solutions or features you've considered, if any. 14 | 15 | **Describe the solution you'd like** 16 | A clear and concise description of what you want to happen. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. 20 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Changelog check 2 | 3 | on: 4 | pull_request: 5 | branches: [ master ] 6 | types: [ opened, synchronize, reopened, labeled, unlabeled ] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-18.04 11 | 12 | steps: 13 | - uses: actions/checkout@v1 14 | 15 | - name: git diff 16 | if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-changelog-needed') }} 17 | env: 18 | BASE_REF: ${{ github.event.pull_request.base.ref }} 19 | run: | 20 | ! git diff --exit-code origin/$BASE_REF -- CHANGES.md 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .merlin 2 | /_build 3 | /ocamlformat.install 4 | /test-extra/code 5 | /_opam 6 | /_coverage 7 | /_build-mingw64 8 | -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = ocamlformat 2 | break-cases = fit 3 | margin = 77 4 | parse-docstrings = true 5 | wrap-comments = true 6 | line-endings = lf 7 | -------------------------------------------------------------------------------- /.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | vendor/*/* 2 | vendor/*/*/* 3 | vendor/*/*/*/* 4 | -------------------------------------------------------------------------------- /.ocp-indent: -------------------------------------------------------------------------------- 1 | normal 2 | base = 2 3 | type = 2 4 | in = 0 5 | with = 0 6 | match_clause = 4 7 | ppx_stritem_ext = 2 8 | max_indent = 4 9 | strict_with = auto 10 | strict_else = always 11 | strict_comments = true 12 | align_ops = true 13 | align_params = always 14 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Facebook has adopted a Code of Conduct that we expect project participants to adhere to. 4 | Please read the [full text](https://code.fb.com/codeofconduct/) 5 | so that you can understand what actions will and will not be tolerated. 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-present, Facebook, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/ocamlformat-rpc/main.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | -------------------------------------------------------------------------------- /bin/ocamlformat/main.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | -------------------------------------------------------------------------------- /emacs/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ; ; 3 | ; OCamlFormat ; 4 | ; ; 5 | ; Copyright (c) Facebook, Inc. and its affiliates. ; 6 | ; ; 7 | ; This source code is licensed under the MIT license found in ; 8 | ; the LICENSE file in the root directory of this source tree. ; 9 | ; ; 10 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 11 | 12 | (install 13 | (package ocamlformat) 14 | (section share_root) 15 | (files 16 | (ocamlformat.el as emacs/site-lisp/ocamlformat.el))) 17 | -------------------------------------------------------------------------------- /lib-rpc/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ocamlformat_rpc_lib) 3 | (public_name ocamlformat-rpc-lib) 4 | (libraries csexp sexplib0)) 5 | -------------------------------------------------------------------------------- /lib/Assoc.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | (** Associativities of Ast terms *) 13 | type t = Left | Non | Right 14 | 15 | val to_string : t -> string 16 | 17 | val equal : t -> t -> bool 18 | 19 | val of_prec : Prec.t -> t 20 | (** [of_prec prec] is the associativity of Ast terms with precedence [prec]. 21 | (Associativity is uniform across precedence levels.) *) 22 | -------------------------------------------------------------------------------- /lib/Docstring.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | val parse : 13 | loc:Warnings.loc 14 | -> string 15 | -> (Odoc_parser.Ast.t, Odoc_parser.Warning.t list) Result.t 16 | 17 | val warn : Format.formatter -> Odoc_parser.Warning.t -> unit 18 | -------------------------------------------------------------------------------- /lib/Fmt_ast.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | (** Format OCaml Ast *) 13 | 14 | val fmt_ast : 15 | 'a Extended_ast.t 16 | -> debug:bool 17 | -> Source.t 18 | -> Cmts.t 19 | -> Conf.t 20 | -> 'a 21 | -> Fmt.t 22 | (** Format a fragment. *) 23 | -------------------------------------------------------------------------------- /lib/Fmt_odoc.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | val fmt : 13 | fmt_code:(string -> (Fmt.t, unit) Result.t) -> Odoc_parser.Ast.t -> Fmt.t 14 | 15 | val diff : 16 | Conf.t -> Cmt.t list -> Cmt.t list -> (string, string) Either.t Sequence.t 17 | (** Difference between two lists of doc comments. *) 18 | 19 | val is_tag_only : Odoc_parser.Ast.t -> bool 20 | (** [true] if the documentation only contains tags *) 21 | -------------------------------------------------------------------------------- /lib/Indent.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | module Valid_ast : sig 13 | val indent_range : 14 | 'a Extended_ast.t 15 | -> unformatted:'a * Source.t * string 16 | -> formatted:'a * Source.t 17 | -> lines:string list 18 | -> range:int * int 19 | -> int list 20 | end 21 | 22 | module Partial_ast : sig 23 | val indent_range : source:string -> range:int * int -> int list 24 | end 25 | -------------------------------------------------------------------------------- /lib/Literal_lexer.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | val string : [`Normalize | `Preserve] -> string -> string option 13 | 14 | val char : string -> string option 15 | -------------------------------------------------------------------------------- /lib/Loc_tree.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | include Non_overlapping_interval_tree.S with type itv = Location.t 13 | 14 | val of_ast : 'a Extended_ast.t -> 'a -> Source.t -> t * Location.t list 15 | (** Use Ast_mapper to collect all locs in ast, and create a tree of them. *) 16 | -------------------------------------------------------------------------------- /lib/Syntax.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | type t = 13 | | Structure 14 | | Signature 15 | | Use_file 16 | | Core_type 17 | | Module_type 18 | | Expression 19 | -------------------------------------------------------------------------------- /lib/Syntax.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | type t = 13 | | Structure 14 | | Signature 15 | | Use_file 16 | | Core_type 17 | | Module_type 18 | | Expression 19 | -------------------------------------------------------------------------------- /lib/Version.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlFormat *) 4 | (* *) 5 | (* Copyright (c) Facebook, Inc. and its affiliates. *) 6 | (* *) 7 | (* This source code is licensed under the MIT license found in *) 8 | (* the LICENSE file in the root directory of this source tree. *) 9 | (* *) 10 | (**************************************************************************) 11 | 12 | let version = 13 | let open Build_info.V1 in 14 | version () |> Option.value_map ~f:Version.to_string ~default:"unknown" 15 | -------------------------------------------------------------------------------- /ocamlformat-rpc-lib.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: "Auto-formatter for OCaml code (RPC mode)" 4 | description: 5 | "OCamlFormat is a tool to automatically format OCaml code in a uniform style. This package defines a RPC interface to OCamlFormat" 6 | maintainer: ["OCamlFormat Team "] 7 | authors: ["Josh Berdine "] 8 | license: "MIT" 9 | homepage: "https://github.com/ocaml-ppx/ocamlformat" 10 | bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues" 11 | depends: [ 12 | "dune" {>= "2.8"} 13 | "ocaml" {>= "4.08" & < "4.14"} 14 | "csexp" 15 | "sexplib0" 16 | "odoc" {with-doc} 17 | ] 18 | build: [ 19 | ["dune" "subst"] {dev} 20 | [ 21 | "dune" 22 | "build" 23 | "-p" 24 | name 25 | "-j" 26 | jobs 27 | "@install" 28 | "@runtest" {with-test} 29 | "@doc" {with-doc} 30 | ] 31 | ] 32 | dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git" 33 | -------------------------------------------------------------------------------- /ocamlformat-rpc.opam.template: -------------------------------------------------------------------------------- 1 | license: ["MIT" "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] # OCamlFormat is distributed under the MIT license. Parts of the OCaml library are vendored for OCamlFormat and distributed under their original LGPL 2.1 license 2 | -------------------------------------------------------------------------------- /ocamlformat.opam.template: -------------------------------------------------------------------------------- 1 | license: ["MIT" "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"] # OCamlFormat is distributed under the MIT license. Parts of the OCaml library are vendored for OCamlFormat and distributed under their original LGPL 2.1 license 2 | -------------------------------------------------------------------------------- /test/cli/bad_kind.t: -------------------------------------------------------------------------------- 1 | $ echo 'module X : S' > a.mli 2 | 3 | $ ocamlformat --impl a.mli 4 | ocamlformat: ignoring "a.mli" (syntax error) 5 | File "a.mli", line 2, characters 0-0: 6 | Error: Syntax error 7 | [1] 8 | -------------------------------------------------------------------------------- /test/cli/check.t: -------------------------------------------------------------------------------- 1 | $ echo 'let x = 1' > a.ml 2 | $ ocamlformat --check a.ml 3 | 4 | $ echo 'let x =1' > a.ml 5 | $ ocamlformat --check a.ml 6 | [1] 7 | 8 | $ echo 'let x = 1' > a.ml 9 | $ ocamlformat --output x.ml --check a.ml 10 | ocamlformat: Cannot specify --output with --check 11 | [1] 12 | 13 | $ echo 'let x = 1' > a.ml 14 | $ ocamlformat --inplace --check a.ml 15 | ocamlformat: Cannot specify --inplace with --check 16 | [1] 17 | -------------------------------------------------------------------------------- /test/cli/dune: -------------------------------------------------------------------------------- 1 | (cram 2 | (package ocamlformat) 3 | (deps %{bin:ocamlformat})) 4 | 5 | (cram 6 | (applies_to large_string) 7 | (enabled_if 8 | (<> %{os_type} Win32))) 9 | -------------------------------------------------------------------------------- /test/cli/env.t: -------------------------------------------------------------------------------- 1 | Invalid option: 2 | 3 | $ echo 'let x = 1' | OCAMLFORMAT="unknown=true" ocamlformat --impl - 4 | ocamlformat: Error while parsing OCAMLFORMAT environment variable: 5 | Unknown option "unknown" 6 | [1] 7 | 8 | Invalid value: 9 | 10 | $ echo 'let x = 1' | OCAMLFORMAT="type-decl=unknown" ocamlformat --impl - 11 | ocamlformat: Error while parsing OCAMLFORMAT environment variable: 12 | For option "type-decl": invalid value `unknown', expected either `compact' or `sparse' 13 | [1] 14 | -------------------------------------------------------------------------------- /test/cli/err_inplace_and_output.t: -------------------------------------------------------------------------------- 1 | $ echo 'let x = 1' > a.ml 2 | 3 | $ ocamlformat --inplace --output o.ml a.ml 4 | ocamlformat: Cannot specify --output with --inplace 5 | [1] 6 | -------------------------------------------------------------------------------- /test/cli/err_no_arg.t: -------------------------------------------------------------------------------- 1 | $ ocamlformat 2 | ocamlformat: Must specify at least one input file, or `-` for stdin 3 | [1] 4 | -------------------------------------------------------------------------------- /test/cli/large_string.t: -------------------------------------------------------------------------------- 1 | $ echo "let _ = \"$(printf '%*s' 300000 | sed 's/ /_ _/g')\"" > a.ml 2 | 3 | $ ocamlformat --impl a.ml -o /dev/null 4 | -------------------------------------------------------------------------------- /test/cli/max_iters.t: -------------------------------------------------------------------------------- 1 | $ echo 'let x = 1' > a.ml 2 | $ ocamlformat --max-iters=1 a.ml 3 | let x = 1 4 | 5 | $ echo 'let x = 1' > a.ml 6 | $ ocamlformat --max-iters=1 a.ml 7 | ocamlformat: "a.ml" was not already formatted. ([max-iters = 1]) 8 | [1] 9 | -------------------------------------------------------------------------------- /test/cli/name.t: -------------------------------------------------------------------------------- 1 | $ echo 'let x = 1' > a.ml 2 | $ ocamlformat --name a.cpp a.ml 3 | let x = 1 4 | 5 | $ echo 'let y =' > syntax_error.ml 6 | $ ocamlformat --name foo.ml syntax_error.ml 7 | ocamlformat: ignoring "foo.ml" (syntax error) 8 | File "foo.ml", line 2, characters 0-0: 9 | Error: Syntax error 10 | [1] 11 | 12 | $ echo 'module X : S' > a.mli 13 | $ ocamlformat --name foo.ml a.mli 14 | ocamlformat: ignoring "foo.ml" (syntax error) 15 | File "foo.ml", line 2, characters 0-0: 16 | Error: Syntax error 17 | [1] 18 | -------------------------------------------------------------------------------- /test/cli/several_files.t: -------------------------------------------------------------------------------- 1 | $ echo 'let x = 1' > a.ml 2 | $ echo 'let x = 2' > b.ml 3 | $ ocamlformat a.ml b.ml 4 | ocamlformat: Must specify exactly one input file without --inplace or --check 5 | [1] 6 | 7 | $ ocamlformat --output x.ml a.ml b.ml 8 | ocamlformat: Must specify exactly one input file without --inplace or --check 9 | [1] 10 | 11 | $ touch a.mli 12 | $ ocamlformat --impl --check a.mli b.ml 13 | ocamlformat: Cannot specify --impl or --intf with multiple inputs 14 | [1] 15 | 16 | $ ocamlformat --name foo.ml --check a.mli b.ml 17 | ocamlformat: Cannot specify --name with multiple inputs 18 | [1] 19 | -------------------------------------------------------------------------------- /test/disabled/dir1/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = ocamlformat 2 | break-cases = fit 3 | margin = 77 4 | parse-docstrings = true 5 | wrap-comments = true 6 | max-iters = 2 7 | -------------------------------------------------------------------------------- /test/disabled/dir1/.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | #This is for tests only 2 | dir2/ignore_1.ml -------------------------------------------------------------------------------- /test/disabled/dir1/dir2/.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | 2 | # this is for test only 3 | 4 | ignore_2.ml -------------------------------------------------------------------------------- /test/disabled/dir1/dir2/ignore_1.ml: -------------------------------------------------------------------------------- 1 | (* ignored in test/disabled/dir1/.ocamlformat-ignore *) 2 | let x = 1 3 | -------------------------------------------------------------------------------- /test/disabled/dir1/dir2/ignore_2.ml: -------------------------------------------------------------------------------- 1 | (* ignored in test/disabled/dir1/dir2/.ocamlformat-ignore *) 2 | let x = 1 3 | -------------------------------------------------------------------------------- /test/disabled/dune: -------------------------------------------------------------------------------- 1 | (rule 2 | (alias runtest) 3 | (deps 4 | (source_tree dir1)) 5 | (package ocamlformat) 6 | (enabled_if 7 | (<> %{os_type} Win32)) 8 | (action 9 | (run %{bin:ocamlformat} -n 1 -i dir1/dir2/ignore_1.ml))) 10 | 11 | (rule 12 | (alias runtest) 13 | (deps 14 | (source_tree dir1)) 15 | (package ocamlformat) 16 | (enabled_if 17 | (<> %{os_type} Win32)) 18 | (action 19 | (run %{bin:ocamlformat} -n 1 -i dir1/dir2/ignore_2.ml))) 20 | -------------------------------------------------------------------------------- /test/failing/dune: -------------------------------------------------------------------------------- 1 | (include dune.inc) 2 | 3 | (rule 4 | (deps 5 | (source_tree .)) 6 | (package ocamlformat) 7 | (action 8 | (with-stdout-to 9 | dune.inc.gen 10 | (run ./gen/gen.exe)))) 11 | 12 | (rule 13 | (alias runtest) 14 | (package ocamlformat) 15 | (action 16 | (diff dune.inc dune.inc.gen))) 17 | -------------------------------------------------------------------------------- /test/failing/gen/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name gen)) 3 | -------------------------------------------------------------------------------- /test/failing/tests/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = ocamlformat 2 | break-cases = fit 3 | margin = 77 4 | parse-docstrings = true 5 | wrap-comments = true 6 | max-iters = 2 7 | -------------------------------------------------------------------------------- /test/failing/tests/comments.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/comments.ml" (syntax error) 2 | File "tests/comments.ml", line 64, characters 0-6: 3 | 64 | module M_ok : sig 4 | ^^^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/core_failing.ml: -------------------------------------------------------------------------------- 1 | exception IOError of 2 | int * 3 | exn 4 | 5 | module type S = S 6 | with type ('a, 'b, 'c) map := ('a, 'b, 'c) t 7 | 8 | let _ = 9 | let start_finaliser_thread () = 10 | ignore (Thread.create (fun () -> Fn.forever (fun () -> 11 | match read_finaliser_queue () with 12 | | None -> Thread.delay 1.0 13 | | Some f -> Exn.handle_uncaught ~exit:false f)) ()) 14 | in 15 | () 16 | 17 | module F 18 | (A) 19 | (B) 20 | -------------------------------------------------------------------------------- /test/failing/tests/core_failing.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/core_failing.ml" (syntax error) 2 | File "tests/core_failing.ml", line 18, characters 6-7: 3 | 18 | (A) 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/core_passing.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/core_passing.ml" (syntax error) 2 | File "tests/core_passing.ml", line 27, characters 0-3: 3 | 27 | let error_string message = error message () <:sexp_of< unit >> 4 | ^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.2) 2 | (formatting disabled) 3 | -------------------------------------------------------------------------------- /test/failing/tests/edge_cases.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/edge_cases.ml" (syntax error) 2 | File "tests/edge_cases.ml", line 90, characters 4-12: 3 | 90 | function (_ : [ `c ]) -> d 4 | ^^^^^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/escaped_nl.ml: -------------------------------------------------------------------------------- 1 | let s1 = "No field 'install', but a field 'remove': install instructions \ 2 | probably part of 'build'. Use the 'install' field or a .install \ 3 | file" 4 | 5 | let x = 6 | cond 40 `Warning 7 | "Package uses flags that aren't recognised by earlier versions in \ 8 | OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ 9 | instead for compatibility" 10 | ~detail:alpha_flags 11 | (alpha_flags <> []) 12 | 13 | let s2 = "bla bla 14 | bli bli \ 15 | blo" 16 | 17 | let s3 = "\ 18 | " 19 | 20 | let s4 = " \ 21 | " 22 | 23 | let s5 = " \ 24 | \ 25 | " 26 | 27 | let s6 = " 28 | " 29 | 30 | let s7 = " 31 | " 32 | 33 | let c1 = ' 34 | ' 35 | 36 | let x1 = f x ' 37 | ' y 38 | z 39 | 40 | let zz = "\ 41 | 42 | s \ 43 | \ 44 | " 45 | -------------------------------------------------------------------------------- /test/failing/tests/escaped_nl.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/escaped_nl.ml" (syntax error) 2 | File "tests/escaped_nl.ml", line 33, characters 9-10: 3 | 33 | let c1 = ' 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/exprs.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/exprs.ml" (syntax error) 2 | File "tests/exprs.ml", line 19, characters 5-6: 3 | 19 | x:x 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/indent_empty.ml: -------------------------------------------------------------------------------- 1 | module M = struct 2 | 3 | let f = 4 | 5 | end 6 | 7 | let g = 8 | 9 | fun x -> 3 + 4 * 10 | -------------------------------------------------------------------------------- /test/failing/tests/indent_empty.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/indent_empty.ml" (syntax error) 2 | File "tests/indent_empty.ml", line 5, characters 0-3: 3 | 5 | end 4 | ^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/js_2018.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/js_2018.ml" (syntax error) 2 | File "tests/js_2018.ml", line 14, characters 0-3: 3 | 14 | let _ = 4 | ^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/js_bench.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/js_bench.ml" (syntax error) 2 | File "tests/js_bench.ml", line 13, characters 28-34: 3 | 13 | BENCH_MODULE "Blit tests" = struct 4 | ^^^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/js_comment.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/js_comment.ml" (syntax error) 2 | File "tests/js_comment.ml", line 165, characters 2-4: 3 | 165 | -> bar_snoo : a b 4 | ^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/js_default.ml: -------------------------------------------------------------------------------- 1 | type t = 2 | { last_trading : Week_date.Spec.t; 3 | first_notice : Week_date.Spec.t option; 4 | first_notice_exceptions : Date.t Year_month.Map.t 5 | with default(Year_month.Map.empty); 6 | offset : Week_date.Offset.t; 7 | (* n > 0 *) 8 | new_contract_expires_in_n_months : int 9 | } 10 | [@@deriving sexp, compare] 11 | 12 | module M = struct 13 | type t = { x: int } 14 | [@@deriving sexp] 15 | end 16 | -------------------------------------------------------------------------------- /test/failing/tests/js_default.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/js_default.ml" (syntax error) 2 | File "tests/js_default.ml", line 5, characters 6-10: 3 | 5 | with default(Year_month.Map.empty); 4 | ^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/js_functor.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/js_functor.ml" (syntax error) 2 | File "tests/js_functor.ml", line 10, characters 4-7: 3 | 10 | end) 4 | ^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/js_low_priority.ml: -------------------------------------------------------------------------------- 1 | (* Relatively low priority Jane Street indentation bugs. *) 2 | 3 | 4 | 5 | (* js-args *) 6 | 7 | (* uncommon *) 8 | let x = 9 | try x with a -> b 10 | | c -> d 11 | let x = 12 | try x 13 | with a -> b 14 | | c -> d 15 | 16 | 17 | 18 | (* js-comment *) 19 | 20 | let mk_cont_parser cont_parse = (); fun _state str ~max_pos ~pos -> 21 | let len = max_pos - pos + 1 in 22 | cont_parse ~pos ~len str 23 | 24 | (* sexp parser is sensitive to 25 | absent newlines at the end of files. *) 26 | 27 | 28 | 29 | (* It would be nice if a partially completed ocamldoc code fragment inside a 30 | comment had the closing delimiter "]}" indented nicely before the comment is 31 | closed. (This has to be the last comment in the file, to be partial.) *) 32 | (* Maybe add: 33 | {[ 34 | val state : t -> [ `Unstarted | `Running | `Stopped ] 35 | ]} 36 | -------------------------------------------------------------------------------- /test/failing/tests/js_low_priority.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/js_low_priority.ml" (syntax error) 2 | File "tests/js_low_priority.ml", line 32, characters 0-2: 3 | 32 | (* Maybe add: 4 | ^^ 5 | Error: Comment not terminated 6 | -------------------------------------------------------------------------------- /test/failing/tests/js_test.ml: -------------------------------------------------------------------------------- 1 | let%test = 2 | let b = true in 3 | b 4 | (* Above, a multi-line TEST (likewise BENCH) was indented wrong only when it 5 | started on the first line. (That wasn't really a big problem.) *) 6 | 7 | (* oUnit *) 8 | 9 | module E = Example 10 | 11 | let%test_module = 12 | (module struct 13 | let%test = false 14 | let%test = 15 | let b = true in 16 | b 17 | let%test "Name_test" = 18 | let b = true in (* tricky for Tuareg *) 19 | b 20 | end) 21 | 22 | let%test_module "Name" = 23 | (module struct 24 | let%test_unit = () 25 | let%test_unit = 26 | let () = () in 27 | () 28 | let%test_unit "Name_unit" = 29 | let () = () in (* tricky for Tuareg *) 30 | () 31 | 32 | let%test_unit = 33 | let msgcount = 10_000 in (* tricky for Tuareg *) 34 | () 35 | end) 36 | 37 | let _ = printf "Hello, world!\n" 38 | -------------------------------------------------------------------------------- /test/failing/tests/js_test.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/js_test.ml" (syntax error) 2 | File "tests/js_test.ml", line 1, characters 9-10: 3 | 1 | let%test = 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/lwt.ml: -------------------------------------------------------------------------------- 1 | let f () = 2 | lwt x = g () in 3 | Lwt.return x 4 | 5 | let f x = match_lwt x with 6 | | A -> A 7 | | B -> B 8 | 9 | let g x = try_lwt 10 | f x 11 | finally 12 | g x 13 | 14 | let a f x = 15 | try_lwt f x 16 | with Failure _ -> () 17 | finally () 18 | 19 | (* should'nt break normal try/with imbrication *) 20 | let z f x = 21 | try 22 | try f x 23 | with Exit -> () 24 | with _ -> () 25 | -------------------------------------------------------------------------------- /test/failing/tests/lwt.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/lwt.ml" (syntax error) 2 | File "tests/lwt.ml", line 5, characters 22-26: 3 | 5 | let f x = match_lwt x with 4 | ^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/macro.ml: -------------------------------------------------------------------------------- 1 | open Foo 2 | 3 | INCLUDE "bar" 4 | 5 | IFDEF "foo" 6 | let f x = 3 7 | ENDIF 8 | 9 | TEST foo 10 | TEST bar 11 | -------------------------------------------------------------------------------- /test/failing/tests/macro.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/macro.ml" (syntax error) 2 | File "tests/macro.ml", line 3, characters 0-7: 3 | 3 | INCLUDE "bar" 4 | ^^^^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/match_fun.ml: -------------------------------------------------------------------------------- 1 | let reset_cond = 2 | match states with 3 | | [ _ ] -> fun _ v _ -> e_id v 4 | | _ -> fun s v clk -> (* … *) 5 | -------------------------------------------------------------------------------- /test/failing/tests/match_fun.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/match_fun.ml" (syntax error) 2 | File "tests/match_fun.ml", line 5, characters 0-0: 3 | Error: Syntax error 4 | -------------------------------------------------------------------------------- /test/failing/tests/misc_2019.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/misc_2019.ml" (syntax error) 2 | File "tests/misc_2019.ml", line 15, characters 2-8: 3 | 15 | module type of struct 4 | ^^^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/module.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/module.ml" (syntax error) 2 | File "tests/module.ml", line 5, characters 18-22: 3 | 5 | include Foo with type t := t 4 | ^^^^ 5 | Error: Syntax error: 'end' expected 6 | File "tests/module.ml", line 3, characters 15-21: 7 | 3 | module G = struct 8 | ^^^^^^ 9 | This 'struct' might be unmatched 10 | -------------------------------------------------------------------------------- /test/failing/tests/nesting.ml: -------------------------------------------------------------------------------- 1 | module M = struct 2 | let a = (((((( 3 | ) 4 | ) 5 | ) 6 | ) 7 | ) 8 | ) 9 | 10 | let a = (ff(ff(ff(ff(ff(ff( 11 | ) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | ) 18 | 19 | let a = [[[[[[ 20 | ] 21 | ] 22 | ] 23 | ] 24 | ] 25 | ] 26 | 27 | let a = [ff[ff[ff[ff[ff[ff[ 28 | ] 29 | ] 30 | ] 31 | ] 32 | ] 33 | ] 34 | ] 35 | -------------------------------------------------------------------------------- /test/failing/tests/nesting.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/nesting.ml" (syntax error) 2 | File "tests/nesting.ml", line 35, characters 0-0: 3 | Error: Syntax error: 'end' expected 4 | File "tests/nesting.ml", line 1, characters 11-17: 5 | 1 | module M = struct 6 | ^^^^^^ 7 | This 'struct' might be unmatched 8 | -------------------------------------------------------------------------------- /test/failing/tests/never_align.ml: -------------------------------------------------------------------------------- 1 | let _ = ( 2 | a 3 | b 4 | c 5 | ) 6 | 7 | let _ = (a 8 | b 9 | c) 10 | 11 | let _ = { 12 | a 13 | b 14 | b 15 | } 16 | 17 | let _ = { a 18 | b 19 | c 20 | } 21 | -------------------------------------------------------------------------------- /test/failing/tests/never_align.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/never_align.ml" (syntax error) 2 | File "tests/never_align.ml", line 13, characters 4-5: 3 | 13 | b 4 | ^ 5 | Error: Syntax error: '}' expected 6 | File "tests/never_align.ml", line 11, characters 8-9: 7 | 11 | let _ = { 8 | ^ 9 | This '{' might be unmatched 10 | -------------------------------------------------------------------------------- /test/failing/tests/ocamldoc.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/ocamldoc.ml" (syntax error) 2 | File "tests/ocamldoc.ml", line 75, characters 0-5: 3 | 75 | class type my_class_type = 4 | ^^^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/partial2.ml: -------------------------------------------------------------------------------- 1 | if () then () else 2 | match () with 3 | | () -> 4 | -------------------------------------------------------------------------------- /test/failing/tests/partial2.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/partial2.ml" (syntax error) 2 | File "tests/partial2.ml", line 4, characters 0-0: 3 | Error: Syntax error 4 | -------------------------------------------------------------------------------- /test/failing/tests/pattern.ml: -------------------------------------------------------------------------------- 1 | let f = match x with 2 | | { x = 3 } -> 3 | let x = 4 in 4 | () 5 | 6 | let f = match x with 7 | | (X|Y) | (Z|U) -> 1 8 | | K -> 2 9 | 10 | let f = match x with 11 | | X when foo = bar -> 12 | fff 13 | | Y when f = x 14 | && g = 3 -> 15 | z 16 | 17 | let f () = 18 | match s with 19 | (* Parenthesized ident ? *) 20 | | x -> x, d 21 | (* Regular ident *) 22 | | _ -> g 23 | ;; 24 | 25 | match x with 26 | | X | Y -> 1 27 | | X -> 28 | 2; 29 | 3 30 | | A -> 2 31 | ;; 32 | 33 | let f g = 34 | (* haha *) 35 | match z with 36 | | Z | B _ -> x 37 | | A (a, _, _, b) as x -> 38 | let x = f a and hr = f b in 39 | f 40 | 41 | let unwind_to = 42 | match t with KType | KModule -> true | Kblob -> false 43 | | _ -> true 44 | 45 | let f x = match x with 46 | | A | B 47 | | C -> 48 | x 49 | | z -> match z with 50 | | _ -> function 51 | | x -> 52 | x 53 | 54 | let fun_dep ulam = function 55 | | A 56 | | B 57 | | C -> 58 | () 59 | 60 | let fun_dep ulam = function 61 | |A 62 | |B|C 63 | |D -> 64 | () 65 | 66 | let _ = 67 | (match bla 68 | with bli) 69 | -------------------------------------------------------------------------------- /test/failing/tests/pattern.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/pattern.ml" (syntax error) 2 | File "tests/pattern.ml", line 68, characters 11-12: 3 | 68 | with bli) 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/ppx_stritem_ext.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/ppx_stritem_ext.ml" (syntax error) 2 | File "tests/ppx_stritem_ext.ml", line 10, characters 11-14: 3 | 10 | module S = sig 4 | ^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/quotations2.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/quotations2.ml" (syntax error) 2 | File "tests/quotations2.ml", line 19, characters 6-8: 3 | 19 | <:xhtml<
  • $str:long$
  • &>> 4 | ^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/record_with.ml: -------------------------------------------------------------------------------- 1 | let a = 2 | { 3 | somerecord 4 | with 5 | a = b; 6 | c = d; 7 | } 8 | 9 | let a = 10 | { 11 | somerecord 12 | with a = b; 13 | c = d; 14 | } 15 | 16 | let z = 17 | { recofzfzfzrd with a = bli; bzeefe = 18 | k 19 | ; efgeg = a 20 | } 21 | 22 | let b = 23 | let z = 24 | { reczfzrd with a = bli; 25 | bzeefe = _; 26 | } 27 | 28 | let b = 29 | let z = 30 | { reczfzrd with a = bli; 31 | bzeefe 32 | } 33 | 34 | let lexbuf = { lexbuf with Lexing.lex_start_p = start_pos; 35 | Lexing.lex_curr_p = start_pos; } 36 | 37 | let () = 38 | { Foo. 39 | foo 40 | ; bar = (fun () -> 41 | if a then b) 42 | } 43 | 44 | let () = 45 | { foo 46 | ; bar = (fun () -> 47 | if a then b) 48 | } 49 | -------------------------------------------------------------------------------- /test/failing/tests/record_with.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/record_with.ml" (syntax error) 2 | File "tests/record_with.ml", line 28, characters 0-3: 3 | 28 | let b = 4 | ^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/unit_classes.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/unit_classes.ml" (syntax error) 2 | File "tests/unit_classes.ml", line 23, characters 24-25: 3 | 23 | method private bar1 x ~y : bool 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/unit_expr.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/unit_expr.ml" (syntax error) 2 | File "tests/unit_expr.ml", line 33, characters 3-4: 3 | 33 | `_ 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/unit_extensions.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/unit_extensions.ml" (syntax error) 2 | File "tests/unit_extensions.ml", line 101, characters 8-11: 3 | 101 | M.sig 4 | ^^^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/unit_lex.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/failing/tests/unit_lex.ml -------------------------------------------------------------------------------- /test/failing/tests/unit_lex.ml.broken-ref: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/failing/tests/unit_lex.ml.broken-ref -------------------------------------------------------------------------------- /test/failing/tests/unit_modtypes.ml: -------------------------------------------------------------------------------- 1 | (** ocaml module types 2 | (http://caml.inria.fr/pub/docs/manual-ocaml/manual018.html) 3 | *) 4 | 5 | module type T = 6 | M.T 7 | 8 | module type T = 9 | sig 10 | end 11 | 12 | module type T = sig 13 | ;; 14 | end 15 | 16 | module type T = 17 | functor (M : T) -> 18 | functor (M1 : T1) -> 19 | sig 20 | end 21 | 22 | module type T = 23 | sig end 24 | with type 'a t = 'b 25 | and module M = M'.MF(X) 26 | and type t' = t'' 27 | 28 | module type T = ( 29 | sig 30 | end 31 | ) 32 | 33 | module type T = 34 | sig 35 | val v : 36 | t 37 | 38 | external x : 'a = 39 | "stub" 40 | 41 | type t = 42 | int 43 | and t2 = 44 | t 45 | 46 | exception Error 47 | of int 48 | 49 | class virtual ['a] cl : 50 | object 51 | end 52 | and cl2 : 53 | object 54 | end 55 | 56 | class type clt = 57 | object 58 | end 59 | and ['a] clt2 = 60 | object 61 | end 62 | 63 | module M : 64 | Sig 65 | 66 | module M (X) (Y): 67 | Sig 68 | 69 | module type Sig 70 | 71 | module type Sig1 = 72 | sig 73 | end 74 | 75 | open 76 | M 77 | 78 | include 79 | M 80 | end 81 | -------------------------------------------------------------------------------- /test/failing/tests/unit_modtypes.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/unit_modtypes.ml" (syntax error) 2 | File "tests/unit_modtypes.ml", line 66, characters 13-14: 3 | 66 | module M (X) (Y): 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/unit_typedefs.ml: -------------------------------------------------------------------------------- 1 | (** ocaml type and exception definitions 2 | (http://caml.inria.fr/pub/docs/manual-ocaml/manual016.html) 3 | *) 4 | 5 | type 6 | t 7 | 8 | type 9 | 'a t 10 | 11 | type 12 | +'_a t 13 | 14 | type 15 | -'a t 16 | 17 | type 18 | ('a, 19 | +'b, 20 | (-'c,-'d)) 21 | t 22 | 23 | type t = 24 | t2 25 | 26 | type t = 27 | A 28 | 29 | type t = 30 | A 31 | | B of 'a 32 | | C of 'a * 'b 33 | | D of ('a) Array.t * 'b list 34 | | E of _ 35 | 36 | type t = 37 | { f1 : t1; 38 | f2 : 'a; 39 | mutable f3: t2; 40 | f4 : 41 | 'a 'b.t2; 42 | } 43 | 44 | type 'a t 45 | constraint 'a = t 46 | constraint 'b = 'a 47 | 48 | type 49 | ('a, 50 | +'b, 51 | (-'c,-'d)) 52 | t 53 | = 54 | { f1 : t1; 55 | f2 : 'a; 56 | mutable f3: t2; 57 | f4 : 58 | t1 * t2; 59 | } 60 | constraint 'a = t 61 | constraint 'b = 'a 62 | 63 | 64 | exception 65 | E 66 | 67 | exception 68 | E of 69 | 'a t * string 70 | 71 | exception 72 | E' = 73 | E 74 | -------------------------------------------------------------------------------- /test/failing/tests/unit_typedefs.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/unit_typedefs.ml" (syntax error) 2 | File "tests/unit_typedefs.ml", line 20, characters 3-4: 3 | 20 | (-'c,-'d)) 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/unit_types.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/unit_types.ml" (syntax error) 2 | File "tests/unit_types.ml", line 32, characters 7-8: 3 | 32 | ( ?_ : int -> t ) 4 | ^ 5 | Error: Syntax error 6 | -------------------------------------------------------------------------------- /test/failing/tests/unit_values.ml.broken-ref: -------------------------------------------------------------------------------- 1 | File "tests/unit_values.ml", line 6, characters 10-11: 2 | 6 | let i32 = −1073741824, 1073741823 3 | ^ 4 | Alert deprecated: ISO-Latin1 characters in identifiers 5 | ocamlformat: ignoring "tests/unit_values.ml" (syntax error) 6 | File "tests/unit_values.ml", line 6, characters 11-12: 7 | 6 | let i32 = −1073741824, 1073741823 8 | ^ 9 | Error: Illegal character (\136) 10 | -------------------------------------------------------------------------------- /test/failing/tests/unstable_docstrings.mli: -------------------------------------------------------------------------------- 1 | (** Blablabla. Otherwise, the given protocol can not be: 2 | {ul 3 | {- registered into {!resolvers}} 4 | {- used as a service with {!serve_with_handler]/{!serve}}} 5 | [protocol] can be hidden - but must be registered with 6 | {!register_protocol}. However, blablabla. 7 | *) 8 | val x : y 9 | -------------------------------------------------------------------------------- /test/failing/tests/unstable_docstrings.mli.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: Cannot process "tests/unstable_docstrings.mli". 2 | Please report this bug at https://github.com/ocaml-ppx/ocamlformat/issues. 3 | BUG: doc comments changed. 4 | File "_none_", line 0, characters -1--1:: 5 | Error: Formatting of doc-comment is unstable (e.g. parses as a list or not depending on the margin): 6 | @@ -1,6 +1,7 @@ 7 | Blablabla. Otherwise, the given protocol can not be: 8 | - {ul 9 | - {- registered into {!resolvers}} 10 | - {- used as a service with {!serve_with_handler]/{!serve}}} 11 | + 12 | + - registered into {!resolvers} 13 | + - used as a service with {!serve_with_handler\]/\{!serve} 14 | + 15 | [protocol] can be hidden - but must be registered with 16 | - {!register_protocol}. However, blablabla. 17 | + {!register_protocol}. However, blablabla. 18 | \ No newline at end of file 19 | Please tighten up this comment in the source or disable the formatting using the option --no-parse-docstrings. 20 | -------------------------------------------------------------------------------- /test/failing/tests/unstable_docstrings.mli.enabled-if: -------------------------------------------------------------------------------- 1 | (<> %{os_type} Win32) 2 | -------------------------------------------------------------------------------- /test/failing/tests/with_2.ml: -------------------------------------------------------------------------------- 1 | let x = 2 | try y with 3 | | A -> _ 4 | | B -> _ 5 | 6 | let x = try y with 7 | | A -> _ 8 | | B -> _ 9 | 10 | let x = 11 | try y with 12 | A -> _ 13 | | B -> _ 14 | 15 | let x = try y with 16 | A -> _ 17 | | B -> _ 18 | 19 | let _ = 20 | let x = 21 | try y with 22 | | A -> _ 23 | | B -> _ 24 | in 25 | let x = try y with 26 | | A -> _ 27 | | B -> _ 28 | in 29 | let x = 30 | try y with 31 | A -> _ 32 | | B -> _ 33 | in 34 | let x = try y with 35 | A -> _ 36 | | B -> _ 37 | -------------------------------------------------------------------------------- /test/failing/tests/with_2.ml.broken-ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/with_2.ml" (syntax error) 2 | File "tests/with_2.ml", line 37, characters 0-0: 3 | Error: Syntax error 4 | -------------------------------------------------------------------------------- /test/passing/dune: -------------------------------------------------------------------------------- 1 | (include dune.inc) 2 | 3 | (rule 4 | (deps 5 | (source_tree .)) 6 | (package ocamlformat) 7 | (action 8 | (with-stdout-to 9 | dune.inc.gen 10 | (run ./gen/gen.exe)))) 11 | 12 | (rule 13 | (alias runtest) 14 | (package ocamlformat) 15 | (action 16 | (diff dune.inc dune.inc.gen))) 17 | -------------------------------------------------------------------------------- /test/passing/gen/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name gen)) 3 | -------------------------------------------------------------------------------- /test/passing/tests/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = ocamlformat 2 | break-cases = fit 3 | margin = 77 4 | parse-docstrings = true 5 | wrap-comments = true 6 | max-iters = 2 7 | ocaml-version = 4.13.0 8 | -------------------------------------------------------------------------------- /test/passing/tests/.ocp-indent: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/.ocp-indent -------------------------------------------------------------------------------- /test/passing/tests/align_cases-break_all.ml.opts: -------------------------------------------------------------------------------- 1 | --align-constructors-decl --align-variants-decl --align-cases --break-cases=all 2 | -------------------------------------------------------------------------------- /test/passing/tests/align_cases.ml.opts: -------------------------------------------------------------------------------- 1 | --align-constructors-decl --align-variants-decl --align-cases 2 | -------------------------------------------------------------------------------- /test/passing/tests/align_infix.ml: -------------------------------------------------------------------------------- 1 | let sum_of_squares num = 2 | num + 1 3 | |> List.range 0 4 | |> List.map ~f:square 5 | |> List.fold_left ~init:0 ~f:( + ) 6 | -------------------------------------------------------------------------------- /test/passing/tests/align_infix.ml.opts: -------------------------------------------------------------------------------- 1 | --break-infix=fit-or-vertical -------------------------------------------------------------------------------- /test/passing/tests/alignment.ml: -------------------------------------------------------------------------------- 1 | let file_contents = [ 2 | ] 3 | @ [ 4 | foo 5 | ] @ [ 6 | bar 7 | ] 8 | 9 | let _ = 10 | match s.src with 11 | | None -> [ 12 | zz 13 | ] + 2 14 | | Some s -> [ Variable ( 15 | s_src, 16 | OpamFormat.make_string (OpamFilename.to_string s) 17 | ); 18 | yy ]; 19 | foo 20 | | Some s -> { 21 | fww = 22 | s_src, 23 | OpamFormat.make_string (OpamFilename.to_string s) 24 | ; gdd = 25 | yy 26 | } 27 | 28 | let _ = 29 | [ x; 30 | y ] 31 | @ z 32 | 33 | let _ = 34 | [ 35 | x; 36 | y ] 37 | @ z 38 | 39 | let _ = [ 40 | x; 41 | y 42 | ] 43 | @ z 44 | -------------------------------------------------------------------------------- /test/passing/tests/alignment.ml.ref: -------------------------------------------------------------------------------- 1 | let file_contents = [] @ [foo] @ [bar] 2 | 3 | let _ = 4 | match s.src with 5 | | None -> [zz] + 2 6 | | Some s -> 7 | [ Variable (s_src, OpamFormat.make_string (OpamFilename.to_string s)) 8 | ; yy ] ; 9 | foo 10 | | Some s -> 11 | { fww= (s_src, OpamFormat.make_string (OpamFilename.to_string s)) 12 | ; gdd= yy } 13 | 14 | let _ = [x; y] @ z 15 | 16 | let _ = [x; y] @ z 17 | 18 | let _ = [x; y] @ z 19 | -------------------------------------------------------------------------------- /test/passing/tests/apply_functor.ml: -------------------------------------------------------------------------------- 1 | module _ = F (functor (X : T) -> X) 2 | module _ = 3 | F 4 | (functor 5 | (X____________________________ : T) 6 | -> 7 | X____________________________) 8 | -------------------------------------------------------------------------------- /test/passing/tests/args_grouped.ml.opts: -------------------------------------------------------------------------------- 1 | --profile=ocamlformat 2 | --margin=100 3 | -------------------------------------------------------------------------------- /test/passing/tests/array.ml: -------------------------------------------------------------------------------- 1 | [| 1222222 2 | ; 1222222 3 | ; 1222222 4 | ; 1222222 5 | ; 1222222 6 | ; 1222222 7 | ; 1222222 8 | ; 1222222 9 | ; 1222222 10 | ; 1222222 11 | ; 1222222 12 | ; 1222222 13 | ; 1222222 14 | ; 1222222 15 | ; 1222222 16 | ; 1222222 17 | ; 1222222 18 | ; 1222222 |] 19 | 20 | let f = function 21 | | [| 1222222 22 | ; 1222222 23 | ; 1222222 24 | ; 1222222 25 | ; 1222222 26 | ; 1222222 27 | ; 1222222 28 | ; 1222222 29 | ; 1222222 30 | ; 1222222 31 | ; 1222222 32 | ; 1222222 33 | ; 1222222 34 | ; 1222222 35 | ; 1222222 36 | ; 1222222 37 | ; 1222222 38 | ; 1222222 |] -> 39 | () 40 | -------------------------------------------------------------------------------- /test/passing/tests/assignment_operator-op_begin_line.ml.opts: -------------------------------------------------------------------------------- 1 | --assignment-operator=begin-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/attribute_and_expression.ml: -------------------------------------------------------------------------------- 1 | let _ = f (2 [@test 2]) 2 | 3 | let tail1 = [1; 2] [@hello] 4 | 5 | let tail2 = 0 :: ([1; 2] [@hello]) 6 | 7 | let tail3 = 0 :: ([] [@hello]) 8 | 9 | let _ = ("%d" : _ format) [@p] 10 | 11 | let _ = (`B `N : p2) [@p] 12 | 13 | let _ = (`So (`Se (`So `O)) : podd) [@p] 14 | -------------------------------------------------------------------------------- /test/passing/tests/attributes.mli: -------------------------------------------------------------------------------- 1 | [@@@ocaml.doc 2 | "_"] 3 | -------------------------------------------------------------------------------- /test/passing/tests/attributes.mli.ref: -------------------------------------------------------------------------------- 1 | [@@@ocaml.doc "_"] 2 | -------------------------------------------------------------------------------- /test/passing/tests/binders.ml: -------------------------------------------------------------------------------- 1 | external f : 'a -> 'a = "asdf" 2 | 3 | external g : 4 | 'aaaaaaa 'aaaaaaaaaaaaaaa 'aaaaaaaaaaaaaaaaaaaaaa 'aaaaaaaaaaaaaa 'aaaaaaa 5 | 'fooooo_foooooo. 'a -> 'a -> 'a = "asdf" 6 | 7 | type f = Foo : 'a -> t 8 | 9 | type f = Foo : 'a -> 'a 10 | 11 | type g = Foo : 'a. 'a -> t 12 | 13 | type g = 14 | | Foo : 15 | 'aaaaaaaaaaa 'bbbbbbbbbbbbbb 'ccccccccccccccc 'fooooo_fooooooo. 16 | 'foo 17 | -> 'b 18 | -------------------------------------------------------------------------------- /test/passing/tests/break_before_in-auto.ml.opts: -------------------------------------------------------------------------------- 1 | --break-before-in=auto 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_before_in.ml.opts: -------------------------------------------------------------------------------- 1 | --break-before-in=fit-or-vertical 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-align.ml.opts: -------------------------------------------------------------------------------- 1 | --nested-match=align 2 | --break-cases=all 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-all.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=all 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-closing_on_separate_line.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=all --indicate-multiline-delimiters=closing-on-separate-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-closing_on_separate_line_leading_nested_match_parens.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=all --indicate-multiline-delimiters=closing-on-separate-line --leading-nested-match-parens 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-cosl_lnmp_cmei.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=all --indicate-multiline-delimiters=closing-on-separate-line --leading-nested-match-parens --cases-matching-exp-indent=normal 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-fit_or_vertical.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=fit-or-vertical 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-nested.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=nested 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-normal_indent.ml.opts: -------------------------------------------------------------------------------- 1 | --cases-matching-exp-indent=normal --break-cases=all 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases-toplevel.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=toplevel 2 | --max-iter=4 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_cases.ml.opts: -------------------------------------------------------------------------------- 1 | --break-cases=fit 2 | --max-iter=4 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_fun_decl-fit_or_vertical.ml.opts: -------------------------------------------------------------------------------- 1 | --break-fun-decl=fit-or-vertical --break-fun-sig=fit-or-vertical 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_fun_decl-smart.ml.opts: -------------------------------------------------------------------------------- 1 | --break-fun-decl=smart --break-fun-sig=smart 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_fun_decl-wrap.ml.opts: -------------------------------------------------------------------------------- 1 | --break-fun-decl=wrap --break-fun-sig=wrap 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_record.ml: -------------------------------------------------------------------------------- 1 | let xxxxxxxxxxxxxxxxxxxxxx x = 2 | { xxxxxxxxxxxxxx 3 | ; xxxxxxxxxxxxxxxxxx = x 4 | ; xxxxxxxxxxxxx 5 | } 6 | ;; 7 | -------------------------------------------------------------------------------- /test/passing/tests/break_record.ml.opts: -------------------------------------------------------------------------------- 1 | --profile=janestreet 2 | --margin=58 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators-after.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=after 2 | --max-iter=3 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators-after_docked.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=after 2 | --dock-collection-brackets 3 | --max-iter=3 4 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators-after_docked_wrap.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=after 2 | --break-collection-expressions=wrap 3 | --dock-collection-brackets 4 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators-after_wrap.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=after 2 | --break-collection-expressions=wrap 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators-before_docked.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=before 2 | --dock-collection-brackets 3 | --max-iter=3 4 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators-before_docked_wrap.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=before 2 | --break-collection-expressions=wrap 3 | --dock-collection-brackets 4 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators-wrap.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=before 2 | --break-collection-expressions=wrap 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_separators.ml.opts: -------------------------------------------------------------------------------- 1 | --break-separators=before 2 | --max-iter=3 3 | -------------------------------------------------------------------------------- /test/passing/tests/break_sequence_before.ml: -------------------------------------------------------------------------------- 1 | [@@@ocamlformat "sequence-style=before"] 2 | 3 | let foo x y = 4 | lazy 5 | ( fooooooooooooooooooooooo 6 | ; fooooooooooooooooooooooo 7 | ;%ext 8 | foooooooooooooooooooooooooo 9 | ; fooooooooooooooooooooooooo ) 10 | 11 | let _ = 12 | do_ 13 | ;%ext 14 | job_1 15 | ; job_2 16 | ; job_1 17 | ; job_2 18 | ; job_1 19 | ;%ext 20 | job_2 21 | ; job_1 22 | ; job_2 23 | ; job_1 24 | ; job_2 25 | ; return () 26 | 27 | let _ = 28 | do_ 29 | ; job_1 30 | ; job_2 31 | ;%ext 32 | f 33 | ( job_1 34 | ; job_2 35 | ; job_1 36 | ; job_2 37 | ; job_1 38 | ;%ext 39 | job_2 40 | ;%ext 41 | job_2 42 | ; job_1 43 | ; job_2 44 | ; job_1 45 | ; job_2 ) 46 | ;%ext 47 | return () 48 | -------------------------------------------------------------------------------- /test/passing/tests/break_string_literals-never.ml.opts: -------------------------------------------------------------------------------- 1 | --break-string-literals=never 2 | -------------------------------------------------------------------------------- /test/passing/tests/break_string_literals.ml.opts: -------------------------------------------------------------------------------- 1 | --break-string-literals=auto 2 | -------------------------------------------------------------------------------- /test/passing/tests/cmdline_override.ml: -------------------------------------------------------------------------------- 1 | let x = 1 2 | 3 | let y = 2 4 | -------------------------------------------------------------------------------- /test/passing/tests/cmdline_override.ml.opts: -------------------------------------------------------------------------------- 1 | --config=module-item-spacing=compact 2 | --module-item-spacing=sparse 3 | -------------------------------------------------------------------------------- /test/passing/tests/cmdline_override2.ml: -------------------------------------------------------------------------------- 1 | let x = 1 2 | 3 | let y = 2 4 | -------------------------------------------------------------------------------- /test/passing/tests/cmdline_override2.ml.opts: -------------------------------------------------------------------------------- 1 | --module-item-spacing=sparse 2 | --config=module-item-spacing=compact 3 | -------------------------------------------------------------------------------- /test/passing/tests/coerce.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | let a :> x = v in 3 | let a : x :> y = v in 4 | let a = (v :> x) in 5 | let a = (v : x :> y) in 6 | let a : x :> y = (v : x :> y) in 7 | () 8 | 9 | let a :> x = v 10 | 11 | let a : x :> y = v 12 | 13 | let a = (v :> x) 14 | 15 | let a = (v : x :> y) 16 | 17 | let a : x :> y = (v : x :> y) 18 | 19 | class c = 20 | let a :> x = v in 21 | let a : x :> y = v in 22 | let a = (v :> x) in 23 | let a = (v : x :> y) in 24 | let a : x :> y = (v : x :> y) in 25 | object end 26 | -------------------------------------------------------------------------------- /test/passing/tests/comment_breaking.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | foo aaaaaaaaaa bbbbbbbbbb cccccccccc |> (ignore : t -> _) ; 3 | bar dddddddddd eeeeeeeeee ffffffffff |> (ignore : t -> _) 4 | 5 | let () = 6 | (* this comment should not change breaking of the following line *) 7 | foo aaaaaaaaaa bbbbbbbbbb cccccccccc |> (ignore : t -> _) ; 8 | bar dddddddddd eeeeeeeeee ffffffffff |> (ignore : t -> _) 9 | -------------------------------------------------------------------------------- /test/passing/tests/comment_in_modules.ml: -------------------------------------------------------------------------------- 1 | module M = struct 2 | (* comments *) 3 | end 4 | 5 | module M : sig 6 | (* comments *) 7 | end = struct 8 | (* comments *) 9 | end 10 | 11 | module type M = sig 12 | (* comments *) 13 | end 14 | 15 | (** Xxxxxxx xxxxxxxx xx xxxxxxx xxxxxxxxxxxxx xxxxxxxxx xx xxxx *) 16 | module Mmmmmmmmmmmmmmmmmmmmmm = Aaaaaaaaaaaaaaaaaaaaaa.Bbbbbbbbbbbbbbbbbbbbbbbb 17 | 18 | (** Xxxxxxx xxxxxxxx xx xxxxxxx xxxxxxxxxxxxx xxxxxxxxx xx xxxx *) 19 | module Fffffffffffffff (Yyyyyyyyyyyyyyy : Z.S) = Gggggggggg (Wwwwwwwwww.Make (Yyyyyyyyyy)) 20 | 21 | module A (* comment *) (A:sig end) : sig end = struct end 22 | 23 | module A (A:sig end) (* comment *) (B: sig end) : sig end = struct end 24 | 25 | module A (A:sig end) (* comment *) : sig end = struct end 26 | 27 | module (* comment *) A (A : sig end) : sig end = struct end 28 | -------------------------------------------------------------------------------- /test/passing/tests/comment_in_modules.ml.ref: -------------------------------------------------------------------------------- 1 | module M = struct 2 | (* comments *) 3 | end 4 | 5 | module M : sig 6 | (* comments *) 7 | end = struct 8 | (* comments *) 9 | end 10 | 11 | module type M = sig 12 | (* comments *) 13 | end 14 | 15 | (** Xxxxxxx xxxxxxxx xx xxxxxxx xxxxxxxxxxxxx xxxxxxxxx xx xxxx *) 16 | module Mmmmmmmmmmmmmmmmmmmmmm = 17 | Aaaaaaaaaaaaaaaaaaaaaa.Bbbbbbbbbbbbbbbbbbbbbbbb 18 | 19 | (** Xxxxxxx xxxxxxxx xx xxxxxxx xxxxxxxxxxxxx xxxxxxxxx xx xxxx *) 20 | module Fffffffffffffff (Yyyyyyyyyyyyyyy : Z.S) = 21 | Gggggggggg (Wwwwwwwwww.Make (Yyyyyyyyyy)) 22 | 23 | module A (* comment *) (A : sig end) : sig end = struct end 24 | 25 | module A (A : sig end) (* comment *) (B : sig end) : sig end = struct end 26 | 27 | module A (A : sig end) : sig end = (* comment *) struct end 28 | 29 | module (* comment *) A (A : sig end) : sig end = struct end 30 | -------------------------------------------------------------------------------- /test/passing/tests/comment_last.ml: -------------------------------------------------------------------------------- 1 | let x = 2 2 | 3 | let y = 3 4 | 5 | (*comment*) 6 | -------------------------------------------------------------------------------- /test/passing/tests/comment_sparse.ml: -------------------------------------------------------------------------------- 1 | [@@@ocamlformat "break-cases=nested"] 2 | 3 | let f x = 4 | match x with 5 | | `A -> 6 | () 7 | | `B -> 8 | (* Proin ipsum nunc, finibus et finibus, semper et mi. Aenean *) 9 | (* pretium fermentum tellus, a faucibus sagittis et. Cras non *) 10 | () 11 | -------------------------------------------------------------------------------- /test/passing/tests/comments.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=4 2 | -------------------------------------------------------------------------------- /test/passing/tests/comments_args.ml: -------------------------------------------------------------------------------- 1 | [@@@ocamlformat "wrap-fun-args=true"] 2 | 3 | let emit_wrapper_function = 4 | Hhas_function.make function_attributes name body 5 | (Hhas_pos.pos_to_span ast_fun.Ast.f_span) 6 | false (* is_async *) 7 | false (* is_generator *) 8 | false (* is_pair_generator *) 9 | hoisted true (* no_injection *) 10 | true (* inout_wrapper *) 11 | is_interceptable false 12 | (* is_memoize_impl *) 13 | Rx.NonRx false 14 | 15 | [@@@ocamlformat "wrap-fun-args=false"] 16 | 17 | let emit_wrapper_function = 18 | Hhas_function.make function_attributes name body 19 | (Hhas_pos.pos_to_span ast_fun.Ast.f_span) 20 | false (* is_async *) 21 | false (* is_generator *) 22 | false (* is_pair_generator *) 23 | hoisted true (* no_injection *) 24 | true (* inout_wrapper *) 25 | is_interceptable false 26 | (* is_memoize_impl *) 27 | Rx.NonRx false 28 | -------------------------------------------------------------------------------- /test/passing/tests/comments_args.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=4 2 | -------------------------------------------------------------------------------- /test/passing/tests/comments_args.ml.ref: -------------------------------------------------------------------------------- 1 | [@@@ocamlformat "wrap-fun-args=true"] 2 | 3 | let emit_wrapper_function = 4 | Hhas_function.make function_attributes name body 5 | (Hhas_pos.pos_to_span ast_fun.Ast.f_span) 6 | false (* is_async *) false (* is_generator *) false 7 | (* is_pair_generator *) hoisted true (* no_injection *) true 8 | (* inout_wrapper *) is_interceptable false (* is_memoize_impl *) Rx.NonRx 9 | false 10 | 11 | [@@@ocamlformat "wrap-fun-args=false"] 12 | 13 | let emit_wrapper_function = 14 | Hhas_function.make 15 | function_attributes 16 | name 17 | body 18 | (Hhas_pos.pos_to_span ast_fun.Ast.f_span) 19 | false (* is_async *) 20 | false (* is_generator *) 21 | false (* is_pair_generator *) 22 | hoisted 23 | true (* no_injection *) 24 | true (* inout_wrapper *) 25 | is_interceptable 26 | false 27 | (* is_memoize_impl *) 28 | Rx.NonRx 29 | false 30 | -------------------------------------------------------------------------------- /test/passing/tests/comments_around_disabled.ml: -------------------------------------------------------------------------------- 1 | (* cmts *) 2 | 3 | [@@@ocamlformat "disable"] 4 | let () = () 5 | [@@@ocamlformat "enable"] 6 | 7 | (* cmts *) 8 | -------------------------------------------------------------------------------- /test/passing/tests/comments_around_disabled.ml.ref: -------------------------------------------------------------------------------- 1 | (* cmts *) 2 | [@@@ocamlformat "disable"] 3 | 4 | let () = () 5 | 6 | [@@@ocamlformat "enable"] 7 | 8 | (* cmts *) 9 | -------------------------------------------------------------------------------- /test/passing/tests/crlf_to_crlf.ml: -------------------------------------------------------------------------------- 1 | let _ = {| 2 | foo 3 | 4 | bar 5 | |} 6 | 7 | (** This is verbatim: 8 | 9 | {v 10 | o o 11 | /\ /\ 12 | /\ /\ 13 | v} 14 | 15 | This is preformated code: 16 | 17 | {[ 18 | let verbatim s = 19 | s |> String.split_lines |> List.map ~f:String.strip 20 | |> fun s -> list s "@," Fmt.str 21 | ]} *) 22 | 23 | (** Lists: 24 | 25 | list with short lines: 26 | 27 | - x 28 | 29 | list with long lines: 30 | 31 | - xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx 32 | xxx xxx xxx xxx xxx xxx 33 | 34 | list with sub lists: 35 | 36 | {ul 37 | {- xxx 38 | 39 | - a 40 | } 41 | } *) 42 | -------------------------------------------------------------------------------- /test/passing/tests/crlf_to_crlf.ml.opts: -------------------------------------------------------------------------------- 1 | --line-endings=crlf 2 | -------------------------------------------------------------------------------- /test/passing/tests/crlf_to_crlf.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = {| 2 | foo 3 | 4 | bar 5 | |} 6 | 7 | (** This is verbatim: 8 | 9 | {v 10 | o o 11 | /\ /\ 12 | /\ /\ 13 | v} 14 | 15 | This is preformated code: 16 | 17 | {[ 18 | let verbatim s = 19 | s |> String.split_lines |> List.map ~f:String.strip 20 | |> fun s -> list s "@," Fmt.str 21 | ]} *) 22 | 23 | (** Lists: 24 | 25 | list with short lines: 26 | 27 | - x 28 | 29 | list with long lines: 30 | 31 | - xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx 32 | xxx xxx xxx xxx xxx xxx 33 | 34 | list with sub lists: 35 | 36 | {ul 37 | {- xxx 38 | 39 | - a 40 | } 41 | } *) 42 | -------------------------------------------------------------------------------- /test/passing/tests/crlf_to_lf.ml: -------------------------------------------------------------------------------- 1 | let _ = {| 2 | foo 3 | 4 | bar 5 | |} 6 | 7 | (** This is verbatim: 8 | 9 | {v 10 | o o 11 | /\ /\ 12 | /\ /\ 13 | v} 14 | 15 | This is preformated code: 16 | 17 | {[ 18 | let verbatim s = 19 | s |> String.split_lines |> List.map ~f:String.strip 20 | |> fun s -> list s "@," Fmt.str 21 | ]} *) 22 | 23 | (** Lists: 24 | 25 | list with short lines: 26 | 27 | - x 28 | 29 | list with long lines: 30 | 31 | - xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx 32 | xxx xxx xxx xxx xxx xxx 33 | 34 | list with sub lists: 35 | 36 | {ul 37 | {- xxx 38 | 39 | - a 40 | } 41 | } *) 42 | -------------------------------------------------------------------------------- /test/passing/tests/crlf_to_lf.ml.opts: -------------------------------------------------------------------------------- 1 | --line-endings=lf 2 | -------------------------------------------------------------------------------- /test/passing/tests/crlf_to_lf.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = {| 2 | foo 3 | 4 | bar 5 | |} 6 | 7 | (** This is verbatim: 8 | 9 | {v 10 | o o 11 | /\ /\ 12 | /\ /\ 13 | v} 14 | 15 | This is preformated code: 16 | 17 | {[ 18 | let verbatim s = 19 | s |> String.split_lines |> List.map ~f:String.strip 20 | |> fun s -> list s "@," Fmt.str 21 | ]} *) 22 | 23 | (** Lists: 24 | 25 | list with short lines: 26 | 27 | - x 28 | 29 | list with long lines: 30 | 31 | - xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx 32 | xxx xxx xxx xxx xxx xxx 33 | 34 | list with sub lists: 35 | 36 | {ul 37 | {- xxx 38 | 39 | - a 40 | } 41 | } *) 42 | -------------------------------------------------------------------------------- /test/passing/tests/custom_list.ml: -------------------------------------------------------------------------------- 1 | type 'a t = [] | ( :: ) of 'a * 'a t 2 | 3 | let _ = ( :: ) 5 4 | -------------------------------------------------------------------------------- /test/passing/tests/dir1/.ocamlformat: -------------------------------------------------------------------------------- 1 | module-item-spacing = compact 2 | -------------------------------------------------------------------------------- /test/passing/tests/dir1/dir2/.ocamlformat: -------------------------------------------------------------------------------- 1 | module-item-spacing = sparse 2 | -------------------------------------------------------------------------------- /test/passing/tests/dir1/dir2/print_config.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/dir1/dir2/print_config.ml -------------------------------------------------------------------------------- /test/passing/tests/directives.mlt: -------------------------------------------------------------------------------- 1 | (* comment before *) 2 | 3 | #directory "+unix" 4 | 5 | #load (* a *) "file" (* b *) 6 | 7 | (* comment after *) 8 | 9 | -------------------------------------------------------------------------------- /test/passing/tests/directives.mlt.ref: -------------------------------------------------------------------------------- 1 | (* comment before *) 2 | #directory "+unix" 3 | 4 | #load (* a *) "file" 5 | (* b *) 6 | 7 | (* comment after *) 8 | -------------------------------------------------------------------------------- /test/passing/tests/disabled.ml: -------------------------------------------------------------------------------- 1 | (* this file does not parse and ocamlformat is disabled *) 2 | let = in 3 | -------------------------------------------------------------------------------- /test/passing/tests/disabled.ml.opts: -------------------------------------------------------------------------------- 1 | --disable -------------------------------------------------------------------------------- /test/passing/tests/disambiguate.ml: -------------------------------------------------------------------------------- 1 | [@@@ocamlformat "disambiguate-non-breaking-match"] 2 | 3 | let () = r := (fun () -> f () ; g ()) 4 | 5 | let () = 6 | r := 7 | fun () -> 8 | f () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () 9 | 10 | let () = r := (function () -> f () ; g ()) 11 | 12 | let () = 13 | r := 14 | function 15 | | () -> 16 | f () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () 17 | 18 | let () = r := (match () with () -> f () ; g ()) 19 | 20 | let () = 21 | r := 22 | match () with 23 | | () -> 24 | f () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () 25 | 26 | let () = r := (try () with () -> f () ; g ()) 27 | 28 | let () = 29 | r := 30 | try () 31 | with () -> 32 | f () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () ; g () 33 | -------------------------------------------------------------------------------- /test/passing/tests/doc_comments-after.ml.opts: -------------------------------------------------------------------------------- 1 | --doc-comments=after-when-possible 2 | -------------------------------------------------------------------------------- /test/passing/tests/doc_comments-before-except-val.ml.opts: -------------------------------------------------------------------------------- 1 | --doc-comments=before-except-val 2 | -------------------------------------------------------------------------------- /test/passing/tests/doc_comments-before.ml.opts: -------------------------------------------------------------------------------- 1 | --doc-comments=before 2 | -------------------------------------------------------------------------------- /test/passing/tests/doc_comments-no-parse-docstrings.mli.opts: -------------------------------------------------------------------------------- 1 | --no-parse-docstrings 2 | --max-iters=3 3 | -------------------------------------------------------------------------------- /test/passing/tests/doc_comments-no-wrap.mli.opts: -------------------------------------------------------------------------------- 1 | --no-wrap-comments 2 | -------------------------------------------------------------------------------- /test/passing/tests/doc_comments_padding.ml: -------------------------------------------------------------------------------- 1 | type t = {a: int (** a *); b: int (** b *)} 2 | 3 | type t = < a: int (** a *) ; b: int (** b *) > 4 | 5 | type t = [`a of int (** a *) | `b of int (** b *)] 6 | 7 | type t = A of int (** a *) | B of int (** b *) 8 | 9 | type t += A of int (** a *) | B of int (** b *) 10 | 11 | [@@@ocamlformat "doc-comments-padding=1"] 12 | 13 | type t = {a: int (** a *); b: int (** b *)} 14 | 15 | type t = < a: int (** a *) ; b: int (** b *) > 16 | 17 | type t = [`a of int (** a *) | `b of int (** b *)] 18 | 19 | type t = A of int (** a *) | B of int (** b *) 20 | 21 | type t += A of int (** a *) | B of int (** b *) 22 | -------------------------------------------------------------------------------- /test/passing/tests/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 2.2) 2 | (formatting disabled) 3 | -------------------------------------------------------------------------------- /test/passing/tests/empty.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/empty.ml -------------------------------------------------------------------------------- /test/passing/tests/empty_ml.ml: -------------------------------------------------------------------------------- 1 | (* test *) 2 | 3 | (* test *) 4 | -------------------------------------------------------------------------------- /test/passing/tests/empty_mli.mli: -------------------------------------------------------------------------------- 1 | (* test *) 2 | 3 | (* test *) 4 | -------------------------------------------------------------------------------- /test/passing/tests/empty_mlt.mlt: -------------------------------------------------------------------------------- 1 | (* test *) 2 | 3 | (* test *) 4 | -------------------------------------------------------------------------------- /test/passing/tests/error1.ml: -------------------------------------------------------------------------------- 1 | a+ 2 | -------------------------------------------------------------------------------- /test/passing/tests/error1.ml.ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/error1.ml" (syntax error) 2 | File "tests/error1.ml", line 2, characters 0-0: 3 | Error: Syntax error 4 | -------------------------------------------------------------------------------- /test/passing/tests/error1.ml.should-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/error1.ml.should-fail -------------------------------------------------------------------------------- /test/passing/tests/error2.ml: -------------------------------------------------------------------------------- 1 | "asdd 2 | -------------------------------------------------------------------------------- /test/passing/tests/error2.ml.ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/error2.ml" (syntax error) 2 | File "tests/error2.ml", line 1, characters 0-1: 3 | 1 | "asdd 4 | ^ 5 | Error: String literal not terminated 6 | -------------------------------------------------------------------------------- /test/passing/tests/error2.ml.should-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/error2.ml.should-fail -------------------------------------------------------------------------------- /test/passing/tests/error3.ml: -------------------------------------------------------------------------------- 1 | let a = () 2 | (** a or b *) 3 | let b = (** ? *) () 4 | -------------------------------------------------------------------------------- /test/passing/tests/error3.ml.ref: -------------------------------------------------------------------------------- 1 | ocamlformat: ignoring "tests/error3.ml" (misplaced documentation comments - warning 50) 2 | File "tests/error3.ml", line 2, characters 0-13: 3 | 2 | (** a or b *) 4 | ^^^^^^^^^^^^^ 5 | Warning 50 [unexpected-docstring]: ambiguous documentation comment 6 | File "tests/error3.ml", line 3, characters 8-16: 7 | 3 | let b = (** ? *) () 8 | ^^^^^^^^ 9 | Warning 50 [unexpected-docstring]: unattached documentation comment (ignored) 10 | Hint: (Warning 50) This file contains a documentation comment (** ... *) that the OCaml compiler does not know how to attach to the AST. OCamlformat does not support these cases. You can find more information at: https://github.com/ocaml-ppx/ocamlformat#overview. If you'd like to disable this check and let ocamlformat make a choice (though it might not be consistent with the ocaml compilers and odoc), you can set the --no-comment-check option. 11 | -------------------------------------------------------------------------------- /test/passing/tests/error3.ml.should-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/error3.ml.should-fail -------------------------------------------------------------------------------- /test/passing/tests/error4.ml: -------------------------------------------------------------------------------- 1 | let a = () 2 | (** a or b *) 3 | let b = (** ? *) () 4 | -------------------------------------------------------------------------------- /test/passing/tests/error4.ml.opts: -------------------------------------------------------------------------------- 1 | --no-comment-check 2 | -------------------------------------------------------------------------------- /test/passing/tests/error4.ml.ref: -------------------------------------------------------------------------------- 1 | File "tests/error4.ml", line 2, characters 0-13: 2 | 2 | (** a or b *) 3 | ^^^^^^^^^^^^^ 4 | Warning 50 [unexpected-docstring]: ambiguous documentation comment 5 | File "tests/error4.ml", line 3, characters 8-16: 6 | 3 | let b = (** ? *) () 7 | ^^^^^^^^ 8 | Warning 50 [unexpected-docstring]: unattached documentation comment (ignored) 9 | (** a or b *) 10 | let a = () 11 | 12 | (** a or b *) 13 | let b = (** ? *) () 14 | -------------------------------------------------------------------------------- /test/passing/tests/escaped_nl.ml: -------------------------------------------------------------------------------- 1 | let s1 = "No field 'install', but a field 'remove': install instructions \ 2 | probably part of 'build'. Use the 'install' field or a .install \ 3 | file" 4 | 5 | let x = 6 | cond 40 `Warning 7 | "Package uses flags that aren't recognised by earlier versions in \ 8 | OPAM 1.2 branch. At the moment, you should use a tag \"flags:foo\" \ 9 | instead for compatibility" 10 | ~detail:alpha_flags 11 | (alpha_flags <> []) 12 | 13 | let s2 = "bla bla 14 | bli bli \ 15 | blo" 16 | 17 | let s3 = "\ 18 | " 19 | 20 | let s4 = " \ 21 | " 22 | 23 | let s5 = " \ 24 | \ 25 | " 26 | 27 | let s6 = " 28 | " 29 | 30 | let s7 = " 31 | " 32 | 33 | let c1 = ' 34 | ' 35 | 36 | let x1 = f x ' 37 | ' y 38 | z 39 | 40 | let zz = "\ 41 | 42 | s \ 43 | \ 44 | " 45 | -------------------------------------------------------------------------------- /test/passing/tests/escaped_nl.ml.ref: -------------------------------------------------------------------------------- 1 | let s1 = 2 | "No field 'install', but a field 'remove': install instructions probably \ 3 | part of 'build'. Use the 'install' field or a .install file" 4 | 5 | let x = 6 | cond 40 `Warning 7 | "Package uses flags that aren't recognised by earlier versions in OPAM \ 8 | 1.2 branch. At the moment, you should use a tag \"flags:foo\" instead \ 9 | for compatibility" 10 | ~detail:alpha_flags (alpha_flags <> []) 11 | 12 | let s2 = "bla bla\n bli bli blo" 13 | 14 | let s3 = "" 15 | 16 | let s4 = " " 17 | 18 | let s5 = " " 19 | 20 | let s6 = "\n" 21 | 22 | let s7 = " \n" 23 | 24 | let c1 = '\n' 25 | 26 | let x1 = f x '\n' y z 27 | 28 | let zz = "\ns " 29 | -------------------------------------------------------------------------------- /test/passing/tests/exp_grouping-parens.ml.opts: -------------------------------------------------------------------------------- 1 | --exp-grouping=parens 2 | -------------------------------------------------------------------------------- /test/passing/tests/exp_grouping.ml.opts: -------------------------------------------------------------------------------- 1 | --exp-grouping=preserve 2 | -------------------------------------------------------------------------------- /test/passing/tests/exp_record.ml: -------------------------------------------------------------------------------- 1 | let x = {a= 1; b= true} 2 | 3 | let x = {a: int = b} 4 | 5 | let x {a: int = b} = 2 6 | 7 | [@@@ocamlformat "space-around-records"] 8 | 9 | let x = { a= 1; b= true } 10 | 11 | let x = { a: int = b } 12 | 13 | let x { a: int = b } = 2 14 | -------------------------------------------------------------------------------- /test/passing/tests/expect_test.ml: -------------------------------------------------------------------------------- 1 | let%expect_test _ = e 2 | 3 | let%bench "test" = fun () -> () 4 | 5 | let%expect_test _ = 6 | assert false ; 7 | [%expect.unreachable] 8 | [@@expect.uncaught_exn 9 | {| 10 | (* CR expect_test_collector: This test expectation appears to contain a backtrace. 11 | This is strongly discouraged as backtraces are fragile. 12 | Please change this test to not include a backtrace. *) 13 | 14 | "Assert_failure test.ml:5:6" 15 | Raised at file "test.ml", line 4, characters 6-18 16 | Called from file "collector/expect_test_collector.ml", line 225, characters 12-19 |}] 17 | 18 | let _ = 19 | assert false ; 20 | [%expect.unreachable] 21 | [@@expect.uncaught_exn 22 | {| 23 | "Assert_failure test.ml:5:6" 24 | Raised at file "test.ml", line 4, characters 6-18 25 | Called from file "collector/expect_test_collector.ml", line 225, characters 12-19 |}] 26 | -------------------------------------------------------------------------------- /test/passing/tests/extensions-indent.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iters=3 2 | --extension-indent=5 3 | --stritem-extension-indent=3 4 | -------------------------------------------------------------------------------- /test/passing/tests/extensions-indent.mli.opts: -------------------------------------------------------------------------------- 1 | --extension-indent=5 2 | --stritem-extension-indent=3 3 | -------------------------------------------------------------------------------- /test/passing/tests/extensions.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iters=3 2 | -------------------------------------------------------------------------------- /test/passing/tests/field-op_begin_line.ml.opts: -------------------------------------------------------------------------------- 1 | --assignment-operator=begin-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/field-op_begin_line.ml.ref: -------------------------------------------------------------------------------- 1 | let foo = 2 | entry.logdata.value_end 3 | <- entry.logdata.value_end - !remove_size + testtesttest ; 4 | entry.logdata.value_end 5 | <- (entry.logdata.value_end - !remove_size + testtesttest) [@foo] ; 6 | (* foooooooooo *) 7 | entry.logdata.value_end 8 | <- (entry.logdata.value_end - !remove_size + testtesttest) [@foo] 9 | (* foooooooooooo *) ; 10 | entry.logdata.value_end 11 | <- entry.logdata.value_end - !remove_size + testtesttest 12 | (* fooooooooooooooooooooooooo *) ; 13 | value_end 14 | <- entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest ; 15 | value_end 16 | <- ( entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest 17 | ) 18 | [@foo] ; 19 | value_end 20 | <- ( entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest 21 | ) 22 | [@foo] 23 | (* fooooooooooooo *) ; 24 | (* foooooooooooooooooooo *) 25 | value_end 26 | <- entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest 27 | (* foooooooo *) ; 28 | foo 29 | -------------------------------------------------------------------------------- /test/passing/tests/field.ml: -------------------------------------------------------------------------------- 1 | let foo = 2 | entry.logdata.value_end <- 3 | entry.logdata.value_end - !remove_size + testtesttest ; 4 | entry.logdata.value_end <- 5 | (entry.logdata.value_end - !remove_size + testtesttest) [@foo] ; 6 | (* foooooooooo *) 7 | entry.logdata.value_end <- 8 | (entry.logdata.value_end - !remove_size + testtesttest) [@foo] 9 | (* foooooooooooo *) ; 10 | entry.logdata.value_end <- 11 | entry.logdata.value_end - !remove_size + testtesttest 12 | (* fooooooooooooooooooooooooo *) ; 13 | value_end <- 14 | entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest ; 15 | value_end <- 16 | ( entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest 17 | ) 18 | [@foo] ; 19 | value_end <- 20 | ( entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest 21 | ) 22 | [@foo] 23 | (* fooooooooooooo *) ; 24 | (* foooooooooooooooooooo *) 25 | value_end <- 26 | entry.logdata.value_end - !remove_size + testtesttesttesttesttesttest 27 | (* foooooooo *) ; 28 | foo 29 | -------------------------------------------------------------------------------- /test/passing/tests/floating_doc.ml: -------------------------------------------------------------------------------- 1 | type t = int 2 | 3 | (** Floating doc comment *) 4 | 5 | and u = float 6 | 7 | let f = () 8 | 9 | (** pesky doc comment *) 10 | 11 | and g = () 12 | -------------------------------------------------------------------------------- /test/passing/tests/for_while.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | foo 3 | ( for i = 1 to 10 do 4 | () 5 | done ) 6 | 7 | let () = 8 | foo 9 | ( while true do 10 | () 11 | done ) 12 | 13 | let _ = 14 | for i = some expr to 1000 do 15 | test this 16 | done 17 | 18 | let _ = 19 | for 20 | something_big = some big expression 21 | to something biggggggggggggggggggggggggggggggg 22 | do 23 | test this 24 | done 25 | 26 | let _ = 27 | for 28 | something_big = 29 | some big expressionnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 30 | to something biggggggggggggggggggggggggggggggg 31 | alsooooooooooooooooooooooooooooooooooooooooooo 32 | do 33 | test this 34 | done 35 | 36 | let _ = 37 | for 38 | something_big = 39 | some big expressionnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 40 | downto something biggggggggggggggggggggggggggggggg 41 | alsooooooooooooooooooooooooooooooooooooooooooo 42 | do 43 | test this 44 | done 45 | 46 | let _ = 47 | while 48 | some bigggggggggggggggggggggg 49 | expressionnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 50 | do 51 | test this 52 | done 53 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files-0.ml.opts: -------------------------------------------------------------------------------- 1 | --numeric=11-13 2 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files-0.ml.ref: -------------------------------------------------------------------------------- 1 | 0 2 | 2 3 | 2 4 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files.ml: -------------------------------------------------------------------------------- 1 | let foooooo 2 | = fooooooooo 3 | 4 | let foooooooo 5 | = bar baaaaar barrr 6 | 7 | module K = struct 8 | let k 9 | 10 | ;; 11 | begin 12 | let x = in 13 | () 14 | 15 | ;; 16 | let foooooo = 17 | fooooo 18 | foooooooo 19 | 20 | let k = 21 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files.ml.opts: -------------------------------------------------------------------------------- 1 | --numeric=7-8 2 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files.ml.ref: -------------------------------------------------------------------------------- 1 | 0 2 | 2 3 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files_with_locations.ml: -------------------------------------------------------------------------------- 1 | let x = 1 + ((* asd *);; 2 | 3 | 4 | 5 | 6 | 7 | let x = "\064" 8 | let x = "@" 9 | 10 | (** parse [ docstring *) 11 | let x = 0 12 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files_with_locations.ml.opts: -------------------------------------------------------------------------------- 1 | --numeric=1-11 2 | -------------------------------------------------------------------------------- /test/passing/tests/format_invalid_files_with_locations.ml.ref: -------------------------------------------------------------------------------- 1 | 0 2 | 0 3 | 0 4 | 0 5 | 0 6 | 0 7 | 21 8 | 21 9 | 0 10 | 21 11 | 21 12 | -------------------------------------------------------------------------------- /test/passing/tests/fun_function.ml: -------------------------------------------------------------------------------- 1 | let s = 2 | List.fold x ~f:(fun y -> function 3 | | Aconstructor avalue -> afunction avalue 4 | | Bconstructor bvalue -> bfunction bvalue ) 5 | -------------------------------------------------------------------------------- /test/passing/tests/function_indent-never.ml.opts: -------------------------------------------------------------------------------- 1 | --function-indent=4 2 | --function-indent-nested=never 3 | -------------------------------------------------------------------------------- /test/passing/tests/function_indent-never.ml.ref: -------------------------------------------------------------------------------- 1 | let foooooooo = function 2 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 3 | 4 | let foooooooo = function 5 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 6 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 7 | 8 | let foo = 9 | fooooooooo foooooooo ~foooooooo:(function 10 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 11 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo ) 12 | 13 | let foooooooo = 14 | if fooooooooooo then function 15 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 16 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 17 | else function 18 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 19 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 20 | -------------------------------------------------------------------------------- /test/passing/tests/function_indent.ml: -------------------------------------------------------------------------------- 1 | let foooooooo = function 2 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 3 | 4 | let foooooooo = function 5 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 6 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 7 | 8 | let foo = 9 | fooooooooo foooooooo ~foooooooo:(function 10 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 11 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo) 12 | 13 | let foooooooo = 14 | if fooooooooooo then 15 | function 16 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 17 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 18 | else 19 | function 20 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 21 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 22 | -------------------------------------------------------------------------------- /test/passing/tests/function_indent.ml.opts: -------------------------------------------------------------------------------- 1 | --function-indent=4 2 | --function-indent-nested=always 3 | -------------------------------------------------------------------------------- /test/passing/tests/function_indent.ml.ref: -------------------------------------------------------------------------------- 1 | let foooooooo = function 2 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 3 | 4 | let foooooooo = function 5 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 6 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 7 | 8 | let foo = 9 | fooooooooo foooooooo ~foooooooo:(function 10 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 11 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo ) 12 | 13 | let foooooooo = 14 | if fooooooooooo then function 15 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 16 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 17 | else function 18 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 19 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 20 | -------------------------------------------------------------------------------- /test/passing/tests/gadt.ml: -------------------------------------------------------------------------------- 1 | type t = A : t 2 | 3 | type t = A : t * 'b -> t 4 | 5 | type (_, _, _, _, _) gadt = 6 | | SomeLongName : 7 | ('a, 'b, long_name * long_name2, 't, 'u) gadt 8 | * ('b, 'c, 'v, 'u, 'k) gadt2 9 | -> ('a, 'c, long_name * 'k, 't, 'v) gadt 10 | | AnEvenLongerName : 11 | ('a, 'b, long_name * long_name2, 't, 'u) gadt 12 | * ('b, 'c, 'v, 'u, 'k) gadt2 13 | -> ('a, 'c, long_name * 'k, 't, 'v) gadt 14 | 15 | type _ t = .. 16 | 17 | type _ t += A : int | B : int -> int 18 | 19 | type t = A : (int -> int) -> int 20 | -------------------------------------------------------------------------------- /test/passing/tests/generative.ml: -------------------------------------------------------------------------------- 1 | module Generative () = struct end 2 | 3 | module M = Generative () 4 | 5 | module M = String_id (M) () 6 | -------------------------------------------------------------------------------- /test/passing/tests/hash_types.ml: -------------------------------------------------------------------------------- 1 | module F (X : sig 2 | type t 3 | end) = 4 | struct 5 | class type ['a] c = 6 | object 7 | method m : 'a -> X.t 8 | end 9 | end 10 | 11 | class ['a] c = 12 | object 13 | constraint 'a = 'a #F(Int).c 14 | end 15 | -------------------------------------------------------------------------------- /test/passing/tests/holes.ml: -------------------------------------------------------------------------------- 1 | let () = _ 2 | 3 | let () = (* A *) _ (* B *) [@attr] (** doc *) (* C *) 4 | 5 | module M = _ 6 | 7 | module M = (* A *) _ (* B *) [@attr] (** doc *) (* C *) 8 | 9 | module M = _ (_) (_) 10 | -------------------------------------------------------------------------------- /test/passing/tests/holes.ml.ref: -------------------------------------------------------------------------------- 1 | let () = _ 2 | 3 | (** doc *) 4 | let () = (* A *) _ (* B *) [@attr] 5 | 6 | (* C *) 7 | 8 | module M = _ 9 | 10 | (** doc *) 11 | module M = (* A *) _ (* B *) [@attr] 12 | 13 | (* C *) 14 | 15 | module M = _ (_) (_) 16 | -------------------------------------------------------------------------------- /test/passing/tests/ifand.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | if cond1 3 | && cond2 4 | then _ 5 | 6 | let _ = function 7 | | _ when x = 2 8 | && y = 3 -> 9 | begin if a = b 10 | || b = c 11 | && c = d then 12 | _ 13 | end 14 | -------------------------------------------------------------------------------- /test/passing/tests/ifand.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = if cond1 && cond2 then _ 2 | 3 | let _ = function 4 | | _ when x = 2 && y = 3 -> if a = b || (b = c && c = d) then _ 5 | -------------------------------------------------------------------------------- /test/passing/tests/indicate_multiline_delimiters-cosl.ml.opts: -------------------------------------------------------------------------------- 1 | --indicate-multiline-delimiters=closing-on-separate-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/indicate_multiline_delimiters-space.ml.opts: -------------------------------------------------------------------------------- 1 | --indicate-multiline-delimiters=space 2 | -------------------------------------------------------------------------------- /test/passing/tests/indicate_multiline_delimiters-space.ml.ref: -------------------------------------------------------------------------------- 1 | let compare = function 2 | | Eq -> ( = ) 3 | | Neq -> ( <> ) 4 | | Lt -> ( < ) 5 | | Le -> ( <= ) 6 | | Gt -> ( > ) 7 | | Ge -> ( >= ) 8 | 9 | let raise fmt = 10 | Fmt.kstr 11 | (fun error_message (result : _ result) -> 12 | match result with 13 | | Ok v -> v 14 | | Error `Oh_no -> invalid_arg error_message ) 15 | fmt 16 | 17 | let raise fmt = 18 | Fmt.kstr 19 | (fun error_message aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb -> 20 | invalid_arg error_message ) 21 | fmt 22 | 23 | let raise fmt = 24 | Fmt.kstr 25 | (fun error_message (result : _ result) -> 26 | match result with 27 | | Ok v -> v 28 | | Error `Oh_no -> invalid_arg error_message ) 29 | fmt 30 | 31 | let raise fmt = 32 | Fmt.kstr 33 | (fun error_message aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb -> 34 | invalid_arg error_message ) 35 | fmt 36 | 37 | let contrived = 38 | List.map 39 | ~f:(fun aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -> 40 | f aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ) 41 | l 42 | -------------------------------------------------------------------------------- /test/passing/tests/indicate_multiline_delimiters.ml: -------------------------------------------------------------------------------- 1 | let compare = function 2 | | Eq -> ( = ) 3 | | Neq -> ( <> ) 4 | | Lt -> ( < ) 5 | | Le -> ( <= ) 6 | | Gt -> ( > ) 7 | | Ge -> ( >= ) 8 | 9 | let raise fmt = 10 | Fmt.kstr 11 | (fun error_message (result : _ result) -> 12 | match result with 13 | | Ok v -> v 14 | | Error `Oh_no -> invalid_arg error_message) 15 | fmt 16 | 17 | let raise fmt = 18 | Fmt.kstr 19 | (fun error_message aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb -> 20 | invalid_arg error_message) 21 | fmt 22 | 23 | let raise fmt = 24 | Fmt.kstr 25 | (fun error_message (result : _ result) -> 26 | match result with 27 | | Ok v -> v 28 | | Error `Oh_no -> invalid_arg error_message) 29 | fmt 30 | 31 | let raise fmt = 32 | Fmt.kstr 33 | (fun error_message aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbb -> 34 | invalid_arg error_message) 35 | fmt 36 | 37 | let contrived = 38 | List.map 39 | ~f:(fun aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -> 40 | f aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) 41 | l 42 | -------------------------------------------------------------------------------- /test/passing/tests/indicate_multiline_delimiters.ml.opts: -------------------------------------------------------------------------------- 1 | --indicate-multiline-delimiters=no 2 | -------------------------------------------------------------------------------- /test/passing/tests/infix_bind-break.ml.opts: -------------------------------------------------------------------------------- 1 | --break-infix=wrap 2 | --break-infix-before-func 3 | -------------------------------------------------------------------------------- /test/passing/tests/infix_bind-fit_or_vertical-break.ml.opts: -------------------------------------------------------------------------------- 1 | --break-infix=fit-or-vertical 2 | --break-infix-before-func 3 | -------------------------------------------------------------------------------- /test/passing/tests/infix_bind-fit_or_vertical.ml.opts: -------------------------------------------------------------------------------- 1 | --break-infix=fit-or-vertical 2 | --no-break-infix-before-func 3 | -------------------------------------------------------------------------------- /test/passing/tests/infix_bind.ml.opts: -------------------------------------------------------------------------------- 1 | --break-infix=wrap 2 | --no-break-infix-before-func 3 | -------------------------------------------------------------------------------- /test/passing/tests/infix_precedence.ml: -------------------------------------------------------------------------------- 1 | let dolore_tempor_in_duis duis_esse esse = 2 | let duis_nisi = Occaecat.sed_duis_nisi duis_esse in 3 | do_dolore_quis_dolore duis_nisi esse 4 | || ( (not 5 | ( match duis_nisi with 6 | | Qui.Occaecat.Enim esse_magna -> 7 | Qui.Occaecat.Enim.do_commodo_dolore esse_magna 8 | | _ -> false ) ) 9 | && Occaecat.sed_aliqua duis_esse <> PariAtur.Aliquip 10 | && not 11 | (Adipisicing.magna_tempor_ipsum_elit_nisi duis_esse 12 | Adipisicing.loremipSumDolorsi ) ) 13 | -------------------------------------------------------------------------------- /test/passing/tests/infix_precedence.ml.opts: -------------------------------------------------------------------------------- 1 | --infix-precedence=parens -------------------------------------------------------------------------------- /test/passing/tests/invalid.ml: -------------------------------------------------------------------------------- 1 | let f = function "as" .. 3 | 3. .. 'q' | 3 .. -3. | -3. .. 3 -> () 2 | 3 | let f = function (lazy (exception A)) -> () | exception (lazy A) -> () 4 | 5 | let f = (A) a b 6 | 7 | let f = (A x) a b 8 | 9 | let f = (`A) a b 10 | 11 | let f = (`A x) a b 12 | 13 | let f = ((::)) a b c 14 | -------------------------------------------------------------------------------- /test/passing/tests/invalid_docstring.ml: -------------------------------------------------------------------------------- 1 | (**{v*) 2 | -------------------------------------------------------------------------------- /test/passing/tests/invalid_docstring.ml.ref: -------------------------------------------------------------------------------- 1 | Warning: Invalid documentation comment: 2 | File "tests/invalid_docstring.ml", line 1, characters 5-5: 3 | End of text is not allowed in '{v ... v}' (verbatim text). 4 | Warning: Invalid documentation comment: 5 | File "tests/invalid_docstring.ml", line 1, characters 3-5: 6 | '{v ... v}' (verbatim text) should not be empty. 7 | (**{v*) 8 | -------------------------------------------------------------------------------- /test/passing/tests/issue114.ml: -------------------------------------------------------------------------------- 1 | let () = (f ()).(2) <- e 2 | -------------------------------------------------------------------------------- /test/passing/tests/issue48.ml: -------------------------------------------------------------------------------- 1 | module X (* : sig val x : unit -> unit end *) = struct 2 | let x () = print_endline "coucou" 3 | end 4 | -------------------------------------------------------------------------------- /test/passing/tests/issue51.ml: -------------------------------------------------------------------------------- 1 | val run : 2 | unit 3 | -> (unit -> ('a, ([> `Msg of string] as 'b)) result) 4 | -> ('a, 'b) result 5 | -------------------------------------------------------------------------------- /test/passing/tests/issue57.ml: -------------------------------------------------------------------------------- 1 | let f (`A x) = x 2 | 3 | let f x = 4 | let (`A y) = x in 5 | y 6 | -------------------------------------------------------------------------------- /test/passing/tests/issue60.ml: -------------------------------------------------------------------------------- 1 | let x : unit = () 2 | -------------------------------------------------------------------------------- /test/passing/tests/issue77.ml: -------------------------------------------------------------------------------- 1 | let div = 2 | [ div 3 | ~a: 4 | [ Reactive.a_style 5 | (React.S.map (sprintf "height: %dpx") 6 | (State.player_height_signal app_state) ) 7 | (* ksprintf a_style "%s" (if_smth "min-height: 300px;" ""); *) ] 8 | content ] 9 | -------------------------------------------------------------------------------- /test/passing/tests/issue85.ml: -------------------------------------------------------------------------------- 1 | let f (module X) = X.x 2 | 3 | let f = function `A {x: int = _} -> () 4 | 5 | let f (`A | `B) = () 6 | -------------------------------------------------------------------------------- /test/passing/tests/issue89.ml: -------------------------------------------------------------------------------- 1 | let f x = !(x.(0)) 2 | -------------------------------------------------------------------------------- /test/passing/tests/ite-compact.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=compact 2 | -------------------------------------------------------------------------------- /test/passing/tests/ite-compact_closing.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=compact 2 | --indicate-multiline-delimiters=closing-on-separate-line 3 | -------------------------------------------------------------------------------- /test/passing/tests/ite-fit_or_vertical.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=fit-or-vertical 2 | -------------------------------------------------------------------------------- /test/passing/tests/ite-fit_or_vertical_closing.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else fit-or-vertical --indicate-multiline-delimiters=closing-on-separate-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/ite-fit_or_vertical_no_indicate.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=fit-or-vertical 2 | --indicate-multiline-delimiters=no 3 | -------------------------------------------------------------------------------- /test/passing/tests/ite-kr.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=k-r 2 | --max-iters=3 3 | -------------------------------------------------------------------------------- /test/passing/tests/ite-kr_closing.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=k-r --max-iters=3 --indicate-multiline-delimiters=closing-on-separate-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/ite-kw_first.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=keyword-first 2 | -------------------------------------------------------------------------------- /test/passing/tests/ite-kw_first_closing.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else keyword-first --indicate-multiline-delimiters=closing-on-separate-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/ite-kw_first_no_indicate.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=keyword-first 2 | --indicate-multiline-delimiters=no 3 | -------------------------------------------------------------------------------- /test/passing/tests/ite-no_indicate.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=compact 2 | --indicate-multiline-delimiters=no 3 | -------------------------------------------------------------------------------- /test/passing/tests/ite.ml.opts: -------------------------------------------------------------------------------- 1 | --if-then-else=compact 2 | -------------------------------------------------------------------------------- /test/passing/tests/js_args.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 2 | -------------------------------------------------------------------------------- /test/passing/tests/js_begin.ml: -------------------------------------------------------------------------------- 1 | let f = function 2 | | zoo -> begin 3 | foo; 4 | bar; 5 | end 6 | ;; 7 | let g = function 8 | | zoo -> ( 9 | foo; 10 | bar; 11 | ) 12 | ;; 13 | let () = 14 | begin match foo with 15 | | Bar -> snoo 16 | end 17 | ;; 18 | -------------------------------------------------------------------------------- /test/passing/tests/js_begin.ml.ref: -------------------------------------------------------------------------------- 1 | let f = function zoo -> foo ; bar 2 | 3 | let g = function zoo -> foo ; bar 4 | 5 | let () = match foo with Bar -> snoo 6 | -------------------------------------------------------------------------------- /test/passing/tests/js_bind.ml: -------------------------------------------------------------------------------- 1 | let assigned_to u = 2 | Deferred.List.filter (Request_util.requests ()) ~f:(fun request -> 3 | if _ 4 | then _ 5 | else 6 | status_request ~request () ~msg_client:no_msg >>= fun status -> 7 | not (up_to_date_user status u)) 8 | 9 | 10 | 11 | let old_good = 12 | foo bar qaz *>>= fun x -> 13 | hey ho lala *>>= fun y -> 14 | return (x,y) 15 | 16 | let old_good = 17 | foo bar qaz +>>= fun x -> 18 | hey ho lala +>>= fun y -> 19 | return (x,y) 20 | 21 | (* generalizations based on Tuareg code *) 22 | let old_good = 23 | foo bar qaz *>>| fun x -> 24 | hey ho lala *>>> fun y -> 25 | foo bar qaz +>>| fun x -> 26 | hey ho lala +>>> fun y -> 27 | return (x,y) 28 | -------------------------------------------------------------------------------- /test/passing/tests/js_bind.ml.ref: -------------------------------------------------------------------------------- 1 | let assigned_to u = 2 | Deferred.List.filter (Request_util.requests ()) ~f:(fun request -> 3 | if _ then _ 4 | else 5 | status_request ~request () ~msg_client:no_msg 6 | >>= fun status -> not (up_to_date_user status u) ) 7 | 8 | let old_good = 9 | foo bar qaz *>>= fun x -> hey ho lala *>>= fun y -> return (x, y) 10 | 11 | let old_good = 12 | foo bar qaz +>>= fun x -> hey ho lala +>>= fun y -> return (x, y) 13 | 14 | (* generalizations based on Tuareg code *) 15 | let old_good = 16 | foo bar qaz 17 | *>>| fun x -> 18 | hey ho lala 19 | *>>> fun y -> 20 | foo bar qaz +>>| fun x -> hey ho lala +>>> fun y -> return (x, y) 21 | -------------------------------------------------------------------------------- /test/passing/tests/js_fun.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 2 | -------------------------------------------------------------------------------- /test/passing/tests/js_fun.ml.ref: -------------------------------------------------------------------------------- 1 | (* preferred list style *) 2 | let z = f [y; foo ~f:(fun () -> arg)] 3 | 4 | let z = f [y; foo ~f:(fun () -> arg)] 5 | 6 | (* legacy list style *) 7 | let _ = [f (fun x -> x); f (fun x -> x); f (fun x -> x)] 8 | 9 | let _ = [f (fun x -> x); f (fun x -> x); f (fun x -> x)] 10 | 11 | let _ = [f (fun x -> x); f (fun x -> x); f (fun x -> x)] 12 | 13 | let _ = 14 | x 15 | >>= fun x -> 16 | (try x with _ -> ()) >>= fun x -> try x with _ -> () >>= fun x -> x 17 | 18 | let () = expr >>| function x -> 3 | y -> 4 19 | 20 | let () = expr >>| fun z -> match z with x -> 3 | y -> 4 21 | 22 | let () = expr >>| fun z -> function x -> 3 | y -> 4 23 | 24 | let () = my_func () >>= function A -> 0 | B -> 0 25 | 26 | let () = my_func () >>= function A -> 0 | B -> 0 27 | 28 | let () = expr >>| function x -> 3 | y -> 4 29 | 30 | let () = expr >>| function x -> 3 | y -> 4 31 | 32 | let f = 33 | f >>= m (fun f x -> y) ; 34 | z 35 | 36 | let f = 37 | f |> m (fun f x -> y) ; 38 | z 39 | 40 | let f = 41 | f |> m (fun f x -> y) ; 42 | z 43 | -------------------------------------------------------------------------------- /test/passing/tests/js_map.ml: -------------------------------------------------------------------------------- 1 | let projection_files = 2 | Deferred.List.map x ~f:(fun p -> 3 | _) 4 | >>| String.split ~on:'\n' 5 | -------------------------------------------------------------------------------- /test/passing/tests/js_map.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 2 | -------------------------------------------------------------------------------- /test/passing/tests/js_map.ml.ref: -------------------------------------------------------------------------------- 1 | let projection_files = 2 | Deferred.List.map x ~f:(fun p -> _) >>| String.split ~on:'\n' 3 | -------------------------------------------------------------------------------- /test/passing/tests/js_pattern.ml: -------------------------------------------------------------------------------- 1 | let f = function 2 | | _ -> 0 3 | ;; 4 | 5 | let f x = match x with 6 | | _ -> 0 7 | ;; 8 | 9 | let f = 10 | function 11 | | _ -> 0 12 | ;; 13 | 14 | let f x = 15 | match x with 16 | | _ -> 0 17 | ;; 18 | 19 | let f x = 20 | begin match x with 21 | | _ -> 0 22 | end 23 | ;; 24 | 25 | let check_price t = function 26 | | { Exec. 27 | trade_at_settlement = (None | Some false); 28 | } -> () 29 | 30 | let check_price t = function 31 | | simpler -> () 32 | | other -> () 33 | 34 | (* Sometimes we like to write big alternations like this, in which case the 35 | comment should typically align with the following clause. *) 36 | let 0 = 37 | match x with 38 | | A 39 | (* a *) 40 | -> a 41 | let 0 = 42 | match x with 43 | A 44 | (* a *) 45 | -> a 46 | 47 | let _ = 48 | a 49 | || match a with 50 | | a -> true 51 | | b -> false 52 | -------------------------------------------------------------------------------- /test/passing/tests/js_pattern.ml.ref: -------------------------------------------------------------------------------- 1 | let f = function _ -> 0 2 | 3 | let f x = match x with _ -> 0 4 | 5 | let f = function _ -> 0 6 | 7 | let f x = match x with _ -> 0 8 | 9 | let f x = match x with _ -> 0 10 | 11 | let check_price t = function 12 | | {Exec.trade_at_settlement= None | Some false} -> () 13 | 14 | let check_price t = function simpler -> () | other -> () 15 | 16 | (* Sometimes we like to write big alternations like this, in which case the 17 | comment should typically align with the following clause. *) 18 | let 0 = match x with A (* a *) -> a 19 | 20 | let 0 = match x with A (* a *) -> a 21 | 22 | let _ = a || match a with a -> true | b -> false 23 | -------------------------------------------------------------------------------- /test/passing/tests/js_poly.ml: -------------------------------------------------------------------------------- 1 | let handle_query qs ~msg_client:_ = 2 | try_with (fun () -> 3 | if _ then 4 | f >>| fun () -> 5 | `Done () 6 | else 7 | _ 8 | ) 9 | ;; 10 | 11 | if _ then 12 | _ 13 | else 14 | assert_branch_has_node branch node >>| fun () -> 15 | { t with node; floating } 16 | ;; 17 | -------------------------------------------------------------------------------- /test/passing/tests/js_poly.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 2 | -------------------------------------------------------------------------------- /test/passing/tests/js_poly.ml.ref: -------------------------------------------------------------------------------- 1 | let handle_query qs ~msg_client:_ = 2 | try_with (fun () -> if _ then f >>| fun () -> `Done () else _) 3 | ;; 4 | 5 | if _ then _ 6 | else assert_branch_has_node branch node >>| fun () -> {t with node; floating} 7 | -------------------------------------------------------------------------------- /test/passing/tests/js_record.ml.ref: -------------------------------------------------------------------------------- 1 | type x = {foo: int; bar: int} 2 | 3 | let x = {x with foo= 3; bar= 5} 4 | 5 | let x = {(* blah blah blah *) 6 | foo= 3; bar= 5} 7 | 8 | let x = [{x with foo= 3; bar= 5}] 9 | 10 | let x = [{(* blah blah blah *) 11 | foo= 3; bar= 5}] 12 | 13 | let x = {M.x with M.foo= 3} 14 | 15 | let x = {x with M.foo= 3} 16 | 17 | let x = {M.foo= 3} 18 | 19 | let _ = {foo with Bar.field1= value1; field2= value2} 20 | 21 | let _ = {foo with Bar.field1= value1; field2= value2} 22 | 23 | (* multicomponent record module pathname *) 24 | let _ = {A.B.a= b; c= d} 25 | 26 | type t = {a: something_lengthy list list [@default String.Map.empty]} 27 | 28 | type t = {a: Something_lengthy.t list list [@default String.Map.empty]} 29 | 30 | type t = {a: something_lengthy list list} 31 | 32 | type t = {a: Something_lengthy.t list list} 33 | 34 | type t = {a: Something_lengthy.t list} 35 | -------------------------------------------------------------------------------- /test/passing/tests/js_sig.mli: -------------------------------------------------------------------------------- 1 | open! Core 2 | 3 | (** First documentation comment. *) 4 | exception First_exception 5 | 6 | (** Second documentation comment. *) 7 | exception Second_exception 8 | 9 | [@@@ocamlformat "parse-docstrings=true"] 10 | [@@@ocamlformat "wrap-comments=true"] 11 | 12 | (** {e foooooooo oooooo oooo oooo ooooo oooo ooooo} {i fooooo ooooo ooo oooooo oo oooooo oooo} {b fooooooo oooooo oooooo oooooo oooooo ooooooo} *) 13 | 14 | (** {e foooooooo oooooooooo ooooooooo ooooooooo} {{!some ref} fooooooooooooo 15 | oooooooo oooooooooo} {b fooooooooooooo oooooooooooo oooooo ooooooo} *) 16 | -------------------------------------------------------------------------------- /test/passing/tests/js_sig.mli.opts: -------------------------------------------------------------------------------- 1 | --profile=janestreet 2 | -------------------------------------------------------------------------------- /test/passing/tests/js_sig.mli.ref: -------------------------------------------------------------------------------- 1 | open! Core 2 | 3 | (** First documentation comment. *) 4 | exception First_exception 5 | 6 | (** Second documentation comment. *) 7 | exception Second_exception 8 | 9 | [@@@ocamlformat "parse-docstrings=true"] 10 | [@@@ocamlformat "wrap-comments=true"] 11 | 12 | (** {e foooooooo oooooo oooo oooo ooooo oooo ooooo} 13 | {i fooooo ooooo ooo oooooo oo oooooo oooo} 14 | {b fooooooo oooooo oooooo oooooo oooooo ooooooo} *) 15 | 16 | (** {e foooooooo oooooooooo ooooooooo ooooooooo} {{!some ref} fooooooooooooo oooooooo 17 | oooooooooo} {b fooooooooooooo oooooooooooo oooooo ooooooo} *) 18 | -------------------------------------------------------------------------------- /test/passing/tests/js_source.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iters=3 2 | --profile=janestreet 3 | -------------------------------------------------------------------------------- /test/passing/tests/js_syntax.ml: -------------------------------------------------------------------------------- 1 | (* s *) 2 | 3 | let _ = 4 | [%raise_structural_sexp 5 | "feature's tip is already an ancestor of new base" 6 | { feature_tip = (old_tip : Rev.t) 7 | ; new_base = (new_base : Rev.t) 8 | }] 9 | 10 | let _ = 11 | [%raise_structural_sexp "feature's tip is already an ancestor of new base" 12 | { feature_tip = (old_tip : Rev.t) 13 | ; new_base = (new_base : Rev.t) 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /test/passing/tests/js_syntax.ml.ref: -------------------------------------------------------------------------------- 1 | (* s *) 2 | 3 | let _ = 4 | [%raise_structural_sexp 5 | "feature's tip is already an ancestor of new base" 6 | {feature_tip= (old_tip : Rev.t); new_base: Rev.t}] 7 | 8 | let _ = 9 | [%raise_structural_sexp 10 | "feature's tip is already an ancestor of new base" 11 | {feature_tip= (old_tip : Rev.t); new_base: Rev.t}] 12 | -------------------------------------------------------------------------------- /test/passing/tests/js_upon.ml: -------------------------------------------------------------------------------- 1 | let f x = 2 | stop 3 | (* We don't do this as a matter of style, but the indentation reveals a common 4 | mistake. *) 5 | >>> fun () -> don't_wait_for (close fd); 6 | bind fd 7 | 8 | let f x = 9 | stop 10 | (* This is what was intended, which is indented correctly, although it's bad 11 | style on my part. *) 12 | >>> (fun () -> don't_wait_for (close fd)); 13 | bind 14 | -------------------------------------------------------------------------------- /test/passing/tests/js_upon.ml.ref: -------------------------------------------------------------------------------- 1 | let f x = 2 | stop 3 | (* We don't do this as a matter of style, but the indentation reveals a 4 | common mistake. *) 5 | >>> fun () -> 6 | don't_wait_for (close fd) ; 7 | bind fd 8 | 9 | let f x = 10 | ( stop 11 | (* This is what was intended, which is indented correctly, although it's 12 | bad style on my part. *) 13 | >>> fun () -> don't_wait_for (close fd) ) ; 14 | bind 15 | -------------------------------------------------------------------------------- /test/passing/tests/kw_extentions.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | let%lwt foo = Lwt.return 1 in 3 | Lwt.return_unit 4 | 5 | let _ = 6 | let%lwt foo = Lwt.return 1 in 7 | let%lwt bar = Lwt.return 1 in 8 | let%lwt baz = Lwt.return 1 in 9 | Lwt.return_unit 10 | 11 | let () = 12 | if%ext true then () else () ; 13 | if%ext true then () else if true then () else () ; 14 | let%ext x = () in 15 | for%ext i = 1 to 10 do 16 | () 17 | done ; 18 | while%ext false do 19 | () 20 | done ; 21 | match%ext x with _ -> () 22 | 23 | let () = 24 | let%ext x = () in 25 | try%ext x with _ -> () 26 | 27 | let () = 28 | if%ext true then () else () ; 29 | if%ext true then () else if true then () else () ; 30 | if%ext true then () else () 31 | 32 | let () = 33 | (match%ext x with _ -> ()) ; 34 | match%ext x with _ -> () 35 | 36 | let () = () ; () ;%ext () ; () ;%ext () 37 | 38 | let _ = 39 | let%ext () = () and () = () in 40 | () 41 | 42 | let () = 43 | f (fun () -> ()) ;%ext 44 | f () 45 | 46 | let () = 47 | f (fun () -> ()) ;%ext 48 | g (fun () -> ()) ; 49 | h (fun () -> ()) ;%ext 50 | i () ; 51 | j () ;%ext 52 | f () 53 | -------------------------------------------------------------------------------- /test/passing/tests/label_option_default_args.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iters=4 -------------------------------------------------------------------------------- /test/passing/tests/labelled_args-414.ml.opts: -------------------------------------------------------------------------------- 1 | --ocaml-version=4.14.0 2 | -------------------------------------------------------------------------------- /test/passing/tests/labelled_args-414.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = 2 | let f ~y = y + 1 in 3 | f ~(y : int) 4 | -------------------------------------------------------------------------------- /test/passing/tests/labelled_args.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | let f ~y = y + 1 in 3 | f ~y:(y : int) 4 | -------------------------------------------------------------------------------- /test/passing/tests/lazy.ml: -------------------------------------------------------------------------------- 1 | let (lazy a) = lazy 1 2 | 3 | let (lazy (a, b)) = lazy (1, 2) 4 | 5 | let () = 6 | let (lazy a) = lazy 1 in 7 | let (lazy (a, b)) = lazy (1, 2) in 8 | () 9 | 10 | let _ = lazy (a.b <- 1) 11 | 12 | let _ = match x with (lazy (Some _ as x)), x -> x 13 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding-in_indent.ml.opts: -------------------------------------------------------------------------------- 1 | --indent-after-in=4 2 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding-indent.ml.opts: -------------------------------------------------------------------------------- 1 | --let-binding-indent=6 2 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding_spacing-double-semicolon.ml.opts: -------------------------------------------------------------------------------- 1 | --let-binding-spacing=double-semicolon 2 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding_spacing-double-semicolon.ml.ref: -------------------------------------------------------------------------------- 1 | let f x = x 2 | 3 | and g x = x 4 | 5 | let f x = x 6 | 7 | and g : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = fun h a b -> h 8 | 9 | and g : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = 10 | fun h a b -> h (i a) (i b) (i c) 11 | ;; 12 | 13 | let f x = x 14 | 15 | let f : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = 16 | fun h a b -> h (i a) (i b) (i c) 17 | ;; 18 | 19 | let f x = x 20 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding_spacing-sparse.ml.opts: -------------------------------------------------------------------------------- 1 | --let-binding-spacing=sparse 2 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding_spacing-sparse.ml.ref: -------------------------------------------------------------------------------- 1 | let f x = x 2 | 3 | and g x = x 4 | 5 | let f x = x 6 | 7 | and g : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = fun h a b -> h 8 | 9 | and g : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = 10 | fun h a b -> h (i a) (i b) (i c) 11 | 12 | 13 | let f x = x 14 | 15 | let f : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = 16 | fun h a b -> h (i a) (i b) (i c) 17 | 18 | 19 | let f x = x 20 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding_spacing.ml: -------------------------------------------------------------------------------- 1 | let f x = x 2 | 3 | and g x = x 4 | 5 | let f x = x 6 | 7 | and g : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = fun h a b -> h 8 | 9 | and g : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = 10 | fun h a b -> h (i a) (i b) (i c) 11 | 12 | let f x = x 13 | 14 | let f : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = 15 | fun h a b -> h (i a) (i b) (i c) 16 | 17 | let f x = x 18 | -------------------------------------------------------------------------------- /test/passing/tests/let_binding_spacing.ml.opts: -------------------------------------------------------------------------------- 1 | --let-binding-spacing=compact 2 | -------------------------------------------------------------------------------- /test/passing/tests/let_in_constr.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | Some 3 | (let open! List in 4 | 1) 5 | -------------------------------------------------------------------------------- /test/passing/tests/let_module-sparse.ml.opts: -------------------------------------------------------------------------------- 1 | --let-module=sparse 2 | -------------------------------------------------------------------------------- /test/passing/tests/let_module-sparse.ml.ref: -------------------------------------------------------------------------------- 1 | let () = 2 | let module X = 3 | Map.Make (struct 4 | type t = t 5 | 6 | let compare = compare 7 | end) 8 | in 9 | foo 10 | 11 | let () = 12 | let module X = 13 | Map.Make (struct 14 | type t = t 15 | end) 16 | [@foo] 17 | in 18 | let module K = Foooooooooo in 19 | (* foooooo *) 20 | let module X = 21 | Map.Make (struct 22 | type t = t (* foooooooooo *) 23 | end) 24 | [@foo] 25 | in 26 | let module T = X [@foo] in 27 | let module X = 28 | Fooo (struct 29 | type t = t 30 | end) 31 | in 32 | foo 33 | 34 | let () = 35 | let module X = 36 | Map.Make 37 | (struct 38 | type t = t 39 | end) 40 | (* foooooooooooooo *) 41 | (struct 42 | type t = t 43 | 44 | type t = t 45 | 46 | type t = t 47 | 48 | type t = t 49 | end) 50 | (struct 51 | type t = t 52 | 53 | type t = t 54 | end) 55 | in 56 | foo 57 | 58 | let f () = 59 | let module (* comment *) 60 | M = struct end in 61 | () 62 | -------------------------------------------------------------------------------- /test/passing/tests/let_module.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | let module X = 3 | Map.Make (struct 4 | type t = t 5 | 6 | let compare = compare 7 | end) 8 | in 9 | foo 10 | 11 | let () = 12 | let module X = 13 | Map.Make (struct 14 | type t = t 15 | end) [@foo] 16 | in 17 | let module K = Foooooooooo in 18 | (* foooooo *) 19 | let module X = 20 | Map.Make (struct 21 | type t = t (* foooooooooo *) 22 | end) [@foo] 23 | in 24 | let module T = X [@foo] in 25 | let module X = 26 | Fooo (struct 27 | type t = t 28 | end) 29 | in 30 | foo 31 | 32 | let () = 33 | let module X = 34 | Map.Make (struct 35 | type t = t 36 | end) 37 | (* foooooooooooooo *) 38 | (struct 39 | type t = t 40 | type t = t 41 | type t = t 42 | type t = t 43 | end) 44 | (struct 45 | type t = t 46 | type t = t 47 | end) 48 | in 49 | foo 50 | 51 | let f () = 52 | let module (* comment *) 53 | M = struct end in 54 | () 55 | -------------------------------------------------------------------------------- /test/passing/tests/let_module.ml.opts: -------------------------------------------------------------------------------- 1 | --let-module=compact 2 | -------------------------------------------------------------------------------- /test/passing/tests/let_module.ml.ref: -------------------------------------------------------------------------------- 1 | let () = 2 | let module X = Map.Make (struct 3 | type t = t 4 | 5 | let compare = compare 6 | end) in 7 | foo 8 | 9 | let () = 10 | let module X = Map.Make (struct 11 | type t = t 12 | end) 13 | [@foo] in 14 | let module K = Foooooooooo in 15 | (* foooooo *) 16 | let module X = Map.Make (struct 17 | type t = t (* foooooooooo *) 18 | end) 19 | [@foo] in 20 | let module T = X [@foo] in 21 | let module X = Fooo (struct 22 | type t = t 23 | end) in 24 | foo 25 | 26 | let () = 27 | let module X = 28 | Map.Make 29 | (struct 30 | type t = t 31 | end) 32 | (* foooooooooooooo *) 33 | (struct 34 | type t = t 35 | 36 | type t = t 37 | 38 | type t = t 39 | 40 | type t = t 41 | end) 42 | (struct 43 | type t = t 44 | 45 | type t = t 46 | end) 47 | in 48 | foo 49 | 50 | let f () = 51 | let module (* comment *) 52 | M = struct end in 53 | () 54 | -------------------------------------------------------------------------------- /test/passing/tests/let_punning.ml: -------------------------------------------------------------------------------- 1 | let ( let* ) x f = f x 2 | 3 | let ( and* ) a b = (a, b) 4 | 5 | let x = 1 6 | 7 | and y = 2 8 | 9 | and z = 3 10 | 11 | let p = 12 | let* x and* y and* z in 13 | (x, y, z) 14 | 15 | let q = 16 | let%foo x and y and z in 17 | (x, y, z) 18 | -------------------------------------------------------------------------------- /test/passing/tests/list-space_around.ml.opts: -------------------------------------------------------------------------------- 1 | --space-around-arrays 2 | --space-around-lists 3 | --space-around-records 4 | --space-around-variants 5 | -------------------------------------------------------------------------------- /test/passing/tests/list_and_comments.ml: -------------------------------------------------------------------------------- 1 | [ 1; (* one *) 2 | 2; (* two *) ] 3 | -------------------------------------------------------------------------------- /test/passing/tests/list_and_comments.ml.ref: -------------------------------------------------------------------------------- 1 | [1; (* one *) 2 (* two *)] 2 | -------------------------------------------------------------------------------- /test/passing/tests/loc_stack.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | ( (* a *) ( (* b *) 2 )) 3 | 4 | let _ = ( 5 | (* before match *) 6 | match (* after match *) x with 7 | | _ -> 1 8 | ) 9 | 10 | let _ = ( 11 | (* before try *) 12 | try (* after try *) x with 13 | | _ -> 1 14 | ) 15 | 16 | let should_inline : Llvm.llvalue -> bool = 17 | fun llv -> 18 | match Llvm.use_begin llv with 19 | | Some use -> ( 20 | match Llvm.use_succ use with 21 | | Some _ -> ( 22 | (* If we are not in the default context, we can only use the OCAMLPATH 23 | variable if it is specific to this build context *) 24 | (* CR-someday diml: maybe we should actually clear OCAMLPATH in other 25 | build contexts *) 26 | match Llvm.classify_value llv with 27 | | Instruction 28 | ( Trunc | ZExt | SExt | FPToUI | FPToSI | UIToFP | SIToFP | FPTrunc 29 | | FPExt | PtrToInt | IntToPtr | BitCast | AddrSpaceCast ) -> 30 | true (* inline casts *) 31 | | _ -> false (* do not inline if >= 2 uses *) ) 32 | | None -> true ) 33 | | None -> true 34 | -------------------------------------------------------------------------------- /test/passing/tests/loc_stack.ml.opts: -------------------------------------------------------------------------------- 1 | -n 3 -------------------------------------------------------------------------------- /test/passing/tests/loc_stack.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = 2 | (* a *) 3 | (* b *) 4 | 2 5 | 6 | let _ = 7 | (* before match *) 8 | match (* after match *) x with _ -> 1 9 | 10 | let _ = 11 | (* before try *) 12 | try (* after try *) x with _ -> 1 13 | 14 | let should_inline : Llvm.llvalue -> bool = 15 | fun llv -> 16 | match Llvm.use_begin llv with 17 | | Some use -> ( 18 | match Llvm.use_succ use with 19 | | Some _ -> ( 20 | (* If we are not in the default context, we can only use the OCAMLPATH 21 | variable if it is specific to this build context *) 22 | (* CR-someday diml: maybe we should actually clear OCAMLPATH in other 23 | build contexts *) 24 | match Llvm.classify_value llv with 25 | | Instruction 26 | ( Trunc | ZExt | SExt | FPToUI | FPToSI | UIToFP | SIToFP | FPTrunc 27 | | FPExt | PtrToInt | IntToPtr | BitCast | AddrSpaceCast ) -> 28 | true (* inline casts *) 29 | | _ -> false (* do not inline if >= 2 uses *) ) 30 | | None -> true ) 31 | | None -> true 32 | -------------------------------------------------------------------------------- /test/passing/tests/locally_abtract_types.ml: -------------------------------------------------------------------------------- 1 | let f (type v) (x : v) = x 2 | 3 | let f (type v) (x : v) : unit = () 4 | 5 | let f : type s. s t -> s = function X x -> x | Y y -> y 6 | 7 | let x = (fun (type a) x -> x) () 8 | 9 | let x = (fun x (type a b c) x -> x) () 10 | 11 | let f = function T x -> (fun (type a) (x : a t) -> x) x 12 | -------------------------------------------------------------------------------- /test/passing/tests/margin_80.ml: -------------------------------------------------------------------------------- 1 | type t = 2 | ([ `foo 3 | | `bar (** 58 chars.................................................. *) ][@js.enum 4 | ]) 5 | let _ = 6 | aa 7 | (bbbbbbbbb cccccccccccc dddddddddddddddddddddddddddddddddddddddddddddddddddd) 8 | 9 | let _ = 10 | aa 11 | (bbbbbbbbb cccccccccccc dddddddddddddddddddddddddddddddddddddd [@dddddddddd]) 12 | 13 | let _ = 14 | aa 15 | (bbbbbbbbb cccccccccccc ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd 16 | [@dddddddddd]) 17 | 18 | let _ = 19 | aa 20 | (bbbbbbbbb cccccccccccc dddddddddddddddddddddddddddddddddddddd) [@dddddddddd] 21 | -------------------------------------------------------------------------------- /test/passing/tests/margin_80.ml.opts: -------------------------------------------------------------------------------- 1 | --margin=80 2 | -------------------------------------------------------------------------------- /test/passing/tests/margin_80.ml.ref: -------------------------------------------------------------------------------- 1 | type t = 2 | ([ `foo 3 | | `bar (** 58 chars.................................................. *) ] 4 | [@js.enum] ) 5 | 6 | let _ = 7 | aa 8 | (bbbbbbbbb cccccccccccc dddddddddddddddddddddddddddddddddddddddddddddddddddd) 9 | 10 | let _ = 11 | aa 12 | (bbbbbbbbb cccccccccccc dddddddddddddddddddddddddddddddddddddd [@dddddddddd]) 13 | 14 | let _ = 15 | aa 16 | (bbbbbbbbb cccccccccccc 17 | ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd 18 | [@dddddddddd] ) 19 | 20 | let _ = 21 | aa 22 | (bbbbbbbbb cccccccccccc dddddddddddddddddddddddddddddddddddddd) 23 | [@dddddddddd] 24 | -------------------------------------------------------------------------------- /test/passing/tests/match2.ml.opts: -------------------------------------------------------------------------------- 1 | --leading-nested-match-parens 2 | -------------------------------------------------------------------------------- /test/passing/tests/match_indent-never.ml.opts: -------------------------------------------------------------------------------- 1 | --match-indent=4 2 | --match-indent-nested=never 3 | -------------------------------------------------------------------------------- /test/passing/tests/match_indent-never.ml.ref: -------------------------------------------------------------------------------- 1 | match fooooooooooooooooooooooo with 2 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 3 | 4 | let foooooooo = 5 | match fooooooooooooooooooooooo with 6 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 7 | 8 | let foooooooo = 9 | try fooooooooooooooooooooooo with 10 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 11 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 12 | 13 | let fooooo = 14 | if foooooooo then 15 | match fooooooooooooooooooooooo with 16 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 17 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 18 | else foooooooo 19 | -------------------------------------------------------------------------------- /test/passing/tests/match_indent.ml: -------------------------------------------------------------------------------- 1 | ;; 2 | match fooooooooooooooooooooooo with 3 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 4 | 5 | let foooooooo = 6 | match fooooooooooooooooooooooo with 7 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 8 | 9 | let foooooooo = 10 | try fooooooooooooooooooooooo with 11 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 12 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 13 | 14 | let fooooo = 15 | if foooooooo then 16 | match fooooooooooooooooooooooo with 17 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 18 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 19 | else foooooooo 20 | -------------------------------------------------------------------------------- /test/passing/tests/match_indent.ml.opts: -------------------------------------------------------------------------------- 1 | --match-indent=4 2 | --match-indent-nested=always 3 | -------------------------------------------------------------------------------- /test/passing/tests/match_indent.ml.ref: -------------------------------------------------------------------------------- 1 | match fooooooooooooooooooooooo with 2 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 3 | 4 | let foooooooo = 5 | match fooooooooooooooooooooooo with 6 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 7 | 8 | let foooooooo = 9 | try fooooooooooooooooooooooo with 10 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 11 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 12 | 13 | let fooooo = 14 | if foooooooo then 15 | match fooooooooooooooooooooooo with 16 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 17 | | fooooooooooooooooooooooo -> foooooooooooooooooooooooooo 18 | else foooooooo 19 | -------------------------------------------------------------------------------- /test/passing/tests/max_indent.ml.opts: -------------------------------------------------------------------------------- 1 | --max-indent=2 2 | -------------------------------------------------------------------------------- /test/passing/tests/module_anonymous.ml: -------------------------------------------------------------------------------- 1 | module _ = struct 2 | let x = (13, 37) 3 | end 4 | 5 | module rec A : sig 6 | type t = B.t 7 | end = 8 | A 9 | 10 | and _ : sig 11 | type t = A.t 12 | 13 | val x : int * int 14 | end = struct 15 | type t = B.t 16 | 17 | let x = (4, 2) 18 | end 19 | 20 | and B : sig 21 | type t 22 | end = struct 23 | type t 24 | 25 | let x = ("foo", "bar") 26 | end 27 | 28 | module type S 29 | 30 | let f (module _ : S) = () 31 | -------------------------------------------------------------------------------- /test/passing/tests/module_item_spacing-preserve.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 2 | --module-item-spacing=preserve 3 | -------------------------------------------------------------------------------- /test/passing/tests/module_item_spacing-sparse.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 2 | --module-item-spacing=sparse 3 | -------------------------------------------------------------------------------- /test/passing/tests/module_item_spacing.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 2 | --module-item-spacing=compact 3 | -------------------------------------------------------------------------------- /test/passing/tests/module_item_spacing.mli.opts: -------------------------------------------------------------------------------- 1 | --max-iter=3 -------------------------------------------------------------------------------- /test/passing/tests/monadic_binding.ml: -------------------------------------------------------------------------------- 1 | let ( let* ) t f = fooooooo 2 | 3 | let ( and* ) t1 t2 = foooooo 4 | 5 | let map f t = 6 | let* a = t in 7 | pure (f a) 8 | 9 | let ( and+ ) t1 t2 = ( and* ) t1 t2 10 | 11 | let ( and+ ) t1 t2 = ( and* ) t1 t2 x 12 | 13 | let ( and+ ) t1 t2 = 14 | ( and* ) t1 t2 x foooooooooooooooooo foooooooooooooooooooo 15 | foooooooooooooooooo foooooooooooooooooo 16 | -------------------------------------------------------------------------------- /test/passing/tests/multi_index_op.ml: -------------------------------------------------------------------------------- 1 | let ( .%{;..} ) = Genarray.get 2 | 3 | let ( .%{;..}<- ) = Genarray.set 4 | 5 | let () = 6 | let x = Genarray.create Float64 c_layout [|3; 4; 5|] in 7 | x.%{0; 0; 0} <- 3. ; 8 | Printf.printf "%f\n" x.%{0; 0; 0} 9 | 10 | (** With path *) 11 | 12 | let _ = a.A.B.*(b; c) 13 | 14 | let _ = a.A.B.*(b; c) <- d 15 | -------------------------------------------------------------------------------- /test/passing/tests/named_existentials.ml: -------------------------------------------------------------------------------- 1 | let ok1 = function Dyn (type a) ((w, x) : a ty * a) -> ignore (x : a) 2 | 3 | let ok2 = function Dyn (type a) ((w, x) : _ * a) -> ignore (x : a) 4 | 5 | type u = C : 'a * ('a -> 'b list) -> u 6 | 7 | let f = function C (type a b) ((x, f) : _ * (a -> b list)) -> ignore (x : a) 8 | 9 | (* with GADT unification *) 10 | type _ expr = 11 | | Int : int -> int expr 12 | | Add : (int -> int -> int) expr 13 | | App : ('a -> 'b) expr * 'a expr -> 'b expr 14 | 15 | let rec eval : type t. t expr -> t = function 16 | | Int n -> n 17 | | Add -> ( + ) 18 | | App (type a) ((f, x) : _ * a expr) -> eval f (eval x : a) 19 | 20 | (* Also allow annotations on multiary constructors *) 21 | type ('a, 'b) pair = Pair of 'a * 'b 22 | 23 | let f = function Pair ((x, y) : int * _) -> x + y 24 | -------------------------------------------------------------------------------- /test/passing/tests/need_format.ml: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/passing/tests/need_format.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iters=1 -------------------------------------------------------------------------------- /test/passing/tests/need_format.ml.ref: -------------------------------------------------------------------------------- 1 | ocamlformat: "tests/need_format.ml" was not already formatted. ([max-iters = 1]) 2 | -------------------------------------------------------------------------------- /test/passing/tests/need_format.ml.should-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/need_format.ml.should-fail -------------------------------------------------------------------------------- /test/passing/tests/new.ml: -------------------------------------------------------------------------------- 1 | let x = new Objects.one ~hello:true () 2 | 3 | let _ = sprintf "Date: %s" (Js.to_string (new%js Js.date_now)##toString) 4 | 5 | let _ = f (new test) a b 6 | 7 | let _ = f (new test x) a b 8 | 9 | let _ = f (new test (new test a b) c) a b 10 | 11 | let _ = f (new%js test) a b 12 | 13 | let _ = f (new%js test x) a b 14 | 15 | let _ = f (new%js test (new%js test a b) c) a b 16 | -------------------------------------------------------------------------------- /test/passing/tests/object2.ml: -------------------------------------------------------------------------------- 1 | let x = 2 | object 3 | inherit foo 4 | method bar = _ 5 | end 6 | 7 | class foo = 8 | object 9 | method x = 2 10 | inherit bar 11 | end 12 | 13 | class foo = 14 | object(this) 15 | inherit bar 16 | end 17 | 18 | class virtual map = object 19 | method visit_expr_node : 20 | 'env 'info_0 'info_1 . 21 | ('env -> 'info_0 -> 'info_1) -> 22 | 'env -> 'info_0 expr_node -> 'info_1 expr_node = 23 | assert false 24 | end 25 | -------------------------------------------------------------------------------- /test/passing/tests/object2.ml.ref: -------------------------------------------------------------------------------- 1 | let x = 2 | object 3 | inherit foo 4 | 5 | method bar = _ 6 | end 7 | 8 | class foo = 9 | object 10 | method x = 2 11 | 12 | inherit bar 13 | end 14 | 15 | class foo = 16 | object (this) 17 | inherit bar 18 | end 19 | 20 | class virtual map = 21 | object 22 | method visit_expr_node 23 | : 'env 'info_0 'info_1. 24 | ('env -> 'info_0 -> 'info_1) 25 | -> 'env 26 | -> 'info_0 expr_node 27 | -> 'info_1 expr_node = 28 | assert false 29 | end 30 | -------------------------------------------------------------------------------- /test/passing/tests/obuild.ml: -------------------------------------------------------------------------------- 1 | type predicate = 2 | Pred_Byte 3 | | Pred_Native 4 | | Pred_Toploop 5 | 6 | let _ = 7 | { pkg with 8 | package_version = projFile.version 9 | ; package_description = _ 10 | ; package_requires = [] } 11 | -------------------------------------------------------------------------------- /test/passing/tests/obuild.ml.ref: -------------------------------------------------------------------------------- 1 | type predicate = Pred_Byte | Pred_Native | Pred_Toploop 2 | 3 | let _ = 4 | { pkg with 5 | package_version= projFile.version 6 | ; package_description= _ 7 | ; package_requires= [] } 8 | -------------------------------------------------------------------------------- /test/passing/tests/ocp_indent_options.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | let f x y = 3 | match x with 4 | | None -> false 5 | | Some loooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 6 | -> ( match y with Some _ -> true | None -> false ) 7 | in 8 | () 9 | -------------------------------------------------------------------------------- /test/passing/tests/ocp_indent_options.ml.opts: -------------------------------------------------------------------------------- 1 | --ocp-indent-config 2 | -------------------------------------------------------------------------------- /test/passing/tests/ocp_indent_options.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = 2 | let f x y = 3 | match x with 4 | | None -> false 5 | | Some loooooooooooooooooooooooooooooooooooooooooooooooooooooooooong -> ( 6 | match y with Some _ -> true | None -> false ) 7 | in 8 | () 9 | -------------------------------------------------------------------------------- /test/passing/tests/open-closing-on-separate-line.ml.opts: -------------------------------------------------------------------------------- 1 | --indicate-multiline-delimiters=closing-on-separate-line 2 | -------------------------------------------------------------------------------- /test/passing/tests/open_types.ml: -------------------------------------------------------------------------------- 1 | type t = .. 2 | 3 | type sub_system = t = .. 4 | -------------------------------------------------------------------------------- /test/passing/tests/override.ml: -------------------------------------------------------------------------------- 1 | let _ = {< x = (x : t) >} 2 | 3 | let _ = {< x = (x[@a] : t [@b]) [@c] >} 4 | 5 | let _ = {< x = x >} 6 | 7 | let _ = {< x = x [@a] >} 8 | 9 | let _ = {< x >} 10 | -------------------------------------------------------------------------------- /test/passing/tests/override.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = {} 2 | 3 | let _ = {} 4 | 5 | let _ = {} 6 | 7 | let _ = {} 8 | 9 | let _ = {} 10 | -------------------------------------------------------------------------------- /test/passing/tests/parens_tuple_patterns.ml: -------------------------------------------------------------------------------- 1 | let a, b = (1, 2) 2 | 3 | let[@ocamlformat "parens-tuple-patterns=always"] (a, b) = (1, 2) 4 | 5 | let[@ocamlformat "parens-tuple-patterns=always"] M.(a, b) = () 6 | 7 | let[@ocamlformat "parens-tuple-patterns=multi-line-only"] a, b = (1, 2) 8 | 9 | let[@ocamlformat "parens-tuple-patterns=multi-line-only"] M.(a, b) = () 10 | -------------------------------------------------------------------------------- /test/passing/tests/partial.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | ffff; 3 | hhhhhh; 4 | fff; 5 | let (quot, _rem) = 6 | let quot_rem n k = 7 | let (d, m) = (n / k, n mod k) in 8 | if d < 0 && m > 0 then (d+1, m-k) 9 | else (d, m) 10 | in 11 | let quot n k = fst (quot_rem n k) in 12 | let rem n k = snd (quot_rem n k) in 13 | 14 | quot, rem 15 | -------------------------------------------------------------------------------- /test/passing/tests/partial.ml.opts: -------------------------------------------------------------------------------- 1 | --numeric=2-14 2 | -------------------------------------------------------------------------------- /test/passing/tests/partial.ml.ref: -------------------------------------------------------------------------------- 1 | 5 2 | 5 3 | 5 4 | 5 5 | 7 6 | 9 7 | 9 8 | 9 9 | 7 10 | 7 11 | 7 12 | 0 13 | 7 14 | -------------------------------------------------------------------------------- /test/passing/tests/partial_double_quotes.ml: -------------------------------------------------------------------------------- 1 | let x = "123" + 2 | -------------------------------------------------------------------------------- /test/passing/tests/partial_double_quotes.ml.opts: -------------------------------------------------------------------------------- 1 | --numeric=1-1 2 | -------------------------------------------------------------------------------- /test/passing/tests/partial_double_quotes.ml.ref: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/passing/tests/polytypes-default.ml.opts: -------------------------------------------------------------------------------- 1 | --profile=default 2 | -------------------------------------------------------------------------------- /test/passing/tests/polytypes-default.ml.ref: -------------------------------------------------------------------------------- 1 | let t1 : 'a 'b. 'a t -> b t = () 2 | 3 | let t2 : 4 | 'a 'b. 5 | 'a t________________________________ -> 6 | 'b t_______________________________________ = 7 | () 8 | 9 | let t3 : 10 | 'long 'sequence 'of_ 'universally 'quantified 'type_ 'variables 'that 11 | 'must 'wrap. 12 | 'a t_________________________________________________ -> 13 | 'b t______________________________________________________________ -> 14 | 'c t______________________________________________________________ = 15 | () 16 | 17 | let t4 : 18 | 'long 'sequence 'of_ 'universally 'quantified 'type_ 'variables 'that 19 | 'must 'wrap. 20 | 'a t_________________________________________________ 21 | * 'b t______________________________________________________________ 22 | * 'c t______________________________________________________________ = 23 | () 24 | 25 | let foo : type a. a = 26 | (* aaaaaa *) 27 | failwith "foo" 28 | -------------------------------------------------------------------------------- /test/passing/tests/polytypes-janestreet.ml.opts: -------------------------------------------------------------------------------- 1 | --profile=janestreet 2 | -------------------------------------------------------------------------------- /test/passing/tests/polytypes-janestreet.ml.ref: -------------------------------------------------------------------------------- 1 | let t1 : 'a 'b. 'a t -> b t = () 2 | 3 | let t2 : 4 | 'a 'b. 5 | 'a t________________________________ -> 'b t_______________________________________ 6 | = 7 | () 8 | ;; 9 | 10 | let t3 : 11 | 'long 'sequence 'of_ 'universally 'quantified 'type_ 'variables 'that 'must 'wrap. 12 | 'a t_________________________________________________ 13 | -> 'b t______________________________________________________________ 14 | -> 'c t______________________________________________________________ 15 | = 16 | () 17 | ;; 18 | 19 | let t4 : 20 | 'long 'sequence 'of_ 'universally 'quantified 'type_ 'variables 'that 'must 'wrap. 21 | 'a t_________________________________________________ 22 | * 'b t______________________________________________________________ 23 | * 'c t______________________________________________________________ 24 | = 25 | () 26 | ;; 27 | 28 | let foo : type a. a = 29 | (* aaaaaa *) 30 | failwith "foo" 31 | ;; 32 | -------------------------------------------------------------------------------- /test/passing/tests/polytypes.ml: -------------------------------------------------------------------------------- 1 | let t1 : 'a 'b. 'a t -> b t = () 2 | 3 | let t2 : 4 | 'a 'b. 5 | 'a t________________________________ 6 | -> 'b t_______________________________________ = 7 | () 8 | 9 | let t3 : 10 | 'long 'sequence 'of_ 'universally 'quantified 'type_ 'variables 'that 11 | 'must 'wrap. 12 | 'a t_________________________________________________ 13 | -> 'b t______________________________________________________________ 14 | -> 'c t______________________________________________________________ = 15 | () 16 | 17 | let t4 : 18 | 'long 'sequence 'of_ 'universally 'quantified 'type_ 'variables 'that 19 | 'must 'wrap. 20 | 'a t_________________________________________________ 21 | * 'b t______________________________________________________________ 22 | * 'c t______________________________________________________________ = 23 | () 24 | 25 | let foo : type a. a = 26 | (* aaaaaa *) 27 | failwith "foo" 28 | -------------------------------------------------------------------------------- /test/passing/tests/pre_post_extensions.ml: -------------------------------------------------------------------------------- 1 | let f x = 2 | [%Trace.call fun {pf} -> pf "%i" x] 3 | ; 4 | print_int x ; 5 | x 6 | |> 7 | [%Trace.retn fun {pf} -> pf "%i"] 8 | 9 | let f x = 10 | [%Trace.call fun {pf} : t -> pf "%i" x] 11 | ; 12 | print_int x ; 13 | x 14 | |> 15 | [%Trace.retn fun {pf} : t -> pf "%i"] 16 | -------------------------------------------------------------------------------- /test/passing/tests/precedence.ml: -------------------------------------------------------------------------------- 1 | a || (b && c);; 2 | 3 | 1 + (3 * 5);; 4 | 5 | 1 < 3 || b 6 | -------------------------------------------------------------------------------- /test/passing/tests/prefix_infix.ml: -------------------------------------------------------------------------------- 1 | let _ = List.filter (( != ) e) l 2 | 3 | let _ = List.map (( != ) x) l 4 | 5 | let _ = x != y 6 | 7 | let _ = - !e 8 | 9 | let _ = - !e.f 10 | -------------------------------------------------------------------------------- /test/passing/tests/print_config.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/print_config.ml -------------------------------------------------------------------------------- /test/passing/tests/print_config.ml.deps: -------------------------------------------------------------------------------- 1 | tests/dir1/dir2/.ocamlformat 2 | tests/dir1/dir2/print_config.ml 3 | -------------------------------------------------------------------------------- /test/passing/tests/print_config.ml.enabled-if: -------------------------------------------------------------------------------- 1 | (<> %{os_type} Win32) 2 | -------------------------------------------------------------------------------- /test/passing/tests/print_config.ml.opts: -------------------------------------------------------------------------------- 1 | %{dep:tests/dir1/dir2/print_config.ml} 2 | --print-config 3 | --config=max-iters=2 4 | -------------------------------------------------------------------------------- /test/passing/tests/profiles.ml: -------------------------------------------------------------------------------- 1 | let a = aaaaaaaaaa aaaaaaaaa 2 | 3 | let b = bbbbbbbbbb bbbbbbbbb 4 | -------------------------------------------------------------------------------- /test/passing/tests/profiles.ml.opts: -------------------------------------------------------------------------------- 1 | --config=margin=20 2 | --profile=janestreet 3 | --module-item-spacing=sparse 4 | -------------------------------------------------------------------------------- /test/passing/tests/profiles2.ml: -------------------------------------------------------------------------------- 1 | let a = aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa 2 | let b = bbbbbbbbbbbbbbbbbbvvbbb bbbvvvbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbb 3 | -------------------------------------------------------------------------------- /test/passing/tests/profiles2.ml.opts: -------------------------------------------------------------------------------- 1 | --profile=janestreet 2 | -------------------------------------------------------------------------------- /test/passing/tests/recmod.mli: -------------------------------------------------------------------------------- 1 | module rec A : sig 2 | type t = AA of B.t 3 | end 4 | 5 | and B : sig 6 | type t = BB of A.t 7 | end 8 | 9 | include sig 10 | (* a *) 11 | end 12 | -------------------------------------------------------------------------------- /test/passing/tests/record-loose.ml.opts: -------------------------------------------------------------------------------- 1 | --field-space=loose 2 | -------------------------------------------------------------------------------- /test/passing/tests/record-tight_decl.ml.opts: -------------------------------------------------------------------------------- 1 | --field-space=tight-decl 2 | -------------------------------------------------------------------------------- /test/passing/tests/record.ml.opts: -------------------------------------------------------------------------------- 1 | --field-space=tight 2 | -------------------------------------------------------------------------------- /test/passing/tests/record_punning.ml: -------------------------------------------------------------------------------- 1 | [%sexp {x: int; y: string}] 2 | 3 | let _ = fun {x: int; y: string} -> () 4 | 5 | let _ = {A.b= A.b} 6 | 7 | let {A.b} = x 8 | 9 | let _ = 10 | object 11 | method x = {} 12 | end 13 | -------------------------------------------------------------------------------- /test/passing/tests/reformat_string.ml: -------------------------------------------------------------------------------- 1 | let _ = ('a') 2 | 3 | let _ = ( 'a' ) 4 | 5 | let _ = ((* test *)"asd" ) 6 | 7 | let _ = ( "asd" ) 8 | 9 | let _ = begin (* te""st *) "asd"end 10 | 11 | let _ = begin "asd" end 12 | 13 | let _ = ('a') 14 | 15 | let _ = ( 'a' ) 16 | 17 | let _ = function ('a' .. 'z') -> () 18 | 19 | 20 | let _ = "aaa\n 21 | e" 22 | -------------------------------------------------------------------------------- /test/passing/tests/reformat_string.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iter=2 2 | -------------------------------------------------------------------------------- /test/passing/tests/reformat_string.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = 'a' 2 | 3 | let _ = 'a' 4 | 5 | let _ = (* test *) "asd" 6 | 7 | let _ = "asd" 8 | 9 | let _ = (* te""st *) "asd" 10 | 11 | let _ = "asd" 12 | 13 | let _ = 'a' 14 | 15 | let _ = 'a' 16 | 17 | let _ = function 'a' .. 'z' -> () 18 | 19 | let _ = "aaa\n\n e" 20 | -------------------------------------------------------------------------------- /test/passing/tests/refs.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | x := 2 ; 3 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx := 4 | 2 ; 5 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx := 6 | something very 7 | looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong ; 8 | xxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxxx xxxxxxxxx xxxxxxxxxxxxx xxxxxxxxxx 9 | xxxxxxxxxxxxx 10 | := something very 11 | looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong ; 12 | xx := 13 | something very 14 | loooooooooooooooooooooooooooooooooooooooooooooooooooooooong ; 15 | if something loooooooooooong then 16 | xx := 17 | something very 18 | loooooooooooooooooooooooooooooooooooooooooooooooooooooooong 19 | ;; 20 | 21 | if row <> row' && col <> col' then 22 | b.(row').(col') <- remove b.(row').(col') value 23 | -------------------------------------------------------------------------------- /test/passing/tests/remove_extra_parens.ml: -------------------------------------------------------------------------------- 1 | let f = function [({xxxxxx}); ({yyyyyyyy})] -> () 2 | -------------------------------------------------------------------------------- /test/passing/tests/remove_extra_parens.ml.ref: -------------------------------------------------------------------------------- 1 | let f = function [{xxxxxx}; {yyyyyyyy}] -> () 2 | -------------------------------------------------------------------------------- /test/passing/tests/revapply_ext.ml: -------------------------------------------------------------------------------- 1 | let _ = () 2 | (* one *) 3 | |> 4 | [%ext fun _ -> ()] 5 | 6 | let _ = () 7 | |> 8 | [%ext fun _ -> ()] 9 | -------------------------------------------------------------------------------- /test/passing/tests/send.ml: -------------------------------------------------------------------------------- 1 | let x obj = obj#hello () 2 | 3 | let x obj_f = (obj_f ())#hello () 4 | 5 | let f obj = obj#hello_some_pretty_long_one ~with_labels:true () 6 | 7 | let f obj = 8 | obj#hello_some_pretty_long_one ~with_labels:true "desjd\ndijsde\n" 9 | {md| 10 | In **markdown** 11 | |md} 12 | -------------------------------------------------------------------------------- /test/passing/tests/sequence-preserve.ml.opts: -------------------------------------------------------------------------------- 1 | --sequence-blank-line=preserve-one --max-iter=3 2 | -------------------------------------------------------------------------------- /test/passing/tests/sequence.ml.opts: -------------------------------------------------------------------------------- 1 | --sequence-blank-line=compact --max-iter=3 2 | -------------------------------------------------------------------------------- /test/passing/tests/shebang.ml: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ocaml 2 | 3 | type t = {a: a; b: b} 4 | 5 | let f x = x 6 | -------------------------------------------------------------------------------- /test/passing/tests/sig_value.mli: -------------------------------------------------------------------------------- 1 | val f : f:(string[@att]) (** doc *) -> unit 2 | val f : f:(string[@att]) (** doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc *) -> unit 3 | val f : f:(string[@att]) -> unit 4 | val f : f:string (** doc *) -> unit 5 | 6 | val f : f:((string * string)[@att]) (** doc *) -> unit 7 | val f : f:((string * string)[@att]) (** doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc *) -> unit 8 | val f : f:((string * string)[@att]) -> unit 9 | val f : f:((string * string)) (** doc *) -> unit 10 | -------------------------------------------------------------------------------- /test/passing/tests/sig_value.mli.ref: -------------------------------------------------------------------------------- 1 | val f : f:(string[@att]) (** doc *) -> unit 2 | 3 | val f : 4 | f:(string[@att]) 5 | (** doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc 6 | doc doc doc doc doc doc doc *) 7 | -> unit 8 | 9 | val f : f:(string[@att]) -> unit 10 | 11 | val f : f:string (** doc *) -> unit 12 | 13 | val f : f:(string * string[@att]) (** doc *) -> unit 14 | 15 | val f : 16 | f:(string * string[@att]) 17 | (** doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc doc 18 | doc doc doc doc doc doc doc *) 19 | -> unit 20 | 21 | val f : f:(string * string[@att]) -> unit 22 | 23 | val f : f:string * string (** doc *) -> unit 24 | -------------------------------------------------------------------------------- /test/passing/tests/single_line.mli: -------------------------------------------------------------------------------- 1 | [@@@ocamlformat "module-item-spacing=compact"] 2 | 3 | val xx_xxxxxxxx : t -> bool 4 | val xx_xxxxxxxx : t -> bool 5 | val xxxxxxxx : t -> [> `Xxxxxxx | `Xxxxxxxxxxx | `Xxxxxxxxxx | `Xxxxxxxxxxxxx] 6 | val xxxxx : t -> t -> t Xxx.t option 7 | -------------------------------------------------------------------------------- /test/passing/tests/source.ml.opts: -------------------------------------------------------------------------------- 1 | --max-iters=3 -------------------------------------------------------------------------------- /test/passing/tests/string.ml: -------------------------------------------------------------------------------- 1 | let f = function 2 | | () -> 3 | raise_s 4 | [%sexp 5 | "Xxxx \036 \036 \036 \036 \036 \036 \036 xxx xxxx xx xxxxxx xx \ 6 | xxx xxxxxxx xxxxxx, xxxxxxx xxxxxxxxxx xx xxxx. Xxxx." 7 | , 0] 8 | 9 | let _ = "\010\xFFa\o123\n\ 10 | \\\u{12345}aa🐪🐪🐪🐪🐪\n" 11 | 12 | let _ = 13 | "aaaaaaaaaaaaaaaaaaaaaaaaa\n \ 14 | bbbbbbbbbbbbbbbbbbbbbbbbbb\n \ 15 | cccccccccccccccccc\n \ 16 | " 17 | 18 | let _ = 19 | "aaaaaaaaaaaaaaaaaaaaaaaaa\n \ 20 | bbbbbbbbbbbbbbbbbbbbbbbbbb\n \ 21 | cccccccccccccccccc\n \ 22 | " 23 | 24 | let _ = ('\xff', '\255', '\n') 25 | 26 | let f = function '\xff'..'\255' -> () 27 | 28 | 29 | let f ("test" [@test "test"]) = 2 30 | 31 | ;; 32 | "@\n \ 33 | xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxxx" 34 | 35 | external%c print: str:string -> d:int -> void = {| 36 | printf("%s (%d)\n",$str,$d); 37 | fflush(stdout); 38 | |} {| 39 | printf("%s (%d)\n",$str,$d); 40 | fflush(stdout); 41 | |} 42 | -------------------------------------------------------------------------------- /test/passing/tests/string.ml.ref: -------------------------------------------------------------------------------- 1 | let f = function 2 | | () -> 3 | raise_s 4 | [%sexp 5 | "Xxxx \036 \036 \036 \036 \036 \036 \036 xxx xxxx xx xxxxxx xx \ 6 | xxx xxxxxxx xxxxxx, xxxxxxx xxxxxxxxxx xx xxxx. Xxxx." 7 | , 0] 8 | 9 | let _ = "\010\xFFa\o123\n\\\u{12345}aa🐪🐪🐪🐪🐪\n" 10 | 11 | let _ = 12 | "aaaaaaaaaaaaaaaaaaaaaaaaa\n\ 13 | \tbbbbbbbbbbbbbbbbbbbbbbbbbb\n\ 14 | \tcccccccccccccccccc\n\ 15 | \t" 16 | 17 | let _ = 18 | "aaaaaaaaaaaaaaaaaaaaaaaaa\n\ 19 | \ bbbbbbbbbbbbbbbbbbbbbbbbbb\n\ 20 | \ cccccccccccccccccc\n\ 21 | \ " 22 | 23 | let _ = ('\xff', '\255', '\n') 24 | 25 | let f = function '\xff' .. '\255' -> () 26 | 27 | let f ("test" [@test "test"]) = 2;; 28 | 29 | "@\n\ 30 | \ xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx \ 31 | xxxxxxxx xxxxxxxxxxx" 32 | 33 | external%c print : str:string -> d:int -> void 34 | = {| 35 | printf("%s (%d)\n",$str,$d); 36 | fflush(stdout); 37 | |} {| 38 | printf("%s (%d)\n",$str,$d); 39 | fflush(stdout); 40 | |} 41 | -------------------------------------------------------------------------------- /test/passing/tests/string_array.ml: -------------------------------------------------------------------------------- 1 | (f ()).(2) <- e;; 2 | 3 | (f ()).(2) <- (e, 2);; 4 | 5 | ((f ()).(2) <- e), 2;; 6 | 7 | (f ()).[2] <- e;; 8 | 9 | (f ()).[2] <- (e, 2);; 10 | 11 | ((f ()).[2] <- e), 2;; 12 | 13 | (f ()).{2} <- e;; 14 | 15 | (f ()).{2} <- (e, 2);; 16 | 17 | ((f ()).{2} <- e), 2;; 18 | 19 | (f ()).{2, 2, 2, 2} <- e;; 20 | 21 | (f ()).{2, 2, 2, 2} <- (e, 2);; 22 | 23 | ((f ()).{2, 2, 2, 2} <- e), 2 24 | 25 | let l = [|(fun x -> x); (fun y -> y)|] 26 | -------------------------------------------------------------------------------- /test/passing/tests/string_wrapping.ml: -------------------------------------------------------------------------------- 1 | let universal_declaration = 2 | "-1- Programs are born and remain free and equal under the law;\n\ 3 | distinctions can only be based on the common good." 4 | -------------------------------------------------------------------------------- /test/passing/tests/symbol.ml: -------------------------------------------------------------------------------- 1 | let op = if b then ( * ) else ( + ) in 2 | () 3 | ;; 4 | 5 | assert ( * );; 6 | 7 | ( * ) [@a];; 8 | 9 | assert ( ( * ) [@a] ) 10 | -------------------------------------------------------------------------------- /test/passing/tests/try_with_or_pattern.ml: -------------------------------------------------------------------------------- 1 | let[@ocamlformat "break-cases=all"] _ = 2 | try () with 3 | | End_of_file 4 | |Not_found -> 5 | () 6 | -------------------------------------------------------------------------------- /test/passing/tests/tuple.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | match w with 3 | | A -> ([], A.(B (C (f x))), None, f x y, g y x) 4 | | B -> (a, b, c, d, e, f) 5 | | C -> 6 | ( [] 7 | , A.(B (C (this is very looooooooooooooooooooooooooooooooooooong x))) 8 | , None 9 | , f x y 10 | , g y x ) 11 | 12 | let _ = [%ext 1, 2, 3] 13 | 14 | let _ = 15 | [%ext 16 | loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 17 | , 2 18 | , 3] 19 | 20 | type t = int [@@deriving 1, 2, 3] 21 | 22 | type t = int 23 | [@@deriving 24 | sexp 25 | , compare 26 | , loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong] 27 | 28 | let _ = 29 | ( 1 30 | , 2 31 | , 3 32 | , looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 33 | ) 34 | 35 | let _ = (1, 2, 3, short);; 36 | 37 | 1 38 | , 2 39 | , 3 40 | , looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 41 | ;; 42 | 43 | 1, 2, 3, short 44 | 45 | let (a, b) : int * int = 46 | let (a, b) : int * int = (1, 2) in 47 | (a, b) 48 | -------------------------------------------------------------------------------- /test/passing/tests/tuple.ml.opts: -------------------------------------------------------------------------------- 1 | --parens-tuple=always 2 | -------------------------------------------------------------------------------- /test/passing/tests/tuple_less_parens.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | match w with 3 | | A -> [], A.(B (C (f x))), None, f x y, g y x 4 | | B -> a, b, c, d, e, f 5 | | C -> 6 | ( [] 7 | , A.(B (C (this is very looooooooooooooooooooooooooooooooooooong x))) 8 | , None 9 | , f x y 10 | , g y x ) 11 | 12 | let _ = [%ext 1, 2, 3] 13 | 14 | let _ = 15 | [%ext 16 | loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 17 | , 2 18 | , 3] 19 | 20 | type t = int [@@deriving 1, 2, 3] 21 | 22 | type t = int 23 | [@@deriving 24 | sexp 25 | , compare 26 | , loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong] 27 | 28 | let _ = 29 | ( 1 30 | , 2 31 | , 3 32 | , looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 33 | ) 34 | 35 | let _ = 1, 2, 3, short;; 36 | 37 | 1 38 | , 2 39 | , 3 40 | , looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong 41 | ;; 42 | 43 | 1, 2, 3, short 44 | 45 | (* make sure to not drop parens for local open. *) 46 | let _ = A.(1, 2) 47 | -------------------------------------------------------------------------------- /test/passing/tests/tuple_less_parens.ml.opts: -------------------------------------------------------------------------------- 1 | --parens-tuple=multi-line-only 2 | -------------------------------------------------------------------------------- /test/passing/tests/tuple_type_parens.ml: -------------------------------------------------------------------------------- 1 | type t = A of a * (b -> unit) 2 | 3 | type u = B of c 4 | 5 | and v = d * e 6 | -------------------------------------------------------------------------------- /test/passing/tests/type_and_constraint.ml: -------------------------------------------------------------------------------- 1 | type 'a t = 'a list constraint 'a = [< `X] 2 | -------------------------------------------------------------------------------- /test/passing/tests/type_annotations.ml: -------------------------------------------------------------------------------- 1 | let f = match None with (_ : int option) -> true 2 | 3 | let f (x : int) : int = e 4 | 5 | let f (x as y : int) : int = e 6 | 7 | let f ((x : int) as y) : int = e 8 | 9 | let f ((x : int) : int) = e 10 | 11 | let _ = match x with exception (e : exn) -> true | _ -> false 12 | 13 | let x = (0 : int :> int) 14 | -------------------------------------------------------------------------------- /test/passing/tests/types-compact-space_around-docked.ml.opts: -------------------------------------------------------------------------------- 1 | --type-decl=compact 2 | --space-around-arrays 3 | --space-around-lists 4 | --space-around-records 5 | --space-around-variants 6 | --break-separators=after 7 | --dock-collection-brackets 8 | -------------------------------------------------------------------------------- /test/passing/tests/types-compact-space_around.ml.opts: -------------------------------------------------------------------------------- 1 | --type-decl=compact 2 | --space-around-arrays 3 | --space-around-lists 4 | --space-around-records 5 | --space-around-variants 6 | -------------------------------------------------------------------------------- /test/passing/tests/types-compact.ml.opts: -------------------------------------------------------------------------------- 1 | --type-decl=compact 2 | -------------------------------------------------------------------------------- /test/passing/tests/types-indent.ml.opts: -------------------------------------------------------------------------------- 1 | --type-decl-indent=6 2 | -------------------------------------------------------------------------------- /test/passing/tests/types-sparse-space_around.ml.opts: -------------------------------------------------------------------------------- 1 | --type-decl=sparse 2 | --space-around-arrays 3 | --space-around-lists 4 | --space-around-records 5 | --space-around-variants 6 | -------------------------------------------------------------------------------- /test/passing/tests/types-sparse.ml.opts: -------------------------------------------------------------------------------- 1 | --type-decl=sparse 2 | -------------------------------------------------------------------------------- /test/passing/tests/unary.ml: -------------------------------------------------------------------------------- 1 | let _ = ~+2 2 | 3 | let _ = + 2 4 | 5 | let _ = + ~-3 6 | 7 | let _ = -3 8 | 9 | let _ = ~+.2 10 | 11 | let _ = +.2 12 | 13 | let _ = ~-.3 14 | 15 | let _ = ~-3. 16 | 17 | let _ = ~-(f x y) 18 | 19 | let _ = -(f x y) 20 | let _ = -f x y 21 | 22 | let x = - !p 23 | 24 | let x = - (!p) 25 | 26 | let y = -r.f 27 | 28 | let y = -(r.f) 29 | 30 | let x = ~- (!p) 31 | let x = ~- !p 32 | 33 | let y = ~-r.f 34 | let y = (~-r).f 35 | 36 | let _ = +f x 37 | 38 | and _ = -f x 39 | let _ = +(f x) 40 | 41 | and _ = -(f x) 42 | 43 | let _ = +.f x 44 | 45 | and _ = -.f x 46 | 47 | let _ = +.(f x) 48 | 49 | and _ = -.(f x) 50 | 51 | let _ = ~-(f r.x) 52 | 53 | let _ = -(!array_ref.(0)) 54 | -------------------------------------------------------------------------------- /test/passing/tests/unary.ml.ref: -------------------------------------------------------------------------------- 1 | let _ = ~+2 2 | 3 | let _ = 2 4 | 5 | let _ = + ~-3 6 | 7 | let _ = -3 8 | 9 | let _ = ~+.2 10 | 11 | let _ = +.2 12 | 13 | let _ = ~-.3 14 | 15 | let _ = ~-3. 16 | 17 | let _ = ~-(f x y) 18 | 19 | let _ = -f x y 20 | 21 | let _ = -f x y 22 | 23 | let x = - !p 24 | 25 | let x = - !p 26 | 27 | let y = -r.f 28 | 29 | let y = -r.f 30 | 31 | let x = ~- (!p) 32 | 33 | let x = ~- (!p) 34 | 35 | let y = ~-r.f 36 | 37 | let y = ~-r.f 38 | 39 | let _ = +f x 40 | 41 | and _ = -f x 42 | 43 | let _ = +f x 44 | 45 | and _ = -f x 46 | 47 | let _ = +.f x 48 | 49 | and _ = -.f x 50 | 51 | let _ = +.f x 52 | 53 | and _ = -.f x 54 | 55 | let _ = ~-(f r.x) 56 | 57 | let _ = -(!array_ref.(0)) 58 | -------------------------------------------------------------------------------- /test/passing/tests/unary_hash.ml: -------------------------------------------------------------------------------- 1 | let f o x = o##x 2 | 3 | let f x = !#x 4 | 5 | let f x = ?#x 6 | 7 | let f x = ~#x 8 | 9 | let f o x = o#-#x 10 | 11 | let f x = !-#x 12 | 13 | let f x = ?-#x 14 | 15 | let f x = ~-#x 16 | 17 | let f x = ?#(x - y) 18 | 19 | let f x = x + ?#(x + y) 20 | -------------------------------------------------------------------------------- /test/passing/tests/unicode.ml: -------------------------------------------------------------------------------- 1 | (* Don't edit this file with an editor that perform unicode normalization *) 2 | 3 | (* normal78901234567890123456789012345678901234567890123456789012345678901 a bū c d e*) 4 | 5 | (* modifier901234567890123456789012345678901234567890123456789012345678901 a bū̃ c d e*) 6 | 7 | (* 12345678901234567890123456789012345678901234567890123456789012345678901 a yo c d e*) 8 | 9 | (* 12345678901234567890123456789012345678901234567890123456789012345678901 a y̲o c d e*) 10 | -------------------------------------------------------------------------------- /test/passing/tests/unicode.ml.opts: -------------------------------------------------------------------------------- 1 | --margin=80 --wrap-comments 2 | -------------------------------------------------------------------------------- /test/passing/tests/unicode.ml.ref: -------------------------------------------------------------------------------- 1 | (* Don't edit this file with an editor that perform unicode normalization *) 2 | 3 | (* normal78901234567890123456789012345678901234567890123456789012345678901 a bū 4 | c d e*) 5 | 6 | (* modifier901234567890123456789012345678901234567890123456789012345678901 a bū̃ 7 | c d e*) 8 | 9 | (* 12345678901234567890123456789012345678901234567890123456789012345678901 a yo 10 | c d e*) 11 | 12 | (* 12345678901234567890123456789012345678901234567890123456789012345678901 a y̲o 13 | c d e*) 14 | -------------------------------------------------------------------------------- /test/passing/tests/use_file.mlt: -------------------------------------------------------------------------------- 1 | #p 2 | 3 | #p "a" 4 | 5 | #p 0;; 6 | 7 | 0;; 8 | 9 | #p 0n 10 | 11 | #p M.T.r 12 | 13 | (* comments *) 14 | (* comments *) 15 | 16 | let () = 3;; 17 | 18 | 2;; 19 | 20 | 3 21 | -------------------------------------------------------------------------------- /test/passing/tests/verbose1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/verbose1.ml -------------------------------------------------------------------------------- /test/passing/tests/verbose1.ml.enabled-if: -------------------------------------------------------------------------------- 1 | (<> %{os_type} Win32) 2 | -------------------------------------------------------------------------------- /test/passing/tests/verbose1.ml.opts: -------------------------------------------------------------------------------- 1 | --print-config 2 | --doc-comments=before 3 | --config=doc-comments=before 4 | -------------------------------------------------------------------------------- /test/passing/tests/verbose2.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/passing/tests/verbose2.ml -------------------------------------------------------------------------------- /test/passing/tests/verbose2.ml.enabled-if: -------------------------------------------------------------------------------- 1 | (<> %{os_type} Win32) 2 | -------------------------------------------------------------------------------- /test/passing/tests/verbose2.ml.opts: -------------------------------------------------------------------------------- 1 | --print-config 2 | --doc-comments=before 3 | --config=doc-comments=before 4 | -------------------------------------------------------------------------------- /test/passing/tests/wrap_comments.ml.opts: -------------------------------------------------------------------------------- 1 | --profile=ocamlformat 2 | -------------------------------------------------------------------------------- /test/passing/tests/wrap_comments_break.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | let _ = 3 | fffffffffff 4 | aaaaaaaaaaaaaaaaaaaaaaaaaaaa 5 | bbbbbbbbbbbbbbbbbbbbbbbbbb 6 | ~f:(fun x -> return xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) 7 | in 8 | 2 9 | -------------------------------------------------------------------------------- /test/passing/tests/wrap_comments_break.ml.opts: -------------------------------------------------------------------------------- 1 | --no-wrap-fun-args 2 | --margin=67 3 | -------------------------------------------------------------------------------- /test/passing/tests/wrapping_functor_args.ml: -------------------------------------------------------------------------------- 1 | (* This declaration looks odd *) 2 | type request_token = 3 | Sociaml_oauth_client.Client.Make(Sociaml_oauth_client.Posix.Clock) 4 | (Sociaml_oauth_client.Posix.MAC_SHA1) 5 | (Sociaml_oauth_client.Posix.Random) 6 | .request_token 7 | 8 | (* Whereas this one works well *) 9 | module OauthClient = 10 | Sociaml_oauth_client.Client.Make 11 | (Sociaml_oauth_client.Posix.Clock) 12 | (Sociaml_oauth_client.Posix.MAC_SHA1) 13 | (Sociaml_oauth_client.Posix.Random) 14 | -------------------------------------------------------------------------------- /test/projects/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = ocamlformat 2 | break-cases = fit 3 | -------------------------------------------------------------------------------- /test/projects/enable_outside_detected_project.expected: -------------------------------------------------------------------------------- 1 | (* The following code should be formatted using OCamlformat's config and not default *) 2 | type t = {foooooo: string; baaaaar: Baaaaar.t} 3 | -------------------------------------------------------------------------------- /test/projects/enable_outside_detected_project/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 1.11) 2 | -------------------------------------------------------------------------------- /test/projects/enable_outside_detected_project/main.ml: -------------------------------------------------------------------------------- 1 | (* The following code should be formatted using OCamlformat's config and not default *) 2 | type t = { 3 | foooooo : string; 4 | baaaaar : Baaaaar.t; 5 | } 6 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project.expected: -------------------------------------------------------------------------------- 1 | File main.ml 2 | Warning: Ocamlformat disabled because [--enable-outside-detected-project] is not set and no [.ocamlformat] was found within the project (root: ../outside_detected_project) 3 | (* The following code should not be formatted *) 4 | type t = { 5 | foooooo : string; 6 | baaaaar : Baaaaar.t; 7 | } 8 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 1.11) 2 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project/main.ml: -------------------------------------------------------------------------------- 1 | (* The following code should not be formatted *) 2 | type t = { 3 | foooooo : string; 4 | baaaaar : Baaaaar.t; 5 | } 6 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project_with_name.expected: -------------------------------------------------------------------------------- 1 | (* This should be formatted with profile=conventional *) 2 | type t = { 3 | foooooooooooooooooooooooooooooo : int; 4 | baaaaaaaaaaaaaaaaaaaaaaaaaaaaar : int; 5 | } 6 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project_with_name/outside_root/.ocamlformat: -------------------------------------------------------------------------------- 1 | # This file won't parse, on purpose 2 | # It shouldn't be interpreted by ocamlformat 3 | this_is_an_error = true 4 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project_with_name/outside_root/a.ml: -------------------------------------------------------------------------------- 1 | (* This should be formatted with profile=conventional *) 2 | type t = { 3 | foooooooooooooooooooooooooooooo : int; 4 | baaaaaaaaaaaaaaaaaaaaaaaaaaaaar : int; 5 | } 6 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project_with_name/outside_root/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 1.11) 2 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project_with_name/project_root/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = conventional 2 | -------------------------------------------------------------------------------- /test/projects/outside_detected_project_with_name/project_root/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 1.11) 2 | -------------------------------------------------------------------------------- /test/rpc/dune: -------------------------------------------------------------------------------- 1 | (test 2 | (name rpc_test) 3 | (libraries ocamlformat-rpc-lib unix) 4 | (deps %{bin:ocamlformat-rpc}) 5 | (modules rpc_test) 6 | (package ocamlformat-rpc) 7 | (enabled_if 8 | (<> %{os_type} Win32)) 9 | (action 10 | (run %{test} %{bin:ocamlformat-rpc}))) 11 | 12 | (test 13 | (name rpc_test_fail) 14 | (libraries ocamlformat-rpc-lib unix) 15 | (modules rpc_test_fail) 16 | (package ocamlformat-rpc) 17 | (action 18 | (run %{test} not-installed-ocamlformat-rpc))) 19 | -------------------------------------------------------------------------------- /test/rpc/rpc_test_fail.expected: -------------------------------------------------------------------------------- 1 | Starting then doing nothing 2 | An error occured while initializing and configuring ocamlformat: 3 | OCamlFormat-RPC did not respond. Check that a compatible version of the OCamlFormat RPC server (ocamlformat-rpc >= 0.18.0) is installed. 4 | No process 5 | Sending requests 6 | No process 7 | No process 8 | No process 9 | -------------------------------------------------------------------------------- /test/unit/dune: -------------------------------------------------------------------------------- 1 | (test 2 | (name test_unit) 3 | (package ocamlformat) 4 | (libraries alcotest base ocamlformat_lib)) 5 | -------------------------------------------------------------------------------- /test/unit/test_ast.mli: -------------------------------------------------------------------------------- 1 | val tests : unit Alcotest.test_case list 2 | -------------------------------------------------------------------------------- /test/unit/test_fmt.mli: -------------------------------------------------------------------------------- 1 | val tests : unit Alcotest.test_case list 2 | -------------------------------------------------------------------------------- /test/unit/test_indent.mli: -------------------------------------------------------------------------------- 1 | val tests : unit Alcotest.test_case list 2 | -------------------------------------------------------------------------------- /test/unit/test_literal_lexer.mli: -------------------------------------------------------------------------------- 1 | val tests : unit Alcotest.test_case list 2 | -------------------------------------------------------------------------------- /test/unit/test_translation_unit.mli: -------------------------------------------------------------------------------- 1 | val tests : unit Alcotest.test_case list 2 | 3 | val reindent : source:string -> range:int * int -> int list -> string 4 | -------------------------------------------------------------------------------- /test/unit/test_unit.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/test/unit/test_unit.mli -------------------------------------------------------------------------------- /tools/gen_changes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ########################################################################## 3 | # # 4 | # OCamlFormat # 5 | # # 6 | # Copyright (c) Facebook, Inc. and its affiliates. # 7 | # # 8 | # This source code is licensed under the MIT license found in # 9 | # the LICENSE file in the root directory of this source tree. # 10 | # # 11 | ########################################################################## 12 | 13 | git log --no-merges --pretty=format:" + %s (%an)" $1..$2 14 | -------------------------------------------------------------------------------- /tools/header.txt: -------------------------------------------------------------------------------- 1 | 2 | OCamlFormat 3 | 4 | Copyright (c) Facebook, Inc. and its affiliates. 5 | 6 | This source code is licensed under the MIT license found in 7 | the LICENSE file in the root directory of this source tree. 8 | 9 | -------------------------------------------------------------------------------- /tools/ocamlformat_test_branch: -------------------------------------------------------------------------------- 1 | _ocamlformat_test_branch() 2 | { 3 | branches=$(command git branch --no-color -a | sed 's/* //' | sed 's/ //g' | sed 's/^remotes\///') 4 | local cur 5 | COMPREPLY=() 6 | cur="${COMP_WORDS[COMP_CWORD]}" 7 | COMPREPLY=( $(compgen -W "${branches}" -- ${cur}) ) 8 | return 0 9 | } 10 | complete -F _ocamlformat_test_branch test_branch.sh 11 | -------------------------------------------------------------------------------- /tools/update_headers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ########################################################################## 3 | # # 4 | # OCamlFormat # 5 | # # 6 | # Copyright (c) Facebook, Inc. and its affiliates. # 7 | # # 8 | # This source code is licensed under the MIT license found in # 9 | # the LICENSE file in the root directory of this source tree. # 10 | # # 11 | ########################################################################## 12 | 13 | find * -type f | grep -v '\(_build\|_opam\|test\|vendor\|.merlin\|ocamlformat.el\)' | grep -v '.*\.\(org\|md\|txt\)$' | xargs headache -c tools/config.headache -h tools/header.txt 14 | -------------------------------------------------------------------------------- /vendor/ocaml-4.13-extended/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ocaml_413_extended) 3 | (flags 4 | (:standard -w -9 -open Parser_shims -open Ocaml_common)) 5 | (libraries compiler-libs.common menhirLib parser_shims ocaml_common)) 6 | 7 | (ocamllex lexer) 8 | 9 | (menhir 10 | (infer false) 11 | (flags 12 | --lalr 13 | --explain 14 | --dump 15 | --strict 16 | -lg 17 | 1 18 | -la 19 | 1 20 | --unused-token 21 | COMMENT 22 | --unused-token 23 | DOCSTRING 24 | --unused-token 25 | EOL 26 | --unused-token 27 | GREATERRBRACKET 28 | --fixed-exception 29 | --table 30 | --strategy 31 | simplified) 32 | (modules parser)) 33 | 34 | (rule 35 | (targets asttypes.ml) 36 | (mode fallback) 37 | (action 38 | (copy# asttypes.mli %{targets}))) 39 | 40 | (rule 41 | (targets parsetree.ml) 42 | (mode fallback) 43 | (action 44 | (copy# parsetree.mli %{targets}))) 45 | -------------------------------------------------------------------------------- /vendor/ocaml-4.13/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ocaml_413) 3 | (flags 4 | (:standard -w -9 -open Parser_shims -open Ocaml_common)) 5 | (libraries compiler-libs.common menhirLib parser_shims ocaml_common)) 6 | 7 | (ocamllex lexer) 8 | 9 | (menhir 10 | (infer false) 11 | (flags 12 | --lalr 13 | --explain 14 | --dump 15 | --strict 16 | -lg 17 | 1 18 | -la 19 | 1 20 | --unused-token 21 | COMMENT 22 | --unused-token 23 | DOCSTRING 24 | --unused-token 25 | EOL 26 | --unused-token 27 | GREATERRBRACKET 28 | --fixed-exception 29 | --table 30 | --strategy 31 | simplified) 32 | (modules parser)) 33 | 34 | (rule 35 | (targets asttypes.ml) 36 | (mode fallback) 37 | (action 38 | (copy# asttypes.mli %{targets}))) 39 | 40 | (rule 41 | (targets parsetree.ml) 42 | (mode fallback) 43 | (action 44 | (copy# parsetree.mli %{targets}))) 45 | -------------------------------------------------------------------------------- /vendor/ocaml-common/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ocaml_common) 3 | (flags 4 | (:standard -w -9 -open Parser_shims)) 5 | (libraries parser_shims)) 6 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/cmdliner_ext.ml: -------------------------------------------------------------------------------- 1 | include Cmdliner 2 | 3 | (** existential package of a Term and a setter for a ref to receive the 4 | parsed value *) 5 | type arg = Arg : 'a Term.t * ('a -> unit) -> arg 6 | 7 | (** convert a list of arg packages to a term for the tuple of all the arg 8 | terms, and apply it to a function that sets all the receiver refs *) 9 | let tuple args = 10 | let pair (Arg (trm_x, set_x)) (Arg (trm_y, set_y)) = 11 | let trm_xy = Term.(const (fun a b -> (a, b)) $ trm_x $ trm_y) in 12 | let set_xy (a, b) = set_x a ; set_y b in 13 | Arg (trm_xy, set_xy) 14 | in 15 | let init = Arg (Term.const (), fun () -> ()) in 16 | let (Arg (trm, set)) = Base.List.fold_right ~f:pair args ~init in 17 | Term.app (Term.const set) trm 18 | 19 | let args : arg list ref = ref [] 20 | 21 | let mk ~default arg = 22 | let var = ref default in 23 | let set x = var := x in 24 | args := Arg (arg, set) :: !args ; 25 | var 26 | 27 | let parse info validate = 28 | Term.eval (Term.(ret (const validate $ tuple !args)), info) 29 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/cmdliner_ext.mli: -------------------------------------------------------------------------------- 1 | (** Extension of Cmdliner supporting lighter-weight option definition *) 2 | 3 | include module type of Cmdliner 4 | 5 | val mk : default:'a -> 'a Term.t -> 'a ref 6 | (** [mk ~default term] is a ref which, after [parse] is called, contains 7 | the value of the command line option specified by [term]. *) 8 | 9 | val parse : Term.info -> (unit -> 'a Term.ret) -> 'a Term.result 10 | (** [parse info validate] parses the command line according to the options 11 | declared by calls to [mk], using manual and version [info], and calling 12 | [validate] to check usage constraints not expressible in the [Term] 13 | language. *) 14 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name ocamlformat_stdlib) 3 | (flags 4 | (:standard -open Ocaml_common)) 5 | (libraries base cmdliner ocaml_common fpath stdio)) 6 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/fpath_ext.ml: -------------------------------------------------------------------------------- 1 | include Fpath 2 | 3 | let cwd () = Caml.Sys.getcwd () |> v 4 | 5 | let exists p = to_string p |> Caml.Sys.file_exists 6 | 7 | let to_absolute file = if is_rel file then append (cwd ()) file else file 8 | 9 | let to_string ?(relativize = false) p = 10 | if relativize then 11 | Base.Option.value_map 12 | (Fpath.relativize ~root:(cwd ()) p) 13 | ~default:(to_string p) ~f:to_string 14 | else to_string p 15 | 16 | let pp fmt p = Format.fprintf fmt "%s" (to_string ~relativize:true p) 17 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/fpath_ext.mli: -------------------------------------------------------------------------------- 1 | include module type of Fpath 2 | 3 | val cwd : unit -> t 4 | (** Current working directory. *) 5 | 6 | val exists : t -> bool 7 | (** [exists p] returns whether the given path [p] exists. *) 8 | 9 | val to_absolute : t -> t 10 | (** [to_absolute p] returns [cwd]/[p] if the [p] is relative, otherwise 11 | returns [p]. *) 12 | 13 | val to_string : ?relativize:bool -> t -> string 14 | (** If [relativize] is set to [true] (it is set to [false] by default), the 15 | path is relativized according to the [cwd]. *) 16 | 17 | val pp : Format.formatter -> t -> unit 18 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/list_ext.ml: -------------------------------------------------------------------------------- 1 | include Base.List 2 | 3 | let partition_map l ~f = 4 | let fst, snd = 5 | fold_left l 6 | ~f:(fun (fst, snd) x -> 7 | match f x with 8 | | Base.Either.First x' -> (x' :: fst, snd) 9 | | Base.Either.Second x' -> (fst, x' :: snd)) 10 | ~init:([], []) 11 | in 12 | (rev fst, rev snd) 13 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/list_ext.mli: -------------------------------------------------------------------------------- 1 | include module type of Base.List 2 | 3 | val partition_map : 4 | 'a list -> f:('a -> ('b, 'c) Base.Either.t) -> 'b list * 'c list 5 | (** [partition_map t ~f] partitions [t] according to [f]. 6 | 7 | @since base.v0.14.0 *) 8 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/ocamlformat_stdlib.ml: -------------------------------------------------------------------------------- 1 | include Base 2 | include Stdio 3 | 4 | module Cmdliner = Cmdliner_ext 5 | module Fpath = Fpath_ext 6 | module List = List_ext 7 | module String = String_ext 8 | module Warning = Warning 9 | module Format = Caml.Format 10 | module Filename = Caml.Filename 11 | 12 | let ( >> ) f g x = g (f x) 13 | 14 | let impossible msg = failwith msg 15 | 16 | let check f x = 17 | assert ( 18 | ignore (f x) ; 19 | true ) ; 20 | x 21 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/ocamlformat_stdlib.mli: -------------------------------------------------------------------------------- 1 | include module type of Base 2 | include module type of Stdio 3 | module Cmdliner = Cmdliner_ext 4 | module Fpath = Fpath_ext 5 | module List = List_ext 6 | module String = String_ext 7 | module Warning = Warning 8 | module Format = Caml.Format 9 | module Filename = Caml.Filename 10 | 11 | val ( >> ) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c 12 | (** Composition of functions: [(f >> g) x] is exactly equivalent to 13 | [g (f (x))]. Left associative. *) 14 | 15 | val impossible : string -> _ 16 | (** Indicate why the call is expected to be impossible. *) 17 | 18 | val check : ('a -> _) -> 'a -> 'a 19 | (** Asserting identity: [check f x] asserts that [f x] does not raise and 20 | returns [x]. *) 21 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/string_ext.ml: -------------------------------------------------------------------------------- 1 | include Base 2 | include String 3 | 4 | let starts_with_whitespace s = (not (is_empty s)) && Char.is_whitespace s.[0] 5 | 6 | let ends_with_whitespace s = 7 | (not (is_empty s)) && Char.is_whitespace s.[length s - 1] 8 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/string_ext.mli: -------------------------------------------------------------------------------- 1 | include module type of Base.String 2 | 3 | val starts_with_whitespace : string -> bool 4 | (** [starts_with_whitespace s] holds if [s] is non empty and starts with a 5 | whitespace character. *) 6 | 7 | val ends_with_whitespace : string -> bool 8 | (** [ends_with_whitespace s] holds if [s] is non empty and ends with a 9 | whitespace character. *) 10 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/warning.ml: -------------------------------------------------------------------------------- 1 | let () = Clflags.error_style := Some Misc.Error_style.Short 2 | 3 | let with_warning_filter ~filter ~f = 4 | let warning_reporter = !Location.warning_reporter in 5 | (Location.warning_reporter := 6 | fun loc warn -> 7 | if filter loc warn then Location.default_warning_reporter loc warn 8 | else None) ; 9 | let reset () = Location.warning_reporter := warning_reporter in 10 | try 11 | let x = f () in 12 | reset () ; x 13 | with e -> reset () ; raise e 14 | 15 | let print_warning l w = 16 | match Location.default_warning_reporter l w with 17 | | Some reporter -> Location.print_report Caml.Format.err_formatter reporter 18 | | None -> () 19 | 20 | let is_unexpected_docstring = function 21 | | Warnings.Unexpected_docstring _ -> true 22 | | _ -> false 23 | -------------------------------------------------------------------------------- /vendor/ocamlformat-stdlib/warning.mli: -------------------------------------------------------------------------------- 1 | val with_warning_filter : 2 | filter:(Location.t -> Warnings.t -> bool) -> f:(unit -> 'a) -> 'a 3 | 4 | val print_warning : Location.t -> Warnings.t -> unit 5 | 6 | val is_unexpected_docstring : Warnings.t -> bool 7 | -------------------------------------------------------------------------------- /vendor/ocamlformat_support/.ocamlformat: -------------------------------------------------------------------------------- 1 | disable 2 | -------------------------------------------------------------------------------- /vendor/ocamlformat_support/README.md: -------------------------------------------------------------------------------- 1 | This directory contains code not authored by Facebook or covered by 2 | its CLA, that is subject to its own copyright (INRIA) and license 3 | (LGPL 2.1 with OCaml linking exception) terms. 4 | 5 | In particular, it contains two files of the OCaml standard library, 6 | and versions modified to add some functionality used by 7 | ocamlformat. This code is included as a temporary measure while the 8 | pull request to include this functionality in the OCaml standard 9 | distribution is under review. 10 | 11 | See [ocaml/ocaml#1229](https://github.com/ocaml/ocaml/pull/1229). 12 | -------------------------------------------------------------------------------- /vendor/ocamlformat_support/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name format_)) 3 | -------------------------------------------------------------------------------- /vendor/parse-wyc/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = conventional 2 | parse-docstrings = true 3 | -------------------------------------------------------------------------------- /vendor/parse-wyc/lib/.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | ast_helper.ml 2 | ast_helper.mli 3 | docstrings.ml 4 | docstrings.mli 5 | -------------------------------------------------------------------------------- /vendor/parse-wyc/lib/annot.ml: -------------------------------------------------------------------------------- 1 | open Ast_helper 2 | open Parsetree 3 | 4 | module Ext = struct 5 | let mk () = (Location.mkloc "merlin.hole" !default_loc, PStr []) 6 | end 7 | 8 | module Exp = struct 9 | let mk () = Exp.extension (Ext.mk ()) 10 | end 11 | 12 | module Cl = struct 13 | let mk () = Cl.extension (Ext.mk ()) 14 | end 15 | 16 | module Cty = struct 17 | let mk () = Cty.extension (Ext.mk ()) 18 | end 19 | 20 | module Pat = struct 21 | let mk () = Pat.extension (Ext.mk ()) 22 | end 23 | 24 | module Mty = struct 25 | let mk () = Mty.extension (Ext.mk ()) 26 | end 27 | 28 | module Mod = struct 29 | let mk () = Mod.extension (Ext.mk ()) 30 | end 31 | -------------------------------------------------------------------------------- /vendor/parse-wyc/lib/annot.mli: -------------------------------------------------------------------------------- 1 | module Exp : sig 2 | val mk : unit -> Parsetree.expression 3 | end 4 | 5 | module Cl : sig 6 | val mk : unit -> Parsetree.class_expr 7 | end 8 | 9 | module Cty : sig 10 | val mk : unit -> Parsetree.class_type 11 | end 12 | 13 | module Pat : sig 14 | val mk : unit -> Parsetree.pattern 15 | end 16 | 17 | module Mty : sig 18 | val mk : unit -> Parsetree.module_type 19 | end 20 | 21 | module Mod : sig 22 | val mk : unit -> Parsetree.module_expr 23 | end 24 | -------------------------------------------------------------------------------- /vendor/parse-wyc/lib/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name parse_wyc) 3 | (modules_without_implementation let_binding) 4 | (libraries menhirLib ocaml_common ocaml_413_extended) 5 | (flags 6 | (:standard -w -9 -open Ocaml_common -open Ocaml_413_extended))) 7 | 8 | (ocamllex lexer) 9 | 10 | (menhir 11 | (flags --strict --inspection --unused-tokens --table --cmly) 12 | (modules parser)) 13 | 14 | (rule 15 | (targets parser_recover.ml) 16 | (deps parser.cmly) 17 | (action 18 | (with-stdout-to 19 | %{targets} 20 | (run ../menhir-recover/main.exe parser.cmly)))) 21 | -------------------------------------------------------------------------------- /vendor/parse-wyc/lib/let_binding.mli: -------------------------------------------------------------------------------- 1 | type let_binding = 2 | { lb_pattern: Parsetree.pattern; 3 | lb_expression: Parsetree.expression; 4 | lb_is_pun: bool; 5 | lb_attributes: Parsetree.attributes; 6 | lb_docs: Docstrings.docs Lazy.t; 7 | lb_text: Docstrings.text Lazy.t; 8 | lb_loc: Location.t; } 9 | 10 | type let_bindings = 11 | { lbs_bindings: let_binding list; 12 | lbs_rec: Asttypes.rec_flag; 13 | lbs_extension: string Asttypes.loc option } 14 | -------------------------------------------------------------------------------- /vendor/parse-wyc/lib/parse_wyc.mli: -------------------------------------------------------------------------------- 1 | val structure : Lexing.lexbuf -> Parsetree.structure 2 | 3 | val signature : Lexing.lexbuf -> Parsetree.signature 4 | 5 | val use_file : Lexing.lexbuf -> Parsetree.toplevel_phrase list 6 | -------------------------------------------------------------------------------- /vendor/parse-wyc/menhir-recover/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all clean 2 | 3 | all: 4 | dune build main.exe 5 | 6 | clean: 7 | dune clean 8 | -------------------------------------------------------------------------------- /vendor/parse-wyc/menhir-recover/dune: -------------------------------------------------------------------------------- 1 | (executable 2 | (name main) 3 | (libraries fix menhirLib menhirSdk)) 4 | -------------------------------------------------------------------------------- /vendor/parse-wyc/menhir-recover/emitter.mli: -------------------------------------------------------------------------------- 1 | open MenhirSdk.Cmly_api 2 | open Attributes 3 | open Synthesis 4 | open Recovery_intf 5 | 6 | module Make 7 | (G : GRAMMAR) 8 | (A : ATTRIBUTES with module G := G) 9 | (S : SYNTHESIZER with module G := G) 10 | (R : RECOVERY with module G := G) : sig 11 | val emit : Format.formatter -> unit 12 | end 13 | -------------------------------------------------------------------------------- /vendor/parse-wyc/menhir-recover/recovery_intf.ml: -------------------------------------------------------------------------------- 1 | open MenhirSdk.Cmly_api 2 | 3 | module type RECOVERY = sig 4 | module G : GRAMMAR 5 | 6 | type item = G.lr1 * G.production * int 7 | 8 | type recovery = { prefix : int; cases : (G.lr1 option * item list) list } 9 | (** [prefix] is the size of the known prefix of the stack. It means that in 10 | the kernel of current state, there is an item whose dot is at position 11 | [prefix]. (we know the incoming symbols for these stack frames and we can 12 | enumerate the possible state numbers). 13 | 14 | [cases] is a mapping that associates to each possible state found at 15 | stack.[-prefix] (or None if the stack is empty) a list of reductions to 16 | execute. 17 | 18 | The actual list of actions to reduce an item [(state, prod, pos)] is given 19 | by [Synthesizer.solution (Trail (state, prod, pos))] *) 20 | 21 | val recover : G.lr1 -> recovery 22 | end 23 | 24 | module type RECOVER = functor 25 | (G : GRAMMAR) 26 | (S : Synthesis.SYNTHESIZER with module G := G) 27 | -> RECOVERY with module G := G 28 | -------------------------------------------------------------------------------- /vendor/parse-wyc/test/unit/dune: -------------------------------------------------------------------------------- 1 | (test 2 | (name test_unit) 3 | (package ocamlformat) 4 | (flags 5 | (:standard -open Ocaml_413_extended)) 6 | (libraries alcotest parse_wyc)) 7 | -------------------------------------------------------------------------------- /vendor/parse-wyc/test/unit/test_unit.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebook-github-bot/ocamlformat/e41024198dc211b9ccf908053ccd3e0b646093ff/vendor/parse-wyc/test/unit/test_unit.mli -------------------------------------------------------------------------------- /vendor/parser-shims/dune: -------------------------------------------------------------------------------- 1 | (library 2 | (name parser_shims) 3 | (libraries compiler-libs.common)) 4 | --------------------------------------------------------------------------------