diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07d5545e2e..3b72541af4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,7 @@ jobs: - 4.11.x - 4.12.x - 4.13.x + - 5.0.x skip-test: - true skip-doc: @@ -46,17 +47,17 @@ jobs: skip-test: false skip-doc: true - os: ubuntu-latest - ocaml-compiler: 5.0.x + ocaml-compiler: 5.1.x skip-effects: false skip-test: false skip-doc: false - os: macos-latest - ocaml-compiler: 5.0.x + ocaml-compiler: 5.1.x skip-effects: true skip-test: false skip-doc: true - os: windows-latest - ocaml-compiler: ocaml.5.0.0,ocaml-option-mingw + ocaml-compiler: ocaml.5.1.0,ocaml-option-mingw skip-effects: false skip-test: false skip-doc: true @@ -85,7 +86,7 @@ jobs: with: ocaml-compiler: ${{ matrix.ocaml-compiler }} opam-repositories: | - dra27: https://github.com/dra27/opam-repository.git#windows-5.0 + dra27: https://github.com/hhugo/opam-repository.git#for-jsoo-ci-windows default: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset opam: https://github.com/ocaml/opam-repository.git dune-cache: true diff --git a/compiler/tests-check-prim/main.output5 b/compiler/tests-check-prim/main.output5 index cf220fbc8b..ce999f293b 100644 --- a/compiler/tests-check-prim/main.output5 +++ b/compiler/tests-check-prim/main.output5 @@ -155,13 +155,9 @@ caml_obj_set_tag caml_obj_truncate From +runtime_events.js: -caml_custom_event_index caml_runtime_events_create_cursor caml_runtime_events_free_cursor caml_runtime_events_read_poll -caml_runtime_events_user_register -caml_runtime_events_user_resolve -caml_runtime_events_user_write From +stdlib.js: caml_build_symbols @@ -187,7 +183,6 @@ caml_set_static_env caml_spacetime_enabled caml_spacetime_only_works_for_native_code caml_sys_const_naked_pointers_checked -caml_sys_is_regular_file From +unix.js: caml_unix_cleanup diff --git a/compiler/tests-check-prim/unix-unix.output5 b/compiler/tests-check-prim/unix-unix.output5 index b4d909e0f9..7452e7d18c 100644 --- a/compiler/tests-check-prim/unix-unix.output5 +++ b/compiler/tests-check-prim/unix-unix.output5 @@ -264,13 +264,9 @@ caml_obj_set_tag caml_obj_truncate From +runtime_events.js: -caml_custom_event_index caml_runtime_events_create_cursor caml_runtime_events_free_cursor caml_runtime_events_read_poll -caml_runtime_events_user_register -caml_runtime_events_user_resolve -caml_runtime_events_user_write From +stdlib.js: caml_build_symbols @@ -296,7 +292,6 @@ caml_set_static_env caml_spacetime_enabled caml_spacetime_only_works_for_native_code caml_sys_const_naked_pointers_checked -caml_sys_is_regular_file From +unix.js: caml_unix_cleanup diff --git a/compiler/tests-check-prim/unix-win32.output5 b/compiler/tests-check-prim/unix-win32.output5 index 253f907ee2..b981d1045b 100644 --- a/compiler/tests-check-prim/unix-win32.output5 +++ b/compiler/tests-check-prim/unix-win32.output5 @@ -230,13 +230,9 @@ caml_obj_set_tag caml_obj_truncate From +runtime_events.js: -caml_custom_event_index caml_runtime_events_create_cursor caml_runtime_events_free_cursor caml_runtime_events_read_poll -caml_runtime_events_user_register -caml_runtime_events_user_resolve -caml_runtime_events_user_write From +stdlib.js: caml_build_symbols @@ -262,7 +258,6 @@ caml_set_static_env caml_spacetime_enabled caml_spacetime_only_works_for_native_code caml_sys_const_naked_pointers_checked -caml_sys_is_regular_file From +unix.js: caml_unix_getpwuid diff --git a/compiler/tests-compiler/effects_continuations.ml b/compiler/tests-compiler/effects_continuations.ml index 953984bcf9..40a49fd709 100644 --- a/compiler/tests-compiler/effects_continuations.ml +++ b/compiler/tests-compiler/effects_continuations.ml @@ -24,6 +24,11 @@ let%expect_test "test-compiler/lib-effects/test1.ml" = compile_and_parse ~effects:true {| + + let list_rev = List.rev + (* Avoid to expose the offset of stdlib modules *) + let () = ignore (list_rev []) + let exceptions s = (* Compiled using 'try ... catch', and 'throw' within the try block *) @@ -78,7 +83,7 @@ let%expect_test "test-compiler/lib-effects/test1.ml" = done let loop3 () = - let l = List.rev [1;2;3] in + let l = list_rev [1;2;3] in let rec f x = match x with | [] -> l @@ -98,118 +103,117 @@ let%expect_test "test-compiler/lib-effects/test1.ml" = {| function exceptions(s, cont){ - try{var _C_ = runtime.caml_int_of_string(s), n = _C_;} - catch(_G_){ - var _v_ = caml_wrap_exception(_G_); - if(_v_[1] !== Stdlib[7]){ + try{var _B_ = runtime.caml_int_of_string(s), n = _B_;} + catch(_F_){ + var _u_ = caml_wrap_exception(_F_); + if(_u_[1] !== Stdlib[7]){ var raise$1 = caml_pop_trap(); - return raise$1(caml_maybe_attach_backtrace(_v_, 0)); + return raise$1(caml_maybe_attach_backtrace(_u_, 0)); } - var n = 0, _w_ = 0; + var n = 0, _v_ = 0; } try{ if(caml_string_equal(s, cst$0)) throw caml_maybe_attach_backtrace(Stdlib[8], 1); - var _B_ = 7, m = _B_; + var _A_ = 7, m = _A_; } - catch(_F_){ - var _x_ = caml_wrap_exception(_F_); - if(_x_ !== Stdlib[8]){ + catch(_E_){ + var _w_ = caml_wrap_exception(_E_); + if(_w_ !== Stdlib[8]){ var raise$0 = caml_pop_trap(); - return raise$0(caml_maybe_attach_backtrace(_x_, 0)); + return raise$0(caml_maybe_attach_backtrace(_w_, 0)); } - var m = 0, _y_ = 0; + var m = 0, _x_ = 0; } runtime.caml_push_trap - (function(_E_){ - if(_E_ === Stdlib[8]) return cont(0); + (function(_D_){ + if(_D_ === Stdlib[8]) return cont(0); var raise = caml_pop_trap(); - return raise(caml_maybe_attach_backtrace(_E_, 0)); + return raise(caml_maybe_attach_backtrace(_D_, 0)); }); if(caml_string_equal(s, cst)){ - var _z_ = Stdlib[8], raise = caml_pop_trap(); - return raise(caml_maybe_attach_backtrace(_z_, 1)); + var _y_ = Stdlib[8], raise = caml_pop_trap(); + return raise(caml_maybe_attach_backtrace(_y_, 1)); } - var _A_ = Stdlib[79]; + var _z_ = Stdlib[79]; return caml_cps_call2 - (_A_, + (_z_, cst_toto, - function(_D_){caml_pop_trap(); return cont([0, [0, _D_, n, m]]);}); + function(_C_){caml_pop_trap(); return cont([0, [0, _C_, n, m]]);}); } //end function cond1(b, cont){ - function _u_(ic){return cont([0, ic, 7]);} + function _t_(ic){return cont([0, ic, 7]);} return b - ? caml_cps_call2(Stdlib[79], cst_toto$0, _u_) - : caml_cps_call2(Stdlib[79], cst_titi, _u_); + ? caml_cps_call2(Stdlib[79], cst_toto$0, _t_) + : caml_cps_call2(Stdlib[79], cst_titi, _t_); } //end function cond2(b, cont){ - function _s_(_t_){return cont(7);} + function _r_(_s_){return cont(7);} return b - ? caml_cps_call2(Stdlib_Printf[3], _a_, _s_) - : caml_cps_call2(Stdlib_Printf[3], _b_, _s_); + ? caml_cps_call2(Stdlib_Printf[3], _a_, _r_) + : caml_cps_call2(Stdlib_Printf[3], _b_, _r_); } //end function cond3(b, cont){ var x = [0, 0]; - function _q_(_r_){return cont(x[1]);} - return b ? (x[1] = 1, _q_(0)) : caml_cps_call2(Stdlib_Printf[3], _c_, _q_); + function _p_(_q_){return cont(x[1]);} + return b ? (x[1] = 1, _p_(0)) : caml_cps_call2(Stdlib_Printf[3], _c_, _p_); } //end function loop1(b, cont){ - var _m_ = Stdlib[79]; + var _l_ = Stdlib[79]; return caml_cps_call2 - (_m_, + (_l_, cst_static_examples_ml, function(ic){ - function _n_(_p_){ - var _o_ = Stdlib[83]; + function _m_(_o_){ + var _n_ = Stdlib[83]; return caml_cps_call2 - (_o_, + (_n_, ic, function(line){ return b - ? caml_cps_call2(Stdlib[53], line, _n_) - : caml_cps_exact_call1(_n_, 0); + ? caml_cps_call2(Stdlib[53], line, _m_) + : caml_cps_exact_call1(_m_, 0); }); } - return _n_(0); + return _m_(0); }); } //end function loop2(param, cont){ - var _h_ = Stdlib[79]; + var _g_ = Stdlib[79]; return caml_cps_call2 - (_h_, + (_g_, cst_static_examples_ml$0, function(ic){ - var _i_ = Stdlib_Printf[3]; - function _j_(_l_){ - var _k_ = Stdlib[83]; + var _h_ = Stdlib_Printf[3]; + function _i_(_k_){ + var _j_ = Stdlib[83]; return caml_cps_call2 - (_k_, + (_j_, ic, function(line){ - return caml_cps_call2(Stdlib[53], line, _j_); + return caml_cps_call2(Stdlib[53], line, _i_); }); } - return caml_cps_call2(_i_, _d_, _j_); + return caml_cps_call2(_h_, _d_, _i_); }); } //end function loop3(param, cont){ - var _f_ = Stdlib_List[9]; return caml_cps_call2 - (_f_, + (list_rev, _e_, function(l){ - function _g_(x){ + function _f_(x){ if(! x) return cont(l); var r = x[2]; - return caml_cps_exact_call1(_g_, r); + return caml_cps_exact_call1(_f_, r); } - return _g_(l); + return _f_(l); }); } //end |}] diff --git a/compiler/tests-compiler/gh1007.ml b/compiler/tests-compiler/gh1007.ml index e4971515a8..46eb031059 100644 --- a/compiler/tests-compiler/gh1007.ml +++ b/compiler/tests-compiler/gh1007.ml @@ -397,6 +397,13 @@ let () = M.run () let%expect_test _ = let prog = {| + +let list_rev = List.rev +let list_iter = List.iter +(* Avoid to expose the offset of stdlib modules *) +let () = ignore (list_rev []) +let () = ignore (list_iter (fun f -> f ()) []) + module M : sig val run : unit -> unit end = struct @@ -426,7 +433,7 @@ end = struct for i = 0 to 4 do ignore (even (i) : bool) done; - List.iter (fun f -> f ()) (List.rev !delayed) + list_iter (fun f -> f ()) (list_rev !delayed) end let () = M.run () @@ -460,7 +467,7 @@ let () = M.run () switch(n){ case 0: var - f = function(param){return caml_call2(Stdlib_Printf[2], _b_, i);}; + f = function(param){return caml_call2(Stdlib_Printf[2], _c_, i);}; delayed[1] = [0, f, delayed[1]]; f(0); return 1; @@ -474,7 +481,7 @@ let () = M.run () switch(n){ case 0: var - f = function(param){return caml_call2(Stdlib_Printf[2], _a_, i);}; + f = function(param){return caml_call2(Stdlib_Printf[2], _b_, i);}; delayed[1] = [0, f, delayed[1]]; f(0); return 0; @@ -491,10 +498,8 @@ let () = M.run () even(i); var _e_ = i + 1 | 0; if(4 === i){ - var - _c_ = caml_call1(Stdlib_List[9], delayed[1]), - _d_ = function(f){return caml_call1(f, 0);}; - return caml_call2(Stdlib_List[17], _d_, _c_); + var _d_ = caml_call1(list_rev, delayed[1]); + return caml_call2(list_iter, function(f){return caml_call1(f, 0);}, _d_); } var i = _e_; } @@ -504,6 +509,13 @@ let () = M.run () let%expect_test _ = let prog = {| + +let list_rev = List.rev +let list_iter = List.iter +(* Avoid to expose the offset of stdlib modules *) +let () = ignore (list_rev []) +let () = ignore (list_iter (fun f -> f ()) []) + module M : sig val run : unit -> unit end = struct @@ -537,7 +549,7 @@ end = struct in ignore (r (even (i)) : bool) done; - List.iter (fun f -> f ()) (List.rev !delayed) + list_iter (fun f -> f ()) (list_rev !delayed) end let () = M.run () @@ -575,11 +587,11 @@ let () = M.run () 748545554, function(param){ function f(param){ - return caml_call2(Stdlib_Printf[2], _c_, i); + return caml_call2(Stdlib_Printf[2], _d_, i); } delayed[1] = [0, f, delayed[1]]; f(0); - return _d_; + return _e_; }]; case 1: return [0, 748545554, function(param){return odd(0);}]; @@ -595,11 +607,11 @@ let () = M.run () 748545554, function(param){ function f(param){ - return caml_call2(Stdlib_Printf[2], _a_, i); + return caml_call2(Stdlib_Printf[2], _b_, i); } delayed[1] = [0, f, delayed[1]]; f(0); - return _b_; + return _c_; }]; case 1: return [0, 748545554, function(param){return even(0);}]; @@ -616,10 +628,8 @@ let () = M.run () if(759635106 <= param$0[1]){ var _g_ = i + 1 | 0; if(4 !== i){var i = _g_; break;} - var - _e_ = caml_call1(Stdlib_List[9], delayed[1]), - _f_ = function(f){return caml_call1(f, 0);}; - return caml_call2(Stdlib_List[17], _f_, _e_); + var _f_ = caml_call1(list_rev, delayed[1]); + return caml_call2(list_iter, function(f){return caml_call1(f, 0);}, _f_); } var f = param$0[2], param$0 = f(0); } diff --git a/compiler/tests-compiler/loops.ml b/compiler/tests-compiler/loops.ml index 4cd3e5af87..ab299a447b 100644 --- a/compiler/tests-compiler/loops.ml +++ b/compiler/tests-compiler/loops.ml @@ -23,8 +23,13 @@ let%expect_test "rec-fun" = let program = compile_and_parse {| - let rec fun_with_loop acc = function - | [] -> List.rev (List.rev (List.rev acc)) + +let list_rev = List.rev +(* Avoid to expose the offset of stdlib modules *) +let () = ignore (list_rev []) + +let rec fun_with_loop acc = function + | [] -> list_rev (list_rev (list_rev acc)) | x :: xs -> fun_with_loop (x :: acc) xs |} in @@ -34,12 +39,9 @@ let%expect_test "rec-fun" = function fun_with_loop(acc, param){ var acc$0 = acc, param$0 = param; for(;;){ - if(! param$0){ - var - _a_ = caml_call1(Stdlib_List[9], acc$0), - _b_ = caml_call1(Stdlib_List[9], _a_); - return caml_call1(Stdlib_List[9], _b_); - } + if(! param$0) + return caml_call1 + (list_rev, caml_call1(list_rev, caml_call1(list_rev, acc$0))); var xs = param$0[2], x = param$0[1], @@ -54,8 +56,13 @@ let%expect_test "rec-fun-2" = let program = compile_and_parse {| +let list_rev = List.rev +(* Avoid to expose the offset of stdlib modules *) +let () = ignore (list_rev []) + + let rec fun_with_loop acc = function - | [] -> List.rev (List.rev (List.rev acc)) + | [] -> list_rev (list_rev (list_rev acc)) | [ 1 ] -> let a = ref acc in for i = 0 to 10 do @@ -76,12 +83,9 @@ let rec fun_with_loop acc = function function fun_with_loop(acc, param){ var acc$0 = acc, param$0 = param; for(;;){ - if(! param$0){ - var - _c_ = caml_call1(Stdlib_List[9], acc$0), - _d_ = caml_call1(Stdlib_List[9], _c_); - return caml_call1(Stdlib_List[9], _d_); - } + if(! param$0) + return caml_call1 + (list_rev, caml_call1(list_rev, caml_call1(list_rev, acc$0))); var x = param$0[1]; if(1 === x && ! param$0[2]){ var a$0 = [0, acc$0], i$0 = 0; @@ -338,6 +342,13 @@ let%expect_test "buffer.add_substitute" = let program = compile_and_parse {| +let string_length = String.length +let string_sub = String.sub + +(* Avoid to expose the offset of stdlib modules *) +let () = ignore (string_length "asd") +let () = ignore (string_sub "asd" 0 3) + let add_substitute = let closing = function | '(' -> ')' @@ -358,7 +369,7 @@ let add_substitute = then if k = 0 then i else advance (k - 1) (i + 1) lim else advance k (i + 1) lim in - advance k start (String.length s) + advance k start (string_length s) in let advance_to_non_alpha s start = let rec advance i lim = @@ -369,7 +380,7 @@ let add_substitute = | 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' -> advance (i + 1) lim | _ -> i in - advance start (String.length s) + advance start (string_length s) in (* We are just at the beginning of an ident in s, starting at start. *) let find_ident s start lim = @@ -381,18 +392,18 @@ let add_substitute = | ('(' | '{') as c -> let new_start = start + 1 in let stop = advance_to_closing c (closing c) 0 s new_start in - String.sub s new_start (stop - start - 1), stop + 1 + string_sub s new_start (stop - start - 1), stop + 1 (* Regular ident *) | _ -> let stop = advance_to_non_alpha s (start + 1) in - String.sub s start (stop - start), stop + string_sub s start (stop - start), stop in let add_char = Buffer.add_char in let add_string = Buffer.add_string in (* Substitute $ident, $(ident), or ${ident} in s, according to the function mapping f. *) let add_substitute b f s = - let lim = String.length s in + let lim = string_length s in let rec subst previous i = if i < lim then ( @@ -476,7 +487,7 @@ let add_substitute = var match$0 = [0, - caml_call3(Stdlib_String[15], s, start$0, stop$0 - start$0 | 0), + caml_call3(string_sub, s, start$0, stop$0 - start$0 | 0), stop$0]; break a; } @@ -499,8 +510,7 @@ let add_substitute = var match$0 = [0, - caml_call3 - (Stdlib_String[15], s, new_start, (stop - start$0 | 0) - 1 | 0), + caml_call3(string_sub, s, new_start, (stop - start$0 | 0) - 1 | 0), stop + 1 | 0]; break; } diff --git a/compiler/tests-compiler/mutable_closure.ml b/compiler/tests-compiler/mutable_closure.ml index e8c34e902b..49f6c3314f 100644 --- a/compiler/tests-compiler/mutable_closure.ml +++ b/compiler/tests-compiler/mutable_closure.ml @@ -91,6 +91,10 @@ let%expect_test _ = let indirect = ref [] + let list_map = List.map + (* Avoid to expose the offset of stdlib modules *) + let () = ignore (list_map (fun f -> f ()) []) + let fun1 () = for i = 0 to 3 do let rec f = function @@ -105,7 +109,7 @@ let%expect_test _ = direct := f i :: !direct; indirect := (fun () -> f i) :: !indirect done; - let indirect = List.map (fun f -> f ()) !indirect in + let indirect = list_map (fun f -> f ()) !indirect in let direct = !direct in assert (indirect = direct) |} @@ -160,12 +164,12 @@ let%expect_test _ = var _g_ = i + 1 | 0; if(3 === i){ var - _c_ = indirect[1], - _d_ = function(f){return caml_call1(f, 0);}, - indirect$0 = caml_call2(Stdlib_List[19], _d_, _c_), + _d_ = indirect[1], + indirect$0 = + caml_call2(list_map, function(f){return caml_call1(f, 0);}, _d_), direct$0 = direct[1]; if(runtime.caml_equal(indirect$0, direct$0)) return 0; - throw caml_maybe_attach_backtrace([0, Assert_failure, _b_], 1); + throw caml_maybe_attach_backtrace([0, Assert_failure, _c_], 1); } var i = _g_; } diff --git a/compiler/tests-jsoo/test_marshal.ml b/compiler/tests-jsoo/test_marshal.ml index 734f0c2145..454e3a6571 100644 --- a/compiler/tests-jsoo/test_marshal.ml +++ b/compiler/tests-jsoo/test_marshal.ml @@ -150,7 +150,9 @@ let%expect_test _ = match Sys.backend_type with | Other "js_of_ocaml" -> Marshal.from_string data 0 | Other _ | Native | Bytecode -> - if ocaml_5_1 then Marshal.from_string data 0 else String.make 10000 'c' + if ocaml_5_1 && not (Sys.win32 || Sys.cygwin) + then Marshal.from_string data 0 + else String.make 10000 'c' in Printf.printf "%s ... (%d)\n" (String.sub s 0 20) (String.length s); [%expect {| cccccccccccccccccccc ... (10000) |}] diff --git a/compiler/tests-toplevel/test_toplevel.ml b/compiler/tests-toplevel/test_toplevel.ml index fde3c45798..8ab784373e 100644 --- a/compiler/tests-toplevel/test_toplevel.ml +++ b/compiler/tests-toplevel/test_toplevel.ml @@ -10,6 +10,7 @@ Missing_module.f;; let lexbuf = Lexing.from_string content in while true do try + Location.reset (); let phr = !Toploop.parse_toplevel_phrase lexbuf in if not (Toploop.execute_phrase true Format.std_formatter phr) then raise Exit with diff --git a/ppx/ppx_deriving_json/tests/dune b/ppx/ppx_deriving_json/tests/dune index c16ec75321..d2607ddee2 100644 --- a/ppx/ppx_deriving_json/tests/dune +++ b/ppx/ppx_deriving_json/tests/dune @@ -26,12 +26,16 @@ (rule (alias runtest) + (enabled_if + (>= %{ocaml_version} 5.1)) ;; (package js_of_ocaml-ppx) (action (diff ppx.mlt ppx.mlt.corrected))) (rule (alias runtest) + (enabled_if + (>= %{ocaml_version} 5.1)) ;; (package js_of_ocaml-ppx) (action (diff gen.mlt gen.mlt.corrected))) diff --git a/ppx/ppx_deriving_json/tests/gen.mlt b/ppx/ppx_deriving_json/tests/gen.mlt index ed52a94468..80a3abe287 100644 --- a/ppx/ppx_deriving_json/tests/gen.mlt +++ b/ppx/ppx_deriving_json/tests/gen.mlt @@ -21,18 +21,18 @@ type int_list = int list[@@deriving json] include struct let _ = fun (_ : int_list) -> () - let rec (int_list_of_json : Deriving_Json_lexer.lexbuf -> int_list) = + let rec int_list_of_json : Deriving_Json_lexer.lexbuf -> int_list = fun buf -> Deriving_Json.read_list (fun buf -> Deriving_Json.Json_int.read buf) buf let _ = int_list_of_json - let rec (int_list_to_json : Buffer.t -> int_list -> unit) = + let rec int_list_to_json : Buffer.t -> int_list -> unit = fun buf -> fun a -> Deriving_Json.write_list (fun buf -> fun a -> Deriving_Json.Json_int.write buf a) buf a let _ = int_list_to_json - let (int_list_json : int_list Deriving_Json.t) = + let int_list_json : int_list Deriving_Json.t = Deriving_Json.make int_list_to_json int_list_of_json let _ = int_list_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -51,18 +51,18 @@ type int_ref = int ref[@@deriving json] include struct let _ = fun (_ : int_ref) -> () - let rec (int_ref_of_json : Deriving_Json_lexer.lexbuf -> int_ref) = + let rec int_ref_of_json : Deriving_Json_lexer.lexbuf -> int_ref = fun buf -> Deriving_Json.read_ref (fun buf -> Deriving_Json.Json_int.read buf) buf let _ = int_ref_of_json - let rec (int_ref_to_json : Buffer.t -> int_ref -> unit) = + let rec int_ref_to_json : Buffer.t -> int_ref -> unit = fun buf -> fun a -> Deriving_Json.write_ref (fun buf -> fun a -> Deriving_Json.Json_int.write buf a) buf a let _ = int_ref_to_json - let (int_ref_json : int_ref Deriving_Json.t) = + let int_ref_json : int_ref Deriving_Json.t = Deriving_Json.make int_ref_to_json int_ref_of_json let _ = int_ref_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -81,18 +81,18 @@ type int_option = int option[@@deriving json] include struct let _ = fun (_ : int_option) -> () - let rec (int_option_of_json : Deriving_Json_lexer.lexbuf -> int_option) = + let rec int_option_of_json : Deriving_Json_lexer.lexbuf -> int_option = fun buf -> Deriving_Json.read_option (fun buf -> Deriving_Json.Json_int.read buf) buf let _ = int_option_of_json - let rec (int_option_to_json : Buffer.t -> int_option -> unit) = + let rec int_option_to_json : Buffer.t -> int_option -> unit = fun buf -> fun a -> Deriving_Json.write_option (fun buf -> fun a -> Deriving_Json.Json_int.write buf a) buf a let _ = int_option_to_json - let (int_option_json : int_option Deriving_Json.t) = + let int_option_json : int_option Deriving_Json.t = Deriving_Json.make int_option_to_json int_option_of_json let _ = int_option_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -111,18 +111,18 @@ type int_array = int array[@@deriving json] include struct let _ = fun (_ : int_array) -> () - let rec (int_array_of_json : Deriving_Json_lexer.lexbuf -> int_array) = + let rec int_array_of_json : Deriving_Json_lexer.lexbuf -> int_array = fun buf -> Deriving_Json.read_array (fun buf -> Deriving_Json.Json_int.read buf) buf let _ = int_array_of_json - let rec (int_array_to_json : Buffer.t -> int_array -> unit) = + let rec int_array_to_json : Buffer.t -> int_array -> unit = fun buf -> fun a -> Deriving_Json.write_array (fun buf -> fun a -> Deriving_Json.Json_int.write buf a) buf a let _ = int_array_to_json - let (int_array_json : int_array Deriving_Json.t) = + let int_array_json : int_array Deriving_Json.t = Deriving_Json.make int_array_to_json int_array_of_json let _ = int_array_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -141,7 +141,7 @@ type tuple1 = (int * string)[@@deriving json] include struct let _ = fun (_ : tuple1) -> () - let rec (tuple1_of_json : Deriving_Json_lexer.lexbuf -> tuple1) = + let rec tuple1_of_json : Deriving_Json_lexer.lexbuf -> tuple1 = fun buf -> Deriving_Json_lexer.read_lbracket buf; ignore (Deriving_Json_lexer.read_tag_1 0 buf); @@ -151,7 +151,7 @@ include (let b = Deriving_Json.Json_string.read buf in Deriving_Json_lexer.read_rbracket buf; (a, b))) let _ = tuple1_of_json - let rec (tuple1_to_json : Buffer.t -> tuple1 -> unit) = + let rec tuple1_to_json : Buffer.t -> tuple1 -> unit = fun buf -> fun a -> let (a, b) = a in @@ -161,7 +161,7 @@ include Deriving_Json.Json_string.write buf b); Buffer.add_string buf "]" let _ = tuple1_to_json - let (tuple1_json : tuple1 Deriving_Json.t) = + let tuple1_json : tuple1 Deriving_Json.t = Deriving_Json.make tuple1_to_json tuple1_of_json let _ = tuple1_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -189,7 +189,7 @@ type variant1 = include struct let _ = fun (_ : variant1) -> () - let rec (variant1_of_json : Deriving_Json_lexer.lexbuf -> variant1) = + let rec variant1_of_json : Deriving_Json_lexer.lexbuf -> variant1 = fun buf -> match Deriving_Json_lexer.read_case buf with | `NCst 0 -> @@ -201,7 +201,7 @@ include | `Cst 0 -> A | _ -> Deriving_Json_lexer.tag_error ~typename:"" buf let _ = variant1_of_json - let rec (variant1_to_json : Buffer.t -> variant1 -> unit) = + let rec variant1_to_json : Buffer.t -> variant1 -> unit = fun buf -> function | D a -> @@ -212,7 +212,7 @@ include | B -> Deriving_Json.Json_int.write buf 1 | A -> Deriving_Json.Json_int.write buf 0 let _ = variant1_to_json - let (variant1_json : variant1 Deriving_Json.t) = + let variant1_json : variant1 Deriving_Json.t = Deriving_Json.make variant1_to_json variant1_of_json let _ = variant1_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -236,7 +236,7 @@ type variant2 = include struct let _ = fun (_ : variant2) -> () - let rec (variant2_of_json : Deriving_Json_lexer.lexbuf -> variant2) = + let rec variant2_of_json : Deriving_Json_lexer.lexbuf -> variant2 = fun buf -> match Deriving_Json_lexer.read_case buf with | `NCst 1 -> @@ -249,7 +249,7 @@ include Deriving_Json_lexer.read_rbracket buf; D a)) | _ -> Deriving_Json_lexer.tag_error ~typename:"" buf let _ = variant2_of_json - let rec (variant2_to_json : Buffer.t -> variant2 -> unit) = + let rec variant2_to_json : Buffer.t -> variant2 -> unit = fun buf -> function | E a -> @@ -262,7 +262,7 @@ include Deriving_Json.Json_string.write buf a); Buffer.add_string buf "]") let _ = variant2_to_json - let (variant2_json : variant2 Deriving_Json.t) = + let variant2_json : variant2 Deriving_Json.t = Deriving_Json.make variant2_to_json variant2_of_json let _ = variant2_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -288,7 +288,7 @@ type record1 = { include struct let _ = fun (_ : record1) -> () - let rec (record1_of_json : Deriving_Json_lexer.lexbuf -> record1) = + let rec record1_of_json : Deriving_Json_lexer.lexbuf -> record1 = fun buf -> Deriving_Json_lexer.read_lbracket buf; ignore (Deriving_Json_lexer.read_tag_2 0 254 buf); @@ -301,7 +301,7 @@ include Deriving_Json.read_option (fun buf -> record1_of_json buf) buf in Deriving_Json_lexer.read_rbracket buf; { f = a; g = b; h = c }))) let _ = record1_of_json - let rec (record1_to_json : Buffer.t -> record1 -> unit) = + let rec record1_to_json : Buffer.t -> record1 -> unit = fun buf -> fun { f; g; h } -> Buffer.add_string buf "[0"; @@ -313,7 +313,7 @@ include (fun buf -> fun a -> record1_to_json buf a) buf h); Buffer.add_string buf "]" let _ = record1_to_json - let (record1_json : record1 Deriving_Json.t) = + let record1_json : record1 Deriving_Json.t = Deriving_Json.make record1_to_json record1_of_json let _ = record1_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -335,11 +335,11 @@ type poly1 = [ `A | `B of string ][@@deriving json] include struct let _ = fun (_ : poly1) -> () - let rec (poly1_recognize : [ `NCst of int | `Cst of int ] -> bool) = + let rec poly1_recognize : [ `NCst of int | `Cst of int ] -> bool = function | `Cst 65 -> true | `NCst 66 -> true | _ -> false let _ = poly1_recognize - let rec (poly1_of_json_with_tag : - Deriving_Json_lexer.lexbuf -> [ `NCst of int | `Cst of int ] -> poly1) + let rec poly1_of_json_with_tag : + Deriving_Json_lexer.lexbuf -> [ `NCst of int | `Cst of int ] -> poly1 = fun buf -> function @@ -349,12 +349,12 @@ include (let v = Deriving_Json.Json_string.read buf in Deriving_Json_lexer.read_rbracket buf; `B v)) | _ -> Deriving_Json_lexer.tag_error ~typename:"" buf - and (poly1_of_json : Deriving_Json_lexer.lexbuf -> poly1) = + and poly1_of_json : Deriving_Json_lexer.lexbuf -> poly1 = fun buf -> poly1_of_json_with_tag buf (Deriving_Json_lexer.read_vcase buf) let _ = poly1_of_json_with_tag and _ = poly1_of_json - let rec (poly1_to_json : Buffer.t -> [> poly1] -> unit) = + let rec poly1_to_json : Buffer.t -> [> poly1] -> unit = fun buf -> fun a -> match a with @@ -368,7 +368,7 @@ include Deriving_Json.Json_string.write buf b); Buffer.add_string buf "]") let _ = poly1_to_json - let (poly1_json : poly1 Deriving_Json.t) = + let poly1_json : poly1 Deriving_Json.t = Deriving_Json.make poly1_to_json poly1_of_json let _ = poly1_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -394,14 +394,14 @@ type poly2 = [ | poly1 | `C of int ][@@deriving json] include struct let _ = fun (_ : poly2) -> () - let rec (poly2_recognize : [ `NCst of int | `Cst of int ] -> bool) = + let rec poly2_recognize : [ `NCst of int | `Cst of int ] -> bool = function | x when poly1_recognize x -> true | `NCst 67 -> true | _ -> false let _ = poly2_recognize - let rec (poly2_of_json_with_tag : - Deriving_Json_lexer.lexbuf -> [ `NCst of int | `Cst of int ] -> poly2) + let rec poly2_of_json_with_tag : + Deriving_Json_lexer.lexbuf -> [ `NCst of int | `Cst of int ] -> poly2 = fun buf -> function @@ -412,12 +412,12 @@ include (let v = Deriving_Json.Json_int.read buf in Deriving_Json_lexer.read_rbracket buf; `C v)) | _ -> Deriving_Json_lexer.tag_error ~typename:"" buf - and (poly2_of_json : Deriving_Json_lexer.lexbuf -> poly2) = + and poly2_of_json : Deriving_Json_lexer.lexbuf -> poly2 = fun buf -> poly2_of_json_with_tag buf (Deriving_Json_lexer.read_vcase buf) let _ = poly2_of_json_with_tag and _ = poly2_of_json - let rec (poly2_to_json : Buffer.t -> [> poly2] -> unit) = + let rec poly2_to_json : Buffer.t -> [> poly2] -> unit = fun buf -> fun a -> match a with @@ -431,7 +431,7 @@ include Deriving_Json.Json_int.write buf b); Buffer.add_string buf "]") let _ = poly2_to_json - let (poly2_json : poly2 Deriving_Json.t) = + let poly2_json : poly2 Deriving_Json.t = Deriving_Json.make poly2_to_json poly2_of_json let _ = poly2_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -464,8 +464,8 @@ type inline_record = include struct let _ = fun (_ : inline_record) -> () - let rec (inline_record_of_json : - Deriving_Json_lexer.lexbuf -> inline_record) = + let rec inline_record_of_json : + Deriving_Json_lexer.lexbuf -> inline_record = fun buf -> match Deriving_Json_lexer.read_case buf with | `NCst 1 -> @@ -480,7 +480,7 @@ include Deriving_Json_lexer.read_rbracket buf; I { name = a; age = b }))) | _ -> Deriving_Json_lexer.tag_error ~typename:"" buf let _ = inline_record_of_json - let rec (inline_record_to_json : Buffer.t -> inline_record -> unit) = + let rec inline_record_to_json : Buffer.t -> inline_record -> unit = fun buf -> function | J { empty } -> @@ -496,7 +496,7 @@ include Deriving_Json.Json_int.write buf age); Buffer.add_string buf "]") let _ = inline_record_to_json - let (inline_record_json : inline_record Deriving_Json.t) = + let inline_record_json : inline_record Deriving_Json.t = Deriving_Json.make inline_record_to_json inline_record_of_json let _ = inline_record_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -516,22 +516,21 @@ type 'a t = 'a array[@@deriving json] include struct let _ = fun (_ : 'a t) -> () - let rec (of_json : + let rec of_json : (Deriving_Json_lexer.lexbuf -> 'a) -> - Deriving_Json_lexer.lexbuf -> 'a t) + Deriving_Json_lexer.lexbuf -> 'a t = fun poly_a -> fun buf -> Deriving_Json.read_array (fun buf -> poly_a buf) buf let _ = of_json - let rec (to_json : (Buffer.t -> 'a -> unit) -> Buffer.t -> 'a t -> unit) - = + let rec to_json : (Buffer.t -> 'a -> unit) -> Buffer.t -> 'a t -> unit = fun poly_a -> fun buf -> fun a -> Deriving_Json.write_array (fun buf -> fun a -> poly_a buf a) buf a let _ = to_json - let (json : 'a Deriving_Json.t -> 'a t Deriving_Json.t) = + let json : 'a Deriving_Json.t -> 'a t Deriving_Json.t = fun poly_a -> Deriving_Json.make (to_json (Deriving_Json.write poly_a)) (of_json (Deriving_Json.read poly_a)) @@ -553,10 +552,10 @@ type ('a, 'b) t = ('a array * 'b)[@@deriving json] include struct let _ = fun (_ : ('a, 'b) t) -> () - let rec (of_json : + let rec of_json : (Deriving_Json_lexer.lexbuf -> 'a) -> (Deriving_Json_lexer.lexbuf -> 'b) -> - Deriving_Json_lexer.lexbuf -> ('a, 'b) t) + Deriving_Json_lexer.lexbuf -> ('a, 'b) t = fun poly_a -> fun poly_b -> @@ -569,9 +568,9 @@ include (let b = poly_b buf in Deriving_Json_lexer.read_rbracket buf; (a, b))) let _ = of_json - let rec (to_json : + let rec to_json : (Buffer.t -> 'a -> unit) -> - (Buffer.t -> 'b -> unit) -> Buffer.t -> ('a, 'b) t -> unit) + (Buffer.t -> 'b -> unit) -> Buffer.t -> ('a, 'b) t -> unit = fun poly_a -> fun poly_b -> @@ -586,8 +585,8 @@ include poly_b buf b); Buffer.add_string buf "]" let _ = to_json - let (json : - 'a Deriving_Json.t -> 'b Deriving_Json.t -> ('a, 'b) t Deriving_Json.t) + let json : + 'a Deriving_Json.t -> 'b Deriving_Json.t -> ('a, 'b) t Deriving_Json.t = fun poly_a -> fun poly_b -> @@ -621,20 +620,20 @@ type t = include struct let _ = fun (_ : t) -> () - let rec (of_json : Deriving_Json_lexer.lexbuf -> t) = + let rec of_json : Deriving_Json_lexer.lexbuf -> t = fun buf -> match Deriving_Json_lexer.read_case buf with | `Cst 1 -> B | `Cst 0 -> A | _ -> Deriving_Json_lexer.tag_error ~typename:"" buf let _ = of_json - let rec (to_json : Buffer.t -> t -> unit) = + let rec to_json : Buffer.t -> t -> unit = fun buf -> function | B -> Deriving_Json.Json_int.write buf 1 | A -> Deriving_Json.Json_int.write buf 0 let _ = to_json - let (json : t Deriving_Json.t) = Deriving_Json.make to_json of_json + let json : t Deriving_Json.t = Deriving_Json.make to_json of_json let _ = json end[@@ocaml.doc "@inline"][@@merlin.hide ];; type t = A | B @@ -704,13 +703,13 @@ type id' = int[@@deriving json] include struct let _ = fun (_ : id') -> () - let rec (id'_of_json : Deriving_Json_lexer.lexbuf -> id') = + let rec id'_of_json : Deriving_Json_lexer.lexbuf -> id' = fun buf -> Deriving_Json.Json_int.read buf let _ = id'_of_json - let rec (id'_to_json : Buffer.t -> id' -> unit) = + let rec id'_to_json : Buffer.t -> id' -> unit = fun buf -> fun a -> Deriving_Json.Json_int.write buf a let _ = id'_to_json - let (id'_json : id' Deriving_Json.t) = + let id'_json : id' Deriving_Json.t = Deriving_Json.make id'_to_json id'_of_json let _ = id'_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; @@ -734,14 +733,14 @@ type poly3 = include struct let _ = fun (_ : poly3) -> () - let rec (poly3_recognize : [ `NCst of int | `Cst of int ] -> bool) = + let rec poly3_recognize : [ `NCst of int | `Cst of int ] -> bool = function | x when poly1_recognize x -> true | `NCst 67 -> true | _ -> false let _ = poly3_recognize - let rec (poly3_of_json_with_tag : - Deriving_Json_lexer.lexbuf -> [ `NCst of int | `Cst of int ] -> poly3) + let rec poly3_of_json_with_tag : + Deriving_Json_lexer.lexbuf -> [ `NCst of int | `Cst of int ] -> poly3 = fun buf -> function @@ -772,12 +771,12 @@ include (Deriving_Json_lexer.read_vcase buf) in Deriving_Json_lexer.read_rbracket buf; `C v)) | _ -> Deriving_Json_lexer.tag_error ~typename:"" buf - and (poly3_of_json : Deriving_Json_lexer.lexbuf -> poly3) = + and poly3_of_json : Deriving_Json_lexer.lexbuf -> poly3 = fun buf -> poly3_of_json_with_tag buf (Deriving_Json_lexer.read_vcase buf) let _ = poly3_of_json_with_tag and _ = poly3_of_json - let rec (poly3_to_json : Buffer.t -> [> poly3] -> unit) = + let rec poly3_to_json : Buffer.t -> [> poly3] -> unit = fun buf -> fun a -> match a with @@ -815,7 +814,7 @@ include Buffer.add_string buf "]"))); Buffer.add_string buf "]") let _ = poly3_to_json - let (poly3_json : poly3 Deriving_Json.t) = + let poly3_json : poly3 Deriving_Json.t = Deriving_Json.make poly3_to_json poly3_of_json let _ = poly3_json end[@@ocaml.doc "@inline"][@@merlin.hide ];; diff --git a/tools/toplevel_expect/toplevel_expect_test.ml-default b/tools/toplevel_expect/toplevel_expect_test.ml-default index 5c9a5d0376..702e512a96 100644 --- a/tools/toplevel_expect/toplevel_expect_test.ml-default +++ b/tools/toplevel_expect/toplevel_expect_test.ml-default @@ -206,7 +206,12 @@ let eval_expectation expectation ~output = if s.str = output then None else - let s = { s with str = output } in + let trimmed = String.trim output in + let normalized = if String.exists ~f:(function '\n' -> true | _ -> false) output + then "\n" ^ trimmed ^ "\n" + else trimmed + in + let s = { s with str = normalized } in Some ( if !Clflags.principal then { expectation with principal = s }