diff --git a/CHANGELOG.md b/CHANGELOG.md index ad9d276661..633db87633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Removed empty line at the end of `switch` statement - Removed empty `default` case from `switch` statement in the generated code - Optimised the Type Extension runtime code and removed trailing `/1` from `RE_EXN_ID` https://github.com/rescript-lang/rescript-compiler/pull/6958 +- Compact output for anonymous functions. https://github.com/rescript-lang/rescript-compiler/pull/6945 #### :bug: Bug Fix - Fix issue where long layout break added a trailing comma in partial application `...`. https://github.com/rescript-lang/rescript-compiler/pull/6949 diff --git a/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js b/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js index e2a8d1556e..575038f3f6 100644 --- a/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js +++ b/jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js @@ -33,7 +33,7 @@ let Gpr3987ReproOk = { make: make }; -React.createElement(make, makeProps("test", (function (param, param$1) { +React.createElement(make, makeProps("test", ((param, param$1) => { }), undefined)); @@ -47,7 +47,7 @@ let Gpr3987ReproOk2 = { React.createElement(Gpr_3987_test$Gpr3987ReproOk2, { value: "test", - onChange: (function (param, param$1) { + onChange: ((param, param$1) => { }) }); @@ -62,7 +62,7 @@ let Gpr3987ReproError = { React.createElement(Gpr_3987_test$Gpr3987ReproError, { value: "test", - onChange: (function (param, param$1) { + onChange: ((param, param$1) => { }) }); diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index a09885ae2f..44fdebef6b 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -163,7 +163,7 @@ let raw_snippet_exp_simple_enough (s : string) = let exp_need_paren (e : J.expression) = match e.expression_desc with (* | Caml_uninitialized_obj _ *) - | Call ({ expression_desc = Fun _ | Raw_js_code _ }, _, _) -> true + | Call ({ expression_desc = Raw_js_code _ }, _, _) -> true | Raw_js_code { code_info = Exp _ } | Fun _ | Caml_block @@ -360,6 +360,12 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t) ~fn_stat (* the context will be continued after this function *) let outer_cxt = Ext_pp_scope.merge cxt set_env in + (* whether the function output can use arrow syntax *) + let arrow = match fn_state with + | Name_top _ -> false + | _ -> not is_method + in + (* the context used to be printed inside this function when printing a function, @@ -385,10 +391,31 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t) ~fn_stat function_body ?directive ~return_unit cxt f b)) else let cxt = - P.paren_group f 1 (fun _ -> formal_parameter_list inner_cxt f l) + match l with + | [ single ] when arrow -> + Ext_pp_scope.ident inner_cxt f single + | l -> + P.paren_group f 1 (fun _ -> formal_parameter_list inner_cxt f l) in P.space f; - P.brace_vgroup f 1 (fun _ -> function_body ?directive ~return_unit cxt f b) + if arrow then ( + P.string f (L.arrow); + P.space f; + ); + match b with + | [ { statement_desc = Return { expression_desc = Undefined _ } } ] + when arrow + -> + P.string f "{"; + P.string f "}"; + + | [ { statement_desc = Return e } ] | [ { statement_desc = Exp e } ] + when arrow && directive == None + -> (if exp_need_paren e then P.paren_group f 0 else P.group f 0) + (fun _ -> ignore (expression ~level:0 cxt f e)) + + | _ -> + P.brace_vgroup f 1 (fun _ -> function_body ?directive ~return_unit cxt f b) in let enclose () = let handle () = @@ -396,24 +423,18 @@ and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t) ~fn_stat match fn_state with | Is_return -> return_sp f; - P.string f (L.function_async ~async); - P.space f; + P.string f (L.function_ ~async ~arrow); + param_body () + | No_name _ -> + P.string f (L.function_ ~async ~arrow); param_body () - | No_name { single_arg } -> - (* see # 1692, add a paren for annoymous function for safety *) - P.cond_paren_group f (not single_arg) (fun _ -> - P.string f (L.function_async ~async); - P.space f; - param_body ()) | Name_non_top x -> ignore (pp_var_assign inner_cxt f x : cxt); - P.string f (L.function_async ~async); - P.space f; + P.string f (L.function_ ~async ~arrow); param_body (); semi f | Name_top x -> - P.string f (L.function_async ~async); - P.space f; + P.string f (L.function_ ~async ~arrow); ignore (Ext_pp_scope.ident inner_cxt f x : cxt); param_body ()) in @@ -504,8 +525,9 @@ and expression_desc cxt ~(level : int) f x : cxt = expression ~level:0 cxt f e2) | Fun { is_method; params; body; env; return_unit; async; directive } -> (* TODO: dump for comments *) - pp_function ?directive ~is_method cxt f ~fn_state:default_fn_exp_state params body - env ~return_unit ~async + pp_function ?directive ~is_method ~return_unit ~async + ~fn_state:default_fn_exp_state + cxt f params body env (* TODO: when [e] is [Js_raw_code] with arity print it in a more precise way @@ -520,7 +542,11 @@ and expression_desc cxt ~(level : int) f x : cxt = P.group f 0 (fun _ -> match (info, el) with | { arity = Full }, _ | _, [] -> - let cxt = expression ~level:15 cxt f e in + let cxt = + P.cond_paren_group f + (match e.expression_desc with Fun _ -> true | _ -> false) + (fun () -> expression ~level:15 cxt f e ) + in P.paren_group f 0 (fun _ -> match el with | [ @@ -538,9 +564,9 @@ and expression_desc cxt ~(level : int) f x : cxt = }; }; ] -> - pp_function ?directive ~is_method ~return_unit ~async cxt f + pp_function ?directive ~is_method ~return_unit ~async ~fn_state:(No_name { single_arg = true }) - params body env + cxt f params body env | _ -> let el = match el with | [e] when e.expression_desc = Undefined {is_unit = true} -> @@ -941,9 +967,9 @@ and variable_declaration top cxt f (variable : J.variable_declaration) : cxt = | _ -> ( match e.expression_desc with | Fun { is_method; params; body; env; return_unit; async; directive } -> - pp_function ?directive ~is_method cxt f ~return_unit ~async + pp_function ?directive ~is_method ~return_unit ~async ~fn_state:(if top then Name_top name else Name_non_top name) - params body env + cxt f params body env | _ -> let cxt = pp_var_assign cxt f name in let cxt = expression ~level:1 cxt f e in @@ -1151,8 +1177,9 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt = match e.expression_desc with | Fun { is_method; params; body; env; return_unit; async; directive } -> let cxt = - pp_function ?directive ~return_unit ~is_method ~async cxt f ~fn_state:Is_return - params body env + pp_function ?directive ~return_unit ~is_method ~async + ~fn_state:Is_return + cxt f params body env in semi f; cxt diff --git a/jscomp/core/js_dump_lit.ml b/jscomp/core/js_dump_lit.ml index ee8b5bbe28..c341c7f1c6 100644 --- a/jscomp/core/js_dump_lit.ml +++ b/jscomp/core/js_dump_lit.ml @@ -22,12 +22,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - let await = "await" -let function_ = "function" +let function_ ~async ~arrow = + match (async, arrow) with + | (true, true) -> "async " + | (false, true) -> "" + | (true, false) -> "async function " + | (false, false) -> "function " -let function_async ~async = if async then "async function" else "function" +let arrow = "=>" let let_ = "let" diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index 229a99337b..ebbd80d281 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -207,7 +207,7 @@ let unit : t = { expression_desc = Undefined {is_unit = true}; comment = None } [Js_fun_env.empty] is a mutable state .. *) -let ocaml_fun ?comment ?immutable_mask ~return_unit ~async ~one_unit_arg ?directive params body : t = +let ocaml_fun ?comment ?immutable_mask ?directive ~return_unit ~async ~one_unit_arg params body : t = let params = if one_unit_arg then [] else params in let len = List.length params in { diff --git a/jscomp/core/js_exp_make.mli b/jscomp/core/js_exp_make.mli index 63b50a916d..2e1cd072bb 100644 --- a/jscomp/core/js_exp_make.mli +++ b/jscomp/core/js_exp_make.mli @@ -88,10 +88,10 @@ val str : ?delim: J.delim -> ?comment: string -> string -> t val ocaml_fun : ?comment:string -> ?immutable_mask:bool array -> + ?directive:string -> return_unit:bool -> async:bool -> one_unit_arg:bool -> - ?directive:string -> J.ident list -> J.block -> t diff --git a/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js b/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js index 447f327d1d..da238ff4d4 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ErrorHandler.res.js @@ -2,9 +2,7 @@ function Make($$Error) { - let notify = function (x) { - return $$Error.notification(x); - }; + let notify = x => $$Error.notification(x); return { notify: notify }; diff --git a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js index 48388edd95..1a0a3edf28 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Hooks.res.js @@ -6,35 +6,25 @@ import * as ImportHookDefault from "./ImportHookDefault.res.js"; function Hooks(Props) { let vehicle = Props.vehicle; - let match = React.useState(function () { - return 0; - }); + let match = React.useState(() => 0); let setCount = match[1]; let count = match[0]; return React.createElement("div", undefined, React.createElement("p", undefined, "Hooks example " + (vehicle.name + (" clicked " + (String(count) + " times")))), React.createElement("button", { - onClick: (function (param) { - setCount(function (param) { - return count + 1 | 0; - }); - }) + onClick: param => setCount(param => count + 1 | 0) }, "Click me"), React.createElement(ImportHooks.make, { person: { name: "Mary", age: 71 }, children: null, - renderMe: (function (x) { - return x.randomString; - }) + renderMe: x => x.randomString }, "child1", "child2"), React.createElement(ImportHookDefault.make, { person: { name: "DefaultImport", age: 42 }, children: null, - renderMe: (function (x) { - return x.randomString; - }) + renderMe: x => x.randomString }, "child1", "child2")); } @@ -114,7 +104,7 @@ let WithRename = { }; function makeWithRef(vehicle) { - return function (ref) { + return ref => { if (ref == null) { return null; } else { @@ -133,15 +123,11 @@ let WithRef = { makeWithRef: Hooks$WithRef$makeWithRef }; -let testForwardRef = React.forwardRef(function (x, y) { - return makeWithRef(x.vehicle)(y); -}); +let testForwardRef = React.forwardRef((x, y) => makeWithRef(x.vehicle)(y)); -let input = React.forwardRef(function (r, ref) { - return React.createElement("div", { - ref: ref - }, r.x); -}); +let input = React.forwardRef((r, ref) => React.createElement("div", { + ref: ref +}, r.x)); let ForwardRef = { input: input diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js index 8f0f909427..d056c1477f 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ImmutableArray.res.js @@ -51,17 +51,13 @@ let rangeBy = Belt_Array.rangeBy; let makeByU = Belt_Array.makeByU; function makeBy(c, f) { - return Belt_Array.makeBy(c, (function (x) { - return f(x); - })); + return Belt_Array.makeBy(c, x => f(x)); } let makeByAndShuffleU = Belt_Array.makeByAndShuffleU; function makeByAndShuffle(c, f) { - return Belt_Array.makeByAndShuffle(c, (function (x) { - return f(x); - })); + return Belt_Array.makeByAndShuffle(c, x => f(x)); } let zip = Belt_Array.zip; @@ -69,9 +65,7 @@ let zip = Belt_Array.zip; let zipByU = Belt_Array.zipByU; function zipBy(a1, a2, f) { - return Belt_Array.zipBy(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.zipBy(a1, a2, (x, y) => f(x, y)); } let unzip = Belt_Array.unzip; @@ -91,129 +85,97 @@ function copy(a) { let forEachU = Belt_Array.forEachU; function forEach(a, f) { - Belt_Array.forEach(a, (function (x) { - f(x); - })); + Belt_Array.forEach(a, x => f(x)); } let mapU = Belt_Array.mapU; function map(a, f) { - return Belt_Array.map(a, (function (x) { - return f(x); - })); + return Belt_Array.map(a, x => f(x)); } let keepWithIndexU = Belt_Array.keepWithIndexU; function keepWithIndex(a, f) { - return Belt_Array.keepWithIndex(a, (function (x, y) { - return f(x, y); - })); + return Belt_Array.keepWithIndex(a, (x, y) => f(x, y)); } let keepMapU = Belt_Array.keepMapU; function keepMap(a, f) { - return Belt_Array.keepMap(a, (function (x) { - return f(x); - })); + return Belt_Array.keepMap(a, x => f(x)); } let forEachWithIndexU = Belt_Array.forEachWithIndexU; function forEachWithIndex(a, f) { - Belt_Array.forEachWithIndex(a, (function (x, y) { - f(x, y); - })); + Belt_Array.forEachWithIndex(a, (x, y) => f(x, y)); } let mapWithIndexU = Belt_Array.mapWithIndexU; function mapWithIndex(a, f) { - return Belt_Array.mapWithIndex(a, (function (x, y) { - return f(x, y); - })); + return Belt_Array.mapWithIndex(a, (x, y) => f(x, y)); } let partitionU = Belt_Array.partitionU; function partition(a, f) { - return Belt_Array.partition(a, (function (x) { - return f(x); - })); + return Belt_Array.partition(a, x => f(x)); } let reduceU = Belt_Array.reduceU; function reduce(a, b, f) { - return Belt_Array.reduce(a, b, (function (x, y) { - return f(x, y); - })); + return Belt_Array.reduce(a, b, (x, y) => f(x, y)); } let reduceReverseU = Belt_Array.reduceReverseU; function reduceReverse(a, b, f) { - return Belt_Array.reduceReverse(a, b, (function (x, y) { - return f(x, y); - })); + return Belt_Array.reduceReverse(a, b, (x, y) => f(x, y)); } let reduceReverse2U = Belt_Array.reduceReverse2U; function reduceReverse2(a1, a2, c, f) { - return Belt_Array.reduceReverse2(a1, a2, c, (function (x, y, z) { - return f(x, y, z); - })); + return Belt_Array.reduceReverse2(a1, a2, c, (x, y, z) => f(x, y, z)); } let someU = Belt_Array.someU; function some(a, f) { - return Belt_Array.some(a, (function (x) { - return f(x); - })); + return Belt_Array.some(a, x => f(x)); } let everyU = Belt_Array.everyU; function every(a, f) { - return Belt_Array.every(a, (function (x) { - return f(x); - })); + return Belt_Array.every(a, x => f(x)); } let every2U = Belt_Array.every2U; function every2(a1, a2, f) { - return Belt_Array.every2(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.every2(a1, a2, (x, y) => f(x, y)); } let some2U = Belt_Array.some2U; function some2(a1, a2, f) { - return Belt_Array.some2(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.some2(a1, a2, (x, y) => f(x, y)); } let cmpU = Belt_Array.cmpU; function cmp(a1, a2, f) { - return Belt_Array.cmp(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.cmp(a1, a2, (x, y) => f(x, y)); } let eqU = Belt_Array.eqU; function eq(a1, a2, f) { - return Belt_Array.eq(a1, a2, (function (x, y) { - return f(x, y); - })); + return Belt_Array.eq(a1, a2, (x, y) => f(x, y)); } let $$Array$1 = { diff --git a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js index 84f321dd72..6e617f004d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/ImportJsValue.res.js @@ -51,9 +51,7 @@ function higherOrder(prim) { return ImportJsValueGen$1.higherOrder(prim); } -let returnedFromHigherOrder = ImportJsValueGen$1.higherOrder(function (prim0, prim1) { - return prim0 + prim1 | 0; -}); +let returnedFromHigherOrder = ImportJsValueGen$1.higherOrder((prim0, prim1) => prim0 + prim1 | 0); function convertVariant(prim) { return ImportJsValueGen$1.convertVariant(prim); diff --git a/jscomp/gentype_tests/typescript-react-example/src/Records.res.js b/jscomp/gentype_tests/typescript-react-example/src/Records.res.js index 36bff49322..8ad1df10ae 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Records.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Records.res.js @@ -6,9 +6,7 @@ import * as Belt_Option from "rescript/lib/es6/belt_Option.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; function computeArea(param) { - return Math.imul(Math.imul(param.x, param.y), Belt_Option.mapWithDefault(param.z, 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(param.x, param.y), Belt_Option.mapWithDefault(param.z, 1, n => n)); } function coord2d(x, y) { @@ -22,30 +20,20 @@ function coord2d(x, y) { let getOpt = Belt_Option.mapWithDefault; function findAddress(business) { - return Belt_Option.mapWithDefault(business.address, /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; + return Belt_Option.mapWithDefault(business.address, /* [] */0, a => ({ + hd: a, + tl: /* [] */0 })); } function findAllAddresses(businesses) { - return Belt_List.toArray(Belt_List.flatten(Belt_List.fromArray(Belt_Array.map(businesses, (function (business) { - return Belt_List.concat(Belt_Option.mapWithDefault(business.address, /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; - })), Belt_Option.mapWithDefault(business.owner, /* [] */0, (function (p) { - return Belt_Option.mapWithDefault(p.address, /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; - })); - }))); - }))))); + return Belt_List.toArray(Belt_List.flatten(Belt_List.fromArray(Belt_Array.map(businesses, business => Belt_List.concat(Belt_Option.mapWithDefault(business.address, /* [] */0, a => ({ + hd: a, + tl: /* [] */0 + })), Belt_Option.mapWithDefault(business.owner, /* [] */0, p => Belt_Option.mapWithDefault(p.address, /* [] */0, a => ({ + hd: a, + tl: /* [] */0 + })))))))); } function getPayload(param) { @@ -75,11 +63,9 @@ function getPayloadRecordPlusOne(param) { } function findAddress2(business) { - return Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(business.address2), /* [] */0, (function (a) { - return { - hd: a, - tl: /* [] */0 - }; + return Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(business.address2), /* [] */0, a => ({ + hd: a, + tl: /* [] */0 })); } @@ -94,15 +80,11 @@ let someBusiness2 = { }; function computeArea3(o) { - return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(o.z), 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(Caml_option.nullable_to_opt(o.z), 1, n => n)); } function computeArea4(o) { - return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(o.z, 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(o.x, o.y), Belt_Option.mapWithDefault(o.z, 1, n => n)); } function testMyRec(x) { diff --git a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js index 7137896d8b..153c834adc 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/TestPromise.res.js @@ -5,10 +5,8 @@ import * as Js_promise from "rescript/lib/es6/js_promise.js"; import * as Caml_option from "rescript/lib/es6/caml_option.js"; function convert(p) { - return Js_promise.then_((function (param) { - return Promise.resolve({ - result: param.s - }); + return Js_promise.then_(param => Promise.resolve({ + result: param.s }), p); } diff --git a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js index 8420bac6b1..e962e18f3d 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/Uncurried.res.js @@ -38,21 +38,21 @@ function sumU(n, m) { } function sumU2(n) { - return function (m) { + return m => { console.log("sumU2 2nd arg", m, "result", n + m | 0); }; } function sumCurried(n) { console.log("sumCurried 1st arg", n); - return function (m) { + return m => { console.log("sumCurried 2nd arg", m, "result", n + m | 0); }; } function sumLblCurried(s, n) { console.log(s, "sumLblCurried 1st arg", n); - return function (m) { + return m => { console.log("sumLblCurried 2nd arg", m, "result", n + m | 0); }; } diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js b/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js index 41de58327c..71b9cb5d02 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Tuples.res.js @@ -7,15 +7,11 @@ function testTuple(param) { } function computeArea(param) { - return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, n => n)); } function computeAreaWithIdent(param) { - return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, (function (n) { - return n; - }))); + return Math.imul(Math.imul(param[0], param[1]), Belt_Option.mapWithDefault(param[2], 1, n => n)); } function computeAreaNoConverters(param) { diff --git a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js index f11c6c55cc..11917c6506 100644 --- a/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js +++ b/jscomp/gentype_tests/typescript-react-example/src/nested/Types.res.js @@ -57,9 +57,7 @@ function testInstantiateTypeParameter(x) { let currentTime = new Date(); -let optFunction = (function () { - return 3; -}); +let optFunction = () => 3; let ObjectId = {}; diff --git a/jscomp/test/Import.js b/jscomp/test/Import.js index b094a389db..56c5384054 100644 --- a/jscomp/test/Import.js +++ b/jscomp/test/Import.js @@ -3,17 +3,11 @@ async function eachIntAsync(list, f) { - return (await import("../../lib/js/belt_List.js").then(function (m) { - return m.forEach; - }))(list, f); + return (await import("../../lib/js/belt_List.js").then(m => m.forEach))(list, f); } function eachIntLazy(list, f) { - return import("../../lib/js/belt_List.js").then(function (m) { - return m.forEach; - }).then(function (each) { - return Promise.resolve(each(list, f)); - }); + return import("../../lib/js/belt_List.js").then(m => m.forEach).then(each => Promise.resolve(each(list, f))); } eachIntLazy({ @@ -25,9 +19,9 @@ eachIntLazy({ tl: /* [] */0 } } -}, (function (n) { +}, n => { console.log("lazy", n); -})); +}); eachIntAsync({ hd: 1, @@ -38,9 +32,9 @@ eachIntAsync({ tl: /* [] */0 } } -}, (function (n) { +}, n => { console.log("async", n); -})); +}); let beltAsModule = await import("../../lib/js/belt_List.js"); diff --git a/jscomp/test/PartialApplicationNoRuntimeCurry.js b/jscomp/test/PartialApplicationNoRuntimeCurry.js index 89cd1695ef..1a69368f5f 100644 --- a/jscomp/test/PartialApplicationNoRuntimeCurry.js +++ b/jscomp/test/PartialApplicationNoRuntimeCurry.js @@ -3,16 +3,12 @@ function add(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } function f(u) { let f$1 = add(u); - return function (extra) { - return f$1(1, extra); - }; + return extra => f$1(1, extra); } exports.add = add; diff --git a/jscomp/test/SafePromises.js b/jscomp/test/SafePromises.js index 73ff7b3c4e..91227a4005 100644 --- a/jscomp/test/SafePromises.js +++ b/jscomp/test/SafePromises.js @@ -5,16 +5,12 @@ let Js_promise2 = require("../../lib/js/js_promise2.js"); async function nestedPromise(xxx) { let xx = await xxx; - Js_promise2.then(xx, (function (x) { - return Promise.resolve((console.log("Promise2.then", x), undefined)); - })); - Js_promise2.$$catch(xx, (function (x) { + Js_promise2.then(xx, x => Promise.resolve((console.log("Promise2.then", x), undefined))); + Js_promise2.$$catch(xx, x => { console.log("Promise2.catch_", x); return Promise.resolve(0); - })); - xx.then(function (x) { - return Promise.resolve((console.log("Promise.then_", x), undefined)); }); + xx.then(x => Promise.resolve((console.log("Promise.then_", x), undefined))); } async function create(x) { diff --git a/jscomp/test/UncurriedAlways.js b/jscomp/test/UncurriedAlways.js index 4b284ff2ca..601d3bfe3a 100644 --- a/jscomp/test/UncurriedAlways.js +++ b/jscomp/test/UncurriedAlways.js @@ -20,9 +20,7 @@ let a = 7; console.log(a); -[1].map(function (x) { - return x + 1 | 0; -}); +[1].map(x => x + 1 | 0); function ptl(extra) { return 10 + extra | 0; diff --git a/jscomp/test/UncurriedExternals.js b/jscomp/test/UncurriedExternals.js index c6928253d2..5ec20d4073 100644 --- a/jscomp/test/UncurriedExternals.js +++ b/jscomp/test/UncurriedExternals.js @@ -14,9 +14,7 @@ function dd() { let h = sum(1.0, 2.0); let M = { - sum: (function (prim0, prim1) { - return sum(prim0, prim1); - }) + sum: (prim0, prim1) => sum(prim0, prim1) }; let hh = M.sum(1.0, 2.0); @@ -36,22 +34,20 @@ let te = { let tcr = {}; function tsiC(c) { - c.increment = (function (amount) { + c.increment = function (amount) { let me = this ; console.log(me); - }); + }; } function tsiU(c) { - c.increment = (function (amount) { + c.increment = function (amount) { let me = this ; console.log(me); - }); + }; } -let match = React.useState(function () { - return 3; -}); +let match = React.useState(() => 3); let StandardNotation_get = match[0]; @@ -75,9 +71,7 @@ let StandardNotation = { function methodWithAsync() { let $$this = this ; - return async function (arg) { - return $$this + arg | 0; - }; + return async arg => $$this + arg | 0; } exports.StandardNotation = StandardNotation; diff --git a/jscomp/test/UntaggedVariants.js b/jscomp/test/UntaggedVariants.js index dcb171e280..6dab75df61 100644 --- a/jscomp/test/UntaggedVariants.js +++ b/jscomp/test/UntaggedVariants.js @@ -367,9 +367,7 @@ function classify$9(v) { } } -let ff = (function (x) { - return x + 1 | 0; -}); +let ff = x => x + 1 | 0; let TestFunctionCase = { classify: classify$9, @@ -488,9 +486,7 @@ async function classify$10(a) { return; } else { if (Array.isArray(a)) { - console.log(Belt_Array.joinWith(a, "-", (function (x) { - return x; - }))); + console.log(Belt_Array.joinWith(a, "-", x => x)); return; } if (a instanceof Promise) { @@ -514,9 +510,7 @@ let Arr = { async function classifyAll(t) { if (Array.isArray(t)) { - console.log(Belt_Array.joinWith(t, "-", (function (x) { - return x; - }))); + console.log(Belt_Array.joinWith(t, "-", x => x)); return; } if (t instanceof Promise) { diff --git a/jscomp/test/a_filename_test.js b/jscomp/test/a_filename_test.js index 5fe5fd915f..1c8fda7a7e 100644 --- a/jscomp/test/a_filename_test.js +++ b/jscomp/test/a_filename_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/a_list_test.js b/jscomp/test/a_list_test.js index 824e4783a2..7bef3fdfe5 100644 --- a/jscomp/test/a_list_test.js +++ b/jscomp/test/a_list_test.js @@ -6,98 +6,92 @@ let Ext_list_test = require("./ext_list_test.js"); let suites_0 = [ "drop", - (function (param) { - return { - TAG: "Eq", - _0: Ext_list_test.drop(3, { - hd: 0, + param => ({ + TAG: "Eq", + _0: Ext_list_test.drop(3, { + hd: 0, + tl: { + hd: 1, tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } + hd: 2, + tl: /* [] */0 } - }), - _1: /* [] */0 - }; + } + }), + _1: /* [] */0 }) ]; let suites_1 = { hd: [ "drop1", - (function (param) { - return { - TAG: "Eq", - _0: Ext_list_test.drop(2, { - hd: 0, + param => ({ + TAG: "Eq", + _0: Ext_list_test.drop(2, { + hd: 0, + tl: { + hd: 1, tl: { - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } + hd: 2, + tl: /* [] */0 } - }), - _1: { - hd: 2, - tl: /* [] */0 } - }; + }), + _1: { + hd: 2, + tl: /* [] */0 + } }) ], tl: { hd: [ "flat_map", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: 0, + tl: { hd: 0, tl: { - hd: 0, + hd: 1, tl: { hd: 1, tl: { - hd: 1, - tl: { - hd: 0, - tl: /* [] */0 - } + hd: 0, + tl: /* [] */0 } } } - }, - _1: Ext_list_test.flat_map((function (x) { - if (x % 2 === 0) { - return { - hd: 0, - tl: /* [] */0 - }; - } else { - return { + } + }, + _1: Ext_list_test.flat_map(x => { + if (x % 2 === 0) { + return { + hd: 0, + tl: /* [] */0 + }; + } else { + return { + hd: 1, + tl: { hd: 1, - tl: { - hd: 1, - tl: /* [] */0 - } - }; - } - }), { + tl: /* [] */0 + } + }; + } + }, { + hd: 0, + tl: { hd: 0, tl: { - hd: 0, + hd: 3, tl: { - hd: 3, - tl: { - hd: 0, - tl: /* [] */0 - } + hd: 0, + tl: /* [] */0 } } - }) - }; + } + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/a_string_test.js b/jscomp/test/a_string_test.js index 881f69d6a4..904650af26 100644 --- a/jscomp/test/a_string_test.js +++ b/jscomp/test/a_string_test.js @@ -7,101 +7,89 @@ let Ext_string_test = require("./ext_string_test.js"); let suites_0 = [ "split", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(true, "hihi", /* 'i' */105), - _1: { + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(true, "hihi", /* 'i' */105), + _1: { + hd: "h", + tl: { hd: "h", tl: { - hd: "h", - tl: { - hd: "", - tl: /* [] */0 - } + hd: "", + tl: /* [] */0 } } - }; + } }) ]; let suites_1 = { hd: [ "split_non_empty", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(undefined, "hihi", /* 'i' */105), - _1: { + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(undefined, "hihi", /* 'i' */105), + _1: { + hd: "h", + tl: { hd: "h", - tl: { - hd: "h", - tl: /* [] */0 - } + tl: /* [] */0 } - }; + } }) ], tl: { hd: [ "split_empty", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(true, "", /* 'i' */105), - _1: /* [] */0 - }; + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(true, "", /* 'i' */105), + _1: /* [] */0 }) ], tl: { hd: [ "split_normal", - (function (param) { - return { - TAG: "Eq", - _0: Ext_string_test.split(true, "h i i", /* ' ' */32), - _1: { - hd: "h", + param => ({ + TAG: "Eq", + _0: Ext_string_test.split(true, "h i i", /* ' ' */32), + _1: { + hd: "h", + tl: { + hd: "i", tl: { hd: "i", - tl: { - hd: "i", - tl: /* [] */0 - } + tl: /* [] */0 } } - }; + } }) ], tl: { hd: [ "split_by", - (function (param) { - return { - TAG: "Eq", - _0: List.filter((function (s) { - return s !== ""; - }), Ext_string_test.split_by(undefined, (function (x) { - if (x === /* ' ' */32) { - return true; - } else { - return x === /* '\t' */9; - } - }), "h hgso hgso \t hi")), - _1: { - hd: "h", + param => ({ + TAG: "Eq", + _0: List.filter(s => s !== "", Ext_string_test.split_by(undefined, x => { + if (x === /* ' ' */32) { + return true; + } else { + return x === /* '\t' */9; + } + }, "h hgso hgso \t hi")), + _1: { + hd: "h", + tl: { + hd: "hgso", tl: { hd: "hgso", tl: { - hd: "hgso", - tl: { - hd: "hi", - tl: /* [] */0 - } + hd: "hi", + tl: /* [] */0 } } } - }; + } }) ], tl: /* [] */0 diff --git a/jscomp/test/and_or_tailcall_test.js b/jscomp/test/and_or_tailcall_test.js index fad105c1a9..19a442c44f 100644 --- a/jscomp/test/and_or_tailcall_test.js +++ b/jscomp/test/and_or_tailcall_test.js @@ -33,24 +33,20 @@ function or_f(b, x, _n) { let suites_0 = [ "and_tail", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: f(true, 1, 0) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: f(true, 1, 0) }) ]; let suites_1 = { hd: [ "or_tail", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: or_f(false, 1, 0) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: or_f(false, 1, 0) }) ], tl: /* [] */0 diff --git a/jscomp/test/ari_regress_test.js b/jscomp/test/ari_regress_test.js index da79d0742c..20043923ee 100644 --- a/jscomp/test/ari_regress_test.js +++ b/jscomp/test/ari_regress_test.js @@ -12,9 +12,7 @@ let h = { function g1(x, y) { let u = x + y | 0; h.contents = h.contents + 1 | 0; - return function (xx, yy) { - return (xx + yy | 0) + u | 0; - }; + return (xx, yy) => (xx + yy | 0) + u | 0; } let u = 8; @@ -27,46 +25,38 @@ function v(__x) { let suites_0 = [ "curry", - (function (param) { - return { - TAG: "Eq", - _0: g, - _1: 7 - }; + param => ({ + TAG: "Eq", + _0: g, + _1: 7 }) ]; let suites_1 = { hd: [ "curry2", - (function (param) { - return { - TAG: "Eq", - _0: 14, - _1: (v(1), v(1)) - }; + param => ({ + TAG: "Eq", + _0: 14, + _1: (v(1), v(1)) }) ], tl: { hd: [ "curry3", - (function (param) { - return { - TAG: "Eq", - _0: x, - _1: 14 - }; + param => ({ + TAG: "Eq", + _0: x, + _1: 14 }) ], tl: { hd: [ "File \"ari_regress_test.res\", line 35, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: h.contents, - _1: 2 - }; + param => ({ + TAG: "Eq", + _0: h.contents, + _1: 2 }) ], tl: /* [] */0 diff --git a/jscomp/test/arith_parser.js b/jscomp/test/arith_parser.js index 4fb23e6ba0..7520e20b28 100644 --- a/jscomp/test/arith_parser.js +++ b/jscomp/test/arith_parser.js @@ -139,32 +139,30 @@ let yynames_block = "\ "; let yyact = [ - (function (param) { + param => { throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", _1: "parser" } }); - }), - (function (__caml_parser_env) { - return Parsing.peek_val(__caml_parser_env, 1); - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => Parsing.peek_val(__caml_parser_env, 1), + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 0); return { TAG: "Numeral", _0: _1 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 0); return { TAG: "Variable", _0: _1 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -172,8 +170,8 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -181,8 +179,8 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -190,8 +188,8 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _1 = Parsing.peek_val(__caml_parser_env, 2); let _3 = Parsing.peek_val(__caml_parser_env, 0); return { @@ -199,25 +197,23 @@ let yyact = [ _0: _1, _1: _3 }; - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => { let _2 = Parsing.peek_val(__caml_parser_env, 0); return { TAG: "Negate", _0: _2 }; - }), - (function (__caml_parser_env) { - return Parsing.peek_val(__caml_parser_env, 1); - }), - (function (__caml_parser_env) { + }, + __caml_parser_env => Parsing.peek_val(__caml_parser_env, 1), + __caml_parser_env => { throw new Error(Parsing.YYexit, { cause: { RE_EXN_ID: Parsing.YYexit, _1: Parsing.peek_val(__caml_parser_env, 0) } }); - }) + } ]; let yytables = { diff --git a/jscomp/test/arity_deopt.js b/jscomp/test/arity_deopt.js index 72352a0e4b..c742f2512d 100644 --- a/jscomp/test/arity_deopt.js +++ b/jscomp/test/arity_deopt.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -33,21 +31,15 @@ function f0(x, y, z) { } function f1(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } function f2(x, y) { - return function (z) { - return (x + y | 0) + z | 0; - }; + return z => (x + y | 0) + z | 0; } function f3(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } eq("File \"arity_deopt.res\", line 47, characters 11-18", 6, 6); diff --git a/jscomp/test/arity_infer.js b/jscomp/test/arity_infer.js index 68084b77bd..18da9fe57b 100644 --- a/jscomp/test/arity_infer.js +++ b/jscomp/test/arity_infer.js @@ -5,9 +5,7 @@ function f0(x) { let tmp; if (x > 3) { - tmp = (function (x) { - return x + 1 | 0; - }); + tmp = x => x + 1 | 0; } else { throw new Error("Not_found", { cause: { @@ -31,24 +29,16 @@ function f3(x) { let tmp; switch (x) { case 0 : - tmp = (function (x) { - return x + 1 | 0; - }); + tmp = x => x + 1 | 0; break; case 1 : - tmp = (function (x) { - return x + 2 | 0; - }); + tmp = x => x + 2 | 0; break; case 2 : - tmp = (function (x) { - return x + 3 | 0; - }); + tmp = x => x + 3 | 0; break; case 3 : - tmp = (function (x) { - return x + 4 | 0; - }); + tmp = x => x + 4 | 0; break; default: throw new Error("Not_found", { diff --git a/jscomp/test/array_data_util.js b/jscomp/test/array_data_util.js index cc98eaa8a8..98acf7b5e8 100644 --- a/jscomp/test/array_data_util.js +++ b/jscomp/test/array_data_util.js @@ -4,15 +4,11 @@ let Belt_Array = require("../../lib/js/belt_Array.js"); function range(i, j) { - return Belt_Array.makeBy((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); + return Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); } function randomRange(i, j) { - let v = Belt_Array.makeBy((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); + let v = Belt_Array.makeBy((j - i | 0) + 1 | 0, k => k + i | 0); Belt_Array.shuffleInPlace(v); return v; } diff --git a/jscomp/test/array_subtle_test.js b/jscomp/test/array_subtle_test.js index 20c655d7d5..4233f2ef8d 100644 --- a/jscomp/test/array_subtle_test.js +++ b/jscomp/test/array_subtle_test.js @@ -19,12 +19,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/array_test.js b/jscomp/test/array_test.js index 3045800bd1..f84793a3f5 100644 --- a/jscomp/test/array_test.js +++ b/jscomp/test/array_test.js @@ -58,38 +58,30 @@ function is_sorted(x) { let array_suites_0 = [ "init", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.init(5, (function (x) { - return x; - })), - _1: [ - 0, - 1, - 2, - 3, - 4 - ] - }; + param => ({ + TAG: "Eq", + _0: $$Array.init(5, x => x), + _1: [ + 0, + 1, + 2, + 3, + 4 + ] }) ]; let array_suites_1 = { hd: [ "toList", - (function (param) { - let aux = function (xs) { - return List.fold_left((function (acc, param) { - return { - hd: [ - $$Array.to_list(param[0]), - param[1] - ], - tl: acc - }; - }), /* [] */0, xs); - }; + param => { + let aux = xs => List.fold_left((acc, param) => ({ + hd: [ + $$Array.to_list(param[0]), + param[1] + ], + tl: acc + }), /* [] */0, xs); let match = List.split(aux({ hd: [ [], @@ -102,98 +94,86 @@ let array_suites_1 = { _0: match[0], _1: match[1] }; - }) + } ], tl: { hd: [ "concat", - (function (param) { - return { - TAG: "Eq", - _0: [ + param => ({ + TAG: "Eq", + _0: [ + 0, + 1, + 2, + 3, + 4, + 5 + ], + _1: Caml_array.concat({ + hd: [ 0, 1, - 2, - 3, - 4, - 5 + 2 ], - _1: Caml_array.concat({ + tl: { hd: [ - 0, - 1, - 2 + 3, + 4 ], tl: { - hd: [ - 3, - 4 - ], + hd: [], tl: { - hd: [], - tl: { - hd: [5], - tl: /* [] */0 - } + hd: [5], + tl: /* [] */0 } } - }) - }; + } + }) }) ], tl: { hd: [ "make", - (function (param) { - return { - TAG: "Eq", - _0: [ - Caml_array.make(100, /* 'a' */97), - Caml_array.make_float(100) - ], - _1: [ - $$Array.init(100, (function (param) { - return /* 'a' */97; - })), - $$Array.init(100, (function (param) { - return 0; - })) - ] - }; + param => ({ + TAG: "Eq", + _0: [ + Caml_array.make(100, /* 'a' */97), + Caml_array.make_float(100) + ], + _1: [ + $$Array.init(100, param => /* 'a' */97), + $$Array.init(100, param => 0) + ] }) ], tl: { hd: [ "sub", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.sub([ - 0, - 1, - 2, - 3, - 4 - ], 2, 2), - _1: [ - 2, - 3 - ] - }; + param => ({ + TAG: "Eq", + _0: $$Array.sub([ + 0, + 1, + 2, + 3, + 4 + ], 2, 2), + _1: [ + 2, + 3 + ] }) ], tl: { hd: [ "blit", - (function (param) { + param => { let u = [ 100, 0, 0 ]; - let v = $$Array.init(3, (function (x) { - return (x << 1); - })); + let v = $$Array.init(3, x => (x << 1)); $$Array.blit(v, 1, u, 1, 2); return { TAG: "Eq", @@ -214,15 +194,13 @@ let array_suites_1 = { u ] }; - }) + } ], tl: { hd: [ "File \"array_test.res\", line 75, characters 8-15", - (function (param) { - let a0 = $$Array.init(100, (function (i) { - return (i << 0); - })); + param => { + let a0 = $$Array.init(100, i => (i << 0)); $$Array.blit(a0, 10, a0, 5, 20); return { TAG: "Eq", @@ -252,19 +230,15 @@ let array_suites_1 = { 26, 27, 28 - ], (function (prim0, prim1) { - return prim0 === prim1; - })) + ], (prim0, prim1) => prim0 === prim1) }; - }) + } ], tl: { hd: [ "File \"array_test.res\", line 118, characters 8-15", - (function (param) { - let a0 = $$Array.init(100, (function (i) { - return (i << 0); - })); + param => { + let a0 = $$Array.init(100, i => (i << 0)); $$Array.blit(a0, 5, a0, 10, 20); return { TAG: "Eq", @@ -296,30 +270,26 @@ let array_suites_1 = { 18, 19, 20 - ], (function (prim0, prim1) { - return prim0 === prim1; - })) + ], (prim0, prim1) => prim0 === prim1) }; - }) + } ], tl: { hd: [ "make", - (function (param) { - return { - TAG: "Eq", - _0: Caml_array.make(2, 1), - _1: [ - 1, - 1 - ] - }; + param => ({ + TAG: "Eq", + _0: Caml_array.make(2, 1), + _1: [ + 1, + 1 + ] }) ], tl: { hd: [ "sort", - (function (param) { + param => { let u = [ 3, 0, @@ -335,22 +305,20 @@ let array_suites_1 = { ], u), _1: true }; - }) + } ], tl: { hd: [ "sort_large", - (function (param) { - let v = $$Array.init(4, (function (i) { - return i % 17; - })); + param => { + let v = $$Array.init(4, i => i % 17); $$Array.sort(Caml.int_compare, v); return { TAG: "Eq", _0: true, _1: is_sorted(v) }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/ast_abstract_test.js b/jscomp/test/ast_abstract_test.js index 27d20ddd01..c8f1e54872 100644 --- a/jscomp/test/ast_abstract_test.js +++ b/jscomp/test/ast_abstract_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/async_await.js b/jscomp/test/async_await.js index ae29f57668..3bdca2ae5d 100644 --- a/jscomp/test/async_await.js +++ b/jscomp/test/async_await.js @@ -12,9 +12,7 @@ async function useNext() { } function Make(I) { - let get = async function (key) { - return await I.get(key); - }; + let get = async key => await I.get(key); return { get: get }; diff --git a/jscomp/test/async_inline.js b/jscomp/test/async_inline.js index e08f9e8df5..247e22bdff 100644 --- a/jscomp/test/async_inline.js +++ b/jscomp/test/async_inline.js @@ -10,17 +10,17 @@ async function willBeInlined() { let inlined = willBeInlined(); function wrapSomethingAsync() { - ((async function (param) { - let test = await Promise.resolve("Test"); - console.log(test); - })(777)); + (async param => { + let test = await Promise.resolve("Test"); + console.log(test); + })(777); } function wrapSomethingAsync2() { - ((async function () { - let test = await Promise.resolve("Test"); - console.log(test); - })()); + (async () => { + let test = await Promise.resolve("Test"); + console.log(test); + })(); } async function doSomethingAsync(someAsyncFunction) { @@ -64,21 +64,15 @@ let tui = 3; let tuia = uncurriedIdAsync(3); function nested1() { - return async function (y) { - return await y; - }; + return async y => await y; } async function nested2() { - return async function (y) { - return await y; - }; + return async y => await y; } function onSubmit() { - return React.useCallback(async function (b) { - return await b; - }); + return React.useCallback(async b => await b); } exports.willBeInlined = willBeInlined; diff --git a/jscomp/test/async_inside_loop.js b/jscomp/test/async_inside_loop.js index 0f1d7d0fe1..889065bf7e 100644 --- a/jscomp/test/async_inside_loop.js +++ b/jscomp/test/async_inside_loop.js @@ -4,7 +4,7 @@ async function topLevelAsyncFunction() { for (let innerScopeVal = 0; innerScopeVal <= 3; ++innerScopeVal) { - let asyncClosureAccessingScopedVal = async function () { + let asyncClosureAccessingScopedVal = async () => { console.log("Accessing scoped var inside loop", innerScopeVal); return await Promise.resolve(); }; diff --git a/jscomp/test/attr_test.js b/jscomp/test/attr_test.js index 2d54972a0b..646d4e7de1 100644 --- a/jscomp/test/attr_test.js +++ b/jscomp/test/attr_test.js @@ -15,9 +15,9 @@ function max2(x, y) { let hh = 1 + 2; function f(x) { - des(x, (function () { + des(x, () => { console.log("hei"); - })); + }); } exports.u = u; diff --git a/jscomp/test/bdd.js b/jscomp/test/bdd.js index f408c2c3d7..a7b4f929b5 100644 --- a/jscomp/test/bdd.js +++ b/jscomp/test/bdd.js @@ -58,7 +58,7 @@ function resize(newSize) { let arr = htab.contents; let newSz_1 = newSize - 1 | 0; let newArr = Caml_array.make(newSize, /* [] */0); - let copyBucket = function (_bucket) { + let copyBucket = _bucket => { while (true) { let bucket = _bucket; if (!bucket) { @@ -334,14 +334,14 @@ function xor(n1, n2) { } function hwb(n) { - let h = function (i, j) { + let h = (i, j) => { if (i === j) { return mkNode("Zero", i, "One"); } else { return xor(and2(not(mkNode("Zero", j, "One")), h(i, j - 1 | 0)), and2(mkNode("Zero", j, "One"), g(i, j - 1 | 0))); } }; - let g = function (i, j) { + let g = (i, j) => { if (i === j) { return mkNode("Zero", i, "One"); } else { diff --git a/jscomp/test/belt_float_ntest.js b/jscomp/test/belt_float_ntest.js index 5513ffad54..701b894b4c 100644 --- a/jscomp/test/belt_float_ntest.js +++ b/jscomp/test/belt_float_ntest.js @@ -9,20 +9,20 @@ function eq(loc, a, b) { Nodeassert.strictEqual(a, b, loc); } -Nodetest.describe("Belt.Float", (function () { - Nodetest.test("fromInt", (function () { +Nodetest.describe("Belt.Float", () => { + Nodetest.test("fromInt", () => { eq("File \"belt_float_ntest.res\", line 9, characters 7-14", 1, 1.0); eq("File \"belt_float_ntest.res\", line 10, characters 7-14", -1, -1.0); - })); - Nodetest.test("toInt", (function () { + }); + Nodetest.test("toInt", () => { eq("File \"belt_float_ntest.res\", line 14, characters 7-14", 1, 1); eq("File \"belt_float_ntest.res\", line 15, characters 7-14", 1, 1); eq("File \"belt_float_ntest.res\", line 16, characters 7-14", 1, 1); eq("File \"belt_float_ntest.res\", line 17, characters 7-14", -1, -1); eq("File \"belt_float_ntest.res\", line 18, characters 7-14", -1, -1); eq("File \"belt_float_ntest.res\", line 19, characters 7-14", -1, -1); - })); - Nodetest.test("fromString", (function () { + }); + Nodetest.test("fromString", () => { eq("File \"belt_float_ntest.res\", line 23, characters 7-14", Belt_Float.fromString("1"), 1.0); eq("File \"belt_float_ntest.res\", line 24, characters 7-14", Belt_Float.fromString("-1"), -1.0); eq("File \"belt_float_ntest.res\", line 25, characters 7-14", Belt_Float.fromString("1.7"), 1.7); @@ -30,19 +30,19 @@ Nodetest.describe("Belt.Float", (function () { eq("File \"belt_float_ntest.res\", line 27, characters 7-14", Belt_Float.fromString("-1.5"), -1.5); eq("File \"belt_float_ntest.res\", line 28, characters 7-14", Belt_Float.fromString("-1.7"), -1.7); eq("File \"belt_float_ntest.res\", line 29, characters 7-14", Belt_Float.fromString("not a float"), undefined); - })); - Nodetest.test("toString", (function () { + }); + Nodetest.test("toString", () => { eq("File \"belt_float_ntest.res\", line 33, characters 7-14", String(1.0), "1"); eq("File \"belt_float_ntest.res\", line 34, characters 7-14", String(-1.0), "-1"); eq("File \"belt_float_ntest.res\", line 35, characters 7-14", String(-1.5), "-1.5"); - })); - Nodetest.test("operators", (function () { + }); + Nodetest.test("operators", () => { eq("File \"belt_float_ntest.res\", line 40, characters 7-14", 2.0 + 3.0, 5.0); eq("File \"belt_float_ntest.res\", line 41, characters 7-14", 2.0 - 3.0, -1.0); eq("File \"belt_float_ntest.res\", line 42, characters 7-14", 2.0 * 3.0, 6.0); eq("File \"belt_float_ntest.res\", line 43, characters 7-14", 3.0 / 2.0, 1.5); - })); -})); + }); +}); let F; diff --git a/jscomp/test/belt_int_ntest.js b/jscomp/test/belt_int_ntest.js index 664dfa5947..823f399f5a 100644 --- a/jscomp/test/belt_int_ntest.js +++ b/jscomp/test/belt_int_ntest.js @@ -9,20 +9,20 @@ function eq(loc, a, b) { Nodeassert.strictEqual(a, b, loc); } -Nodetest.describe("Belt.Int", (function () { - Nodetest.test("toFloat", (function () { +Nodetest.describe("Belt.Int", () => { + Nodetest.test("toFloat", () => { eq("File \"belt_int_ntest.res\", line 9, characters 7-14", 1, 1.0); eq("File \"belt_int_ntest.res\", line 10, characters 7-14", -1, -1.0); - })); - Nodetest.test("fromFloat", (function () { + }); + Nodetest.test("fromFloat", () => { eq("File \"belt_int_ntest.res\", line 14, characters 7-14", 1, 1); eq("File \"belt_int_ntest.res\", line 15, characters 7-14", 1, 1); eq("File \"belt_int_ntest.res\", line 16, characters 7-14", 1, 1); eq("File \"belt_int_ntest.res\", line 17, characters 7-14", -1, -1); eq("File \"belt_int_ntest.res\", line 18, characters 7-14", -1, -1); eq("File \"belt_int_ntest.res\", line 19, characters 7-14", -1, -1); - })); - Nodetest.test("fromString", (function () { + }); + Nodetest.test("fromString", () => { eq("File \"belt_int_ntest.res\", line 23, characters 7-14", Belt_Int.fromString("1"), 1); eq("File \"belt_int_ntest.res\", line 24, characters 7-14", Belt_Int.fromString("-1"), -1); eq("File \"belt_int_ntest.res\", line 25, characters 7-14", Belt_Int.fromString("1.7"), 1); @@ -30,18 +30,18 @@ Nodetest.describe("Belt.Int", (function () { eq("File \"belt_int_ntest.res\", line 27, characters 7-14", Belt_Int.fromString("-1.5"), -1); eq("File \"belt_int_ntest.res\", line 28, characters 7-14", Belt_Int.fromString("-1.7"), -1); eq("File \"belt_int_ntest.res\", line 29, characters 7-14", Belt_Int.fromString("not an int"), undefined); - })); - Nodetest.test("toString", (function () { + }); + Nodetest.test("toString", () => { eq("File \"belt_int_ntest.res\", line 33, characters 7-14", String(1), "1"); eq("File \"belt_int_ntest.res\", line 34, characters 7-14", String(-1), "-1"); - })); - Nodetest.test("operators", (function () { + }); + Nodetest.test("operators", () => { eq("File \"belt_int_ntest.res\", line 40, characters 7-14", 5, 5); eq("File \"belt_int_ntest.res\", line 41, characters 7-14", -1, -1); eq("File \"belt_int_ntest.res\", line 42, characters 7-14", 6, 6); eq("File \"belt_int_ntest.res\", line 43, characters 7-14", 0, 0); - })); -})); + }); +}); let I; diff --git a/jscomp/test/belt_mapint_ntest.js b/jscomp/test/belt_mapint_ntest.js index f5402de1f1..eac12a4e46 100644 --- a/jscomp/test/belt_mapint_ntest.js +++ b/jscomp/test/belt_mapint_ntest.js @@ -9,8 +9,8 @@ function ok(loc, a) { Nodeassert.ok(a, loc); } -Nodetest.describe("Belt.Map.Int", (function () { - Nodetest.test("set", (function () { +Nodetest.describe("Belt.Map.Int", () => { + Nodetest.test("set", () => { let m; for (let i = 0; i <= 999999; ++i) { m = Belt_MapInt.set(m, i, i); @@ -22,8 +22,8 @@ Nodetest.describe("Belt.Map.Int", (function () { m = Belt_MapInt.remove(m, i$2); } ok("File \"belt_mapint_ntest.res\", line 24, characters 7-14", Belt_MapInt.isEmpty(m)); - })); -})); + }); +}); let M; diff --git a/jscomp/test/belt_result_alias_test.js b/jscomp/test/belt_result_alias_test.js index 8cc5b93095..b857620b87 100644 --- a/jscomp/test/belt_result_alias_test.js +++ b/jscomp/test/belt_result_alias_test.js @@ -6,15 +6,11 @@ let Belt_Result = require("../../lib/js/belt_Result.js"); Belt_Result.map({ TAG: "Ok", _0: "Test" -}, (function (r) { - return "Value: " + r; -})); +}, r => "Value: " + r); Belt_Result.getWithDefault(Belt_Result.map({ TAG: "Error", _0: "error" -}, (function (r) { - return "Value: " + r; -})), "success"); +}, r => "Value: " + r), "success"); /* Not a pure module */ diff --git a/jscomp/test/bench.js b/jscomp/test/bench.js index d1403d2e36..8223ef2471 100644 --- a/jscomp/test/bench.js +++ b/jscomp/test/bench.js @@ -5,9 +5,7 @@ let Caml_array = require("../../lib/js/caml_array.js"); let Pervasives = require("../../lib/js/pervasives.js"); function map(f, a) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = x => f(x); let l = a.length; if (l === 0) { return []; @@ -20,9 +18,7 @@ function map(f, a) { } function init(l, f) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = x => f(x); if (l === 0) { return []; } @@ -42,9 +38,7 @@ function init(l, f) { } function fold_left(f, x, a) { - let f$1 = function (x, y) { - return f(x, y); - }; + let f$1 = (x, y) => f(x, y); let r = x; for (let i = 0, i_finish = a.length; i < i_finish; ++i) { r = f$1(r, a[i]); @@ -53,15 +47,9 @@ function fold_left(f, x, a) { } function f2() { - let arr = init(3000000, (function (i) { - return i; - })); - let b = map((function (i) { - return i + i - 1; - }), arr); - let v = fold_left((function (prim0, prim1) { - return prim0 + prim1; - }), 0, b); + let arr = init(3000000, i => i); + let b = map(i => i + i - 1, arr); + let v = fold_left((prim0, prim1) => prim0 + prim1, 0, b); console.log(Pervasives.string_of_float(v)); } diff --git a/jscomp/test/bs_abstract_test.js b/jscomp/test/bs_abstract_test.js index 650119951d..9ce29796a9 100644 --- a/jscomp/test/bs_abstract_test.js +++ b/jscomp/test/bs_abstract_test.js @@ -10,9 +10,7 @@ let v = { v.tl = v; let f = { - k: (function (x, y) { - return x === y; - }), + k: (x, y) => x === y, y: "x" }; @@ -21,9 +19,7 @@ function uf(u) { } function uf1(u) { - return function (extra) { - return u.y1(1, extra); - }; + return extra => u.y1(1, extra); } function uf2(u) { diff --git a/jscomp/test/bs_array_test.js b/jscomp/test/bs_array_test.js index 00f3f1dda6..610ef1fa8b 100644 --- a/jscomp/test/bs_array_test.js +++ b/jscomp/test/bs_array_test.js @@ -32,12 +32,10 @@ function neq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Neq", - _0: x, - _1: y - }; + () => ({ + TAG: "Neq", + _0: x, + _1: y }) ], tl: suites.contents @@ -53,13 +51,7 @@ console.log([ 2, 3, 4 -].filter(function (x) { - return x > 2; -}).map(function (x, i) { - return x + i | 0; -}).reduce((function (x, y) { - return x + y | 0; -}), 0)); +].filter(x => x > 2).map((x, i) => x + i | 0).reduce((x, y) => x + y | 0, 0)); let v = [ 1, @@ -80,19 +72,19 @@ eq("File \"bs_array_test.res\", line 31, characters 4-11", [ undefined ]); -$$throw("File \"bs_array_test.res\", line 35, characters 8-15", (function () { +$$throw("File \"bs_array_test.res\", line 35, characters 8-15", () => { Belt_Array.getExn([ 0, 1 ], -1); -})); +}); -$$throw("File \"bs_array_test.res\", line 36, characters 8-15", (function () { +$$throw("File \"bs_array_test.res\", line 36, characters 8-15", () => { Belt_Array.getExn([ 0, 1 ], 2); -})); +}); function f(extra) { return Belt_Array.getExn([ @@ -109,19 +101,15 @@ b("File \"bs_array_test.res\", line 38, characters 4-11", Caml_obj.equal([ 1 ])); -$$throw("File \"bs_array_test.res\", line 44, characters 8-15", (function () { - Belt_Array.setExn([ - 0, - 1 - ], -1, 0); -})); +$$throw("File \"bs_array_test.res\", line 44, characters 8-15", () => Belt_Array.setExn([ + 0, + 1 +], -1, 0)); -$$throw("File \"bs_array_test.res\", line 45, characters 8-15", (function () { - Belt_Array.setExn([ - 0, - 1 - ], 2, 0); -})); +$$throw("File \"bs_array_test.res\", line 45, characters 8-15", () => Belt_Array.setExn([ + 0, + 1 +], 2, 0)); b("File \"bs_array_test.res\", line 46, characters 4-11", !Belt_Array.set([ 1, @@ -186,9 +174,7 @@ function add(x, y) { return x + y | 0; } -let v$5 = Belt_Array.makeBy(3000, (function (i) { - return i; -})); +let v$5 = Belt_Array.makeBy(3000, i => i); let u = Belt_Array.shuffle(v$5); @@ -232,34 +218,26 @@ b("File \"bs_array_test.res\", line 101, characters 4-11", Caml_obj.equal(Belt_A b("File \"bs_array_test.res\", line 102, characters 4-11", Caml_obj.equal(Belt_Array.rangeBy(3, 3, 1), [3])); -eq("File \"bs_array_test.res\", line 106, characters 5-12", Belt_Array.reduceReverse([], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), 100); +eq("File \"bs_array_test.res\", line 106, characters 5-12", Belt_Array.reduceReverse([], 100, (prim0, prim1) => prim0 - prim1 | 0), 100); eq("File \"bs_array_test.res\", line 107, characters 5-12", Belt_Array.reduceReverse([ 1, 2 -], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), 97); +], 100, (prim0, prim1) => prim0 - prim1 | 0), 97); eq("File \"bs_array_test.res\", line 108, characters 5-12", Belt_Array.reduceReverse([ 1, 2, 3, 4 -], 100, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), 90); +], 100, (prim0, prim1) => prim0 - prim1 | 0), 90); eq("File \"bs_array_test.res\", line 109, characters 5-12", Belt_Array.reduceWithIndex([ 1, 2, 3, 4 -], 0, (function (acc, x, i) { - return (acc + x | 0) + i | 0; -})), 16); +], 0, (acc, x, i) => (acc + x | 0) + i | 0), 16); b("File \"bs_array_test.res\", line 110, characters 4-11", Belt_Array.reduceReverse2([ 1, @@ -268,9 +246,7 @@ b("File \"bs_array_test.res\", line 110, characters 4-11", Belt_Array.reduceReve ], [ 1, 2 -], 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})) === 6); +], 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); function addone(x) { return x + 1 | 0; @@ -300,13 +276,9 @@ function makeMatrixExn(sx, sy, init) { return res; } -eq("File \"bs_array_test.res\", line 129, characters 5-12", Belt_Array.makeBy(0, (function (param) { - return 1; -})), []); +eq("File \"bs_array_test.res\", line 129, characters 5-12", Belt_Array.makeBy(0, param => 1), []); -eq("File \"bs_array_test.res\", line 130, characters 5-12", Belt_Array.makeBy(3, (function (i) { - return i; -})), [ +eq("File \"bs_array_test.res\", line 130, characters 5-12", Belt_Array.makeBy(3, i => i), [ 0, 1, 2 @@ -345,9 +317,7 @@ eq("File \"bs_array_test.res\", line 134, characters 5-12", makeMatrixExn(1, 1, eq("File \"bs_array_test.res\", line 135, characters 5-12", [].slice(0), []); -eq("File \"bs_array_test.res\", line 136, characters 5-12", Belt_Array.map([], (function (prim) { - return prim + 1 | 0; -})), []); +eq("File \"bs_array_test.res\", line 136, characters 5-12", Belt_Array.map([], prim => prim + 1 | 0), []); eq("File \"bs_array_test.res\", line 137, characters 5-12", Belt_Array.mapWithIndex([], add), []); @@ -387,9 +357,7 @@ eq("File \"bs_array_test.res\", line 142, characters 5-12", Belt_Array.map([ 1, 2, 3 -], (function (prim) { - return prim + 1 | 0; -})), [ +], prim => prim + 1 | 0), [ 2, 3, 4 @@ -428,24 +396,18 @@ eq("File \"bs_array_test.res\", line 146, characters 5-12", Belt_List.toArray({ 3 ]); -let v$6 = Belt_Array.makeBy(10, (function (i) { - return i; -})); +let v$6 = Belt_Array.makeBy(10, i => i); -let v0 = Belt_Array.keep(v$6, (function (x) { - return x % 2 === 0; -})); +let v0 = Belt_Array.keep(v$6, x => x % 2 === 0); -let v1 = Belt_Array.keep(v$6, (function (x) { - return x % 3 === 0; -})); +let v1 = Belt_Array.keep(v$6, x => x % 3 === 0); -let v2 = Belt_Array.keepMap(v$6, (function (x) { +let v2 = Belt_Array.keepMap(v$6, x => { if (x % 2 === 0) { return x + 1 | 0; } -})); +}); eq("File \"bs_array_test.res\", line 160, characters 5-12", v0, [ 0, @@ -478,9 +440,7 @@ let a = [ 5 ]; -let match = Belt_Array.partition(a, (function (x) { - return x % 2 === 0; -})); +let match = Belt_Array.partition(a, x => x % 2 === 0); eq("File \"bs_array_test.res\", line 168, characters 5-12", match[0], [ 2, @@ -493,9 +453,7 @@ eq("File \"bs_array_test.res\", line 169, characters 5-12", match[1], [ 5 ]); -let match$1 = Belt_Array.partition(a, (function (x) { - return x === 2; -})); +let match$1 = Belt_Array.partition(a, x => x === 2); eq("File \"bs_array_test.res\", line 171, characters 5-12", match$1[0], [2]); @@ -506,9 +464,7 @@ eq("File \"bs_array_test.res\", line 172, characters 5-12", match$1[1], [ 5 ]); -let match$2 = Belt_Array.partition([], (function (x) { - return false; -})); +let match$2 = Belt_Array.partition([], x => false); eq("File \"bs_array_test.res\", line 174, characters 5-12", match$2[0], []); @@ -633,9 +589,7 @@ eq("File \"bs_array_test.res\", line 205, characters 5-12", Belt_Array.sliceToEn eq("File \"bs_array_test.res\", line 206, characters 5-12", Belt_Array.sliceToEnd(a$2, 6), []); -let a$3 = Belt_Array.makeBy(10, (function (x) { - return x; -})); +let a$3 = Belt_Array.makeBy(10, x => x); Belt_Array.fill(a$3, 0, 3, 0); @@ -802,9 +756,7 @@ eq("File \"bs_array_test.res\", line 236, characters 5-12", b$1, [ 3 ]); -let a0 = Belt_Array.makeBy(10, (function (x) { - return x; -})); +let a0 = Belt_Array.makeBy(10, x => x); let b0 = Belt_Array.make(10, 3); @@ -876,9 +828,7 @@ Belt_Array.blit(a0, -11, b0, -11, 2); eq("File \"bs_array_test.res\", line 253, characters 5-12", b0.slice(0), a0); -let aa = Belt_Array.makeBy(10, (function (x) { - return x; -})); +let aa = Belt_Array.makeBy(10, x => x); Belt_Array.blit(aa, -1, aa, 1, 2); @@ -1015,9 +965,7 @@ eq("File \"bs_array_test.res\", line 273, characters 5-12", Belt_Array.zipBy([ 1, 2, 3 -], (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), [ +], (prim0, prim1) => prim0 - prim1 | 0), [ 1, 1, 1 @@ -1032,15 +980,11 @@ eq("File \"bs_array_test.res\", line 274, characters 5-12", Belt_Array.zipBy([ 3, 4, 1 -], (function (prim0, prim1) { - return prim0 - prim1 | 0; -})), Belt_Array.map([ +], (prim0, prim1) => prim0 - prim1 | 0), Belt_Array.map([ 1, 1, 1 -], (function (x) { - return -x | 0; -}))); +], x => -x | 0)); eq("File \"bs_array_test.res\", line 275, characters 5-12", Belt_Array.unzip([ [ @@ -1072,9 +1016,9 @@ function sumUsingForEach(xs) { let v = { contents: 0 }; - Belt_Array.forEach(xs, (function (x) { + Belt_Array.forEach(xs, x => { v.contents = v.contents + x | 0; - })); + }); return v.contents; } @@ -1092,33 +1036,25 @@ b("File \"bs_array_test.res\", line 288, characters 4-11", !Belt_Array.every([ 2, 3, 4 -], (function (x) { - return x > 2; -}))); +], x => x > 2)); b("File \"bs_array_test.res\", line 289, characters 4-11", Belt_Array.some([ 1, 3, 7, 8 -], (function (x) { - return x % 2 === 0; -}))); +], x => x % 2 === 0)); b("File \"bs_array_test.res\", line 290, characters 4-11", !Belt_Array.some([ 1, 3, 7 -], (function (x) { - return x % 2 === 0; -}))); +], x => x % 2 === 0)); b("File \"bs_array_test.res\", line 291, characters 4-11", !Belt_Array.eq([ 0, 1 -], [1], (function (prim0, prim1) { - return prim0 === prim1; -}))); +], [1], (prim0, prim1) => prim0 === prim1)); let c$1 = { contents: 0 @@ -1128,9 +1064,9 @@ b("File \"bs_array_test.res\", line 293, characters 4-11", (Belt_Array.forEachWi 1, 1, 1 -], (function (i, v) { +], (i, v) => { c$1.contents = (c$1.contents + i | 0) + v | 0; -})), c$1.contents === 6)); +}), c$1.contents === 6)); function id(loc, x) { let u = x.slice(0); @@ -1170,9 +1106,7 @@ function some2(xs, ys, x) { eq("File \"bs_array_test.res\", line 326, characters 5-12", every2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 327, characters 5-12", every2({ hd: 2, @@ -1183,9 +1117,7 @@ eq("File \"bs_array_test.res\", line 327, characters 5-12", every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 328, characters 5-12", every2({ hd: 2, @@ -1193,9 +1125,7 @@ eq("File \"bs_array_test.res\", line 328, characters 5-12", every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 329, characters 5-12", every2({ hd: 2, @@ -1209,9 +1139,7 @@ eq("File \"bs_array_test.res\", line 329, characters 5-12", every2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_array_test.res\", line 330, characters 5-12", every2({ hd: 2, @@ -1225,16 +1153,12 @@ eq("File \"bs_array_test.res\", line 330, characters 5-12", every2({ hd: 0, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 331, characters 5-12", some2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_array_test.res\", line 332, characters 5-12", some2({ hd: 2, @@ -1245,9 +1169,7 @@ eq("File \"bs_array_test.res\", line 332, characters 5-12", some2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 333, characters 5-12", some2({ hd: 2, @@ -1261,9 +1183,7 @@ eq("File \"bs_array_test.res\", line 333, characters 5-12", some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 334, characters 5-12", some2({ hd: 0, @@ -1277,9 +1197,7 @@ eq("File \"bs_array_test.res\", line 334, characters 5-12", some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_array_test.res\", line 335, characters 5-12", some2({ hd: 0, @@ -1293,9 +1211,7 @@ eq("File \"bs_array_test.res\", line 335, characters 5-12", some2({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_array_test.res\", line 339, characters 5-12", Belt_Array.concat([], [ 1, @@ -1446,33 +1362,25 @@ eq("File \"bs_array_test.res\", line 357, characters 5-12", Belt_Array.getBy([ 1, 2, 3 -], (function (x) { - return x > 1; -})), 2); +], x => x > 1), 2); eq("File \"bs_array_test.res\", line 358, characters 5-12", Belt_Array.getBy([ 1, 2, 3 -], (function (x) { - return x > 3; -})), undefined); +], x => x > 3), undefined); eq("File \"bs_array_test.res\", line 362, characters 5-12", Belt_Array.getIndexBy([ 1, 2, 3 -], (function (x) { - return x > 1; -})), 1); +], x => x > 1), 1); eq("File \"bs_array_test.res\", line 363, characters 5-12", Belt_Array.getIndexBy([ 1, 2, 3 -], (function (x) { - return x > 3; -})), undefined); +], x => x > 3), undefined); let arr = []; diff --git a/jscomp/test/bs_auto_uncurry.js b/jscomp/test/bs_auto_uncurry.js index 3ea45355c0..1b0f3d0dd9 100644 --- a/jscomp/test/bs_auto_uncurry.js +++ b/jscomp/test/bs_auto_uncurry.js @@ -12,9 +12,7 @@ let xbs = Array.prototype.map.call([ 2, 3, 5 -], (function (x) { - return x + 1 | 0; -})); +], x => x + 1 | 0); function f(cb) { return Array.prototype.map.call([ @@ -38,18 +36,14 @@ let xs = Array.prototype.map.call([ 2, 1 ] -], (function (param) { - return (param[1] + param[0] | 0) + 1 | 0; -})); +], param => (param[1] + param[0] | 0) + 1 | 0); function f_0() { - return hi(function () { - - }); + return hi(() => {}); } function f_01() { - return hi(function (x) { + return hi(x => { if (x === undefined) { console.log("x"); return; @@ -59,7 +53,7 @@ function f_01() { } function f_02(xs) { - return hi(function (x) { + return hi(x => { xs.contents = x; console.log("x"); }); @@ -78,33 +72,23 @@ function h1(x, y, u, z) { } function add3(x) { - return function (y, z) { - return (x + y | 0) + z | 0; - }; + return (y, z) => (x + y | 0) + z | 0; } function h2(x) { - return ff(x, (function (prim0, prim1) { - return prim0 + prim1 | 0; - })); + return ff(x, (prim0, prim1) => prim0 + prim1 | 0); } function h3(x) { - return ff(x, (function (y, z) { - return (1 + y | 0) + z | 0; - })); + return ff(x, (y, z) => (1 + y | 0) + z | 0); } function h4(x) { - return ff1(x, 3, (function (y, z) { - return (1 + y | 0) + z | 0; - })); + return ff1(x, 3, (y, z) => (1 + y | 0) + z | 0); } function h5(x) { - return ff2(x, "3", (function (y, z) { - return (2 + y | 0) + z | 0; - })); + return ff2(x, "3", (y, z) => (2 + y | 0) + z | 0); } function add(x, y) { diff --git a/jscomp/test/bs_auto_uncurry_test.js b/jscomp/test/bs_auto_uncurry_test.js index 0e218a1999..c44c98800e 100644 --- a/jscomp/test/bs_auto_uncurry_test.js +++ b/jscomp/test/bs_auto_uncurry_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -38,14 +36,14 @@ let xs = { contents: /* [] */0 }; -hi(function (x) { +hi(x => { xs.contents = { hd: x, tl: xs.contents }; }); -hi(function (x) { +hi(x => { xs.contents = { hd: x, tl: xs.contents @@ -64,9 +62,7 @@ eq("File \"bs_auto_uncurry_test.res\", line 28, characters 5-12", [ 1, 2, 3 -].map(function (x) { - return x + 1 | 0; -}), [ +].map(x => x + 1 | 0), [ 2, 3, 4 @@ -76,9 +72,7 @@ eq("File \"bs_auto_uncurry_test.res\", line 29, characters 5-12", [ 1, 2, 3 -].map(function (x) { - return x + 1 | 0; -}), [ +].map(x => x + 1 | 0), [ 2, 3, 4 @@ -88,33 +82,25 @@ eq("File \"bs_auto_uncurry_test.res\", line 31, characters 5-12", [ 1, 2, 3 -].reduce((function (prim0, prim1) { - return prim0 + prim1 | 0; -}), 0), 6); +].reduce((prim0, prim1) => prim0 + prim1 | 0, 0), 6); eq("File \"bs_auto_uncurry_test.res\", line 33, characters 5-12", [ 1, 2, 3 -].reduce((function (x, y, i) { - return (x + y | 0) + i | 0; -}), 0), 9); +].reduce((x, y, i) => (x + y | 0) + i | 0, 0), 9); eq("File \"bs_auto_uncurry_test.res\", line 35, characters 5-12", [ 1, 2, 3 -].some(function (x) { - return x < 1; -}), false); +].some(x => x < 1), false); eq("File \"bs_auto_uncurry_test.res\", line 37, characters 5-12", [ 1, 2, 3 -].every(function (x) { - return x > 0; -}), true); +].every(x => x > 0), true); Mt.from_pair_suites("Bs_auto_uncurry_test", suites.contents); diff --git a/jscomp/test/bs_hashmap_test.js b/jscomp/test/bs_hashmap_test.js index 8dc9d9d08f..62e1d947f6 100644 --- a/jscomp/test/bs_hashmap_test.js +++ b/jscomp/test/bs_hashmap_test.js @@ -98,9 +98,7 @@ for (let i$1 = 0; i$1 <= 2000; ++i$1) { eqx("File \"bs_hashmap_test.res\", line 57, characters 6-13", v$1.size, 98000); -b("File \"bs_hashmap_test.res\", line 58, characters 4-11", Belt_Array.every(Array_data_util.range(2001, 100000), (function (x) { - return Belt_HashMap.has(v$1, x); -}))); +b("File \"bs_hashmap_test.res\", line 58, characters 4-11", Belt_Array.every(Array_data_util.range(2001, 100000), x => Belt_HashMap.has(v$1, x))); Mt.from_pair_suites("Bs_hashmap_test", suites.contents); diff --git a/jscomp/test/bs_hashset_int_test.js b/jscomp/test/bs_hashset_int_test.js index 36dbe3366d..cb3339dcec 100644 --- a/jscomp/test/bs_hashset_int_test.js +++ b/jscomp/test/bs_hashset_int_test.js @@ -33,9 +33,9 @@ function sum2(h) { let v = { contents: 0 }; - Belt_HashSetInt.forEach(h, (function (x) { + Belt_HashSetInt.forEach(h, x => { v.contents = v.contents + x | 0; - })); + }); return v.contents; } diff --git a/jscomp/test/bs_ignore_effect.js b/jscomp/test/bs_ignore_effect.js index 9aebbaf3a1..d432098c6b 100644 --- a/jscomp/test/bs_ignore_effect.js +++ b/jscomp/test/bs_ignore_effect.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/bs_list_test.js b/jscomp/test/bs_list_test.js index ab3f5d2f58..f5a308dd12 100644 --- a/jscomp/test/bs_list_test.js +++ b/jscomp/test/bs_list_test.js @@ -31,9 +31,9 @@ function sum(xs) { let v = { contents: 0 }; - Belt_List.forEach(xs, (function (x) { + Belt_List.forEach(xs, x => { v.contents = v.contents + x | 0; - })); + }); return v.contents; } @@ -41,15 +41,13 @@ function sum2(xs, ys) { let v = { contents: 0 }; - Belt_List.forEach2(xs, ys, (function (x, y) { + Belt_List.forEach2(xs, ys, (x, y) => { v.contents = (v.contents + x | 0) + y | 0; - })); + }); return v.contents; } -let u = Belt_List.makeBy(5, (function (i) { - return Math.imul(i, i); -})); +let u = Belt_List.makeBy(5, i => Math.imul(i, i)); function f(i) { eq("File \"bs_list_test.res\", line 27, characters 18-25", Belt_List.getExn(u, i), Math.imul(i, i)); @@ -59,9 +57,7 @@ for (let i = 0; i <= 4; ++i) { f(i); } -eq("File \"bs_list_test.res\", line 31, characters 5-12", Belt_List.map(u, (function (i) { - return i + 1 | 0; -})), { +eq("File \"bs_list_test.res\", line 31, characters 5-12", Belt_List.map(u, i => i + 1 | 0), { hd: 1, tl: { hd: 2, @@ -90,9 +86,7 @@ eq("File \"bs_list_test.res\", line 32, characters 5-12", Belt_List.getBy({ } } } -}, (function (x) { - return x % 2 === 0; -})), 4); +}, x => x % 2 === 0), 4); eq("File \"bs_list_test.res\", line 33, characters 5-12", Belt_List.getBy({ hd: 1, @@ -106,9 +100,7 @@ eq("File \"bs_list_test.res\", line 33, characters 5-12", Belt_List.getBy({ } } } -}, (function (x) { - return x % 5 === 0; -})), undefined); +}, x => x % 5 === 0), undefined); eq("FLATTEN", Belt_List.flatten({ hd: { @@ -128,9 +120,7 @@ eq("FLATTEN", Belt_List.flatten({ tl: { hd: /* [] */0, tl: { - hd: Belt_List.makeBy(4, (function (i) { - return i; - })), + hd: Belt_List.makeBy(4, i => i), tl: /* [] */0 } } @@ -213,9 +203,7 @@ eq("CONCATMANY", Belt_List.concatMany([ tl: /* [] */0 }, /* [] */0, - Belt_List.makeBy(4, (function (i) { - return i; - })) + Belt_List.makeBy(4, i => i) ]), { hd: 1, tl: { @@ -321,15 +309,7 @@ eq("CONCATMANY", Belt_List.concatMany([{ } }); -eq("File \"bs_list_test.res\", line 66, characters 2-9", Belt_List.toArray(Belt_List.concat(Belt_List.makeBy(100, (function (i) { - return i; -})), Belt_List.makeBy(100, (function (i) { - return i; -})))), Belt_Array.concat(Belt_Array.makeBy(100, (function (i) { - return i; -})), Belt_Array.makeBy(100, (function (i) { - return i; -})))); +eq("File \"bs_list_test.res\", line 66, characters 2-9", Belt_List.toArray(Belt_List.concat(Belt_List.makeBy(100, i => i), Belt_List.makeBy(100, i => i))), Belt_Array.concat(Belt_Array.makeBy(100, i => i), Belt_Array.makeBy(100, i => i))); eq("APPEND", Belt_List.concat({ hd: 1, @@ -522,9 +502,7 @@ eq("PARTITION", Belt_List.partition({ } } } -}, (function (x) { - return !mod2(x); -})), [ +}, x => !mod2(x)), [ /* [] */0, { hd: 2, @@ -726,9 +704,7 @@ function id(x) { return x; } -eq("MAP", Belt_List.map(Belt_List.makeBy(5, id), (function (x) { - return (x << 1); -})), { +eq("MAP", Belt_List.map(Belt_List.makeBy(5, id), x => (x << 1)), { hd: 0, tl: { hd: 2, @@ -750,9 +726,7 @@ eq("MAP", Belt_List.map(/* [] */0, id), /* [] */0); eq("MAP", Belt_List.map({ hd: 1, tl: /* [] */0 -}, (function (x) { - return -x | 0; -})), { +}, x => -x | 0), { hd: -1, tl: /* [] */0 }); @@ -765,9 +739,7 @@ let length_10_id = Belt_List.makeBy(10, id); let length_8_id = Belt_List.makeBy(8, id); -let d = Belt_List.makeBy(10, (function (x) { - return (x << 1); -})); +let d = Belt_List.makeBy(10, x => (x << 1)); eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), d); @@ -783,9 +755,7 @@ eq("MAP2", Belt_List.zipBy({ eq("MAP2", Belt_List.zipBy(/* [] */0, /* [] */0, add), /* [] */0); -eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, (function (x) { - return (x << 1); -})), { +eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Belt_List.map(length_8_id, x => (x << 1)), { hd: 16, tl: { hd: 18, @@ -793,13 +763,9 @@ eq("MAP2", Belt_List.zipBy(length_10_id, length_10_id, add), Belt_List.concat(Be } })); -eq("MAP2", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (function (i, x) { - return i + x | 0; -}))); +eq("MAP2", Belt_List.zipBy(length_10_id, length_8_id, add), Belt_List.mapWithIndex(length_8_id, (i, x) => i + x | 0)); -eq("MAP2", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, (function (x) { - return (x << 1); -}))); +eq("MAP2", Belt_List.reverse(Belt_List.mapReverse2(length_10_id, length_10_id, add)), Belt_List.map(length_10_id, x => (x << 1))); let xs = Belt_List.reverse(Belt_List.mapReverse2(length_8_id, length_10_id, add)); @@ -822,9 +788,7 @@ eq("MAP2", Belt_List.mapReverse2({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x + y | 0; -})), { +}, (x, y) => x + y | 0), { hd: 4, tl: { hd: 2, @@ -1017,9 +981,7 @@ b("File \"bs_list_test.res\", line 205, characters 4-11", Belt_List.hasAssoc({ tl: /* [] */0 } } -}, 2, (function (prim0, prim1) { - return prim0 === prim1; -}))); +}, 2, (prim0, prim1) => prim0 === prim1)); b("File \"bs_list_test.res\", line 206, characters 4-11", !Belt_List.hasAssoc({ hd: [ @@ -1039,9 +1001,7 @@ b("File \"bs_list_test.res\", line 206, characters 4-11", !Belt_List.hasAssoc({ tl: /* [] */0 } } -}, 4, (function (prim0, prim1) { - return prim0 === prim1; -}))); +}, 4, (prim0, prim1) => prim0 === prim1)); b("File \"bs_list_test.res\", line 207, characters 4-11", Belt_List.hasAssoc({ hd: [ @@ -1061,9 +1021,7 @@ b("File \"bs_list_test.res\", line 207, characters 4-11", Belt_List.hasAssoc({ tl: /* [] */0 } } -}, 4, (function (x, y) { - return (x + 1 | 0) === y; -}))); +}, 4, (x, y) => (x + 1 | 0) === y)); eq("REMOVEASSOQ", Belt_List.removeAssoc({ hd: [ @@ -1083,9 +1041,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 3, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 3, (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1117,9 +1073,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 1, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 1, (prim0, prim1) => prim0 === prim1), { hd: [ 2, "2" @@ -1151,9 +1105,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 2, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 2, (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1185,9 +1137,7 @@ eq("REMOVEASSOQ", Belt_List.removeAssoc({ tl: /* [] */0 } } -}, 0, (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 0, (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1329,9 +1279,7 @@ let ll0 = Belt_List.removeAssoc(ll, 0, eqx); b("File \"bs_list_test.res\", line 222, characters 4-11", ll === ll0); -let ll1 = Belt_List.setAssoc(ll, 2, "22", (function (prim0, prim1) { - return prim0 === prim1; -})); +let ll1 = Belt_List.setAssoc(ll, 2, "22", (prim0, prim1) => prim0 === prim1); eq("File \"bs_list_test.res\", line 224, characters 5-12", ll1, { hd: [ @@ -1353,9 +1301,7 @@ eq("File \"bs_list_test.res\", line 224, characters 5-12", ll1, { } }); -let ll2 = Belt_List.setAssoc(ll1, 22, "2", (function (prim0, prim1) { - return prim0 === prim1; -})); +let ll2 = Belt_List.setAssoc(ll1, 22, "2", (prim0, prim1) => prim0 === prim1); b("File \"bs_list_test.res\", line 226, characters 4-11", Caml_obj.equal(ll2, { hd: [ @@ -1385,9 +1331,7 @@ b("File \"bs_list_test.res\", line 229, characters 4-11", Caml_obj.equal(Belt_Li tl: /* [] */0 } } -}, 2, "x", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 2, "x", (prim0, prim1) => prim0 === prim1), { hd: [ 1, "a" @@ -1419,9 +1363,7 @@ b("File \"bs_list_test.res\", line 234, characters 4-11", Caml_obj.equal(Belt_Li ], tl: /* [] */0 } -}, 2, "2", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 2, "2", (prim0, prim1) => prim0 === prim1), { hd: [ 2, "2" @@ -1441,9 +1383,7 @@ b("File \"bs_list_test.res\", line 234, characters 4-11", Caml_obj.equal(Belt_Li } })); -eq("File \"bs_list_test.res\", line 237, characters 5-12", Belt_List.setAssoc(/* [] */0, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; -})), { +eq("File \"bs_list_test.res\", line 237, characters 5-12", Belt_List.setAssoc(/* [] */0, 1, "1", (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1459,9 +1399,7 @@ eq("File \"bs_list_test.res\", line 239, characters 5-12", Belt_List.setAssoc({ "2" ], tl: /* [] */0 -}, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 1, "1", (prim0, prim1) => prim0 === prim1), { hd: [ 1, "1" @@ -1481,9 +1419,7 @@ eq("File \"bs_list_test.res\", line 241, characters 5-12", Belt_List.setAssoc({ ], tl: /* [] */0 } -}, 1, "1", (function (prim0, prim1) { - return prim0 === prim1; -})), { +}, 1, "1", (prim0, prim1) => prim0 === prim1), { hd: [ 0, "0" @@ -1515,9 +1451,7 @@ b("File \"bs_list_test.res\", line 242, characters 4-11", Caml_obj.equal(Belt_Li tl: /* [] */0 } } -}, 2, (function (prim0, prim1) { - return prim0 === prim1; -})), "b")); +}, 2, (prim0, prim1) => prim0 === prim1), "b")); b("File \"bs_list_test.res\", line 243, characters 4-11", Belt_List.getAssoc({ hd: [ @@ -1537,9 +1471,7 @@ b("File \"bs_list_test.res\", line 243, characters 4-11", Belt_List.getAssoc({ tl: /* [] */0 } } -}, 4, (function (prim0, prim1) { - return prim0 === prim1; -})) === undefined); +}, 4, (prim0, prim1) => prim0 === prim1) === undefined); eq("File \"bs_list_test.res\", line 248, characters 4-11", [ Belt_List.head(length_10_id), @@ -1551,15 +1483,13 @@ eq("File \"bs_list_test.res\", line 248, characters 4-11", [ eq("File \"bs_list_test.res\", line 255, characters 5-12", Belt_List.head(/* [] */0), undefined); -$$throw("File \"bs_list_test.res\", line 256, characters 8-15", (function () { - Belt_List.headExn(/* [] */0); -})); +$$throw("File \"bs_list_test.res\", line 256, characters 8-15", () => Belt_List.headExn(/* [] */0)); -$$throw("File \"bs_list_test.res\", line 257, characters 8-15", (function () { +$$throw("File \"bs_list_test.res\", line 257, characters 8-15", () => { Belt_List.tailExn(/* [] */0); -})); +}); -$$throw("File \"bs_list_test.res\", line 258, characters 8-15", (function () { +$$throw("File \"bs_list_test.res\", line 258, characters 8-15", () => { Belt_List.getExn({ hd: 0, tl: { @@ -1567,9 +1497,9 @@ $$throw("File \"bs_list_test.res\", line 258, characters 8-15", (function () { tl: /* [] */0 } }, -1); -})); +}); -$$throw("File \"bs_list_test.res\", line 259, characters 8-15", (function () { +$$throw("File \"bs_list_test.res\", line 259, characters 8-15", () => { Belt_List.getExn({ hd: 0, tl: { @@ -1577,7 +1507,7 @@ $$throw("File \"bs_list_test.res\", line 259, characters 8-15", (function () { tl: /* [] */0 } }, 2); -})); +}); eq("File \"bs_list_test.res\", line 260, characters 5-12", Belt_List.map({ hd: 0, @@ -1585,15 +1515,13 @@ eq("File \"bs_list_test.res\", line 260, characters 5-12", Belt_List.map({ hd: 1, tl: /* [] */0 } -}, (function (i) { - return Belt_List.getExn({ - hd: 0, - tl: { - hd: 1, - tl: /* [] */0 - } - }, i); -})), { +}, i => Belt_List.getExn({ + hd: 0, + tl: { + hd: 1, + tl: /* [] */0 + } +}, i)), { hd: 0, tl: { hd: 1, @@ -1611,17 +1539,13 @@ eq("File \"bs_list_test.res\", line 262, characters 5-12", Belt_List.tailExn({ tl: /* [] */0 }), /* [] */0); -Belt_List.forEachWithIndex(length_10_id, (function (i, x) { - eq("File \"bs_list_test.res\", line 263, characters 48-55", Belt_List.get(length_10_id, i), x); -})); +Belt_List.forEachWithIndex(length_10_id, (i, x) => eq("File \"bs_list_test.res\", line 263, characters 48-55", Belt_List.get(length_10_id, i), x)); eq("File \"bs_list_test.res\", line 264, characters 5-12", Belt_List.tail(/* [] */0), undefined); eq("File \"bs_list_test.res\", line 265, characters 5-12", Belt_List.drop(/* [] */0, 3), undefined); -eq("File \"bs_list_test.res\", line 266, characters 5-12", Belt_List.mapWithIndex(/* [] */0, (function (i, x) { - return i + x | 0; -})), /* [] */0); +eq("File \"bs_list_test.res\", line 266, characters 5-12", Belt_List.mapWithIndex(/* [] */0, (i, x) => i + x | 0), /* [] */0); eq("File \"bs_list_test.res\", line 267, characters 5-12", Belt_List.get(length_10_id, -1), undefined); @@ -1645,11 +1569,7 @@ eq("File \"bs_list_test.res\", line 290, characters 5-12", Belt_List.reduce(leng eq("File \"bs_list_test.res\", line 291, characters 5-12", Belt_List.reduceReverse(length_10_id, 0, add), 45); -eq("File \"bs_list_test.res\", line 292, characters 5-12", Belt_List.reduceReverse(Belt_List.makeBy(10000, (function (i) { - return i; -})), 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -})), 49995000); +eq("File \"bs_list_test.res\", line 292, characters 5-12", Belt_List.reduceReverse(Belt_List.makeBy(10000, i => i), 0, (prim0, prim1) => prim0 + prim1 | 0), 49995000); eq("File \"bs_list_test.res\", line 295, characters 5-12", sum2(length_10_id, length_10_id), 90); @@ -1657,9 +1577,7 @@ eq("File \"bs_list_test.res\", line 296, characters 5-12", sum2(length_8_id, len eq("File \"bs_list_test.res\", line 297, characters 5-12", sum2(length_10_id, length_8_id), 56); -eq("File \"bs_list_test.res\", line 298, characters 5-12", Belt_List.reduce2(length_10_id, length_8_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 56); +eq("File \"bs_list_test.res\", line 298, characters 5-12", Belt_List.reduce2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); eq("File \"bs_list_test.res\", line 299, characters 5-12", Belt_List.reduce2({ hd: 1, @@ -1679,17 +1597,11 @@ eq("File \"bs_list_test.res\", line 299, characters 5-12", Belt_List.reduce2({ tl: /* [] */0 } } -}, 0, (function (a, b, c) { - return (a + b | 0) + c | 0; -})), 18); +}, 0, (a, b, c) => (a + b | 0) + c | 0), 18); -eq("File \"bs_list_test.res\", line 300, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_8_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 56); +eq("File \"bs_list_test.res\", line 300, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_8_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 56); -eq("File \"bs_list_test.res\", line 301, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_10_id, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 90); +eq("File \"bs_list_test.res\", line 301, characters 5-12", Belt_List.reduceReverse2(length_10_id, length_10_id, 0, (acc, x, y) => (acc + x | 0) + y | 0), 90); eq("File \"bs_list_test.res\", line 302, characters 5-12", Belt_List.reduceReverse2({ hd: 1, @@ -1706,9 +1618,7 @@ eq("File \"bs_list_test.res\", line 302, characters 5-12", Belt_List.reduceRever hd: 2, tl: /* [] */0 } -}, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})), 6); +}, 0, (acc, x, y) => (acc + x | 0) + y | 0), 6); eq("File \"bs_list_test.res\", line 303, characters 5-12", Belt_List.every({ hd: 2, @@ -1761,9 +1671,7 @@ eq("File \"bs_list_test.res\", line 309, characters 5-12", Belt_List.has({ tl: /* [] */0 } } -}, "2", (function (x, s) { - return String(x) === s; -})), true); +}, "2", (x, s) => String(x) === s), true); eq("File \"bs_list_test.res\", line 310, characters 5-12", Belt_List.has({ hd: 1, @@ -1774,9 +1682,7 @@ eq("File \"bs_list_test.res\", line 310, characters 5-12", Belt_List.has({ tl: /* [] */0 } } -}, "0", (function (x, s) { - return String(x) === s; -})), false); +}, "0", (x, s) => String(x) === s), false); b("File \"bs_list_test.res\", line 312, characters 4-11", Belt_List.reduceReverse({ hd: 1, @@ -1790,9 +1696,7 @@ b("File \"bs_list_test.res\", line 312, characters 4-11", Belt_List.reduceRevers } } } -}, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -})) === 10); +}, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); b("File \"bs_list_test.res\", line 313, characters 4-11", Belt_List.reduceReverse({ hd: 1, @@ -1806,9 +1710,7 @@ b("File \"bs_list_test.res\", line 313, characters 4-11", Belt_List.reduceRevers } } } -}, 10, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})) === 0); +}, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); b("File \"bs_list_test.res\", line 314, characters 4-11", Caml_obj.equal(Belt_List.reduceReverse({ hd: 1, @@ -1848,9 +1750,7 @@ b("File \"bs_list_test.res\", line 315, characters 4-11", Belt_List.reduce({ } } } -}, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -})) === 10); +}, 0, (prim0, prim1) => prim0 + prim1 | 0) === 10); b("File \"bs_list_test.res\", line 316, characters 4-11", Belt_List.reduce({ hd: 1, @@ -1864,9 +1764,7 @@ b("File \"bs_list_test.res\", line 316, characters 4-11", Belt_List.reduce({ } } } -}, 10, (function (prim0, prim1) { - return prim0 - prim1 | 0; -})) === 0); +}, 10, (prim0, prim1) => prim0 - prim1 | 0) === 0); b("File \"bs_list_test.res\", line 317, characters 4-11", Caml_obj.equal(Belt_List.reduce({ hd: 1, @@ -1906,9 +1804,7 @@ b("File \"bs_list_test.res\", line 318, characters 4-11", Belt_List.reduceWithIn } } } -}, 0, (function (acc, x, i) { - return (acc + x | 0) + i | 0; -})) === 16); +}, 0, (acc, x, i) => (acc + x | 0) + i | 0) === 16); b("File \"bs_list_test.res\", line 319, characters 4-11", Belt_List.reduceReverse2({ hd: 1, @@ -1925,27 +1821,19 @@ b("File \"bs_list_test.res\", line 319, characters 4-11", Belt_List.reduceRevers hd: 2, tl: /* [] */0 } -}, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})) === 6); +}, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 6); -let a$1 = Belt_List.makeBy(10000, (function (i) { - return i; -})); +let a$1 = Belt_List.makeBy(10000, i => i); b("File \"bs_list_test.res\", line 322, characters 4-11", Belt_List.reduceReverse2(a$1, { hd: 0, tl: a$1 -}, 0, (function (acc, x, y) { - return (acc + x | 0) + y | 0; -})) === 99980001); +}, 0, (acc, x, y) => (acc + x | 0) + y | 0) === 99980001); eq("File \"bs_list_test.res\", line 328, characters 5-12", Belt_List.every2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 329, characters 5-12", Belt_List.every2({ hd: 2, @@ -1956,9 +1844,7 @@ eq("File \"bs_list_test.res\", line 329, characters 5-12", Belt_List.every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 330, characters 5-12", Belt_List.every2({ hd: 2, @@ -1966,9 +1852,7 @@ eq("File \"bs_list_test.res\", line 330, characters 5-12", Belt_List.every2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 331, characters 5-12", Belt_List.every2({ hd: 2, @@ -1982,9 +1866,7 @@ eq("File \"bs_list_test.res\", line 331, characters 5-12", Belt_List.every2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_list_test.res\", line 332, characters 5-12", Belt_List.every2({ hd: 2, @@ -1998,16 +1880,12 @@ eq("File \"bs_list_test.res\", line 332, characters 5-12", Belt_List.every2({ hd: 0, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 333, characters 5-12", Belt_List.some2(/* [] */0, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_list_test.res\", line 334, characters 5-12", Belt_List.some2({ hd: 2, @@ -2018,9 +1896,7 @@ eq("File \"bs_list_test.res\", line 334, characters 5-12", Belt_List.some2({ }, { hd: 1, tl: /* [] */0 -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 335, characters 5-12", Belt_List.some2({ hd: 2, @@ -2034,9 +1910,7 @@ eq("File \"bs_list_test.res\", line 335, characters 5-12", Belt_List.some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 336, characters 5-12", Belt_List.some2({ hd: 0, @@ -2050,9 +1924,7 @@ eq("File \"bs_list_test.res\", line 336, characters 5-12", Belt_List.some2({ hd: 4, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), false); +}, (x, y) => x > y), false); eq("File \"bs_list_test.res\", line 337, characters 5-12", Belt_List.some2({ hd: 0, @@ -2066,9 +1938,7 @@ eq("File \"bs_list_test.res\", line 337, characters 5-12", Belt_List.some2({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x > y; -})), true); +}, (x, y) => x > y), true); eq("File \"bs_list_test.res\", line 338, characters 5-12", Belt_List.some2({ hd: 1, @@ -2085,14 +1955,10 @@ eq("File \"bs_list_test.res\", line 338, characters 5-12", Belt_List.some2({ hd: -2, tl: /* [] */0 } -}, (function (x, y) { - return x === y; -})), false); +}, (x, y) => x === y), false); function makeTest(n) { - eq("File \"bs_list_test.res\", line 341, characters 23-30", Belt_List.make(n, 3), Belt_List.makeBy(n, (function (param) { - return 3; - }))); + eq("File \"bs_list_test.res\", line 341, characters 23-30", Belt_List.make(n, 3), Belt_List.makeBy(n, param => 3)); } eq("File \"bs_list_test.res\", line 343, characters 12-19", { @@ -2371,9 +2237,7 @@ b("File \"bs_list_test.res\", line 374, characters 4-11", !Belt_List.eq({ hd: 2, tl: /* [] */0 } -}, (function (x, y) { - return x === y; -}))); +}, (x, y) => x === y)); b("File \"bs_list_test.res\", line 375, characters 4-11", Belt_List.eq({ hd: 1, @@ -2393,9 +2257,7 @@ b("File \"bs_list_test.res\", line 375, characters 4-11", Belt_List.eq({ tl: /* [] */0 } } -}, (function (x, y) { - return x === y; -}))); +}, (x, y) => x === y)); b("File \"bs_list_test.res\", line 376, characters 4-11", !Belt_List.eq({ hd: 1, @@ -2415,9 +2277,7 @@ b("File \"bs_list_test.res\", line 376, characters 4-11", !Belt_List.eq({ tl: /* [] */0 } } -}, (function (x, y) { - return x === y; -}))); +}, (x, y) => x === y)); b("File \"bs_list_test.res\", line 377, characters 4-11", !Belt_List.eq({ hd: 1, @@ -2440,20 +2300,16 @@ b("File \"bs_list_test.res\", line 377, characters 4-11", !Belt_List.eq({ } } } -}, (function (prim0, prim1) { - return prim0 === prim1; -}))); +}, (prim0, prim1) => prim0 === prim1)); -let u0 = Belt_List.makeBy(20, (function (x) { - return x; -})); +let u0 = Belt_List.makeBy(20, x => x); -let u1 = Belt_List.keepMap(u0, (function (x) { +let u1 = Belt_List.keepMap(u0, x => { if (x % 7 === 0) { return x + 1 | 0; } -})); +}); eq("File \"bs_list_test.res\", line 388, characters 5-12", u1, { hd: 1, @@ -2478,12 +2334,12 @@ b("File \"bs_list_test.res\", line 390, characters 4-11", Caml_obj.equal(Belt_Li } } } -}, (function (x) { +}, x => { if (x % 2 === 0) { return -x | 0; } -})), { +}), { hd: -2, tl: { hd: -4, @@ -2503,12 +2359,12 @@ b("File \"bs_list_test.res\", line 404, characters 4-11", Belt_List.keepMap({ } } } -}, (function (x) { +}, x => { if (x % 5 === 0) { return x; } -})) === /* [] */0); +}) === /* [] */0); Mt.from_pair_suites("Bs_list_test", suites.contents); diff --git a/jscomp/test/bs_map_set_dict_test.js b/jscomp/test/bs_map_set_dict_test.js index a032c6e69e..5cc84fab8d 100644 --- a/jscomp/test/bs_map_set_dict_test.js +++ b/jscomp/test/bs_map_set_dict_test.js @@ -53,9 +53,7 @@ let m00 = { }; let I2 = { - cmp: (function (x, y) { - return Caml.int_compare(y, x); - }) + cmp: (x, y) => Caml.int_compare(y, x) }; let m_cmp = Icmp2.cmp; @@ -114,63 +112,51 @@ function f(none) { } function $eq$tilde(a, b) { - return function (extra) { - return Belt_Map.eq(a, b, extra); - }; + return extra => Belt_Map.eq(a, b, extra); } -let u0 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 39), (function (x) { - return [ - x, - x - ]; -})), Icmp); +let u0 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 39), x => [ + x, + x +]), Icmp); let u1 = Belt_Map.set(u0, 39, 120); -b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.every2(Belt_MapDict.toArray(u0.data), Belt_Array.map(Array_data_util.range(0, 39), (function (x) { - return [ - x, - x - ]; -})), (function (param, param$1) { +b("File \"bs_map_set_dict_test.res\", line 72, characters 4-11", Belt_Array.every2(Belt_MapDict.toArray(u0.data), Belt_Array.map(Array_data_util.range(0, 39), x => [ + x, + x +]), (param, param$1) => { if (param[0] === param$1[0]) { return param[1] === param$1[1]; } else { return false; } -}))); - -b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_MapDict.toList(u0.data), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), (function (x) { - return [ - x, - x - ]; -}))), (function (param, param$1) { +})); + +b("File \"bs_map_set_dict_test.res\", line 79, characters 4-11", Belt_List.every2(Belt_MapDict.toList(u0.data), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), x => [ + x, + x +])), (param, param$1) => { if (param[0] === param$1[0]) { return param[1] === param$1[1]; } else { return false; } -}))); +})); eq("File \"bs_map_set_dict_test.res\", line 84, characters 5-12", Belt_Map.get(u0, 39), 39); eq("File \"bs_map_set_dict_test.res\", line 85, characters 5-12", Belt_Map.get(u1, 39), 120); -let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, (function (x) { - return [ - x, - x - ]; -})), Icmp); - -eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, (function (x) { - return [ - x, - x - ]; -})), Belt_MapDict.toArray(u.data)); +let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, x => [ + x, + x +]), Icmp); + +eq("File \"bs_map_set_dict_test.res\", line 90, characters 5-12", Belt_Array.makeBy(10000, x => [ + x, + x +]), Belt_MapDict.toArray(u.data)); Mt.from_pair_suites("Bs_map_set_dict_test", suites.contents); diff --git a/jscomp/test/bs_map_test.js b/jscomp/test/bs_map_test.js index 689645a29f..585b8956f4 100644 --- a/jscomp/test/bs_map_test.js +++ b/jscomp/test/bs_map_test.js @@ -19,12 +19,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -36,11 +34,9 @@ function b(loc, v) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Ok", - _0: v - }; + () => ({ + TAG: "Ok", + _0: v }) ], tl: suites.contents @@ -55,12 +51,10 @@ function emptyMap() { } -let v = Belt_Array.makeByAndShuffle(1000000, (function (i) { - return [ - i, - i - ]; -})); +let v = Belt_Array.makeByAndShuffle(1000000, i => [ + i, + i +]); let u = Belt_MapInt.fromArray(v); @@ -68,9 +62,7 @@ Belt_MapInt.checkInvariantInternal(u); let firstHalf = Belt_Array.slice(v, 0, 2000); -let xx = Belt_Array.reduce(firstHalf, u, (function (acc, param) { - return Belt_MapInt.remove(acc, param[0]); -})); +let xx = Belt_Array.reduce(firstHalf, u, (acc, param) => Belt_MapInt.remove(acc, param[0])); Belt_MapInt.checkInvariantInternal(u); diff --git a/jscomp/test/bs_mutable_set_test.js b/jscomp/test/bs_mutable_set_test.js index 484e86f318..8c17ab5ba9 100644 --- a/jscomp/test/bs_mutable_set_test.js +++ b/jscomp/test/bs_mutable_set_test.js @@ -113,33 +113,29 @@ let v = { data: Belt_internalSetInt.fromArray(xs$1) }; -let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), (function (x) { - return Belt_MutableSetInt.removeCheck(v, x); -})); +let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSetInt.removeCheck(v, x)); -let indeedRemoved = Belt_Array.reduce(bs, 0, (function (acc, x) { +let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_mutable_set_test.res\", line 72, characters 9-16", indeedRemoved, 500); eq("File \"bs_mutable_set_test.res\", line 73, characters 9-16", Belt_internalAVLset.size(v.data), 501); -let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), (function (x) { - return Belt_MutableSetInt.addCheck(v, x); -})); +let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSetInt.addCheck(v, x)); -let indeedAded = Belt_Array.reduce(cs, 0, (function (acc, x) { +let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_mutable_set_test.res\", line 82, characters 9-16", indeedAded, 1000); @@ -157,15 +153,9 @@ eq("File \"bs_mutable_set_test.res\", line 87, characters 9-16", Belt_internalAV eq("File \"bs_mutable_set_test.res\", line 88, characters 9-16", Belt_internalAVLset.maxUndefined(v.data), 2000); -eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (function (x, y) { - return x + y | 0; -})), 1876250); +eq("File \"bs_mutable_set_test.res\", line 89, characters 9-16", Belt_MutableSetInt.reduce(v, 0, (x, y) => x + y | 0), 1876250); -b("File \"bs_mutable_set_test.res\", line 90, characters 8-15", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, (function (i) { - return i + 500 | 0; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_mutable_set_test.res\", line 90, characters 8-15", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); eq("File \"bs_mutable_set_test.res\", line 91, characters 9-16", Belt_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); @@ -185,13 +175,9 @@ let aa = match$1[0]; b("File \"bs_mutable_set_test.res\", line 96, characters 8-15", match[1]); -b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (function (x, y) { - return x === y; -}))); +b("File \"bs_mutable_set_test.res\", line 97, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (x, y) => x === y)); -b("File \"bs_mutable_set_test.res\", line 98, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_mutable_set_test.res\", line 98, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_mutable_set_test.res\", line 99, characters 8-15", Belt_MutableSetInt.subset(aa, v)); @@ -213,13 +199,9 @@ let aa$1 = match$3[0]; b("File \"bs_mutable_set_test.res\", line 105, characters 8-15", !match$2[1]); -b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_mutable_set_test.res\", line 106, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_mutable_set_test.res\", line 107, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_mutable_set_test.res\", line 107, characters 8-15", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_mutable_set_test.res\", line 108, characters 8-15", Belt_MutableSetInt.subset(aa$1, v)); @@ -378,17 +360,11 @@ let a0 = { data: Belt_internalSetInt.fromArray(xs$24) }; -let a1 = Belt_MutableSetInt.keep(a0, (function (x) { - return x % 2 === 0; -})); +let a1 = Belt_MutableSetInt.keep(a0, x => x % 2 === 0); -let a2 = Belt_MutableSetInt.keep(a0, (function (x) { - return x % 2 !== 0; -})); +let a2 = Belt_MutableSetInt.keep(a0, x => x % 2 !== 0); -let match$4 = Belt_MutableSetInt.partition(a0, (function (x) { - return x % 2 === 0; -})); +let match$4 = Belt_MutableSetInt.partition(a0, x => x % 2 === 0); let a4 = match$4[1]; @@ -413,9 +389,7 @@ Belt_List.forEach({ } } } -}, (function (x) { - Belt_internalAVLset.checkInvariantInternal(x.data); -})); +}, x => Belt_internalAVLset.checkInvariantInternal(x.data)); let v$1 = { data: undefined @@ -427,9 +401,7 @@ for (let i$2 = 0; i$2 <= 100000; ++i$2) { Belt_internalAVLset.checkInvariantInternal(v$1.data); -b("File \"bs_mutable_set_test.res\", line 188, characters 10-17", Belt_Range.every(0, 100000, (function (i) { - return Belt_internalSetInt.has(v$1.data, i); -}))); +b("File \"bs_mutable_set_test.res\", line 188, characters 10-17", Belt_Range.every(0, 100000, i => Belt_internalSetInt.has(v$1.data, i))); eq("File \"bs_mutable_set_test.res\", line 189, characters 5-12", Belt_internalAVLset.size(v$1.data), 100001); @@ -471,9 +443,7 @@ eq("File \"bs_mutable_set_test.res\", line 216, characters 5-12", Belt_internalA b("File \"bs_mutable_set_test.res\", line 217, characters 4-11", Belt_MutableSetInt.isEmpty(v$3)); -let xs$25 = Belt_Array.makeBy(30, (function (i) { - return i; -})); +let xs$25 = Belt_Array.makeBy(30, i => i); let v$4 = { data: Belt_internalSetInt.fromArray(xs$25) @@ -504,9 +474,7 @@ function id(loc, x) { data: Belt_internalAVLset.fromSortedArrayUnsafe(x) }; Belt_internalAVLset.checkInvariantInternal(u.data); - b(loc, Belt_Array.every2(Belt_internalAVLset.toArray(u.data), x, (function (prim0, prim1) { - return prim0 === prim1; - }))); + b(loc, Belt_Array.every2(Belt_internalAVLset.toArray(u.data), x, (prim0, prim1) => prim0 === prim1)); } id("File \"bs_mutable_set_test.res\", line 242, characters 5-12", []); @@ -598,17 +566,11 @@ let v$5 = { data: Belt_internalSetInt.fromArray(xs$26) }; -let copyV = Belt_MutableSetInt.keep(v$5, (function (x) { - return x % 8 === 0; -})); +let copyV = Belt_MutableSetInt.keep(v$5, x => x % 8 === 0); -let match$5 = Belt_MutableSetInt.partition(v$5, (function (x) { - return x % 8 === 0; -})); +let match$5 = Belt_MutableSetInt.partition(v$5, x => x % 8 === 0); -let cc$1 = Belt_MutableSetInt.keep(v$5, (function (x) { - return x % 8 !== 0; -})); +let cc$1 = Belt_MutableSetInt.keep(v$5, x => x % 8 !== 0); for (let i$6 = 0; i$6 <= 200; ++i$6) { Belt_MutableSetInt.remove(v$5, i$6); @@ -616,9 +578,7 @@ for (let i$6 = 0; i$6 <= 200; ++i$6) { eq("File \"bs_mutable_set_test.res\", line 264, characters 5-12", Belt_internalAVLset.size(copyV.data), 126); -eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_internalAVLset.toArray(copyV.data), Belt_Array.makeBy(126, (function (i) { - return (i << 3); -}))); +eq("File \"bs_mutable_set_test.res\", line 265, characters 5-12", Belt_internalAVLset.toArray(copyV.data), Belt_Array.makeBy(126, i => (i << 3))); eq("File \"bs_mutable_set_test.res\", line 266, characters 5-12", Belt_internalAVLset.size(v$5.data), 800); @@ -648,9 +608,7 @@ b("File \"bs_mutable_set_test.res\", line 275, characters 4-11", Belt_MutableSet data: Belt_internalSetInt.fromArray(xs$29) })); -let xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), (function (x) { - return (x << 1); -})); +let xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), x => (x << 1)); let d = { data: Belt_internalSetInt.fromArray(xs$30) @@ -660,17 +618,13 @@ let match$8 = Belt_MutableSetInt.split(d, 1001); let match$9 = match$8[0]; -let xs$31 = Belt_Array.makeBy(501, (function (x) { - return (x << 1); -})); +let xs$31 = Belt_Array.makeBy(501, x => (x << 1)); b("File \"bs_mutable_set_test.res\", line 278, characters 4-11", Belt_MutableSetInt.eq(match$9[0], { data: Belt_internalSetInt.fromArray(xs$31) })); -let xs$32 = Belt_Array.makeBy(500, (function (x) { - return 1002 + (x << 1) | 0; -})); +let xs$32 = Belt_Array.makeBy(500, x => 1002 + (x << 1) | 0); b("File \"bs_mutable_set_test.res\", line 279, characters 4-11", Belt_MutableSetInt.eq(match$9[1], { data: Belt_internalSetInt.fromArray(xs$32) diff --git a/jscomp/test/bs_poly_map_test.js b/jscomp/test/bs_poly_map_test.js index aa8030e6e3..b1d01724bb 100644 --- a/jscomp/test/bs_poly_map_test.js +++ b/jscomp/test/bs_poly_map_test.js @@ -46,42 +46,40 @@ function emptyMap() { } function mergeInter(s1, s2) { - let m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { + let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { if (v1 !== undefined && v2 !== undefined) { return Caml_option.some(undefined); } - })); + }); return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function mergeUnion(s1, s2) { - let m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { + let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { if (v1 !== undefined || v2 !== undefined) { return Caml_option.some(undefined); } - })); + }); return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function mergeDiff(s1, s2) { - let m = Belt_Map.merge(s1, s2, (function (k, v1, v2) { + let m = Belt_Map.merge(s1, s2, (k, v1, v2) => { if (v1 !== undefined && v2 === undefined) { return Caml_option.some(undefined); } - })); + }); return Belt_Set.fromArray(Belt_MapDict.keysToArray(m.data), Icmp); } function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), (function (x) { - return [ - x, - x - ]; - })); + return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ + x, + x + ]); } let u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); @@ -102,20 +100,20 @@ let a1 = Belt_Map.set(a0, 3, 33); let a2 = Belt_Map.remove(a1, 3); -let a3 = Belt_Map.update(a2, 3, (function (k) { +let a3 = Belt_Map.update(a2, 3, k => { if (k !== undefined) { return k + 1 | 0; } else { return 11; } -})); +}); -let a4 = Belt_Map.update(a2, 3, (function (k) { +let a4 = Belt_Map.update(a2, 3, k => { if (k !== undefined) { return k + 1 | 0; } -})); +}); let a5 = Belt_Map.remove(a0, 3); @@ -169,14 +167,12 @@ eq("File \"bs_poly_map_test.res\", line 108, characters 5-12", Belt_Map.get(u1$1 eq("File \"bs_poly_map_test.res\", line 109, characters 5-12", Belt_Map.get(u0$1, 3), 3); function acc(m, is) { - return Belt_Array.reduce(is, m, (function (a, i) { - return Belt_Map.update(a, i, (function (n) { - if (n !== undefined) { - return n + 1 | 0; - } else { - return 1; - } - })); + return Belt_Array.reduce(is, m, (a, i) => Belt_Map.update(a, i, n => { + if (n !== undefined) { + return n + 1 | 0; + } else { + return 1; + } })); } @@ -189,14 +185,10 @@ let m = { let m1 = acc(m, Belt_Array.concat(Array_data_util.randomRange(0, 20), Array_data_util.randomRange(10, 30))); -b("File \"bs_poly_map_test.res\", line 126, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, (function (i) { - return [ - i, - i >= 10 && i <= 20 ? 2 : 1 - ]; -})), Icmp), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_map_test.res\", line 126, characters 4-11", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, i => [ + i, + i >= 10 && i <= 20 ? 2 : 1 +]), Icmp), (x, y) => x === y)); let v0_cmp = Icmp.cmp; @@ -205,23 +197,17 @@ let v0 = { data: undefined }; -let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { - return [ - x, - x - ]; -}))); +let v1 = Belt_Map.mergeMany(v0, Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ + x, + x +])); -let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), (function (x) { - return [ - x, - x - ]; -})), Icmp); +let v2 = Belt_Map.fromArray(Belt_Array.map(Array_data_util.randomRange(0, 10000), x => [ + x, + x +]), Icmp); -b("File \"bs_poly_map_test.res\", line 150, characters 4-11", Belt_Map.eq(v1, v2, (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_map_test.res\", line 150, characters 4-11", Belt_Map.eq(v1, v2, (x, y) => x === y)); function inc(x) { if (x !== undefined) { @@ -269,17 +255,9 @@ b("File \"bs_poly_map_test.res\", line 182, characters 4-11", Belt_MapDict.isEmp b("File \"bs_poly_map_test.res\", line 184, characters 4-11", pres !== undefined ? pres === 5000 : false); -b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[0].data), Belt_Array.makeBy(5000, (function (i) { - return i; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_map_test.res\", line 190, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_poly_map_test.res\", line 191, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[1].data), Belt_Array.makeBy(5000, (function (i) { - return 5001 + i | 0; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_map_test.res\", line 191, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$1[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); let v7 = Belt_Map.remove(v3, 5000); @@ -289,17 +267,9 @@ let match$6 = match$5[0]; b("File \"bs_poly_map_test.res\", line 196, characters 4-11", match$5[1] === undefined); -b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[0].data), Belt_Array.makeBy(5000, (function (i) { - return i; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); - -b("File \"bs_poly_map_test.res\", line 203, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[1].data), Belt_Array.makeBy(5000, (function (i) { - return 5001 + i | 0; -})), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_map_test.res\", line 202, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[0].data), Belt_Array.makeBy(5000, i => i), (prim0, prim1) => prim0 === prim1)); + +b("File \"bs_poly_map_test.res\", line 203, characters 4-11", Belt_Array.eq(Belt_MapDict.keysToArray(match$6[1].data), Belt_Array.makeBy(5000, i => 5001 + i | 0), (prim0, prim1) => prim0 === prim1)); Mt.from_pair_suites("Bs_poly_map_test", suites.contents); diff --git a/jscomp/test/bs_poly_mutable_map_test.js b/jscomp/test/bs_poly_mutable_map_test.js index 85020d2aca..5d8d490da6 100644 --- a/jscomp/test/bs_poly_mutable_map_test.js +++ b/jscomp/test/bs_poly_mutable_map_test.js @@ -38,12 +38,10 @@ function ff(x) { } function randomRange(i, j) { - return Belt_Array.map(Array_data_util.randomRange(i, j), (function (x) { - return [ - x, - x - ]; - })); + return Belt_Array.map(Array_data_util.randomRange(i, j), x => [ + x, + x + ]); } let a0 = Belt_MutableMap.fromArray(randomRange(0, 10), Icmp); @@ -79,13 +77,9 @@ let a0$1 = Belt_MutableMap.fromArray(randomRange(0, 10000), Icmp); Belt_MutableMap.set(a0$1, 2000, 33); -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), (function (prim) { - return prim[0]; -}))); +Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(0, 1998), prim => prim[0])); -Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(2002, 11000), (function (prim) { - return prim[0]; -}))); +Belt_MutableMap.removeMany(a0$1, Belt_Array.map(randomRange(2002, 11000), prim => prim[0])); eq("File \"bs_poly_mutable_map_test.res\", line 39, characters 5-12", Belt_internalAVLtree.toArray(a0$1.data), [ [ diff --git a/jscomp/test/bs_poly_mutable_set_test.js b/jscomp/test/bs_poly_mutable_set_test.js index 26d94fd88b..02a95bc8e5 100644 --- a/jscomp/test/bs_poly_mutable_set_test.js +++ b/jscomp/test/bs_poly_mutable_set_test.js @@ -118,33 +118,29 @@ b("File \"bs_poly_mutable_set_test.res\", line 54, characters 4-11", Belt_Mutabl let v = Belt_MutableSet.fromArray(Array_data_util.randomRange(1000, 2000), IntCmp); -let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), (function (x) { - return Belt_MutableSet.removeCheck(v, x); -})); +let bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), x => Belt_MutableSet.removeCheck(v, x)); -let indeedRemoved = Belt_Array.reduce(bs, 0, (function (acc, x) { +let indeedRemoved = Belt_Array.reduce(bs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_poly_mutable_set_test.res\", line 67, characters 5-12", indeedRemoved, 500); eq("File \"bs_poly_mutable_set_test.res\", line 68, characters 5-12", Belt_internalAVLset.size(v.data), 501); -let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), (function (x) { - return Belt_MutableSet.addCheck(v, x); -})); +let cs = Belt_Array.map(Array_data_util.randomRange(500, 2000), x => Belt_MutableSet.addCheck(v, x)); -let indeedAded = Belt_Array.reduce(cs, 0, (function (acc, x) { +let indeedAded = Belt_Array.reduce(cs, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_poly_mutable_set_test.res\", line 77, characters 5-12", indeedAded, 1000); @@ -163,15 +159,9 @@ eq("File \"bs_poly_mutable_set_test.res\", line 82, characters 5-12", Belt_inter eq("File \"bs_poly_mutable_set_test.res\", line 83, characters 5-12", Belt_internalAVLset.maxUndefined(v.data), 2000); -eq("File \"bs_poly_mutable_set_test.res\", line 84, characters 5-12", Belt_MutableSet.reduce(v, 0, (function (x, y) { - return x + y | 0; -})), 1876250); +eq("File \"bs_poly_mutable_set_test.res\", line 84, characters 5-12", Belt_MutableSet.reduce(v, 0, (x, y) => x + y | 0), 1876250); -b("File \"bs_poly_mutable_set_test.res\", line 85, characters 4-11", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, (function (i) { - return i + 500 | 0; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 85, characters 4-11", Belt_List.eq(Belt_internalAVLset.toList(v.data), Belt_List.makeBy(1501, i => i + 500 | 0), (x, y) => x === y)); eq("File \"bs_poly_mutable_set_test.res\", line 86, characters 5-12", Belt_internalAVLset.toArray(v.data), Array_data_util.range(500, 2000)); @@ -191,13 +181,9 @@ let aa = match$1[0]; b("File \"bs_poly_mutable_set_test.res\", line 91, characters 4-11", match[1]); -b("File \"bs_poly_mutable_set_test.res\", line 92, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 92, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_poly_mutable_set_test.res\", line 93, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 93, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_poly_mutable_set_test.res\", line 94, characters 4-11", Belt_MutableSet.subset(aa, v)); @@ -219,13 +205,9 @@ let aa$1 = match$3[0]; b("File \"bs_poly_mutable_set_test.res\", line 100, characters 4-11", !match$2[1]); -b("File \"bs_poly_mutable_set_test.res\", line 101, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 101, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(aa$1.data), Array_data_util.range(500, 999), (prim0, prim1) => prim0 === prim1)); -b("File \"bs_poly_mutable_set_test.res\", line 102, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (function (prim0, prim1) { - return prim0 === prim1; -}))); +b("File \"bs_poly_mutable_set_test.res\", line 102, characters 4-11", Belt_Array.eq(Belt_internalAVLset.toArray(bb$1.data), Array_data_util.range(1001, 2000), (prim0, prim1) => prim0 === prim1)); b("File \"bs_poly_mutable_set_test.res\", line 103, characters 4-11", Belt_MutableSet.subset(aa$1, v)); @@ -288,17 +270,11 @@ b("File \"bs_poly_mutable_set_test.res\", line 150, characters 4-11", Belt_Mutab let a0 = Belt_MutableSet.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); -let a1 = Belt_MutableSet.keep(a0, (function (x) { - return x % 2 === 0; -})); +let a1 = Belt_MutableSet.keep(a0, x => x % 2 === 0); -let a2 = Belt_MutableSet.keep(a0, (function (x) { - return x % 2 !== 0; -})); +let a2 = Belt_MutableSet.keep(a0, x => x % 2 !== 0); -let match$4 = Belt_MutableSet.partition(a0, (function (x) { - return x % 2 === 0; -})); +let match$4 = Belt_MutableSet.partition(a0, x => x % 2 === 0); let a4 = match$4[1]; @@ -323,9 +299,7 @@ Belt_List.forEach({ } } } -}, (function (x) { - Belt_internalAVLset.checkInvariantInternal(x.data); -})); +}, x => Belt_internalAVLset.checkInvariantInternal(x.data)); Mt.from_pair_suites("Bs_poly_mutable_set_test", suites.contents); diff --git a/jscomp/test/bs_poly_set_test.js b/jscomp/test/bs_poly_set_test.js index 186f46caff..1645d3d1bd 100644 --- a/jscomp/test/bs_poly_set_test.js +++ b/jscomp/test/bs_poly_set_test.js @@ -146,9 +146,7 @@ let u26 = Belt_Set.add({ data: undefined }, 3); -let ss = Belt_Array.makeByAndShuffle(100, (function (i) { - return (i << 1); -})); +let ss = Belt_Array.makeByAndShuffle(100, i => (i << 1)); let u27 = Belt_Set.fromArray(ss, IntCmp); @@ -200,12 +198,12 @@ function testIterToList(xs) { let v = { contents: /* [] */0 }; - Belt_SetDict.forEach(xs.data, (function (x) { + Belt_SetDict.forEach(xs.data, x => { v.contents = { hd: x, tl: v.contents }; - })); + }); return Belt_List.reverse(v.contents); } @@ -213,12 +211,12 @@ function testIterToList2(xs) { let v = { contents: /* [] */0 }; - Belt_SetDict.forEach(xs.data, (function (x) { + Belt_SetDict.forEach(xs.data, x => { v.contents = { hd: x, tl: v.contents }; - })); + }); return Belt_List.reverse(v.contents); } @@ -228,21 +226,11 @@ let u1$1 = Belt_Set.remove(u0$1, 17); let u2$1 = Belt_Set.add(u1$1, 33); -b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_List.makeBy(21, (function (i) { - return i; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_set_test.res\", line 110, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); -b("File \"bs_poly_set_test.res\", line 111, characters 4-11", Belt_List.every2(testIterToList2(u0$1), Belt_List.makeBy(21, (function (i) { - return i; -})), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_set_test.res\", line 111, characters 4-11", Belt_List.every2(testIterToList2(u0$1), Belt_List.makeBy(21, i => i), (x, y) => x === y)); -b("File \"bs_poly_set_test.res\", line 112, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_SetDict.toList(u0$1.data), (function (x, y) { - return x === y; -}))); +b("File \"bs_poly_set_test.res\", line 112, characters 4-11", Belt_List.every2(testIterToList(u0$1), Belt_SetDict.toList(u0$1.data), (x, y) => x === y)); function f(x) { return x === 17; @@ -262,9 +250,7 @@ function f$2(x) { b("File \"bs_poly_set_test.res\", line 115, characters 4-11", Belt_SetDict.every(u0$1.data, f$2)); -b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(u0$1.data, (function (x) { - return x < 24; -}))); +b("File \"bs_poly_set_test.res\", line 116, characters 4-11", Belt_SetDict.every(u0$1.data, x => x < 24)); function f$3(x) { return x < 24; @@ -290,17 +276,11 @@ b("File \"bs_poly_set_test.res\", line 120, characters 4-11", Belt_Set.cmp(u0$1, let a0 = Belt_Set.fromArray(Array_data_util.randomRange(0, 1000), IntCmp); -let a1 = Belt_Set.keep(a0, (function (x) { - return x % 2 === 0; -})); +let a1 = Belt_Set.keep(a0, x => x % 2 === 0); -let a2 = Belt_Set.keep(a0, (function (x) { - return x % 2 !== 0; -})); +let a2 = Belt_Set.keep(a0, x => x % 2 !== 0); -let match = Belt_Set.partition(a0, (function (x) { - return x % 2 === 0; -})); +let match = Belt_Set.partition(a0, x => x % 2 === 0); let a4 = match[1]; @@ -314,13 +294,13 @@ eq("File \"bs_poly_set_test.res\", line 129, characters 5-12", Belt_Set.getExn(a eq("File \"bs_poly_set_test.res\", line 130, characters 5-12", Belt_Set.getExn(a0, 4), 4); -t("File \"bs_poly_set_test.res\", line 131, characters 4-11", (function () { +t("File \"bs_poly_set_test.res\", line 131, characters 4-11", () => { Belt_Set.getExn(a0, 1002); -})); +}); -t("File \"bs_poly_set_test.res\", line 132, characters 4-11", (function () { +t("File \"bs_poly_set_test.res\", line 132, characters 4-11", () => { Belt_Set.getExn(a0, -1); -})); +}); eq("File \"bs_poly_set_test.res\", line 133, characters 5-12", Belt_SetDict.size(a0.data), 1001); @@ -332,13 +312,9 @@ let match$2 = match$1[0]; b("File \"bs_poly_set_test.res\", line 136, characters 4-11", match$1[1]); -eq("File \"bs_poly_set_test.res\", line 137, characters 5-12", Belt_SetDict.toArray(match$2[0].data), Belt_Array.makeBy(200, (function (i) { - return i; -}))); +eq("File \"bs_poly_set_test.res\", line 137, characters 5-12", Belt_SetDict.toArray(match$2[0].data), Belt_Array.makeBy(200, i => i)); -eq("File \"bs_poly_set_test.res\", line 138, characters 5-12", Belt_SetDict.toList(match$2[1].data), Belt_List.makeBy(800, (function (i) { - return i + 201 | 0; -}))); +eq("File \"bs_poly_set_test.res\", line 138, characters 5-12", Belt_SetDict.toList(match$2[1].data), Belt_List.makeBy(800, i => i + 201 | 0)); let a7 = Belt_Set.remove(a0, 200); @@ -352,13 +328,9 @@ let a8 = match$4[0]; b("File \"bs_poly_set_test.res\", line 141, characters 4-11", !match$3[1]); -eq("File \"bs_poly_set_test.res\", line 142, characters 5-12", Belt_SetDict.toArray(a8.data), Belt_Array.makeBy(200, (function (i) { - return i; -}))); +eq("File \"bs_poly_set_test.res\", line 142, characters 5-12", Belt_SetDict.toArray(a8.data), Belt_Array.makeBy(200, i => i)); -eq("File \"bs_poly_set_test.res\", line 143, characters 5-12", Belt_SetDict.toList(a9.data), Belt_List.makeBy(800, (function (i) { - return i + 201 | 0; -}))); +eq("File \"bs_poly_set_test.res\", line 143, characters 5-12", Belt_SetDict.toList(a9.data), Belt_List.makeBy(800, i => i + 201 | 0)); eq("File \"bs_poly_set_test.res\", line 144, characters 5-12", Belt_SetDict.minimum(a8.data), 0); @@ -379,15 +351,11 @@ Belt_List.forEach({ } } } -}, (function (x) { - Belt_SetDict.checkInvariantInternal(x.data); -})); +}, x => Belt_SetDict.checkInvariantInternal(x.data)); let a = Belt_Set.fromArray([], IntCmp); -let m$1 = Belt_Set.keep(a, (function (x) { - return x % 2 === 0; -})); +let m$1 = Belt_Set.keep(a, x => x % 2 === 0); b("File \"bs_poly_set_test.res\", line 151, characters 4-11", Belt_SetDict.isEmpty(m$1.data)); diff --git a/jscomp/test/bs_queue_test.js b/jscomp/test/bs_queue_test.js index cb4358d47e..23b344361b 100644 --- a/jscomp/test/bs_queue_test.js +++ b/jscomp/test/bs_queue_test.js @@ -767,7 +767,7 @@ let i$7 = { contents: 1 }; -Belt_MutableQueue.forEach(q$5, (function (j) { +Belt_MutableQueue.forEach(q$5, j => { if (i$7.contents !== j) { throw new Error("Assert_failure", { cause: { @@ -781,7 +781,7 @@ Belt_MutableQueue.forEach(q$5, (function (j) { }); } i$7.contents = i$7.contents + 1 | 0; -})); +}); let q1$1 = { length: 0, @@ -1312,11 +1312,7 @@ if (!Caml_obj.equal(Belt_MutableQueue.toArray(q2$4), v)) { }); } -if (Belt_MutableQueue.reduce(q2$4, 0, (function (x, y) { - return x - y | 0; - })) !== Belt_Array.reduce(v, 0, (function (x, y) { - return x - y | 0; - }))) { +if (Belt_MutableQueue.reduce(q2$4, 0, (x, y) => x - y | 0) !== Belt_Array.reduce(v, 0, (x, y) => x - y | 0)) { throw new Error("Assert_failure", { cause: { RE_EXN_ID: "Assert_failure", @@ -1338,9 +1334,7 @@ let q$6 = Belt_MutableQueue.fromArray([ 4 ]); -let q1$5 = Belt_MutableQueue.map(q$6, (function (x) { - return x - 1 | 0; -})); +let q1$5 = Belt_MutableQueue.map(q$6, x => x - 1 | 0); eq("File \"bs_queue_test.res\", line 197, characters 5-12", Belt_MutableQueue.toArray(q1$5), [ 0, @@ -1353,9 +1347,7 @@ let q$7 = Belt_MutableQueue.fromArray([]); b("File \"bs_queue_test.res\", line 198, characters 4-11", q$7.length === 0); -let q$8 = Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), (function (x) { - return x + 1 | 0; -})); +let q$8 = Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), x => x + 1 | 0); b("File \"bs_queue_test.res\", line 199, characters 4-11", q$8.length === 0); diff --git a/jscomp/test/bs_set_int_test.js b/jscomp/test/bs_set_int_test.js index b3eb0f0a2a..7cf08f608f 100644 --- a/jscomp/test/bs_set_int_test.js +++ b/jscomp/test/bs_set_int_test.js @@ -55,15 +55,11 @@ let u = Belt_SetInt.intersect(Belt_SetInt.fromArray([ b("File \"bs_set_int_test.res\", line 27, characters 11-18", Belt_SetInt.eq(Belt_SetInt.fromArray([3]), u)); function range(i, j) { - return $$Array.init((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - })); + return $$Array.init((j - i | 0) + 1 | 0, k => k + i | 0); } function revRange(i, j) { - return $$Array.of_list(List.rev($$Array.to_list($$Array.init((j - i | 0) + 1 | 0, (function (k) { - return k + i | 0; - }))))); + return $$Array.of_list(List.rev($$Array.to_list($$Array.init((j - i | 0) + 1 | 0, k => k + i | 0)))); } let v = Belt_SetInt.fromArray($$Array.append(range(100, 1000), revRange(400, 1500))); @@ -72,9 +68,7 @@ let i = range(100, 1500); b("File \"bs_set_int_test.res\", line 37, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); -let match = Belt_SetInt.partition(v, (function (x) { - return x % 3 === 0; -})); +let match = Belt_SetInt.partition(v, x => x % 3 === 0); let l; @@ -162,11 +156,7 @@ function approx(loc, x, y) { b(loc, x === y); } -eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (function (x, y) { - return x + y | 0; -})), Belt_Array.reduce(ss, 0, (function (prim0, prim1) { - return prim0 + prim1 | 0; -}))); +eq("File \"bs_set_int_test.res\", line 125, characters 5-12", Belt_SetInt.reduce(v$1, 0, (x, y) => x + y | 0), Belt_Array.reduce(ss, 0, (prim0, prim1) => prim0 + prim1 | 0)); approx("File \"bs_set_int_test.res\", line 126, characters 9-16", -1, minv); @@ -216,9 +206,7 @@ let v$10 = Belt_SetInt.remove(v$9, 1); b("File \"bs_set_int_test.res\", line 146, characters 4-11", Belt_SetInt.isEmpty(v$10)); -let v$11 = Belt_Array.makeByAndShuffle(1000000, (function (i) { - return i; -})); +let v$11 = Belt_Array.makeByAndShuffle(1000000, i => i); let u$1 = Belt_SetInt.fromArray(v$11); @@ -341,17 +329,15 @@ let v3 = Belt_SetInt.removeMany(v2, [ 2001 ]); -let us = Belt_Array.map(Array_data_util.randomRange(1000, 3000), (function (x) { - return Belt_SetInt.has(v$12, x); -})); +let us = Belt_Array.map(Array_data_util.randomRange(1000, 3000), x => Belt_SetInt.has(v$12, x)); -let counted = Belt_Array.reduce(us, 0, (function (acc, x) { +let counted = Belt_Array.reduce(us, 0, (acc, x) => { if (x) { return acc + 1 | 0; } else { return acc; } -})); +}); eq("File \"bs_set_int_test.res\", line 235, characters 5-12", counted, 1001); diff --git a/jscomp/test/bs_sort_test.js b/jscomp/test/bs_sort_test.js index e52e8cfe62..a3c9b0a5f8 100644 --- a/jscomp/test/bs_sort_test.js +++ b/jscomp/test/bs_sort_test.js @@ -92,17 +92,17 @@ eq("File \"bs_sort_test.res\", line 52, characters 5-12", diffs(Array_data_util. 2 ]); -b("File \"bs_sort_test.res\", line 56, characters 4-11", Belt_Range.every(0, 200, (function (i) { +b("File \"bs_sort_test.res\", line 56, characters 4-11", Belt_Range.every(0, 200, i => { let v = Array_data_util.randomRange(0, i); Belt_SortArray.stableSortInPlaceBy(v, cmp); return Belt_SortArray.isSorted(v, cmp); -}))); +})); -b("File \"bs_sort_test.res\", line 64, characters 4-11", Belt_Range.every(0, 200, (function (i) { +b("File \"bs_sort_test.res\", line 64, characters 4-11", Belt_Range.every(0, 200, i => { let v = Array_data_util.randomRange(0, i); Belt_SortArray.stableSortInPlaceBy(v, cmp); return Belt_SortArray.isSorted(v, cmp); -}))); +})); b("File \"bs_sort_test.res\", line 71, characters 4-11", Belt_SortArray.isSorted([], cmp)); @@ -151,9 +151,7 @@ let u$1 = [ ] ]; -eq("File \"bs_sort_test.res\", line 95, characters 5-12", Belt_SortArray.stableSortBy(u$1, (function (param, param$1) { - return param[0] - param$1[0] | 0; -})), [ +eq("File \"bs_sort_test.res\", line 95, characters 5-12", Belt_SortArray.stableSortBy(u$1, (param, param$1) => param[0] - param$1[0] | 0), [ [ 1, "a" @@ -187,9 +185,7 @@ let u$2 = [ ] ]; -eq("File \"bs_sort_test.res\", line 98, characters 4-11", Belt_SortArray.stableSortBy(u$2, (function (param, param$1) { - return param[0] - param$1[0] | 0; -})), [ +eq("File \"bs_sort_test.res\", line 98, characters 4-11", Belt_SortArray.stableSortBy(u$2, (param, param$1) => param[0] - param$1[0] | 0), [ [ 1, "b" @@ -235,9 +231,7 @@ let u$3 = [ ] ]; -eq("File \"bs_sort_test.res\", line 104, characters 4-11", Belt_SortArray.stableSortBy(u$3, (function (param, param$1) { - return param[0] - param$1[0] | 0; -})), [ +eq("File \"bs_sort_test.res\", line 104, characters 4-11", Belt_SortArray.stableSortBy(u$3, (param, param$1) => param[0] - param$1[0] | 0), [ [ 1, "c" @@ -323,13 +317,9 @@ eq("File \"bs_sort_test.res\", line 116, characters 5-12", Belt_SortArray.binary let aa = Array_data_util.range(0, 1000); -b("File \"bs_sort_test.res\", line 118, characters 4-11", Belt_Range.every(0, 1000, (function (i) { - return Belt_SortArray.binarySearchBy(aa, i, cmp) === i; -}))); +b("File \"bs_sort_test.res\", line 118, characters 4-11", Belt_Range.every(0, 1000, i => Belt_SortArray.binarySearchBy(aa, i, cmp) === i)); -let cc = Belt_Array.map(Array_data_util.range(0, 2000), (function (x) { - return (x << 1); -})); +let cc = Belt_Array.map(Array_data_util.range(0, 2000), x => (x << 1)); eq("File \"bs_sort_test.res\", line 121, characters 5-12", Belt_SortArray.binarySearchBy(cc, 5000, cmp) ^ -1, 2001); @@ -339,9 +329,7 @@ eq("File \"bs_sort_test.res\", line 123, characters 5-12", Belt_SortArray.binary eq("File \"bs_sort_test.res\", line 125, characters 5-12", Belt_SortArray.binarySearchBy(cc, 1, cmp) ^ -1, 1); -b("File \"bs_sort_test.res\", line 126, characters 6-13", Belt_Range.every(0, 1999, (function (i) { - return (Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp) ^ -1) === (i + 1 | 0); -}))); +b("File \"bs_sort_test.res\", line 126, characters 6-13", Belt_Range.every(0, 1999, i => (Belt_SortArray.binarySearchBy(cc, (i << 1) + 1 | 0, cmp) ^ -1) === (i + 1 | 0))); function lt(x, y) { return x < y; diff --git a/jscomp/test/bs_stack_test.js b/jscomp/test/bs_stack_test.js index 793432b9f3..f30fee5221 100644 --- a/jscomp/test/bs_stack_test.js +++ b/jscomp/test/bs_stack_test.js @@ -63,7 +63,7 @@ function inOrder3(v) { Belt_MutableStack.push(s, v$1); current = v$1.left; }; - Belt_MutableStack.dynamicPopIter(s, (function (popped) { + Belt_MutableStack.dynamicPopIter(s, popped => { Belt_MutableQueue.add(q, popped.value); let current = popped.right; while (current !== undefined) { @@ -71,7 +71,7 @@ function inOrder3(v) { Belt_MutableStack.push(s, v); current = v.left; }; - })); + }); return Belt_MutableQueue.toArray(q); } diff --git a/jscomp/test/bs_string_test.js b/jscomp/test/bs_string_test.js index 7570541190..3dc70613f0 100644 --- a/jscomp/test/bs_string_test.js +++ b/jscomp/test/bs_string_test.js @@ -16,21 +16,17 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents }; } -eq("File \"bs_string_test.res\", line 10, characters 2-9", "ghso ghso g".split(" ").reduce((function (x, y) { - return x + ("-" + y); -}), ""), "-ghso-ghso-g"); +eq("File \"bs_string_test.res\", line 10, characters 2-9", "ghso ghso g".split(" ").reduce((x, y) => x + ("-" + y), ""), "-ghso-ghso-g"); Mt.from_pair_suites("Bs_string_test", suites.contents); diff --git a/jscomp/test/buffer_test.js b/jscomp/test/buffer_test.js index 8c5c3c9701..b67e35703a 100644 --- a/jscomp/test/buffer_test.js +++ b/jscomp/test/buffer_test.js @@ -11,25 +11,23 @@ let v = "gso"; let suites_0 = [ "equal", - (function (param) { - return { - TAG: "Eq", - _0: [ - Caml_bytes.get(Bytes.make(3, /* 'a' */97), 0), - Bytes.make(3, /* 'a' */97)[0] - ], - _1: [ - /* 'a' */97, - /* 'a' */97 - ] - }; + param => ({ + TAG: "Eq", + _0: [ + Caml_bytes.get(Bytes.make(3, /* 'a' */97), 0), + Bytes.make(3, /* 'a' */97)[0] + ], + _1: [ + /* 'a' */97, + /* 'a' */97 + ] }) ]; let suites_1 = { hd: [ "equal2", - (function (param) { + param => { let u = Bytes.make(3, /* 'a' */97); u[0] = /* 'b' */98; return { @@ -43,12 +41,12 @@ let suites_1 = { /* 'g' */103 ] }; - }) + } ], tl: { hd: [ "buffer", - (function (param) { + param => { let v = Buffer.create(30); for (let i = 0; i <= 10; ++i) { Buffer.add_string(v, String(i)); @@ -58,7 +56,7 @@ let suites_1 = { _0: Buffer.contents(v), _1: "012345678910" }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/bytes_split_gpr_743_test.js b/jscomp/test/bytes_split_gpr_743_test.js index 476a31379c..7ab680613a 100644 --- a/jscomp/test/bytes_split_gpr_743_test.js +++ b/jscomp/test/bytes_split_gpr_743_test.js @@ -20,12 +20,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/caml_compare_bigint_test.js b/jscomp/test/caml_compare_bigint_test.js index 1427f44a73..7d451210b5 100644 --- a/jscomp/test/caml_compare_bigint_test.js +++ b/jscomp/test/caml_compare_bigint_test.js @@ -9,199 +9,163 @@ function isLessThan(title, small, big) { return { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.compare(big, small) > 0 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.compare(big, small) > 0 }) ], tl: { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.compare(small, big) < 0 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.compare(small, big) < 0 }) ], tl: { hd: [ "< operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(small, big) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(small, big) }) ], tl: { hd: [ "<= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessequal(small, big) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessequal(small, big) }) ], tl: { hd: [ "> operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan(big, small) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan(big, small) }) ], tl: { hd: [ ">= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterequal(big, small) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterequal(big, small) }) ], tl: { hd: [ "min: " + title, - (function (param) { - return { - TAG: "Eq", - _0: small, - _1: Caml_obj.min(big, small) - }; + param => ({ + TAG: "Eq", + _0: small, + _1: Caml_obj.min(big, small) }) ], tl: { hd: [ "min: " + title, - (function (param) { - return { - TAG: "Eq", - _0: small, - _1: Caml_obj.min(small, big) - }; + param => ({ + TAG: "Eq", + _0: small, + _1: Caml_obj.min(small, big) }) ], tl: { hd: [ "max: " + title, - (function (param) { - return { - TAG: "Eq", - _0: big, - _1: Caml_obj.max(big, small) - }; + param => ({ + TAG: "Eq", + _0: big, + _1: Caml_obj.max(big, small) }) ], tl: { hd: [ "max: " + title, - (function (param) { - return { - TAG: "Eq", - _0: big, - _1: Caml_obj.max(small, big) - }; + param => ({ + TAG: "Eq", + _0: big, + _1: Caml_obj.max(small, big) }) ], tl: { hd: [ "!== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: big !== small - }; + param => ({ + TAG: "Eq", + _0: true, + _1: big !== small }) ], tl: { hd: [ "!== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: small !== big - }; + param => ({ + TAG: "Eq", + _0: true, + _1: small !== big }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.notequal(big, small) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.notequal(big, small) }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.notequal(small, big) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.notequal(small, big) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal(big, small) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal(big, small) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal(small, big) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal(small, big) }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: big === small - }; + param => ({ + TAG: "Eq", + _0: false, + _1: big === small }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: small === big - }; + param => ({ + TAG: "Eq", + _0: false, + _1: small === big }) ], tl: /* [] */0 @@ -229,177 +193,145 @@ function isEqual(title, num1, num2) { return { hd: [ "< operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.lessthan(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.lessthan(num2, num1) }) ], tl: { hd: [ "<= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessequal(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessequal(num2, num1) }) ], tl: { hd: [ "> operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.greaterthan(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.greaterthan(num1, num2) }) ], tl: { hd: [ ">= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterequal(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterequal(num1, num2) }) ], tl: { hd: [ "min: " + title, - (function (param) { - return { - TAG: "Eq", - _0: num1, - _1: Caml_obj.min(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: num1, + _1: Caml_obj.min(num1, num2) }) ], tl: { hd: [ "max: " + title, - (function (param) { - return { - TAG: "Eq", - _0: num1, - _1: Caml_obj.max(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: num1, + _1: Caml_obj.max(num1, num2) }) ], tl: { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Caml_obj.compare(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Caml_obj.compare(num1, num2) }) ], tl: { hd: [ "compare: " + title, - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Caml_obj.compare(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Caml_obj.compare(num2, num1) }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: num1 !== num2 - }; + param => ({ + TAG: "Eq", + _0: false, + _1: num1 !== num2 }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: num2 !== num1 - }; + param => ({ + TAG: "Eq", + _0: false, + _1: num2 !== num1 }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.notequal(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.notequal(num1, num2) }) ], tl: { hd: [ "!= operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.notequal(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.notequal(num2, num1) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.equal(num1, num2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.equal(num1, num2) }) ], tl: { hd: [ "== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.equal(num2, num1) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.equal(num2, num1) }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: num1 === num2 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: num1 === num2 }) ], tl: { hd: [ "=== operator: " + title, - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: num2 === num1 - }; + param => ({ + TAG: "Eq", + _0: true, + _1: num2 === num1 }) ], tl: /* [] */0 diff --git a/jscomp/test/caml_compare_test.js b/jscomp/test/caml_compare_test.js index 2df1c2ab5b..2ecd05a679 100644 --- a/jscomp/test/caml_compare_test.js +++ b/jscomp/test/caml_compare_test.js @@ -8,11 +8,7 @@ let Caml_js_exceptions = require("../../lib/js/caml_js_exceptions.js"); let function_equal_test; try { - function_equal_test = Caml_obj.equal((function (x) { - return x + 1 | 0; - }), (function (x) { - return x + 2 | 0; - })); + function_equal_test = Caml_obj.equal(x => x + 1 | 0, x => x + 2 | 0); } catch (raw_exn) { let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); function_equal_test = exn.RE_EXN_ID === "Invalid_argument" && exn._1 === "equal: functional value" ? true : false; @@ -22,47 +18,67 @@ let suites = { contents: { hd: [ "File \"caml_compare_test.res\", line 12, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(undefined, 1) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(undefined, 1) }) ], tl: { hd: [ "option2", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(1, 2) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(1, 2) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 14, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan({ - hd: 1, - tl: /* [] */0 - }, /* [] */0) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan({ + hd: 1, + tl: /* [] */0 + }, /* [] */0) }) ], tl: { hd: [ "listeq", - (function () { - return { + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.equal({ + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }, { + hd: 1, + tl: { + hd: 2, + tl: { + hd: 3, + tl: /* [] */0 + } + } + }) + }) + ], + tl: { + hd: [ + "listneq", + () => ({ TAG: "Eq", _0: true, - _1: Caml_obj.equal({ + _1: Caml_obj.greaterthan({ hd: 1, tl: { hd: 2, @@ -76,51 +92,57 @@ let suites = { tl: { hd: 2, tl: { - hd: 3, + hd: 2, tl: /* [] */0 } } }) - }; - }) - ], - tl: { - hd: [ - "listneq", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan({ - hd: 1, - tl: { - hd: 2, - tl: { - hd: 3, - tl: /* [] */0 - } - } - }, { - hd: 1, - tl: { - hd: 2, - tl: { - hd: 2, - tl: /* [] */0 - } - } - }) - }; }) ], tl: { hd: [ "custom_u", - (function () { - return { + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan([ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 1 + } + ], [ + { + TAG: "A", + _0: 3 + }, + { + TAG: "B", + _0: 2, + _1: false + }, + { + TAG: "C", + _0: 0 + } + ]) + }) + ], + tl: { + hd: [ + "custom_u2", + () => ({ TAG: "Eq", _0: true, - _1: Caml_obj.greaterthan([ + _1: Caml_obj.equal([ { TAG: "A", _0: 3 @@ -146,128 +168,78 @@ let suites = { }, { TAG: "C", - _0: 0 + _0: 1 } ]) - }; - }) - ], - tl: { - hd: [ - "custom_u2", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.equal([ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 1 - } - ], [ - { - TAG: "A", - _0: 3 - }, - { - TAG: "B", - _0: 2, - _1: false - }, - { - TAG: "C", - _0: 1 - } - ]) - }; }) ], tl: { hd: [ "function", - (function () { - return { - TAG: "Eq", - _0: true, - _1: function_equal_test - }; + () => ({ + TAG: "Eq", + _0: true, + _1: function_equal_test }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 20, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(undefined, 1) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(undefined, 1) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 21, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(undefined, [ - 1, - 30 - ]) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(undefined, [ + 1, + 30 + ]) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 22, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan([ - 1, - 30 - ], undefined) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan([ + 1, + 30 + ], undefined) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 24, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan({ - hd: 2, + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -275,28 +247,28 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -305,73 +277,67 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 27, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan({ - hd: 1, + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan({ + hd: 1, + tl: /* [] */0 + }, { + hd: 1, + tl: { + hd: 409, tl: /* [] */0 - }, { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 28, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.lessthan(/* [] */0, { - hd: 409, - tl: /* [] */0 - }) - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.lessthan(/* [] */0, { + hd: 409, + tl: /* [] */0 + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 30, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Caml_obj.greaterthan({ - hd: 2, + () => ({ + TAG: "Eq", + _0: true, + _1: Caml_obj.greaterthan({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -380,26 +346,26 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -407,59 +373,53 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 33, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: false, - _1: false - }; + () => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 34, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: false, - _1: false - }; + () => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 36, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal({ - hd: 2, + () => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -467,28 +427,28 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -497,39 +457,37 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 40, characters 6-13", - (function () { - return { - TAG: "Eq", - _0: false, - _1: Caml_obj.equal({ - hd: 2, + () => ({ + TAG: "Eq", + _0: false, + _1: Caml_obj.equal({ + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, - tl: { - hd: 409, - tl: /* [] */0 - } + hd: 409, + tl: /* [] */0 } } } @@ -538,26 +496,26 @@ let suites = { } } } - }, { - hd: 2, + } + }, { + hd: 2, + tl: { + hd: 6, tl: { - hd: 6, + hd: 1, tl: { hd: 1, tl: { - hd: 1, + hd: 2, tl: { - hd: 2, + hd: 1, tl: { - hd: 1, + hd: 4, tl: { - hd: 4, + hd: 2, tl: { - hd: 2, - tl: { - hd: 1, - tl: /* [] */0 - } + hd: 1, + tl: /* [] */0 } } } @@ -565,351 +523,325 @@ let suites = { } } } - }) - }; + } + }) }) ], tl: { hd: [ "cmp_id", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1, - y: 2 - }, { - x: 1, - y: 2 - }), - _1: 0 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1, + y: 2 + }, { + x: 1, + y: 2 + }), + _1: 0 }) ], tl: { hd: [ "cmp_val", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1 - }, { - x: 2 - }), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1 + }, { + x: 2 + }), + _1: -1 }) ], tl: { hd: [ "cmp_val2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 2 - }, { - x: 1 - }), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 2 + }, { + x: 1 + }), + _1: 1 }) ], tl: { hd: [ "cmp_empty", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({}, {}), - _1: 0 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({}, {}), + _1: 0 }) ], tl: { hd: [ "cmp_empty2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({}, {x:1}), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({}, {x:1}), + _1: -1 }) ], tl: { hd: [ "cmp_swap", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1, - y: 2 - }, { - y: 2, - x: 1 - }), - _1: 0 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1, + y: 2 + }, { + y: 2, + x: 1 + }), + _1: 0 }) ], tl: { hd: [ "cmp_size", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({x:1}, {x:1, y:2}), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({x:1}, {x:1, y:2}), + _1: -1 }) ], tl: { hd: [ "cmp_size2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({x:1, y:2}, {x:1}), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({x:1, y:2}, {x:1}), + _1: 1 }) ], tl: { hd: [ "cmp_order", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 0, - y: 1 - }, { - x: 1, - y: 0 - }), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 0, + y: 1 + }, { + x: 1, + y: 0 + }), + _1: -1 }) ], tl: { hd: [ "cmp_order2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: 1, - y: 0 - }, { - x: 0, - y: 1 - }), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: 1, + y: 0 + }, { + x: 0, + y: 1 + }), + _1: 1 }) ], tl: { hd: [ "cmp_in_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + hd: { + x: 1 + }, + tl: /* [] */0 + }, { + hd: { + x: 2 + }, + tl: /* [] */0 + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_in_list2", + () => ({ TAG: "Eq", _0: Caml_obj.compare({ hd: { - x: 1 + x: 2 }, tl: /* [] */0 }, { hd: { - x: 2 + x: 1 }, tl: /* [] */0 }), - _1: -1 - }; - }) - ], - tl: { - hd: [ - "cmp_in_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - hd: { - x: 2 - }, - tl: /* [] */0 - }, { - hd: { - x: 1 - }, - tl: /* [] */0 - }), - _1: 1 - }; + _1: 1 }) ], tl: { hd: [ "cmp_with_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + x: { + hd: 0, + tl: /* [] */0 + } + }, { + x: { + hd: 1, + tl: /* [] */0 + } + }), + _1: -1 + }) + ], + tl: { + hd: [ + "cmp_with_list2", + () => ({ TAG: "Eq", _0: Caml_obj.compare({ x: { - hd: 0, + hd: 1, tl: /* [] */0 } }, { x: { - hd: 1, + hd: 0, tl: /* [] */0 } }), - _1: -1 - }; - }) - ], - tl: { - hd: [ - "cmp_with_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - x: { - hd: 1, - tl: /* [] */0 - } - }, { - x: { - hd: 0, - tl: /* [] */0 - } - }), - _1: 1 - }; + _1: 1 }) ], tl: { hd: [ "eq_id", - (function () { - return { - TAG: "Ok", - _0: Caml_obj.equal({ - x: 1, - y: 2 - }, { - x: 1, - y: 2 - }) - }; + () => ({ + TAG: "Ok", + _0: Caml_obj.equal({ + x: 1, + y: 2 + }, { + x: 1, + y: 2 + }) }) ], tl: { hd: [ "eq_val", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - x: 1 - }, { - x: 2 - }), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + x: 1 + }, { + x: 2 + }), + _1: false }) ], tl: { hd: [ "eq_val2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - x: 2 - }, { - x: 1 - }), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + x: 2 + }, { + x: 1 + }), + _1: false }) ], tl: { hd: [ "eq_empty", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({}, {}), - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({}, {}), + _1: true }) ], tl: { hd: [ "eq_empty2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({}, {x:1}), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({}, {x:1}), + _1: false }) ], tl: { hd: [ "eq_swap", - (function () { - return { - TAG: "Ok", - _0: Caml_obj.equal({ - x: 1, - y: 2 - }, { - y: 2, - x: 1 - }) - }; + () => ({ + TAG: "Ok", + _0: Caml_obj.equal({ + x: 1, + y: 2 + }, { + y: 2, + x: 1 + }) }) ], tl: { hd: [ "eq_size", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({x:1}, {x:1, y:2}), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({x:1}, {x:1, y:2}), + _1: false }) ], tl: { hd: [ "eq_size2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({x:1, y:2}, {x:1}), - _1: false - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({x:1, y:2}, {x:1}), + _1: false }) ], tl: { hd: [ "eq_in_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + hd: { + x: 1 + }, + tl: /* [] */0 + }, { + hd: { + x: 2 + }, + tl: /* [] */0 + }), + _1: false + }) + ], + tl: { + hd: [ + "eq_in_list2", + () => ({ TAG: "Eq", _0: Caml_obj.equal({ hd: { - x: 1 + x: 2 }, tl: /* [] */0 }, { @@ -918,36 +850,32 @@ let suites = { }, tl: /* [] */0 }), - _1: false - }; - }) - ], - tl: { - hd: [ - "eq_in_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - hd: { - x: 2 - }, - tl: /* [] */0 - }, { - hd: { - x: 2 - }, - tl: /* [] */0 - }), - _1: true - }; + _1: true }) ], tl: { hd: [ "eq_with_list", - (function () { - return { + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({ + x: { + hd: 0, + tl: /* [] */0 + } + }, { + x: { + hd: 0, + tl: /* [] */0 + } + }), + _1: true + }) + ], + tl: { + hd: [ + "eq_with_list2", + () => ({ TAG: "Eq", _0: Caml_obj.equal({ x: { @@ -956,116 +884,80 @@ let suites = { } }, { x: { - hd: 0, + hd: 1, tl: /* [] */0 } }), - _1: true - }; - }) - ], - tl: { - hd: [ - "eq_with_list2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({ - x: { - hd: 0, - tl: /* [] */0 - } - }, { - x: { - hd: 1, - tl: /* [] */0 - } - }), - _1: false - }; + _1: false }) ], tl: { hd: [ "eq_no_prototype", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.equal({x:1}, ((function(){let o = Object.create(null);o.x = 1;return o;})())), - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.equal({x:1}, ((function(){let o = Object.create(null);o.x = 1;return o;})())), + _1: true }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 76, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(null, { - hd: 3, - tl: /* [] */0 - }), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(null, { + hd: 3, + tl: /* [] */0 + }), + _1: -1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 77, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare({ - hd: 3, - tl: /* [] */0 - }, null), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare({ + hd: 3, + tl: /* [] */0 + }, null), + _1: 1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 78, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(null, 0), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(null, 0), + _1: -1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 79, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(0, null), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(0, null), + _1: 1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 80, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(undefined, 0), - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(undefined, 0), + _1: -1 }) ], tl: { hd: [ "File \"caml_compare_test.res\", line 81, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare(0, undefined), - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare(0, undefined), + _1: 1 }) ], tl: /* [] */0 diff --git a/jscomp/test/caml_format_test.js b/jscomp/test/caml_format_test.js index f184d33bb2..cd25cfec4b 100644 --- a/jscomp/test/caml_format_test.js +++ b/jscomp/test/caml_format_test.js @@ -79,26 +79,22 @@ let of_string = [ ]; function from_float_of_string(xs) { - return $$Array.mapi((function (i, param) { - return Pervasives.string_of_float; - }), xs); + return $$Array.mapi((i, param) => Pervasives.string_of_float, xs); } function from_of_string(xs) { - return $$Array.to_list($$Array.mapi((function (i, param) { + return $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "of_string " + String(i), - (function (param) { - return { - TAG: "Eq", - _0: Caml_format.int_of_string(b), - _1: a - }; + param => ({ + TAG: "Eq", + _0: Caml_format.int_of_string(b), + _1: a }) ]; - }), of_string)); + }, of_string)); } let to_str = Caml_format.int_of_string; @@ -144,67 +140,57 @@ let pairs$1 = [ let suites = Pervasives.$at(from_of_string(of_string), Pervasives.$at({ hd: [ "isnan_of_string", - (function () { - return { - TAG: "Eq", - _0: true, - _1: Pervasives.classify_float(Caml_format.float_of_string("nan")) === "FP_nan" - }; + () => ({ + TAG: "Eq", + _0: true, + _1: Pervasives.classify_float(Caml_format.float_of_string("nan")) === "FP_nan" }) ], tl: /* [] */0 -}, Pervasives.$at($$Array.to_list($$Array.mapi((function (i, param) { +}, Pervasives.$at($$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "infinity_of_string " + String(i), - (function () { - return { - TAG: "Eq", - _0: a, - _1: Pervasives.classify_float(Caml_format.float_of_string(b)) - }; + () => ({ + TAG: "Eq", + _0: a, + _1: Pervasives.classify_float(Caml_format.float_of_string(b)) }) ]; -}), pairs)), Pervasives.$at({ +}, pairs)), Pervasives.$at({ hd: [ "throw", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_format.float_of_string(""); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_format.float_of_string(""); + } }) ], tl: { hd: [ "format_int", - (function () { - return { - TAG: "Eq", - _0: " 33", - _1: Caml_format.format_int("%32d", 33) - }; + () => ({ + TAG: "Eq", + _0: " 33", + _1: Caml_format.format_int("%32d", 33) }) ], tl: /* [] */0 } -}, $$Array.to_list($$Array.mapi((function (i, param) { +}, $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "normal_float_of_string " + String(i), - (function () { - return { - TAG: "Eq", - _0: a, - _1: Caml_format.float_of_string(b) - }; + () => ({ + TAG: "Eq", + _0: a, + _1: Caml_format.float_of_string(b) }) ]; -}), pairs$1)))))); +}, pairs$1)))))); function ff(extra) { return Caml_format.format_int("%32d", extra); @@ -320,41 +306,35 @@ let float_data = [ let int64_suites_0 = [ "i64_simple7", - (function (param) { - return { - TAG: "Eq", - _0: Caml_int64.to_string([ - 0, - 3333 - ]), - _1: "3333" - }; + param => ({ + TAG: "Eq", + _0: Caml_int64.to_string([ + 0, + 3333 + ]), + _1: "3333" }) ]; let int64_suites_1 = { hd: [ "i64_simple15", - (function (param) { - return { - TAG: "Eq", - _0: Caml_int64.to_string(Caml_int64.neg_one), - _1: "-1" - }; + param => ({ + TAG: "Eq", + _0: Caml_int64.to_string(Caml_int64.neg_one), + _1: "-1" }) ], tl: { hd: [ "i64_simple16", - (function (param) { - return { - TAG: "Eq", - _0: Caml_int64.to_string([ - -1, - 4294956185 - ]), - _1: "-11111" - }; + param => ({ + TAG: "Eq", + _0: Caml_int64.to_string([ + -1, + 4294956185 + ]), + _1: "-11111" }) ], tl: /* [] */0 @@ -423,34 +403,30 @@ let of_string_data = [ ] ]; -Mt.from_pair_suites("Caml_format_test", Pervasives.$at(suites, Pervasives.$at($$Array.to_list($$Array.mapi((function (i, param) { +Mt.from_pair_suites("Caml_format_test", Pervasives.$at(suites, Pervasives.$at($$Array.to_list($$Array.mapi((i, param) => { let str_result = param[2]; let f = param[1]; let fmt = param[0]; return [ "loat_format " + String(i), - (function () { - return { - TAG: "Eq", - _0: Caml_format.format_float(fmt, f), - _1: str_result - }; + () => ({ + TAG: "Eq", + _0: Caml_format.format_float(fmt, f), + _1: str_result }) ]; -}), float_data)), Pervasives.$at(int64_suites, $$Array.to_list($$Array.mapi((function (i, param) { +}, float_data)), Pervasives.$at(int64_suites, $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "int64_of_string " + String(i) + " ", - (function () { - return { - TAG: "Eq", - _0: Caml_format.int64_of_string(b), - _1: a - }; + () => ({ + TAG: "Eq", + _0: Caml_format.int64_of_string(b), + _1: a }) ]; -}), of_string_data)))))); +}, of_string_data)))))); let float_suites = { hd: "float_nan", diff --git a/jscomp/test/chain_code_test.js b/jscomp/test/chain_code_test.js index a290de375a..74d651ce60 100644 --- a/jscomp/test/chain_code_test.js +++ b/jscomp/test/chain_code_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/chn_test.js b/jscomp/test/chn_test.js index a3f98dfeb4..306622fec7 100644 --- a/jscomp/test/chn_test.js +++ b/jscomp/test/chn_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -35,7 +33,7 @@ console.log("ä½ å¥½ï¼Œ\n世界"); console.log("\x3f\u003f\b\t\n\v\f\r\0\"'"); function convert(s) { - return $$Array.to_list(Array.from(s, (function (x) { + return $$Array.to_list(Array.from(s, x => { let x$1 = x.codePointAt(0); if (x$1 !== undefined) { return x$1; @@ -50,7 +48,7 @@ function convert(s) { ] } }); - }))); + })); } eq("File \"chn_test.res\", line 24, characters 4-11", "ä½ å¥½ï¼Œ\n世界", "ä½ å¥½ï¼Œ\n世界"); diff --git a/jscomp/test/class_type_ffi_test.js b/jscomp/test/class_type_ffi_test.js index b38f435362..ad02e32fbc 100644 --- a/jscomp/test/class_type_ffi_test.js +++ b/jscomp/test/class_type_ffi_test.js @@ -19,9 +19,7 @@ function off2(o, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { } function mk_f() { - return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) { - return a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); - }; + return (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) => a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); } exports.test_set = test_set; diff --git a/jscomp/test/coercion_module_alias_test.js b/jscomp/test/coercion_module_alias_test.js index 996ebb34db..5d8e7c4612 100644 --- a/jscomp/test/coercion_module_alias_test.js +++ b/jscomp/test/coercion_module_alias_test.js @@ -27,9 +27,7 @@ console.log(prim$2); let f = List.length; function g(x) { - return List.length(List.map((function (prim) { - return prim + 1 | 0; - }), x)); + return List.length(List.map(prim => prim + 1 | 0, x)); } function F(X) { diff --git a/jscomp/test/complex_if_test.js b/jscomp/test/complex_if_test.js index cdd266d2cb..15a13ed2bc 100644 --- a/jscomp/test/complex_if_test.js +++ b/jscomp/test/complex_if_test.js @@ -122,12 +122,10 @@ function string_escaped(s) { let suites_0 = [ "complete_escape", - (function (param) { - return { - TAG: "Eq", - _0: Bytes.to_string(escaped(Bytes.of_string("\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"))), - _1: "\\000\\001\\002\\003\\004\\005\\006\\007\\b\\t\\n\\011\\012\\r\\014\\015\\016\\017\\018\\019\\020\\021\\022\\023\\024\\025\\026\\027\\028\\029\\030\\031 !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\127\\128\\129\\130\\131\\132\\133\\134\\135\\136\\137\\138\\139\\140\\141\\142\\143\\144\\145\\146\\147\\148\\149\\150\\151\\152\\153\\154\\155\\156\\157\\158\\159\\160\\161\\162\\163\\164\\165\\166\\167\\168\\169\\170\\171\\172\\173\\174\\175\\176\\177\\178\\179\\180\\181\\182\\183\\184\\185\\186\\187\\188\\189\\190\\191\\192\\193\\194\\195\\196\\197\\198\\199\\200\\201\\202\\203\\204\\205\\206\\207\\208\\209\\210\\211\\212\\213\\214\\215\\216\\217\\218\\219\\220\\221\\222\\223\\224\\225\\226\\227\\228\\229\\230\\231\\232\\233\\234\\235\\236\\237\\238\\239\\240\\241\\242\\243\\244\\245\\246\\247\\248\\249\\250\\251\\252\\253\\254\\255" - }; + param => ({ + TAG: "Eq", + _0: Bytes.to_string(escaped(Bytes.of_string("\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"))), + _1: "\\000\\001\\002\\003\\004\\005\\006\\007\\b\\t\\n\\011\\012\\r\\014\\015\\016\\017\\018\\019\\020\\021\\022\\023\\024\\025\\026\\027\\028\\029\\030\\031 !\\\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\127\\128\\129\\130\\131\\132\\133\\134\\135\\136\\137\\138\\139\\140\\141\\142\\143\\144\\145\\146\\147\\148\\149\\150\\151\\152\\153\\154\\155\\156\\157\\158\\159\\160\\161\\162\\163\\164\\165\\166\\167\\168\\169\\170\\171\\172\\173\\174\\175\\176\\177\\178\\179\\180\\181\\182\\183\\184\\185\\186\\187\\188\\189\\190\\191\\192\\193\\194\\195\\196\\197\\198\\199\\200\\201\\202\\203\\204\\205\\206\\207\\208\\209\\210\\211\\212\\213\\214\\215\\216\\217\\218\\219\\220\\221\\222\\223\\224\\225\\226\\227\\228\\229\\230\\231\\232\\233\\234\\235\\236\\237\\238\\239\\240\\241\\242\\243\\244\\245\\246\\247\\248\\249\\250\\251\\252\\253\\254\\255" }) ]; diff --git a/jscomp/test/complex_test.js b/jscomp/test/complex_test.js index 042a16c82b..e822054260 100644 --- a/jscomp/test/complex_test.js +++ b/jscomp/test/complex_test.js @@ -6,15 +6,13 @@ let Complex = require("../../lib/js/complex.js"); let suites_0 = [ "basic_add", - (function (param) { - return { - TAG: "Eq", - _0: { - re: 2, - im: 2 - }, - _1: Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i) - }; + param => ({ + TAG: "Eq", + _0: { + re: 2, + im: 2 + }, + _1: Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i) }) ]; diff --git a/jscomp/test/complex_while_loop.js b/jscomp/test/complex_while_loop.js index 89e5f7a681..74fe66fea8 100644 --- a/jscomp/test/complex_while_loop.js +++ b/jscomp/test/complex_while_loop.js @@ -4,8 +4,8 @@ function f() { let n = 0; - while ((function () { - let fib = function (x) { + while ((() => { + let fib = x => { if (x === 0 || x === 1) { return 1; } else { @@ -20,7 +20,7 @@ function f() { } function ff() { - while ((function () { + while ((() => { let b = 9; return (3 + b | 0) > 10; })()) { diff --git a/jscomp/test/condition_compilation_test.js b/jscomp/test/condition_compilation_test.js index 74f9d79ea3..da2f401b42 100644 --- a/jscomp/test/condition_compilation_test.js +++ b/jscomp/test/condition_compilation_test.js @@ -24,12 +24,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/const_block_test.js b/jscomp/test/const_block_test.js index e436304834..bbe5d66ae1 100644 --- a/jscomp/test/const_block_test.js +++ b/jscomp/test/const_block_test.js @@ -57,7 +57,7 @@ let suites_0 = [ let suites_1 = { hd: [ "avoid_mutable_inline_test", - (function () { + () => { Caml_array.set(c, 0, 3); Caml_array.set(c, 1, 4); return { @@ -72,7 +72,7 @@ let suites_1 = { ], _1: c }; - }) + } ], tl: /* [] */0 }; diff --git a/jscomp/test/cps_test.js b/jscomp/test/cps_test.js index 31fe97de7a..89b9d6eb94 100644 --- a/jscomp/test/cps_test.js +++ b/jscomp/test/cps_test.js @@ -9,24 +9,22 @@ function test() { let v = { contents: 0 }; - let f = function (_n, _acc) { + let f = (_n, _acc) => { while (true) { let acc = _acc; let n = _n; if (n === 0) { return acc(); } - _acc = (function () { + _acc = () => { v.contents = v.contents + n | 0; return acc(); - }); + }; _n = n - 1 | 0; continue; }; }; - f(10, (function () { - - })); + f(10, () => {}); return v.contents; } @@ -34,17 +32,13 @@ function test_closure() { let v = { contents: 0 }; - let arr = Caml_array.make(6, (function (x) { - return x; - })); + let arr = Caml_array.make(6, x => x); for (let i = 0; i <= 5; ++i) { - Caml_array.set(arr, i, (function (param) { - return i; - })); + Caml_array.set(arr, i, param => i); } - $$Array.iter((function (i) { + $$Array.iter(i => { v.contents = v.contents + i(0) | 0; - }), arr); + }, arr); return v.contents; } @@ -52,52 +46,42 @@ function test_closure2() { let v = { contents: 0 }; - let arr = Caml_array.make(6, (function (x) { - return x; - })); + let arr = Caml_array.make(6, x => x); for (let i = 0; i <= 5; ++i) { let j = i + i | 0; - Caml_array.set(arr, i, (function (param) { - return j; - })); + Caml_array.set(arr, i, param => j); } - $$Array.iter((function (i) { + $$Array.iter(i => { v.contents = v.contents + i(0) | 0; - }), arr); + }, arr); return v.contents; } Mt.from_pair_suites("Cps_test", { hd: [ "cps_test_sum", - (function () { - return { - TAG: "Eq", - _0: 55, - _1: test() - }; + () => ({ + TAG: "Eq", + _0: 55, + _1: test() }) ], tl: { hd: [ "cps_test_closure", - (function () { - return { - TAG: "Eq", - _0: 15, - _1: test_closure() - }; + () => ({ + TAG: "Eq", + _0: 15, + _1: test_closure() }) ], tl: { hd: [ "cps_test_closure2", - (function () { - return { - TAG: "Eq", - _0: 30, - _1: test_closure2() - }; + () => ({ + TAG: "Eq", + _0: 30, + _1: test_closure2() }) ], tl: /* [] */0 diff --git a/jscomp/test/demo_page.js b/jscomp/test/demo_page.js index 2148270da4..f506133343 100644 --- a/jscomp/test/demo_page.js +++ b/jscomp/test/demo_page.js @@ -41,11 +41,9 @@ function f(extra) { } ReactDom.render(React.createClass({ - render: (function () { - return React.DOM.div({ - alt: "pic" - }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!")); - }) + render: () => React.DOM.div({ + alt: "pic" + }, React.DOM.h1(undefined, "hello react"), React.DOM.h2(undefined, "type safe!")) }), document.getElementById("hi")); exports.fib = fib; diff --git a/jscomp/test/demo_pipe.js b/jscomp/test/demo_pipe.js index 2a83141fe6..ade4eaf5be 100644 --- a/jscomp/test/demo_pipe.js +++ b/jscomp/test/demo_pipe.js @@ -3,11 +3,11 @@ function register(rl) { - return rl.on("line", (function (x) { + return rl.on("line", x => { console.log(x); - })).on("close", (function () { + }).on("close", () => { console.log("finished"); - })); + }); } exports.register = register; diff --git a/jscomp/test/digest_test.js b/jscomp/test/digest_test.js index f6f053b4cc..732af43acb 100644 --- a/jscomp/test/digest_test.js +++ b/jscomp/test/digest_test.js @@ -148,67 +148,55 @@ let ref = [ Mt.from_pair_suites("Digest_test", Pervasives.$at({ hd: [ "File \"digest_test.res\", line 9, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("value")), - _1: "2063c1608d6e0baf80249c42e2be5804" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("value")), + _1: "2063c1608d6e0baf80249c42e2be5804" }) ], tl: { hd: [ "File \"digest_test.res\", line 11, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog")), - _1: "9e107d9d372bb6826bd81d3542a419d6" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog")), + _1: "9e107d9d372bb6826bd81d3542a419d6" }) ], tl: { hd: [ "File \"digest_test.res\", line 18, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.")), - _1: "e4d909c290d0fb1ca068ffaddf22cbd0" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.")), + _1: "e4d909c290d0fb1ca068ffaddf22cbd0" }) ], tl: { hd: [ "File \"digest_test.res\", line 24, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("")), - _1: "d41d8cd98f00b204e9800998ecf8427e" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("")), + _1: "d41d8cd98f00b204e9800998ecf8427e" }) ], tl: { hd: [ "File \"digest_test.res\", line 26, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), - _1: "7065cc36bba1d155fb09f9d02f22e8bf" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), + _1: "7065cc36bba1d155fb09f9d02f22e8bf" }) ], tl: { hd: [ "File \"digest_test.res\", line 45, characters 10-17", - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), - _1: "b9193d1df4b7a8f0a25ffdd1005c5b2b" - }; + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.The quick brown fox jumps over the lazy dog.")), + _1: "b9193d1df4b7a8f0a25ffdd1005c5b2b" }) ], tl: /* [] */0 @@ -217,18 +205,14 @@ Mt.from_pair_suites("Digest_test", Pervasives.$at({ } } } -}, $$Array.to_list($$Array.map((function (i) { - return [ - String(i), - (function () { - return { - TAG: "Eq", - _0: Digest.to_hex(Digest.string("a".repeat(i))), - _1: Caml_array.get(ref, i) - }; - }) - ]; -}), Ext_array_test.range(0, 129))))); +}, $$Array.to_list($$Array.map(i => [ + String(i), + () => ({ + TAG: "Eq", + _0: Digest.to_hex(Digest.string("a".repeat(i))), + _1: Caml_array.get(ref, i) + }) +], Ext_array_test.range(0, 129))))); exports.f = f; /* Not a pure module */ diff --git a/jscomp/test/div_by_zero_test.js b/jscomp/test/div_by_zero_test.js index 6d14eeef6c..3ef3a489e5 100644 --- a/jscomp/test/div_by_zero_test.js +++ b/jscomp/test/div_by_zero_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -39,79 +37,67 @@ function add(suite) { add([ "File \"div_by_zero_test.res\", line 11, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.div(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.div(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 12, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.mod_(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.mod_(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 13, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.div(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.div(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 14, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int32.mod_(3, 0); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int32.mod_(3, 0); + } }) ]); add([ "File \"div_by_zero_test.res\", line 15, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int64.div([ - 0, - 3 - ], Caml_int64.zero); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int64.div([ + 0, + 3 + ], Caml_int64.zero); + } }) ]); add([ "File \"div_by_zero_test.res\", line 16, characters 7-14", - (function () { - return { - TAG: "ThrowAny", - _0: (function () { - Caml_int64.mod_([ - 0, - 3 - ], Caml_int64.zero); - }) - }; + () => ({ + TAG: "ThrowAny", + _0: () => { + Caml_int64.mod_([ + 0, + 3 + ], Caml_int64.zero); + } }) ]); diff --git a/jscomp/test/dollar_escape_test.js b/jscomp/test/dollar_escape_test.js index 820c31b7eb..4e8146f941 100644 --- a/jscomp/test/dollar_escape_test.js +++ b/jscomp/test/dollar_escape_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/earger_curry_test.js b/jscomp/test/earger_curry_test.js index be5e5b3cb0..8e6d741bff 100644 --- a/jscomp/test/earger_curry_test.js +++ b/jscomp/test/earger_curry_test.js @@ -6,9 +6,7 @@ let Caml_array = require("../../lib/js/caml_array.js"); let Pervasives = require("../../lib/js/pervasives.js"); function map(f, a) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = x => f(x); let l = a.length; if (l === 0) { return []; @@ -21,9 +19,7 @@ function map(f, a) { } function init(l, f) { - let f$1 = function (x) { - return f(x); - }; + let f$1 = x => f(x); if (l === 0) { return []; } @@ -43,9 +39,7 @@ function init(l, f) { } function fold_left(f, x, a) { - let f$1 = function (x, y) { - return f(x, y); - }; + let f$1 = (x, y) => f(x, y); let r = x; for (let i = 0, i_finish = a.length; i < i_finish; ++i) { r = f$1(r, a[i]); @@ -54,15 +48,9 @@ function fold_left(f, x, a) { } function f2() { - let arr = init(30000000, (function (i) { - return i; - })); - let b = map((function (i) { - return i + i - 1; - }), arr); - let v = fold_left((function (prim0, prim1) { - return prim0 + prim1; - }), 0, b); + let arr = init(30000000, i => i); + let b = map(i => i + i - 1, arr); + let v = fold_left((prim0, prim1) => prim0 + prim1, 0, b); console.log(Pervasives.string_of_float(v)); } @@ -81,12 +69,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -117,15 +103,11 @@ function add5(a0, a1, a2, a3, a4) { } function f(x) { - return function (extra, extra$1) { - return add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), extra, extra$1); - }; + return (extra, extra$1) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), extra, extra$1); } function g(x) { - let u = function (a, b) { - return add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), a, b); - }; + let u = (a, b) => add5(x, (v.contents = v.contents + 1 | 0, 1), (v.contents = v.contents + 1 | 0, 2), a, b); all_v.contents = { hd: v.contents, tl: all_v.contents diff --git a/jscomp/test/epsilon_test.js b/jscomp/test/epsilon_test.js index 07c8ae1e65..58cfd7092c 100644 --- a/jscomp/test/epsilon_test.js +++ b/jscomp/test/epsilon_test.js @@ -8,24 +8,20 @@ let v = (Number.EPSILON?Number.EPSILON:2.220446049250313e-16); let suites_0 = [ "epsilon", - (function (param) { - return { - TAG: "Eq", - _0: Pervasives.epsilon_float, - _1: v - }; + param => ({ + TAG: "Eq", + _0: Pervasives.epsilon_float, + _1: v }) ]; let suites_1 = { hd: [ "raw_epsilon", - (function (param) { - return { - TAG: "Eq", - _0: 2.220446049250313e-16, - _1: v - }; + param => ({ + TAG: "Eq", + _0: 2.220446049250313e-16, + _1: v }) ], tl: /* [] */0 diff --git a/jscomp/test/es6_module_test.js b/jscomp/test/es6_module_test.js index b990ee9ecb..63507f8917 100644 --- a/jscomp/test/es6_module_test.js +++ b/jscomp/test/es6_module_test.js @@ -11,29 +11,25 @@ function length(param) { Mt.from_pair_suites("Es6_module_test", { hd: [ "list_length", - (function () { - return { - TAG: "Eq", - _0: List.length({ - hd: 1, - tl: { - hd: 2, - tl: /* [] */0 - } - }), - _1: 2 - }; + () => ({ + TAG: "Eq", + _0: List.length({ + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + }), + _1: 2 }) ], tl: { hd: [ "length", - (function () { - return { - TAG: "Eq", - _0: 3, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: 3, + _1: 3 }) ], tl: /* [] */0 diff --git a/jscomp/test/event_ffi.js b/jscomp/test/event_ffi.js index d4144f53a3..55421f3adb 100644 --- a/jscomp/test/event_ffi.js +++ b/jscomp/test/event_ffi.js @@ -20,9 +20,7 @@ function h10(x) { } function h30(x) { - return function (a) { - return x(3, 3, a); - }; + return a => x(3, 3, a); } function h33(x) { @@ -42,9 +40,7 @@ function a0() { } function a1() { - return function (x) { - return x; - }; + return x => x; } function a2(x, y) { @@ -56,7 +52,7 @@ function a3(x, y, z) { } function xx() { - return function (param) { + return param => { console.log(3); }; } diff --git a/jscomp/test/exception_raise_test.js b/jscomp/test/exception_raise_test.js index 70c918c055..e847b09f39 100644 --- a/jscomp/test/exception_raise_test.js +++ b/jscomp/test/exception_raise_test.js @@ -127,28 +127,26 @@ let suites = { contents: { hd: [ "File \"exception_raise_test.res\", line 120, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: [ - f, - ff, - fff, - a0 - ], - _1: [ - 2, - 2, - 2, - 2 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + f, + ff, + fff, + a0 + ], + _1: [ + 2, + 2, + 2, + 2 + ] }) ], tl: { hd: [ "File \"exception_raise_test.res\", line 123, characters 6-13", - (function () { + () => { if (a1.RE_EXN_ID === Js_exn.$$Error) { return { TAG: "Eq", @@ -166,7 +164,7 @@ let suites = { ] } }); - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/exception_rebound_err_test.js b/jscomp/test/exception_rebound_err_test.js index 403e7a2b7f..e795fde624 100644 --- a/jscomp/test/exception_rebound_err_test.js +++ b/jscomp/test/exception_rebound_err_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/ext_array_test.js b/jscomp/test/ext_array_test.js index d3793e0f0c..7c824a62e7 100644 --- a/jscomp/test/ext_array_test.js +++ b/jscomp/test/ext_array_test.js @@ -112,9 +112,7 @@ function range(from, to_) { } }); } - return $$Array.init((to_ - from | 0) + 1 | 0, (function (i) { - return i + from | 0; - })); + return $$Array.init((to_ - from | 0) + 1 | 0, i => i + from | 0); } function map2i(f, a, b) { @@ -127,9 +125,7 @@ function map2i(f, a, b) { } }); } - return $$Array.mapi((function (i, a) { - return f(i, a, b[i]); - }), a); + return $$Array.mapi((i, a) => f(i, a, b[i]), a); } function tolist_aux(a, f, _i, _res) { diff --git a/jscomp/test/ext_bytes_test.js b/jscomp/test/ext_bytes_test.js index d011a861d0..3a7ad98c91 100644 --- a/jscomp/test/ext_bytes_test.js +++ b/jscomp/test/ext_bytes_test.js @@ -170,17 +170,13 @@ let f = Char.chr; let a$2 = Bytes.unsafe_to_string(Bytes.init(100, f)); -let b = Bytes.init(100, (function (i) { - return /* '\000' */0; -})); +let b = Bytes.init(100, i => /* '\000' */0); Bytes.blit_string(a$2, 10, b, 5, 10); eq("File \"ext_bytes_test.res\", line 141, characters 4-11", b, Bytes.of_string("\x00\x00\x00\x00\x00\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")); -let s = Bytes.init(50000, (function (i) { - return Char.chr(i % 137); -})); +let s = Bytes.init(50000, i => Char.chr(i % 137)); let s1 = Bytes.to_string(s); diff --git a/jscomp/test/ext_filename_test.js b/jscomp/test/ext_filename_test.js index e443d10358..7628c95abe 100644 --- a/jscomp/test/ext_filename_test.js +++ b/jscomp/test/ext_filename_test.js @@ -19,9 +19,7 @@ let node_parent = ".."; let node_current = "."; -let cwd = CamlinternalLazy.from_fun(function () { - return Caml_sys.sys_getcwd(); -}); +let cwd = CamlinternalLazy.from_fun(() => Caml_sys.sys_getcwd()); function path_as_directory(x) { if (x === "" || Ext_string_test.ends_with(x, Filename.dir_sep)) { @@ -33,7 +31,7 @@ function path_as_directory(x) { function absolute_path(s) { let s$1 = Filename.is_relative(s) ? Filename.concat(CamlinternalLazy.force(cwd), s) : s; - let aux = function (_s) { + let aux = _s => { while (true) { let s = _s; let base = Filename.basename(s); @@ -97,7 +95,7 @@ function relative_path(file_or_dir_1, file_or_dir_2) { let relevant_dir2 = file_or_dir_2.NAME === "File" ? Filename.dirname(file_or_dir_2.VAL) : file_or_dir_2.VAL; let dir1 = Ext_string_test.split(undefined, relevant_dir1, os_path_separator_char); let dir2 = Ext_string_test.split(undefined, relevant_dir2, os_path_separator_char); - let go = function (_dir1, _dir2) { + let go = (_dir1, _dir2) => { while (true) { let dir2 = _dir2; let dir1 = _dir1; @@ -106,9 +104,7 @@ function relative_path(file_or_dir_1, file_or_dir_2) { _dir1 = dir1.tl; continue; } - return Pervasives.$at(List.map((function (param) { - return node_parent; - }), dir2), dir1); + return Pervasives.$at(List.map(param => node_parent, dir2), dir1); }; }; let ys = go(dir1, dir2); @@ -141,7 +137,7 @@ function node_relative_path(node_modules_shorten, file1, dep_file) { VAL: absolute_path(file1.VAL) })) + (node_sep + Filename.basename(file2)); } - let skip = function (_i) { + let skip = _i => { while (true) { let i = _i; if (i >= len) { @@ -189,7 +185,7 @@ function find_package_json_dir(cwd) { return find_root_filename(cwd, Test_literals.bsconfig_json); } -let package_dir = CamlinternalLazy.from_fun(function () { +let package_dir = CamlinternalLazy.from_fun(() => { let cwd$1 = CamlinternalLazy.force(cwd); return find_root_filename(cwd$1, Test_literals.bsconfig_json); }); @@ -264,31 +260,27 @@ function rel_normalized_absolute_path(from, to_) { } let xs = xss.tl; if (!yss) { - return List.fold_left((function (acc, param) { - return Filename.concat(acc, Ext_string_test.parent_dir_lit); - }), Ext_string_test.parent_dir_lit, xs); + return List.fold_left((acc, param) => Filename.concat(acc, Ext_string_test.parent_dir_lit), Ext_string_test.parent_dir_lit, xs); } if (xss.hd === yss.hd) { _yss = yss.tl; _xss = xs; continue; } - let start = List.fold_left((function (acc, param) { - return Filename.concat(acc, Ext_string_test.parent_dir_lit); - }), Ext_string_test.parent_dir_lit, xs); + let start = List.fold_left((acc, param) => Filename.concat(acc, Ext_string_test.parent_dir_lit), Ext_string_test.parent_dir_lit, xs); return List.fold_left(Filename.concat, start, yss); }; } function normalize_absolute_path(x) { - let drop_if_exist = function (xs) { + let drop_if_exist = xs => { if (xs) { return xs.tl; } else { return /* [] */0; } }; - let normalize_list = function (_acc, _paths) { + let normalize_list = (_acc, _paths) => { while (true) { let paths = _paths; let acc = _acc; @@ -347,9 +339,7 @@ function get_extension(x) { let simple_convert_node_path_to_os_path; if (Sys.unix) { - simple_convert_node_path_to_os_path = (function (x) { - return x; - }); + simple_convert_node_path_to_os_path = x => x; } else if (Sys.win32 || false) { simple_convert_node_path_to_os_path = Ext_string_test.replace_slash_backward; } else { diff --git a/jscomp/test/ext_list_test.js b/jscomp/test/ext_list_test.js index 34f7d88f78..5c17bb62a0 100644 --- a/jscomp/test/ext_list_test.js +++ b/jscomp/test/ext_list_test.js @@ -29,7 +29,7 @@ function excludes(p, l) { let excluded = { contents: false }; - let aux = function (_accu, _x) { + let aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -69,7 +69,7 @@ function exclude_with_fact(p, l) { let excluded = { contents: undefined }; - let aux = function (_accu, _x) { + let aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -105,7 +105,7 @@ function exclude_with_fact2(p1, p2, l) { let excluded2 = { contents: undefined }; - let aux = function (_accu, _x) { + let aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -161,7 +161,7 @@ function same_length(_xs, _ys) { } function filter_mapi(f, xs) { - let aux = function (_i, _xs) { + let aux = (_i, _xs) => { while (true) { let xs = _xs; let i = _i; @@ -223,7 +223,7 @@ function filter_map2(f, _xs, _ys) { } function filter_map2i(f, xs, ys) { - let aux = function (_i, _xs, _ys) { + let aux = (_i, _xs, _ys) => { while (true) { let ys = _ys; let xs = _xs; @@ -648,9 +648,7 @@ function for_all_opt(p, _x) { } function fold(f, l, init) { - return List.fold_left((function (acc, i) { - return f(i, init); - }), init, l); + return List.fold_left((acc, i) => f(i, init), init, l); } function rev_map_acc(acc, f, l) { @@ -774,9 +772,7 @@ function split_map(f, xs) { function reduce_from_right(fn, lst) { let match = List.rev(lst); if (match) { - return List.fold_left((function (x, y) { - return fn(y, x); - }), match.hd, match.tl); + return List.fold_left((x, y) => fn(y, x), match.hd, match.tl); } throw new Error("Invalid_argument", { cause: { diff --git a/jscomp/test/ext_string_test.js b/jscomp/test/ext_string_test.js index c73d6f37a0..69409ccddf 100644 --- a/jscomp/test/ext_string_test.js +++ b/jscomp/test/ext_string_test.js @@ -54,7 +54,7 @@ function split_by(keep_emptyOpt, is_delim, str) { function trim(s) { let i = 0; let j = s.length; - while ((function () { + while ((() => { let tmp = false; if (i < j) { let u = s.codePointAt(i); @@ -65,7 +65,7 @@ function trim(s) { i = i + 1 | 0; }; let k = j - 1 | 0; - while ((function () { + while ((() => { let tmp = false; if (k >= i) { let u = s.codePointAt(k); @@ -82,20 +82,18 @@ function split(keep_empty, str, on) { if (str === "") { return /* [] */0; } else { - return split_by(keep_empty, (function (x) { - return x === on; - }), str); + return split_by(keep_empty, x => x === on, str); } } function quick_split_by_ws(str) { - return split_by(false, (function (x) { + return split_by(false, x => { if (x === /* '\t' */9 || x === /* '\n' */10) { return true; } else { return x === /* ' ' */32; } - }), str); + }, str); } function starts_with(s, beg) { @@ -147,9 +145,7 @@ function ends_with_then_chop(s, beg) { } function check_any_suffix_case(s, suffixes) { - return List.exists((function (x) { - return ends_with(s, x); - }), suffixes); + return List.exists(x => ends_with(s, x), suffixes); } function check_any_suffix_case_then_chop(s, suffixes) { @@ -169,7 +165,7 @@ function check_any_suffix_case_then_chop(s, suffixes) { } function escaped(s) { - let needs_escape = function (_i) { + let needs_escape = _i => { while (true) { let i = _i; if (i >= s.length) { @@ -449,7 +445,7 @@ function is_valid_module_file(s) { } else if (match < 65) { return false; } - return unsafe_for_all_range(s, 1, len - 1 | 0, (function (x) { + return unsafe_for_all_range(s, 1, len - 1 | 0, x => { if (x >= 65) { if (x > 96 || x < 91) { return x < 123; @@ -461,7 +457,7 @@ function is_valid_module_file(s) { } else { return x === 39; } - })); + }); } function is_valid_npm_package_name(s) { @@ -481,7 +477,7 @@ function is_valid_npm_package_name(s) { } else if (match !== 64) { return false; } - return unsafe_for_all_range(s, 1, len - 1 | 0, (function (x) { + return unsafe_for_all_range(s, 1, len - 1 | 0, x => { if (x >= 58) { if (x >= 97) { return x < 123; @@ -493,7 +489,7 @@ function is_valid_npm_package_name(s) { } else { return true; } - })); + }); } function is_valid_source_name(name) { @@ -575,13 +571,13 @@ function replace_slash_backward(x) { if (unsafe_no_char(x, /* '/' */47, 0, len - 1 | 0)) { return x; } else { - return $$String.map((function (x) { + return $$String.map(x => { if (x !== 47) { return x; } else { return /* '\\' */92; } - }), x); + }, x); } } @@ -590,13 +586,13 @@ function replace_backward_slash(x) { if (unsafe_no_char(x, /* '\\' */92, 0, len - 1 | 0)) { return x; } else { - return $$String.map((function (x) { + return $$String.map(x => { if (x !== 92) { return x; } else { return /* '/' */47; } - }), x); + }, x); } } diff --git a/jscomp/test/extensible_variant_test.js b/jscomp/test/extensible_variant_test.js index dbebc62d58..cfadcd2dde 100644 --- a/jscomp/test/extensible_variant_test.js +++ b/jscomp/test/extensible_variant_test.js @@ -38,46 +38,40 @@ function to_int(x) { let suites_0 = [ "test_int", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: to_int({ - RE_EXN_ID: Int, - _1: 3, - _2: 0 - }) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: to_int({ + RE_EXN_ID: Int, + _1: 3, + _2: 0 + }) }) ]; let suites_1 = { hd: [ "test_int2", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: to_int({ - RE_EXN_ID: Int$1, - _1: 3, - _2: 0 - }) - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: to_int({ + RE_EXN_ID: Int$1, + _1: 3, + _2: 0 + }) }) ], tl: { hd: [ "test_string", - (function (param) { - return { - TAG: "Eq", - _0: -1, - _1: to_int({ - RE_EXN_ID: Str, - _1: "x" - }) - }; + param => ({ + TAG: "Eq", + _0: -1, + _1: to_int({ + RE_EXN_ID: Str, + _1: "x" + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/ffi_arity_test.js b/jscomp/test/ffi_arity_test.js index eb3eb30760..ad382cb1b0 100644 --- a/jscomp/test/ffi_arity_test.js +++ b/jscomp/test/ffi_arity_test.js @@ -5,13 +5,9 @@ let Mt = require("./mt.js"); function f(v) { if (v % 2 === 0) { - return function (v) { - return Math.imul(v, v); - }; + return v => Math.imul(v, v); } else { - return function (v) { - return v + v | 0; - }; + return v => v + v | 0; } } @@ -19,25 +15,19 @@ let v = [ 1, 2, 3 -].map(function (a, b) { - return f(a)(b); -}); +].map((a, b) => f(a)(b)); let vv = [ 1, 2, 3 -].map(function (a, b) { - return a + b | 0; -}); +].map((a, b) => a + b | 0); let hh = [ "1", "2", "3" -].map(function (x) { - return parseInt(x); -}); +].map(x => parseInt(x)); function u() { return 3; @@ -70,46 +60,40 @@ fff(); Mt.from_pair_suites("Ffi_arity_test", { hd: [ "File \"ffi_arity_test.res\", line 51, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: v, - _1: [ - 0, - 1, - 4 - ] - }; + () => ({ + TAG: "Eq", + _0: v, + _1: [ + 0, + 1, + 4 + ] }) ], tl: { hd: [ "File \"ffi_arity_test.res\", line 52, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: vv, - _1: [ - 1, - 3, - 5 - ] - }; + () => ({ + TAG: "Eq", + _0: vv, + _1: [ + 1, + 3, + 5 + ] }) ], tl: { hd: [ "File \"ffi_arity_test.res\", line 53, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: hh, - _1: [ - 1, - 2, - 3 - ] - }; + () => ({ + TAG: "Eq", + _0: hh, + _1: [ + 1, + 2, + 3 + ] }) ], tl: /* [] */0 diff --git a/jscomp/test/ffi_array_test.js b/jscomp/test/ffi_array_test.js index 1fa6dbda0f..ea510b33cf 100644 --- a/jscomp/test/ffi_array_test.js +++ b/jscomp/test/ffi_array_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -33,9 +31,7 @@ eq("File \"ffi_array_test.res\", line 11, characters 12-19", [ 2, 3, 4 -].map(function (x) { - return x + 1 | 0; -}), [ +].map(x => x + 1 | 0), [ 2, 3, 4, diff --git a/jscomp/test/ffi_js_test.js b/jscomp/test/ffi_js_test.js index b97a7f580d..6fd4eb6399 100644 --- a/jscomp/test/ffi_js_test.js +++ b/jscomp/test/ffi_js_test.js @@ -27,12 +27,10 @@ function eq(loc, param) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/ffi_splice_test.js b/jscomp/test/ffi_splice_test.js index 7f52cffcc2..1885b6ec2e 100644 --- a/jscomp/test/ffi_splice_test.js +++ b/jscomp/test/ffi_splice_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/flexible_array_test.js b/jscomp/test/flexible_array_test.js index 8ce92b71c2..7e932c4ae9 100644 --- a/jscomp/test/flexible_array_test.js +++ b/jscomp/test/flexible_array_test.js @@ -269,12 +269,8 @@ function sort(s) { return s; } let head = get(s, 0); - let larger = sort(filter_from(1, (function (x) { - return Caml_obj.greaterthan(x, head); - }), s)); - let smaller = sort(filter_from(1, (function (x) { - return Caml_obj.lessequal(x, head); - }), s)); + let larger = sort(filter_from(1, x => Caml_obj.greaterthan(x, head), s)); + let smaller = sort(filter_from(1, x => Caml_obj.lessequal(x, head), s)); return append(smaller, push_front(larger, head)); } @@ -335,13 +331,9 @@ if (!$eq$tilde(sort(u), [ }); } -let v = $$Array.init(500, (function (i) { - return 500 - i | 0; -})); +let v = $$Array.init(500, i => 500 - i | 0); -$eq$tilde(sort(of_array(v)), $$Array.init(500, (function (i) { - return i + 1 | 0; -}))); +$eq$tilde(sort(of_array(v)), $$Array.init(500, i => i + 1 | 0)); exports.sub = sub; exports.update = update; diff --git a/jscomp/test/float_of_bits_test.js b/jscomp/test/float_of_bits_test.js index 7b6747eae2..d4f450973a 100644 --- a/jscomp/test/float_of_bits_test.js +++ b/jscomp/test/float_of_bits_test.js @@ -25,57 +25,49 @@ let int32_pairs = [ ]; function from_pairs(pair) { - return List.concat($$Array.to_list($$Array.mapi((function (i, param) { + return List.concat($$Array.to_list($$Array.mapi((i, param) => { let f = param[1]; let i32 = param[0]; return { hd: [ "int32_float_of_bits " + i, - (function (param) { - return { - TAG: "Eq", - _0: Caml_float.int_float_of_bits(i32), - _1: f - }; + param => ({ + TAG: "Eq", + _0: Caml_float.int_float_of_bits(i32), + _1: f }) ], tl: { hd: [ "int32_bits_of_float " + i, - (function (param) { - return { - TAG: "Eq", - _0: Caml_float.int_bits_of_float(f), - _1: i32 - }; + param => ({ + TAG: "Eq", + _0: Caml_float.int_bits_of_float(f), + _1: i32 }) ], tl: /* [] */0 } }; - }), int32_pairs))); + }, int32_pairs))); } let suites = Pervasives.$at({ hd: [ "one", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.bits_of_float(1.0), - _1: one_float - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.bits_of_float(1.0), + _1: one_float }) ], tl: { hd: [ "two", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.float_of_bits(one_float), - _1: 1.0 - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.float_of_bits(one_float), + _1: 1.0 }) ], tl: /* [] */0 diff --git a/jscomp/test/float_test.js b/jscomp/test/float_test.js index 7998fe9d09..e463d77f83 100644 --- a/jscomp/test/float_test.js +++ b/jscomp/test/float_test.js @@ -118,20 +118,18 @@ let results = $$Array.append([ ]); function from_pairs(ps) { - return $$Array.to_list($$Array.mapi((function (i, param) { + return $$Array.to_list($$Array.mapi((i, param) => { let b = param[1]; let a = param[0]; return [ "pair " + i, - (function (param) { - return { - TAG: "Approx", - _0: a, - _1: b - }; + param => ({ + TAG: "Approx", + _0: a, + _1: b }) ]; - }), ps)); + }, ps)); } let float_compare = Caml.float_compare; @@ -191,7 +189,7 @@ eq("File \"float_test.res\", line 62, characters 4-11", [ true ]); -eq("File \"float_test.res\", line 71, characters 4-11", $$Array.map((function (x) { +eq("File \"float_test.res\", line 71, characters 4-11", $$Array.map(x => { if (x > 0) { return 1; } else if (x < 0) { @@ -199,9 +197,7 @@ eq("File \"float_test.res\", line 71, characters 4-11", $$Array.map((function (x } else { return 0; } -}), $$Array.map((function (param) { - return Caml.float_compare(param[0], param[1]); -}), [ +}, $$Array.map(param => Caml.float_compare(param[0], param[1]), [ [ 1, 3 @@ -325,45 +321,37 @@ let a = match$4[0]; Mt.from_pair_suites("Float_test", Pervasives.$at({ hd: [ "mod_float", - (function () { - return { - TAG: "Approx", - _0: 3.2 % 0.5, - _1: 0.200000000000000178 - }; + () => ({ + TAG: "Approx", + _0: 3.2 % 0.5, + _1: 0.200000000000000178 }) ], tl: { hd: [ "modf_float1", - (function () { - return { - TAG: "Approx", - _0: a, - _1: 0.299999999999997158 - }; + () => ({ + TAG: "Approx", + _0: a, + _1: 0.299999999999997158 }) ], tl: { hd: [ "modf_float2", - (function () { - return { - TAG: "Approx", - _0: b, - _1: 32 - }; + () => ({ + TAG: "Approx", + _0: b, + _1: 32 }) ], tl: { hd: [ "int_of_float", - (function () { - return { - TAG: "Eq", - _0: 3, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: 3, + _1: 3 }) ], tl: /* [] */0 diff --git a/jscomp/test/for_loop_test.js b/jscomp/test/for_loop_test.js index 55b6cf0e27..11a546508a 100644 --- a/jscomp/test/for_loop_test.js +++ b/jscomp/test/for_loop_test.js @@ -9,20 +9,14 @@ function for_3(x) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let j = (i << 1); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + j | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -30,21 +24,15 @@ function for_4(x) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let j = (i << 1); let k = (j << 1); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + k | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -52,20 +40,14 @@ function for_5(x, u) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); for (let i = 0, i_finish = x.length; i < i_finish; ++i) { let k = Math.imul((u << 1), u); - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = v.contents + k | 0; - })); + }); } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return v.contents; } @@ -73,11 +55,7 @@ function for_6(x, u) { let v = { contents: 0 }; - let arr = $$Array.map((function (param) { - return function () { - - }; - }), x); + let arr = $$Array.map(param => (() => {}), x); let v4 = { contents: 0 }; @@ -95,15 +73,13 @@ function for_6(x, u) { let k = Math.imul((u << 1), u); let h = (v5.contents << 1); v2.contents = v2.contents + 1 | 0; - Caml_array.set(arr, i, (function () { + Caml_array.set(arr, i, () => { v.contents = (((((v.contents + k | 0) + v2.contents | 0) + v4.contents | 0) + v5.contents | 0) + h | 0) + u | 0; - })); + }); } inspect_3 = v2.contents; } - $$Array.iter((function (x) { - x(); - }), arr); + $$Array.iter(x => x(), arr); return [ v.contents, v4.contents, @@ -116,19 +92,15 @@ function for_7() { let v = { contents: 0 }; - let arr = Caml_array.make(21, (function () { - - })); + let arr = Caml_array.make(21, () => {}); for (let i = 0; i <= 6; ++i) { for (let j = 0; j <= 2; ++j) { - Caml_array.set(arr, Math.imul(i, 3) + j | 0, (function () { + Caml_array.set(arr, Math.imul(i, 3) + j | 0, () => { v.contents = (v.contents + i | 0) + j | 0; - })); + }); } } - $$Array.iter((function (f) { - f(); - }), arr); + $$Array.iter(f => f(), arr); return v.contents; } @@ -136,21 +108,17 @@ function for_8() { let v = { contents: 0 }; - let arr = Caml_array.make(21, (function () { - - })); + let arr = Caml_array.make(21, () => {}); for (let i = 0; i <= 6; ++i) { let k = (i << 1); for (let j = 0; j <= 2; ++j) { let h = i + j | 0; - Caml_array.set(arr, Math.imul(i, 3) + j | 0, (function () { + Caml_array.set(arr, Math.imul(i, 3) + j | 0, () => { v.contents = (((v.contents + i | 0) + j | 0) + h | 0) + k | 0; - })); + }); } } - $$Array.iter((function (f) { - f(); - }), arr); + $$Array.iter(f => f(), arr); return v.contents; } @@ -158,7 +126,7 @@ function for_9() { let v = { contents: /* [] */0 }; - let collect = function (x) { + let collect = x => { v.contents = { hd: x, tl: v.contents @@ -170,12 +138,8 @@ function for_9() { let vv2 = { contents: 0 }; - let arr = Caml_array.make(4, (function () { - - })); - let arr2 = Caml_array.make(2, (function () { - - })); + let arr = Caml_array.make(4, () => {}); + let arr2 = Caml_array.make(2, () => {}); for (let i = 0; i <= 1; ++i) { let v$1 = { contents: 0 @@ -184,20 +148,16 @@ function for_9() { for (let j = 0; j <= 1; ++j) { v$1.contents = v$1.contents + 1 | 0; collect(v$1.contents); - Caml_array.set(arr, (i << 1) + j | 0, (function () { + Caml_array.set(arr, (i << 1) + j | 0, () => { vv.contents = vv.contents + v$1.contents | 0; - })); + }); } - Caml_array.set(arr2, i, (function () { + Caml_array.set(arr2, i, () => { vv2.contents = vv2.contents + v$1.contents | 0; - })); + }); } - $$Array.iter((function (f) { - f(); - }), arr); - $$Array.iter((function (f) { - f(); - }), arr2); + $$Array.iter(f => f(), arr); + $$Array.iter(f => f(), arr2); return [[ vv.contents, $$Array.of_list(List.rev(v.contents)), @@ -207,93 +167,79 @@ function for_9() { let suites_0 = [ "for_loop_test_3", - (function (param) { - return { - TAG: "Eq", - _0: 90, - _1: for_3(Caml_array.make(10, 2)) - }; + param => ({ + TAG: "Eq", + _0: 90, + _1: for_3(Caml_array.make(10, 2)) }) ]; let suites_1 = { hd: [ "for_loop_test_4", - (function (param) { - return { - TAG: "Eq", - _0: 180, - _1: for_4(Caml_array.make(10, 2)) - }; + param => ({ + TAG: "Eq", + _0: 180, + _1: for_4(Caml_array.make(10, 2)) }) ], tl: { hd: [ "for_loop_test_5", - (function (param) { - return { - TAG: "Eq", - _0: 2420, - _1: for_5(Caml_array.make(10, 2), 11) - }; + param => ({ + TAG: "Eq", + _0: 2420, + _1: for_5(Caml_array.make(10, 2), 11) }) ], tl: { hd: [ "for_loop_test_6", - (function (param) { - return { - TAG: "Eq", - _0: [ - 30, - 1, - 2, - 3 - ], - _1: for_6(Caml_array.make(3, 0), 0) - }; + param => ({ + TAG: "Eq", + _0: [ + 30, + 1, + 2, + 3 + ], + _1: for_6(Caml_array.make(3, 0), 0) }) ], tl: { hd: [ "for_loop_test_7", - (function (param) { - return { - TAG: "Eq", - _0: 84, - _1: for_7() - }; + param => ({ + TAG: "Eq", + _0: 84, + _1: for_7() }) ], tl: { hd: [ "for_loop_test_8", - (function (param) { - return { - TAG: "Eq", - _0: 294, - _1: for_8() - }; + param => ({ + TAG: "Eq", + _0: 294, + _1: for_8() }) ], tl: { hd: [ "for_loop_test_9", - (function (param) { - return { - TAG: "Eq", - _0: [[ - 10, - [ - 1, - 2, - 2, - 3 - ], - 5 - ]], - _1: for_9() - }; + param => ({ + TAG: "Eq", + _0: [[ + 10, + [ + 1, + 2, + 2, + 3 + ], + 5 + ]], + _1: for_9() }) ], tl: /* [] */0 diff --git a/jscomp/test/for_side_effect_test.js b/jscomp/test/for_side_effect_test.js index ad61a8bb8d..5ad59cf45d 100644 --- a/jscomp/test/for_side_effect_test.js +++ b/jscomp/test/for_side_effect_test.js @@ -21,12 +21,10 @@ function test2() { let suites_0 = [ "for_order", - (function (param) { - return { - TAG: "Eq", - _0: 10, - _1: test2() - }; + param => ({ + TAG: "Eq", + _0: 10, + _1: test2() }) ]; diff --git a/jscomp/test/format_test.js b/jscomp/test/format_test.js index e7dbc96ed5..126980a702 100644 --- a/jscomp/test/format_test.js +++ b/jscomp/test/format_test.js @@ -20,12 +20,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -77,9 +75,7 @@ eq("File \"format_test.res\", line 45, characters 5-12", (1 + 4095 / 4096) * 8, eq("File \"format_test.res\", line 46, characters 5-12", (1 + 65535 / 65536) * 8, 15.9998779296875); function f(loc, ls) { - List.iter((function (param) { - eq(loc, Caml_format.float_of_string(param[0]), param[1]); - }), ls); + List.iter(param => eq(loc, Caml_format.float_of_string(param[0]), param[1]), ls); } f("File \"format_test.res\", line 53, characters 11-18", { @@ -107,9 +103,7 @@ function sl(f) { } function aux_list(loc, ls) { - List.iter((function (param) { - eq(loc, Caml_format.hexstring_of_float(param[0], -1, /* '-' */45), param[1]); - }), ls); + List.iter(param => eq(loc, Caml_format.hexstring_of_float(param[0], -1, /* '-' */45), param[1]), ls); } let literals_0 = [ @@ -186,9 +180,7 @@ scan_float("File \"format_test.res\", line 80, characters 13-20", "0x3f.p1", 126 scan_float("File \"format_test.res\", line 81, characters 13-20", "0x1.3333333333333p-2", 0.3); -List.iter((function (param) { - scan_float("File \"format_test.res\", line 82, characters 35-42", param[1], param[0]); -}), literals); +List.iter(param => scan_float("File \"format_test.res\", line 82, characters 35-42", param[1], param[0]), literals); let f1 = - -9.9; diff --git a/jscomp/test/functor_app_test.js b/jscomp/test/functor_app_test.js index 53402b6e29..0bbeb2abfc 100644 --- a/jscomp/test/functor_app_test.js +++ b/jscomp/test/functor_app_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/functor_def.js b/jscomp/test/functor_def.js index 8c1046548d..756262d85a 100644 --- a/jscomp/test/functor_def.js +++ b/jscomp/test/functor_def.js @@ -16,7 +16,7 @@ function $$return() { } function Make(U) { - let h = function (x, x$1) { + let h = (x, x$1) => { console.log(f(x$1, x$1)); return U.say(x$1, x$1); }; diff --git a/jscomp/test/functor_ffi.js b/jscomp/test/functor_ffi.js index 0d7c442e2e..70f82d1356 100644 --- a/jscomp/test/functor_ffi.js +++ b/jscomp/test/functor_ffi.js @@ -4,9 +4,7 @@ let Caml_option = require("../../lib/js/caml_option.js"); function Make(S) { - let opt_get = function (f, i) { - return Caml_option.undefined_to_opt(f[i]); - }; + let opt_get = (f, i) => Caml_option.undefined_to_opt(f[i]); return { opt_get: opt_get }; diff --git a/jscomp/test/functors.js b/jscomp/test/functors.js index f56f95b996..44b8b1ef0a 100644 --- a/jscomp/test/functors.js +++ b/jscomp/test/functors.js @@ -3,12 +3,8 @@ function O(X) { - let cow = function (x) { - return X.foo(x); - }; - let sheep = function (x) { - return 1 + X.foo(x) | 0; - }; + let cow = x => X.foo(x); + let sheep = x => 1 + X.foo(x) | 0; return { cow: cow, sheep: sheep @@ -16,12 +12,8 @@ function O(X) { } function F(X, Y) { - let cow = function (x) { - return Y.foo(X.foo(x)); - }; - let sheep = function (x) { - return 1 + Y.foo(X.foo(x)) | 0; - }; + let cow = x => Y.foo(X.foo(x)); + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; return { cow: cow, sheep: sheep @@ -29,32 +21,26 @@ function F(X, Y) { } function F1(X, Y) { - let sheep = function (x) { - return 1 + Y.foo(X.foo(x)) | 0; - }; + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; return { sheep: sheep }; } function F2(X, Y) { - let sheep = function (x) { - return 1 + Y.foo(X.foo(x)) | 0; - }; + let sheep = x => 1 + Y.foo(X.foo(x)) | 0; return { sheep: sheep }; } let M = { - F: (function (funarg, funarg$1) { - let sheep = function (x) { - return 1 + funarg$1.foo(funarg.foo(x)) | 0; - }; + F: (funarg, funarg$1) => { + let sheep = x => 1 + funarg$1.foo(funarg.foo(x)) | 0; return { sheep: sheep }; - }) + } }; exports.O = O; diff --git a/jscomp/test/genlex_test.js b/jscomp/test/genlex_test.js index 0638104f8c..7aa4e74b15 100644 --- a/jscomp/test/genlex_test.js +++ b/jscomp/test/genlex_test.js @@ -59,54 +59,52 @@ function to_list(s) { let suites_0 = [ "lexer_stream_genlex", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: { + TAG: "Int", + _0: 3 + }, + tl: { hd: { - TAG: "Int", - _0: 3 + TAG: "Kwd", + _0: "(" }, tl: { hd: { - TAG: "Kwd", - _0: "(" + TAG: "Int", + _0: 3 }, tl: { hd: { - TAG: "Int", - _0: 3 + TAG: "Kwd", + _0: "+" }, tl: { hd: { - TAG: "Kwd", - _0: "+" + TAG: "Int", + _0: 2 }, tl: { hd: { TAG: "Int", - _0: 2 + _0: -1 }, tl: { hd: { - TAG: "Int", - _0: -1 + TAG: "Kwd", + _0: ")" }, - tl: { - hd: { - TAG: "Kwd", - _0: ")" - }, - tl: /* [] */0 - } + tl: /* [] */0 } } } } } - }, - _1: to_list(lexer(Stream.of_string("3(3 + 2 -1)"))) - }; + } + }, + _1: to_list(lexer(Stream.of_string("3(3 + 2 -1)"))) }) ]; diff --git a/jscomp/test/global_exception_regression_test.js b/jscomp/test/global_exception_regression_test.js index 443bf1ee90..a659c2d3fb 100644 --- a/jscomp/test/global_exception_regression_test.js +++ b/jscomp/test/global_exception_regression_test.js @@ -17,24 +17,20 @@ let s = { let suites_0 = [ "not_found_equal", - (function (param) { - return { - TAG: "Eq", - _0: u, - _1: v - }; + param => ({ + TAG: "Eq", + _0: u, + _1: v }) ]; let suites_1 = { hd: [ "not_found_not_equal_end_of_file", - (function (param) { - return { - TAG: "Neq", - _0: u, - _1: s - }; + param => ({ + TAG: "Neq", + _0: u, + _1: s }) ], tl: /* [] */0 diff --git a/jscomp/test/global_module_alias_test.js b/jscomp/test/global_module_alias_test.js index 99890d07ea..7752010026 100644 --- a/jscomp/test/global_module_alias_test.js +++ b/jscomp/test/global_module_alias_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/google_closure_test.js b/jscomp/test/google_closure_test.js index 488df56280..2e9cbe212d 100644 --- a/jscomp/test/google_closure_test.js +++ b/jscomp/test/google_closure_test.js @@ -7,23 +7,21 @@ let Test_google_closure = require("./test_google_closure.js"); Mt.from_pair_suites("Closure", { hd: [ "partial", - (function () { - return { - TAG: "Eq", - _0: [ - Test_google_closure.a, - Test_google_closure.b, - Test_google_closure.c - ], - _1: [ - "3", - 101, - [ - 1, - 2 - ] + () => ({ + TAG: "Eq", + _0: [ + Test_google_closure.a, + Test_google_closure.b, + Test_google_closure.c + ], + _1: [ + "3", + 101, + [ + 1, + 2 ] - }; + ] }) ], tl: /* [] */0 diff --git a/jscomp/test/gpr496_test.js b/jscomp/test/gpr496_test.js index 89eb671d8d..b7c42a58bc 100644 --- a/jscomp/test/gpr496_test.js +++ b/jscomp/test/gpr496_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1154_test.js b/jscomp/test/gpr_1154_test.js index b951f6fc97..409b24e7fa 100644 --- a/jscomp/test/gpr_1154_test.js +++ b/jscomp/test/gpr_1154_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1409_test.js b/jscomp/test/gpr_1409_test.js index ec0b717f46..0fd2d32db4 100644 --- a/jscomp/test/gpr_1409_test.js +++ b/jscomp/test/gpr_1409_test.js @@ -19,12 +19,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -46,9 +44,7 @@ function map(f, x) { function make(foo, param) { let tmp = {}; - let tmp$1 = map((function (prim) { - return String(prim); - }), foo); + let tmp$1 = map(prim => String(prim), foo); if (tmp$1 !== undefined) { tmp.foo = tmp$1; } diff --git a/jscomp/test/gpr_1423_app_test.js b/jscomp/test/gpr_1423_app_test.js index da8edcbc0e..e87c3e1fc1 100644 --- a/jscomp/test/gpr_1423_app_test.js +++ b/jscomp/test/gpr_1423_app_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents @@ -32,9 +30,7 @@ function foo(f) { console.log(f("a1", undefined)); } -foo(function (none, extra) { - return none + "a2"; -}); +foo((none, extra) => none + "a2"); function foo2(f) { return f("a1", undefined); diff --git a/jscomp/test/gpr_1438.js b/jscomp/test/gpr_1438.js index 9d8750c886..8f89b09dfb 100644 --- a/jscomp/test/gpr_1438.js +++ b/jscomp/test/gpr_1438.js @@ -16,9 +16,7 @@ function actionKey(key, a, b, c, d, e) { case 118 : return a; } - return function (param) { - - }; + return param => {}; } exports.actionKey = actionKey; diff --git a/jscomp/test/gpr_1503_test.js b/jscomp/test/gpr_1503_test.js index 41af088b96..c5bd31f0c6 100644 --- a/jscomp/test/gpr_1503_test.js +++ b/jscomp/test/gpr_1503_test.js @@ -19,12 +19,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1539_test.js b/jscomp/test/gpr_1539_test.js index 3cd7784433..e8b2d507a8 100644 --- a/jscomp/test/gpr_1539_test.js +++ b/jscomp/test/gpr_1539_test.js @@ -22,9 +22,7 @@ Caml_module.update_mod({ "add" ]] }, Point, { - add: (function (prim0, prim1) { - return prim0.add(prim1); - }) + add: (prim0, prim1) => prim0.add(prim1) }); let CRS; diff --git a/jscomp/test/gpr_1658_test.js b/jscomp/test/gpr_1658_test.js index 22768108a3..f0b9e8752e 100644 --- a/jscomp/test/gpr_1658_test.js +++ b/jscomp/test/gpr_1658_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1667_test.js b/jscomp/test/gpr_1667_test.js index a1f9c44493..9da1661ecb 100644 --- a/jscomp/test/gpr_1667_test.js +++ b/jscomp/test/gpr_1667_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1692_test.js b/jscomp/test/gpr_1692_test.js index 884c49a7dc..7c0694ed44 100644 --- a/jscomp/test/gpr_1692_test.js +++ b/jscomp/test/gpr_1692_test.js @@ -2,8 +2,6 @@ 'use strict'; -((function (f) { - return 0; - })("")); +(f => 0)(""); /* Not a pure module */ diff --git a/jscomp/test/gpr_1701_test.js b/jscomp/test/gpr_1701_test.js index 81226bbfca..dbf9f7c67a 100644 --- a/jscomp/test/gpr_1701_test.js +++ b/jscomp/test/gpr_1701_test.js @@ -83,7 +83,7 @@ function read_lines2(inc) { } function read_lines3(inc) { - let loop = function (acc) { + let loop = acc => { try { let l = input_line(inc); return loop({ diff --git a/jscomp/test/gpr_1716_test.js b/jscomp/test/gpr_1716_test.js index ae4d162250..63584127f3 100644 --- a/jscomp/test/gpr_1716_test.js +++ b/jscomp/test/gpr_1716_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1728_test.js b/jscomp/test/gpr_1728_test.js index 90f5f5fa50..a593c54a84 100644 --- a/jscomp/test/gpr_1728_test.js +++ b/jscomp/test/gpr_1728_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1749_test.js b/jscomp/test/gpr_1749_test.js index c0df289865..a253398ae6 100644 --- a/jscomp/test/gpr_1749_test.js +++ b/jscomp/test/gpr_1749_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1760_test.js b/jscomp/test/gpr_1760_test.js index 070945f187..a1a7811211 100644 --- a/jscomp/test/gpr_1760_test.js +++ b/jscomp/test/gpr_1760_test.js @@ -18,12 +18,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1762_test.js b/jscomp/test/gpr_1762_test.js index 99d10508f4..5624f6b6c7 100644 --- a/jscomp/test/gpr_1762_test.js +++ b/jscomp/test/gpr_1762_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1817_test.js b/jscomp/test/gpr_1817_test.js index f28147a06b..a8e9c48e83 100644 --- a/jscomp/test/gpr_1817_test.js +++ b/jscomp/test/gpr_1817_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1822_test.js b/jscomp/test/gpr_1822_test.js index 73e3a281bb..bbabae4d9f 100644 --- a/jscomp/test/gpr_1822_test.js +++ b/jscomp/test/gpr_1822_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_1943_test.js b/jscomp/test/gpr_1943_test.js index 49cadb62cf..0231c905ae 100644 --- a/jscomp/test/gpr_1943_test.js +++ b/jscomp/test/gpr_1943_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_2316_test.js b/jscomp/test/gpr_2316_test.js index 9740acfc1a..aa33122ecb 100644 --- a/jscomp/test/gpr_2316_test.js +++ b/jscomp/test/gpr_2316_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_2487.js b/jscomp/test/gpr_2487.js index 64a188c760..517bf784b3 100644 --- a/jscomp/test/gpr_2487.js +++ b/jscomp/test/gpr_2487.js @@ -11,9 +11,7 @@ let b = Belt_Array.eq([ 1, 2, 3 -], (function (prim0, prim1) { - return prim0 === prim1; -})); +], (prim0, prim1) => prim0 === prim1); let A; diff --git a/jscomp/test/gpr_2608_test.js b/jscomp/test/gpr_2608_test.js index 3e58451f94..f3a4853f53 100644 --- a/jscomp/test/gpr_2608_test.js +++ b/jscomp/test/gpr_2608_test.js @@ -24,18 +24,14 @@ let oppHeroes = { let huntGrootCondition = false; if (List.length(/* [] */0) > 0) { - let x = List.filter((function (h) { - return List.hd(/* [] */0) <= 1000; - }), oppHeroes); + let x = List.filter(h => List.hd(/* [] */0) <= 1000, oppHeroes); huntGrootCondition = List.length(x) === 0; } let huntGrootCondition2 = true; if (List.length(/* [] */0) < 0) { - let x$1 = List.filter((function (h) { - return List.hd(/* [] */0) <= 1000; - }), oppHeroes); + let x$1 = List.filter(h => List.hd(/* [] */0) <= 1000, oppHeroes); huntGrootCondition2 = List.length(x$1) === 0; } diff --git a/jscomp/test/gpr_2682_test.js b/jscomp/test/gpr_2682_test.js index 9cad19d945..4b85655c95 100644 --- a/jscomp/test/gpr_2682_test.js +++ b/jscomp/test/gpr_2682_test.js @@ -30,16 +30,16 @@ let N = { forIn({ x: 3 -}, (function (x) { +}, x => { console.log(x); -})); +}); forIn({ x: 3, y: 3 -}, (function (x) { +}, x => { console.log(x); -})); +}); let f3 = (()=>true); diff --git a/jscomp/test/gpr_3536_test.js b/jscomp/test/gpr_3536_test.js index e07b0156a2..4f40fea997 100644 --- a/jscomp/test/gpr_3536_test.js +++ b/jscomp/test/gpr_3536_test.js @@ -23,13 +23,7 @@ function xx(obj, a0, a1, a2, a3, a4, a5) { eq("File \"gpr_3536_test.res\", line 18, characters 12-19", 5, 5); -eq("File \"gpr_3536_test.res\", line 20, characters 12-19", xx(3, (function (prim0, prim1) { - return prim0 - prim1 | 0; -}), 2, (function (prim0, prim1) { - return prim0 + prim1 | 0; -}), 4, (function (prim0, prim1) { - return Math.imul(prim0, prim1); -}), 3), 11); +eq("File \"gpr_3536_test.res\", line 20, characters 12-19", xx(3, (prim0, prim1) => prim0 - prim1 | 0, 2, (prim0, prim1) => prim0 + prim1 | 0, 4, (prim0, prim1) => Math.imul(prim0, prim1), 3), 11); Mt.from_pair_suites("Gpr_3536_test", suites.contents); diff --git a/jscomp/test/gpr_3566_test.js b/jscomp/test/gpr_3566_test.js index 5604508e53..aab0570a8a 100644 --- a/jscomp/test/gpr_3566_test.js +++ b/jscomp/test/gpr_3566_test.js @@ -75,9 +75,7 @@ function Test4($star) { } function Test5($star) { - let f = function (x) { - return Caml_option.some(x); - }; + let f = x => Caml_option.some(x); let Caml_option$1 = {}; return { f: f, @@ -87,9 +85,7 @@ function Test5($star) { function Test6($star) { let Caml_option$1 = {}; - let f = function (x) { - return Caml_option.some(x); - }; + let f = x => Caml_option.some(x); return { Caml_option: Caml_option$1, f: f @@ -105,9 +101,7 @@ function Test7($star) { function Test8($star) { let Curry = {}; - let f = function (x) { - return x(1); - }; + let f = x => x(1); return { Curry: Curry, f: f @@ -115,9 +109,7 @@ function Test8($star) { } function Test9($star) { - let f = function (x) { - return x(1); - }; + let f = x => x(1); let Curry = {}; return { f: f, diff --git a/jscomp/test/gpr_3697_test.js b/jscomp/test/gpr_3697_test.js index 4e52d927dc..c2bae67104 100644 --- a/jscomp/test/gpr_3697_test.js +++ b/jscomp/test/gpr_3697_test.js @@ -6,9 +6,7 @@ let CamlinternalLazy = require("../../lib/js/camlinternalLazy.js"); function fix() { return { TAG: "Fix", - _0: CamlinternalLazy.from_fun(function () { - return fix(); - }) + _0: CamlinternalLazy.from_fun(() => fix()) }; } diff --git a/jscomp/test/gpr_3875_test.js b/jscomp/test/gpr_3875_test.js index 51d9d0db8d..6dcd01cc61 100644 --- a/jscomp/test/gpr_3875_test.js +++ b/jscomp/test/gpr_3875_test.js @@ -58,9 +58,7 @@ function eq(loc, x, y) { Mt.eq_suites(test_id, suites, loc, x, y); } -compilerBug("x", undefined, true, (function () { - return true; -})); +compilerBug("x", undefined, true, () => true); eq("File \"gpr_3875_test.res\", line 35, characters 5-12", result.contents, "Some x, f returns true"); diff --git a/jscomp/test/gpr_405_test.js b/jscomp/test/gpr_405_test.js index fc7a5c6494..3c406084b4 100644 --- a/jscomp/test/gpr_405_test.js +++ b/jscomp/test/gpr_405_test.js @@ -11,7 +11,7 @@ function Make(funarg) { equal: $$let.equal, hash: $$let.hash }); - let find_default = function (htbl, x) { + let find_default = (htbl, x) => { try { return H.find(htbl, x); } catch (raw_exn) { @@ -24,7 +24,7 @@ function Make(funarg) { }); } }; - let min_cutset = function (gr, first_node) { + let min_cutset = (gr, first_node) => { let n_labels = H.create(97); let l_labels = H.create(97); let already_processed = H.create(97); @@ -35,7 +35,7 @@ function Make(funarg) { let counter = { contents: 1 }; - let step2 = function (top, rest_of_stack) { + let step2 = (top, rest_of_stack) => { if (find_default(already_processed, top)) { throw new Error("Assert_failure", { cause: { diff --git a/jscomp/test/gpr_4274_test.js b/jscomp/test/gpr_4274_test.js index 125e98a008..c32273387d 100644 --- a/jscomp/test/gpr_4274_test.js +++ b/jscomp/test/gpr_4274_test.js @@ -8,9 +8,9 @@ let N = {}; function f(X, xs) { X.forEach(xs, { - i: (function (x) { + i: x => { console.log(x.x); - }) + } }); } @@ -19,9 +19,9 @@ Belt_List.forEach({ x: 3 }, tl: /* [] */0 -}, (function (x) { +}, x => { console.log(x.x); -})); +}); let Foo = {}; @@ -29,9 +29,7 @@ let bar = [{ foo: "bar" }]; -Belt_Array.map(bar, (function (b) { - return b.foo; -})); +Belt_Array.map(bar, b => b.foo); exports.N = N; exports.f = f; diff --git a/jscomp/test/gpr_459_test.js b/jscomp/test/gpr_459_test.js index 3284e178ee..c43d1267f6 100644 --- a/jscomp/test/gpr_459_test.js +++ b/jscomp/test/gpr_459_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_858_unit2_test.js b/jscomp/test/gpr_858_unit2_test.js index ce8f9934ef..8485cff5a8 100644 --- a/jscomp/test/gpr_858_unit2_test.js +++ b/jscomp/test/gpr_858_unit2_test.js @@ -3,19 +3,17 @@ let delayed = { - contents: (function () { - - }) + contents: () => {} }; for (let i = 1; i <= 2; ++i) { - let f = function (n, x) { + let f = (n, x) => { if (x !== 0) { let prev = delayed.contents; - delayed.contents = (function () { + delayed.contents = () => { prev(); f(((n + 1 | 0) + i | 0) - i | 0, x - 1 | 0); - }); + }; return; } if (i === n) { diff --git a/jscomp/test/gpr_904_test.js b/jscomp/test/gpr_904_test.js index f130ac5a27..7f1380b73f 100644 --- a/jscomp/test/gpr_904_test.js +++ b/jscomp/test/gpr_904_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/gpr_977_test.js b/jscomp/test/gpr_977_test.js index 46834c894a..aa765405f2 100644 --- a/jscomp/test/gpr_977_test.js +++ b/jscomp/test/gpr_977_test.js @@ -17,12 +17,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/hash_test.js b/jscomp/test/hash_test.js index e16a1f3cc0..aebfabff04 100644 --- a/jscomp/test/hash_test.js +++ b/jscomp/test/hash_test.js @@ -20,9 +20,7 @@ function eq(f, x, y) { Mt_global.collect_eq(test_id, suites, f, x, y); } -let test_strings = $$Array.init(32, (function (i) { - return Caml_string.make(i, Char.chr(i)); -})); +let test_strings = $$Array.init(32, i => Caml_string.make(i, Char.chr(i))); let test_strings_hash_results = [ 0, diff --git a/jscomp/test/hashtbl_test.js b/jscomp/test/hashtbl_test.js index c772bd678d..a4b95c66f8 100644 --- a/jscomp/test/hashtbl_test.js +++ b/jscomp/test/hashtbl_test.js @@ -9,14 +9,12 @@ let Hashtbl = require("../../lib/js/hashtbl.js"); let MoreLabels = require("../../lib/js/moreLabels.js"); function to_list(tbl) { - return Hashtbl.fold((function (k, v, acc) { - return { - hd: [ - k, - v - ], - tl: acc - }; + return Hashtbl.fold((k, v, acc) => ({ + hd: [ + k, + v + ], + tl: acc }), tbl, /* [] */0); } @@ -25,9 +23,7 @@ function f() { Hashtbl.add(tbl, 1, /* '1' */49); Hashtbl.add(tbl, 2, /* '2' */50); let extra = to_list(tbl); - return List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), extra); + return List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), extra); } function g(count) { @@ -39,54 +35,46 @@ function g(count) { Hashtbl.replace(tbl, (i$1 << 1), String(i$1)); } let v = to_list(tbl); - return $$Array.of_list(List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), v)); + return $$Array.of_list(List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), v)); } let suites_0 = [ "simple", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: [ + 1, + /* '1' */49 + ], + tl: { hd: [ - 1, - /* '1' */49 + 2, + /* '2' */50 ], - tl: { - hd: [ - 2, - /* '2' */50 - ], - tl: /* [] */0 - } - }, - _1: f() - }; + tl: /* [] */0 + } + }, + _1: f() }) ]; let suites_1 = { hd: [ "more_iterations", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.init(1001, (function (i) { - return [ - (i << 1), - String(i) - ]; - })), - _1: g(1000) - }; + param => ({ + TAG: "Eq", + _0: $$Array.init(1001, i => [ + (i << 1), + String(i) + ]), + _1: g(1000) }) ], tl: { hd: [ "More_labels_regressionfix_374", - (function (param) { + param => { let tbl = MoreLabels.Hashtbl.create(undefined, 30); Hashtbl.add(tbl, 3, 3); return { @@ -94,7 +82,7 @@ let suites_1 = { _0: tbl.size, _1: 1 }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/ignore_test.js b/jscomp/test/ignore_test.js index a32d149c2b..dc2915a59f 100644 --- a/jscomp/test/ignore_test.js +++ b/jscomp/test/ignore_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/import2.js b/jscomp/test/import2.js index 54321a1a75..3f5a1f3bb1 100644 --- a/jscomp/test/import2.js +++ b/jscomp/test/import2.js @@ -3,9 +3,7 @@ let A = require("a").default; -let a = import("a").then(function (m) { - return m.default; -}); +let a = import("a").then(m => m.default); let b = A; diff --git a/jscomp/test/import_external.js b/jscomp/test/import_external.js index 324766ba4b..38dab08678 100644 --- a/jscomp/test/import_external.js +++ b/jscomp/test/import_external.js @@ -2,9 +2,7 @@ 'use strict'; -let f8 = import("a").then(function (m) { - return m.default; -}); +let f8 = import("a").then(m => m.default); exports.f8 = f8; /* f8 Not a pure module */ diff --git a/jscomp/test/import_side_effect.js b/jscomp/test/import_side_effect.js index a00f681262..afbe3337f7 100644 --- a/jscomp/test/import_side_effect.js +++ b/jscomp/test/import_side_effect.js @@ -2,9 +2,7 @@ 'use strict'; -let a = import("./side_effect2.js").then(function (m) { - return m.a; -}); +let a = import("./side_effect2.js").then(m => m.a); let M = await import("./side_effect.js"); diff --git a/jscomp/test/import_side_effect_free.js b/jscomp/test/import_side_effect_free.js index 918c70f482..4df30a1a43 100644 --- a/jscomp/test/import_side_effect_free.js +++ b/jscomp/test/import_side_effect_free.js @@ -2,9 +2,7 @@ 'use strict'; -let a = await import("./side_effect_free.js").then(function (m) { - return m.a; -}); +let a = await import("./side_effect_free.js").then(m => m.a); exports.a = a; /* a Not a pure module */ diff --git a/jscomp/test/inline_map2_test.js b/jscomp/test/inline_map2_test.js index 8acb03a28d..f9d8d4da7c 100644 --- a/jscomp/test/inline_map2_test.js +++ b/jscomp/test/inline_map2_test.js @@ -7,14 +7,14 @@ let List = require("../../lib/js/list.js"); let Caml_option = require("../../lib/js/caml_option.js"); function Make(Ord) { - let height = function (x) { + let height = x => { if (typeof x !== "object") { return 0; } else { return x._4; } }; - let create = function (l, x, d, r) { + let create = (l, x, d, r) => { let hl = height(l); let hr = height(r); return { @@ -26,17 +26,15 @@ function Make(Ord) { _4: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 }; }; - let singleton = function (x, d) { - return { - TAG: "Node", - _0: "Empty", - _1: x, - _2: d, - _3: "Empty", - _4: 1 - }; - }; - let bal = function (l, x, d, r) { + let singleton = (x, d) => ({ + TAG: "Node", + _0: "Empty", + _1: x, + _2: d, + _3: "Empty", + _4: 1 + }); + let bal = (l, x, d, r) => { let hl; hl = typeof l !== "object" ? 0 : l._4; let hr; @@ -102,14 +100,14 @@ function Make(Ord) { } }); }; - let is_empty = function (x) { + let is_empty = x => { if (typeof x !== "object") { return true; } else { return false; } }; - let add = function (x, data, x_) { + let add = (x, data, x_) => { if (typeof x_ !== "object") { return { TAG: "Node", @@ -140,7 +138,7 @@ function Make(Ord) { return bal(l, v, d, add(x, data, r)); } }; - let find = function (x, _x_) { + let find = (x, _x_) => { while (true) { let x_ = _x_; if (typeof x_ !== "object") { @@ -158,7 +156,7 @@ function Make(Ord) { continue; }; }; - let mem = function (x, _x_) { + let mem = (x, _x_) => { while (true) { let x_ = _x_; if (typeof x_ !== "object") { @@ -172,7 +170,7 @@ function Make(Ord) { continue; }; }; - let min_binding = function (_x) { + let min_binding = _x => { while (true) { let x = _x; if (typeof x !== "object") { @@ -193,7 +191,7 @@ function Make(Ord) { continue; }; }; - let max_binding = function (_x) { + let max_binding = _x => { while (true) { let x = _x; if (typeof x !== "object") { @@ -214,7 +212,7 @@ function Make(Ord) { continue; }; }; - let remove_min_binding = function (x) { + let remove_min_binding = x => { if (typeof x !== "object") { throw new Error("Invalid_argument", { cause: { @@ -230,7 +228,7 @@ function Make(Ord) { return bal(remove_min_binding(l), x._1, x._2, x._3); } }; - let remove = function (x, x_) { + let remove = (x, x_) => { if (typeof x_ !== "object") { return "Empty"; } @@ -254,7 +252,7 @@ function Make(Ord) { return bal(l, v, d, remove(x, r)); } }; - let iter = function (f, _x) { + let iter = (f, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -266,7 +264,7 @@ function Make(Ord) { continue; }; }; - let map = function (f, x) { + let map = (f, x) => { if (typeof x !== "object") { return "Empty"; } @@ -282,7 +280,7 @@ function Make(Ord) { _4: x._4 }; }; - let mapi = function (f, x) { + let mapi = (f, x) => { if (typeof x !== "object") { return "Empty"; } @@ -299,7 +297,7 @@ function Make(Ord) { _4: x._4 }; }; - let fold = function (f, _m, _accu) { + let fold = (f, _m, _accu) => { while (true) { let accu = _accu; let m = _m; @@ -311,7 +309,7 @@ function Make(Ord) { continue; }; }; - let for_all = function (p, _x) { + let for_all = (p, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -327,7 +325,7 @@ function Make(Ord) { continue; }; }; - let exists = function (p, _x) { + let exists = (p, _x) => { while (true) { let x = _x; if (typeof x !== "object") { @@ -343,21 +341,21 @@ function Make(Ord) { continue; }; }; - let add_min_binding = function (k, v, x) { + let add_min_binding = (k, v, x) => { if (typeof x !== "object") { return singleton(k, v); } else { return bal(add_min_binding(k, v, x._0), x._1, x._2, x._3); } }; - let add_max_binding = function (k, v, x) { + let add_max_binding = (k, v, x) => { if (typeof x !== "object") { return singleton(k, v); } else { return bal(x._0, x._1, x._2, add_max_binding(k, v, x._3)); } }; - let join = function (l, v, d, r) { + let join = (l, v, d, r) => { if (typeof l !== "object") { return add_min_binding(v, d, r); } @@ -374,7 +372,7 @@ function Make(Ord) { return create(l, v, d, r); } }; - let concat = function (t1, t2) { + let concat = (t1, t2) => { if (typeof t1 !== "object") { return t2; } @@ -384,14 +382,14 @@ function Make(Ord) { let match = min_binding(t2); return join(t1, match[0], match[1], remove_min_binding(t2)); }; - let concat_or_join = function (t1, v, d, t2) { + let concat_or_join = (t1, v, d, t2) => { if (d !== undefined) { return join(t1, v, Caml_option.valFromOption(d), t2); } else { return concat(t1, t2); } }; - let split = function (x, x_) { + let split = (x, x_) => { if (typeof x_ !== "object") { return [ "Empty", @@ -426,7 +424,7 @@ function Make(Ord) { match$1[2] ]; }; - let merge = function (f, s1, s2) { + let merge = (f, s1, s2) => { if (typeof s1 !== "object") { if (typeof s2 !== "object") { return "Empty"; @@ -456,7 +454,7 @@ function Make(Ord) { let match$1 = split(v2, s1); return concat_or_join(merge(f, match$1[0], s2._0), v2, f(v2, match$1[1], Caml_option.some(s2._2)), merge(f, match$1[2], s2._3)); }; - let filter = function (p, x) { + let filter = (p, x) => { if (typeof x !== "object") { return "Empty"; } @@ -471,7 +469,7 @@ function Make(Ord) { return concat(l$p, r$p); } }; - let partition = function (p, x) { + let partition = (p, x) => { if (typeof x !== "object") { return [ "Empty", @@ -499,7 +497,7 @@ function Make(Ord) { ]; } }; - let cons_enum = function (_m, _e) { + let cons_enum = (_m, _e) => { while (true) { let e = _e; let m = _m; @@ -517,7 +515,7 @@ function Make(Ord) { continue; }; }; - let compare = function (cmp, m1, m2) { + let compare = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -546,7 +544,7 @@ function Make(Ord) { continue; }; }; - let equal = function (cmp, m1, m2) { + let equal = (cmp, m1, m2) => { let _e1 = cons_enum(m1, "End"); let _e2 = cons_enum(m2, "End"); while (true) { @@ -573,14 +571,14 @@ function Make(Ord) { continue; }; }; - let cardinal = function (x) { + let cardinal = x => { if (typeof x !== "object") { return 0; } else { return (cardinal(x._0) + 1 | 0) + cardinal(x._3) | 0; } }; - let bindings_aux = function (_accu, _x) { + let bindings_aux = (_accu, _x) => { while (true) { let x = _x; let accu = _accu; @@ -598,9 +596,7 @@ function Make(Ord) { continue; }; }; - let bindings = function (s) { - return bindings_aux(/* [] */0, s); - }; + let bindings = s => bindings_aux(/* [] */0, s); return { height: height, create: create, @@ -1305,9 +1301,7 @@ let IntMap = { choose: min_binding }; -let m = List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +let m = List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 @@ -1998,9 +1992,7 @@ let SMap = { choose: min_binding$1 }; -let s = List.fold_left((function (acc, param) { - return add$1(param[0], param[1], acc); -}), "Empty", { +let s = List.fold_left((acc, param) => add$1(param[0], param[1], acc), "Empty", { hd: [ "10", /* 'a' */97 @@ -2029,23 +2021,19 @@ let s = List.fold_left((function (acc, param) { Mt.from_pair_suites("Inline_map2_test", { hd: [ "assertion1", - (function () { - return { - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 }) ], tl: { hd: [ "assertion2", - (function () { - return { - TAG: "Eq", - _0: find$1("10", s), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find$1("10", s), + _1: /* 'a' */97 }) ], tl: /* [] */0 diff --git a/jscomp/test/inline_map_demo.js b/jscomp/test/inline_map_demo.js index 842d8a800a..10ebfd5494 100644 --- a/jscomp/test/inline_map_demo.js +++ b/jscomp/test/inline_map_demo.js @@ -141,9 +141,7 @@ function add(x, data, tree) { } } -let m = List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +let m = List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 @@ -191,12 +189,10 @@ function find(px, _x) { Mt.from_pair_suites("Inline_map_demo", { hd: [ "find", - (function () { - return { - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 }) ], tl: /* [] */0 diff --git a/jscomp/test/inline_map_test.js b/jscomp/test/inline_map_test.js index 1a2655903f..343b9ec72f 100644 --- a/jscomp/test/inline_map_test.js +++ b/jscomp/test/inline_map_test.js @@ -144,9 +144,7 @@ function find(x, _x_) { }; } -let m = List.fold_left((function (acc, param) { - return add(param[0], param[1], acc); -}), "Empty", { +let m = List.fold_left((acc, param) => add(param[0], param[1], acc), "Empty", { hd: [ 10, /* 'a' */97 @@ -175,12 +173,10 @@ let m = List.fold_left((function (acc, param) { Mt.from_pair_suites("Inline_map_test", { hd: [ "find", - (function () { - return { - TAG: "Eq", - _0: find(10, m), - _1: /* 'a' */97 - }; + () => ({ + TAG: "Eq", + _0: find(10, m), + _1: /* 'a' */97 }) ], tl: /* [] */0 diff --git a/jscomp/test/inline_record_test.js b/jscomp/test/inline_record_test.js index 28e795d78f..b6e71324b1 100644 --- a/jscomp/test/inline_record_test.js +++ b/jscomp/test/inline_record_test.js @@ -36,13 +36,9 @@ let v1 = { function f(x) { if (x.TAG === "A0") { - return List.fold_left((function (prim0, prim1) { - return prim0 + prim1 | 0; - }), x.lbl, x.more); + return List.fold_left((prim0, prim1) => prim0 + prim1 | 0, x.lbl, x.more); } else { - return List.fold_left((function (prim0, prim1) { - return prim0 + prim1 | 0; - }), 0, x.more); + return List.fold_left((prim0, prim1) => prim0 + prim1 | 0, 0, x.more); } } diff --git a/jscomp/test/inline_regression_test.js b/jscomp/test/inline_regression_test.js index 2eefed637f..a1ca7bdd55 100644 --- a/jscomp/test/inline_regression_test.js +++ b/jscomp/test/inline_regression_test.js @@ -38,19 +38,15 @@ function generic_basename(is_dir_sep, current_dir_name, name) { } function basename(extra) { - return generic_basename((function (s, i) { - return Caml_string.get(s, i) === /* '/' */47; - }), Filename.current_dir_name, extra); + return generic_basename((s, i) => Caml_string.get(s, i) === /* '/' */47, Filename.current_dir_name, extra); } let suites_0 = [ "basename", - (function (param) { - return { - TAG: "Eq", - _0: basename("b/c/a.b"), - _1: "a.b" - }; + param => ({ + TAG: "Eq", + _0: basename("b/c/a.b"), + _1: "a.b" }) ]; diff --git a/jscomp/test/inner_unused.js b/jscomp/test/inner_unused.js index a4d727f7ea..9f4fb403b8 100644 --- a/jscomp/test/inner_unused.js +++ b/jscomp/test/inner_unused.js @@ -7,9 +7,7 @@ function f(x) { } function M(S) { - let f = function (x) { - return x; - }; + let f = x => x; return { f: f }; diff --git a/jscomp/test/installation_test.js b/jscomp/test/installation_test.js index 3f46493c48..0c84e4c34b 100644 --- a/jscomp/test/installation_test.js +++ b/jscomp/test/installation_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/int32_test.js b/jscomp/test/int32_test.js index a2d0f1710f..de01fef604 100644 --- a/jscomp/test/int32_test.js +++ b/jscomp/test/int32_test.js @@ -16,9 +16,7 @@ function f(x) { ]; } -let shift_right_logical_tests_0 = $$Array.map((function (x) { - return (-1 >>> x) | 0; -}), Ext_array_test.range(0, 31)); +let shift_right_logical_tests_0 = $$Array.map(x => (-1 >>> x) | 0, Ext_array_test.range(0, 31)); let shift_right_logical_tests_1 = [ -1, @@ -60,9 +58,7 @@ let shift_right_logical_tests = [ shift_right_logical_tests_1 ]; -let shift_right_tests_0 = $$Array.map((function (x) { - return (Int32.min_int >> x); -}), Ext_array_test.range(0, 31)); +let shift_right_tests_0 = $$Array.map(x => (Int32.min_int >> x), Ext_array_test.range(0, 31)); let shift_right_tests_1 = [ -2147483648, @@ -104,9 +100,7 @@ let shift_right_tests = [ shift_right_tests_1 ]; -let shift_left_tests_0 = $$Array.map((function (x) { - return (1 << x); -}), Ext_array_test.range(0, 31)); +let shift_left_tests_0 = $$Array.map(x => (1 << x), Ext_array_test.range(0, 31)); let shift_left_tests_1 = [ 1, @@ -156,61 +150,45 @@ let suites = { contents: Pervasives.$at({ hd: [ "File \"int32_test.res\", line 131, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: 1, - _1: 1 - }; + () => ({ + TAG: "Eq", + _0: 1, + _1: 1 }) ], tl: { hd: [ "File \"int32_test.res\", line 132, characters 9-16", - (function () { - return { - TAG: "Eq", - _0: -2147483647, - _1: -2147483647 - }; + () => ({ + TAG: "Eq", + _0: -2147483647, + _1: -2147483647 }) ], tl: /* [] */0 } - }, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_logical_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; - }), shift_right_logical_tests_0, shift_right_logical_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; - }), shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_left_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; - }), shift_left_tests_0, shift_left_tests_1))))) + }, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_logical_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) + ], shift_right_logical_tests_0, shift_right_logical_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) + ], shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_left_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) + ], shift_left_tests_0, shift_left_tests_1))))) }; let test_id = { diff --git a/jscomp/test/int64_mul_div_test.js b/jscomp/test/int64_mul_div_test.js index 0b3755be19..e2c3036e63 100644 --- a/jscomp/test/int64_mul_div_test.js +++ b/jscomp/test/int64_mul_div_test.js @@ -306,17 +306,15 @@ let pairs = [ ]; function from_pairs(prefix, pairs) { - return $$Array.to_list($$Array.mapi((function (i, param) { + return $$Array.to_list($$Array.mapi((i, param) => { let b = param[2]; let a = param[1]; let result = param[0]; return [ prefix + "_" + i, - (function (param) { - return commutative_mul(result, a, b); - }) + param => commutative_mul(result, a, b) ]; - }), pairs)); + }, pairs)); } let small_pairs = [ @@ -1509,28 +1507,26 @@ let simple_divs = [ ]; function from(xs) { - return List.mapi((function (i, param) { + return List.mapi((i, param) => { let d = param[3]; let c = param[2]; let b = param[1]; let a = param[0]; return [ "small_divs " + i, - (function (param) { - return { - TAG: "Eq", - _0: [ - c, - d - ], - _1: [ - Caml_int64.div(a, b), - Caml_int64.mod_(a, b) - ] - }; + param => ({ + TAG: "Eq", + _0: [ + c, + d + ], + _1: [ + Caml_int64.div(a, b), + Caml_int64.mod_(a, b) + ] }) ]; - }), $$Array.to_list(xs)); + }, $$Array.to_list(xs)); } let to_string = [[ @@ -1566,111 +1562,93 @@ let int64_compare_tests = [ ]; function from_compare(xs) { - return List.mapi((function (i, param) { + return List.mapi((i, param) => { let c = param[2]; let b = param[1]; let a = param[0]; return [ "int64_compare " + i, - (function (param) { - return { - TAG: "Eq", - _0: c, - _1: Caml_int64.compare(a, b) - }; + param => ({ + TAG: "Eq", + _0: c, + _1: Caml_int64.compare(a, b) }) ]; - }), $$Array.to_list(xs)); + }, $$Array.to_list(xs)); } function from_to_string(xs) { - return List.mapi((function (i, param) { + return List.mapi((i, param) => { let str_a = param[1]; let a = param[0]; return [ "to_string " + i, - (function (param) { - return { - TAG: "Eq", - _0: str_a, - _1: Caml_int64.to_string(a) - }; + param => ({ + TAG: "Eq", + _0: str_a, + _1: Caml_int64.to_string(a) }) ]; - }), $$Array.to_list(xs)); + }, $$Array.to_list(xs)); } -Mt.from_pair_suites("Int64_mul_div_test", Pervasives.$at(from_pairs("random", pairs), Pervasives.$at(from_pairs("small", small_pairs), Pervasives.$at(List.mapi((function (i, param) { +Mt.from_pair_suites("Int64_mul_div_test", Pervasives.$at(from_pairs("random", pairs), Pervasives.$at(from_pairs("small", small_pairs), Pervasives.$at(List.mapi((i, param) => { let f = param[1]; let i64 = param[0]; return [ "to_float_" + i, - (function () { - return { - TAG: "Eq", - _0: Caml_int64.to_float(i64), - _1: f - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.to_float(i64), + _1: f }) ]; -}), $$Array.to_list(to_floats)), Pervasives.$at(List.mapi((function (i, param) { +}, $$Array.to_list(to_floats)), Pervasives.$at(List.mapi((i, param) => { let i64 = param[1]; let f = param[0]; return [ "of_float_" + i, - (function () { - return { - TAG: "Eq", - _0: Caml_int64.of_float(f), - _1: i64 - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.of_float(f), + _1: i64 }) ]; -}), $$Array.to_list(of_float_pairs)), Pervasives.$at({ +}, $$Array.to_list(of_float_pairs)), Pervasives.$at({ hd: [ "compare_check_complete", - (function () { - return { - TAG: "Eq", - _0: $$Array.map((function (param) { - return true; - }), check_complete_compare), - _1: check_complete_compare - }; + () => ({ + TAG: "Eq", + _0: $$Array.map(param => true, check_complete_compare), + _1: check_complete_compare }) ], tl: /* [] */0 }, Pervasives.$at(from(simple_divs), Pervasives.$at(from_compare(int64_compare_tests), { hd: [ "div_rem_0", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.zero, - _1: Caml_int64.zero - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.zero, + _1: Caml_int64.zero }) ], tl: { hd: [ "div_rem_1", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.neg_one, - _1: Caml_int64.neg_one - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.neg_one, + _1: Caml_int64.neg_one }) ], tl: { hd: [ "File \"int64_mul_div_test.res\", line 263, characters 19-26", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.to_float(Int64.max_int), - _1: 9.22337203685477581e+18 - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.to_float(Int64.max_int), + _1: 9.22337203685477581e+18 }) ], tl: /* [] */0 diff --git a/jscomp/test/int64_string_test.js b/jscomp/test/int64_string_test.js index 2d59d31d7d..c1ce0329b6 100644 --- a/jscomp/test/int64_string_test.js +++ b/jscomp/test/int64_string_test.js @@ -1304,7 +1304,7 @@ let random_data = { } }; -Belt_List.forEach(random_data, (function (u) { +Belt_List.forEach(random_data, u => { if (u) { if (u.tl) { throw new Error("Assert_failure", { @@ -1331,7 +1331,7 @@ Belt_List.forEach(random_data, (function (u) { ] } }); -})); +}); eq("File \"int64_string_test.res\", line 195, characters 3-10", Caml_int64.to_string([ -2097152, diff --git a/jscomp/test/int64_test.js b/jscomp/test/int64_test.js index 1e80a73778..fa1dbbd745 100644 --- a/jscomp/test/int64_test.js +++ b/jscomp/test/int64_test.js @@ -35,9 +35,7 @@ function commutative_add(result, a, b) { let generic_compare = Caml_obj.compare; -let shift_left_tests_0 = $$Array.map((function (i) { - return Caml_int64.lsl_(Caml_int64.one, i); -}), Ext_array_test.range(0, 63)); +let shift_left_tests_0 = $$Array.map(i => Caml_int64.lsl_(Caml_int64.one, i), Ext_array_test.range(0, 63)); let shift_left_tests_1 = [ Caml_int64.one, @@ -297,9 +295,7 @@ let shift_left_tests = [ shift_left_tests_1 ]; -let shift_right_tests_0 = $$Array.map((function (i) { - return Caml_int64.asr_(Caml_int64.min_int, i); -}), Ext_array_test.range(0, 63)); +let shift_right_tests_0 = $$Array.map(i => Caml_int64.asr_(Caml_int64.min_int, i), Ext_array_test.range(0, 63)); let shift_right_tests_1 = [ Caml_int64.min_int, @@ -559,9 +555,7 @@ let shift_right_tests = [ shift_right_tests_1 ]; -let shift_right_logical_suites_0 = $$Array.map((function (i) { - return Caml_int64.lsr_(Caml_int64.min_int, i); -}), Ext_array_test.range(0, 63)); +let shift_right_logical_suites_0 = $$Array.map(i => Caml_int64.lsr_(Caml_int64.min_int, i), Ext_array_test.range(0, 63)); let shift_right_logical_suites_1 = [ Caml_int64.min_int, @@ -852,1208 +846,1112 @@ function fac(_n, _acc) { let suites = Pervasives.$at({ hd: [ "add_one", - (function () { - return { - TAG: "Eq", - _0: v, - _1: [ - 0, - 2147483648 - ] - }; + () => ({ + TAG: "Eq", + _0: v, + _1: [ + 0, + 2147483648 + ] }) ], tl: { hd: [ "add_2", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4294967294 - ], - _1: Caml_int64.add(a, a) - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967294 + ], + _1: Caml_int64.add(a, a) }) ], tl: { hd: [ "add_3", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.zero, - _1: Caml_int64.zero - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.zero, + _1: Caml_int64.zero }) ], tl: { hd: [ "add_4", - (function () { - return commutative_add([ - -1, - 4294967294 - ], [ - -1, - 4294967293 - ], Caml_int64.one); - }) + () => commutative_add([ + -1, + 4294967294 + ], [ + -1, + 4294967293 + ], Caml_int64.one) ], tl: { hd: [ "add_5", - (function () { - return commutative_add([ - -1, - 4294967293 - ], [ - -1, - 4294967293 - ], Caml_int64.zero); - }) + () => commutative_add([ + -1, + 4294967293 + ], [ + -1, + 4294967293 + ], Caml_int64.zero) ], tl: { hd: [ "add_6", - (function () { - return commutative_add([ - 0, - 4 - ], [ - -1, - 4294967293 - ], [ - 0, - 7 - ]); - }) + () => commutative_add([ + 0, + 4 + ], [ + -1, + 4294967293 + ], [ + 0, + 7 + ]) ], tl: { hd: [ "add_7", - (function () { - return commutative_add([ - 1, - 0 - ], [ - 0, - 2147483648 - ], [ - 0, - 2147483648 - ]); - }) + () => commutative_add([ + 1, + 0 + ], [ + 0, + 2147483648 + ], [ + 0, + 2147483648 + ]) ], tl: { hd: [ "add_8", - (function () { - return commutative_add([ - 1, - 0 - ], [ - 0, - 4294967295 - ], Caml_int64.one); - }) + () => commutative_add([ + 1, + 0 + ], [ + 0, + 4294967295 + ], Caml_int64.one) ], tl: { hd: [ "add_9", - (function () { - return commutative_add([ - 0, - 4294967295 - ], [ - 0, - 2147483648 - ], [ - 0, - 2147483647 - ]); - }) + () => commutative_add([ + 0, + 4294967295 + ], [ + 0, + 2147483648 + ], [ + 0, + 2147483647 + ]) ], tl: { hd: [ "add_10", - (function () { - return commutative_add([ - 0, - 2147483648 - ], [ - 0, - 2147483648 - ], Caml_int64.zero); - }) + () => commutative_add([ + 0, + 2147483648 + ], [ + 0, + 2147483648 + ], Caml_int64.zero) ], tl: { hd: [ "add_11", - (function () { - return commutative_add([ - 0, - 4294967295 - ], [ - 0, - 4294967295 - ], Caml_int64.zero); - }) + () => commutative_add([ + 0, + 4294967295 + ], [ + 0, + 4294967295 + ], Caml_int64.zero) ], tl: { hd: [ "to_int32", - (function () { - return { + () => ({ + TAG: "Eq", + _0: 3, + _1: Caml_int64.to_int32([ + 0, + 3 + ]) + }) + ], + tl: { + hd: [ + "to_int", + () => ({ TAG: "Eq", _0: 3, _1: Caml_int64.to_int32([ 0, 3 ]) - }; - }) - ], - tl: { - hd: [ - "to_int", - (function () { - return { - TAG: "Eq", - _0: 3, - _1: Caml_int64.to_int32([ - 0, - 3 - ]) - }; }) ], tl: { hd: [ "of_int", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 3 - ], - _1: [ - 0, - 3 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 3 + ], + _1: [ + 0, + 3 + ] }) ], tl: { hd: [ "lognot", - (function () { - return { + () => ({ + TAG: "Eq", + _0: [ + -1, + 4294967293 + ], + _1: [ + -1, + 4294967293 + ] + }) + ], + tl: { + hd: [ + "neg", + () => ({ TAG: "Eq", _0: [ -1, - 4294967293 + 4294967294 ], _1: [ -1, - 4294967293 + 4294967294 ] - }; - }) - ], - tl: { - hd: [ - "neg", - (function () { - return { - TAG: "Eq", - _0: [ - -1, - 4294967294 - ], - _1: [ - -1, - 4294967294 - ] - }; }) ], tl: { hd: [ "File \"int64_test.res\", line 277, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: Int64.min_int, - _1: Caml_int64.neg(Int64.min_int) - }; + () => ({ + TAG: "Eq", + _0: Int64.min_int, + _1: Caml_int64.neg(Int64.min_int) }) ], tl: { hd: [ "File \"int64_test.res\", line 279, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Int64.max_int, - _1: Caml_int64.neg(Caml_int64.add(Int64.min_int, Caml_int64.one)) - }; + () => ({ + TAG: "Eq", + _0: Int64.max_int, + _1: Caml_int64.neg(Caml_int64.add(Int64.min_int, Caml_int64.one)) }) ], tl: { hd: [ "sub1", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 2 - ], - _1: [ - 0, - 2 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 2 + ], + _1: [ + 0, + 2 + ] }) ], tl: { hd: [ "xor1", - (function () { - return { - TAG: "Eq", - _0: [ - [ - 0, - 286331153 - ], - Caml_int64.xor(a, [ - 0, - 4009750271 - ]) + () => ({ + TAG: "Eq", + _0: [ + [ + 0, + 286331153 ], - _1: [ - [ - 0, - 286331153 - ], - [ - 0, - 2432700672 - ] + Caml_int64.xor(a, [ + 0, + 4009750271 + ]) + ], + _1: [ + [ + 0, + 286331153 + ], + [ + 0, + 2432700672 ] - }; + ] }) ], tl: { hd: [ "or", - (function () { - return { + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967295 + ], + _1: [ + 0, + 4294967295 + ] + }) + ], + tl: { + hd: [ + "and", + () => ({ TAG: "Eq", _0: [ 0, - 4294967295 + 4008636142 ], _1: [ 0, - 4294967295 + 4008636142 ] - }; - }) - ], - tl: { - hd: [ - "and", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4008636142 - ], - _1: [ - 0, - 4008636142 - ] - }; }) ], tl: { hd: [ "lsl", - (function () { - return { + () => ({ + TAG: "Eq", + _0: $$Array.map(x => Caml_int64.lsl_(Caml_int64.one, x), $$Array.init(64, i => i)), + _1: [ + Caml_int64.one, + [ + 0, + 2 + ], + [ + 0, + 4 + ], + [ + 0, + 8 + ], + [ + 0, + 16 + ], + [ + 0, + 32 + ], + [ + 0, + 64 + ], + [ + 0, + 128 + ], + [ + 0, + 256 + ], + [ + 0, + 512 + ], + [ + 0, + 1024 + ], + [ + 0, + 2048 + ], + [ + 0, + 4096 + ], + [ + 0, + 8192 + ], + [ + 0, + 16384 + ], + [ + 0, + 32768 + ], + [ + 0, + 65536 + ], + [ + 0, + 131072 + ], + [ + 0, + 262144 + ], + [ + 0, + 524288 + ], + [ + 0, + 1048576 + ], + [ + 0, + 2097152 + ], + [ + 0, + 4194304 + ], + [ + 0, + 8388608 + ], + [ + 0, + 16777216 + ], + [ + 0, + 33554432 + ], + [ + 0, + 67108864 + ], + [ + 0, + 134217728 + ], + [ + 0, + 268435456 + ], + [ + 0, + 536870912 + ], + [ + 0, + 1073741824 + ], + [ + 0, + 2147483648 + ], + [ + 1, + 0 + ], + [ + 2, + 0 + ], + [ + 4, + 0 + ], + [ + 8, + 0 + ], + [ + 16, + 0 + ], + [ + 32, + 0 + ], + [ + 64, + 0 + ], + [ + 128, + 0 + ], + [ + 256, + 0 + ], + [ + 512, + 0 + ], + [ + 1024, + 0 + ], + [ + 2048, + 0 + ], + [ + 4096, + 0 + ], + [ + 8192, + 0 + ], + [ + 16384, + 0 + ], + [ + 32768, + 0 + ], + [ + 65536, + 0 + ], + [ + 131072, + 0 + ], + [ + 262144, + 0 + ], + [ + 524288, + 0 + ], + [ + 1048576, + 0 + ], + [ + 2097152, + 0 + ], + [ + 4194304, + 0 + ], + [ + 8388608, + 0 + ], + [ + 16777216, + 0 + ], + [ + 33554432, + 0 + ], + [ + 67108864, + 0 + ], + [ + 134217728, + 0 + ], + [ + 268435456, + 0 + ], + [ + 536870912, + 0 + ], + [ + 1073741824, + 0 + ], + Caml_int64.min_int + ] + }) + ], + tl: { + hd: [ + "lsr", + () => ({ TAG: "Eq", - _0: $$Array.map((function (x) { - return Caml_int64.lsl_(Caml_int64.one, x); - }), $$Array.init(64, (function (i) { - return i; - }))), + _0: $$Array.map(x => Caml_int64.lsr_(Caml_int64.neg_one, x), $$Array.init(64, i => i)), _1: [ - Caml_int64.one, + Caml_int64.neg_one, + Caml_int64.max_int, [ - 0, - 2 + 1073741823, + 4294967295 ], [ - 0, - 4 + 536870911, + 4294967295 ], [ - 0, - 8 + 268435455, + 4294967295 ], [ - 0, - 16 + 134217727, + 4294967295 ], [ - 0, - 32 + 67108863, + 4294967295 ], [ - 0, - 64 + 33554431, + 4294967295 ], [ - 0, - 128 + 16777215, + 4294967295 ], [ - 0, - 256 + 8388607, + 4294967295 ], [ - 0, - 512 + 4194303, + 4294967295 ], [ - 0, - 1024 + 2097151, + 4294967295 ], [ - 0, - 2048 + 1048575, + 4294967295 ], [ - 0, - 4096 + 524287, + 4294967295 ], [ - 0, - 8192 + 262143, + 4294967295 ], [ - 0, - 16384 + 131071, + 4294967295 ], [ - 0, - 32768 + 65535, + 4294967295 ], [ - 0, - 65536 + 32767, + 4294967295 ], [ - 0, - 131072 + 16383, + 4294967295 ], [ - 0, - 262144 + 8191, + 4294967295 ], [ - 0, - 524288 + 4095, + 4294967295 ], [ - 0, - 1048576 + 2047, + 4294967295 ], [ - 0, - 2097152 + 1023, + 4294967295 ], [ - 0, - 4194304 + 511, + 4294967295 ], [ - 0, - 8388608 + 255, + 4294967295 ], [ - 0, - 16777216 + 127, + 4294967295 ], [ - 0, - 33554432 + 63, + 4294967295 ], [ - 0, - 67108864 + 31, + 4294967295 ], [ - 0, - 134217728 + 15, + 4294967295 ], [ - 0, - 268435456 + 7, + 4294967295 ], [ - 0, - 536870912 + 3, + 4294967295 ], [ - 0, - 1073741824 + 1, + 4294967295 ], [ 0, - 2147483648 - ], - [ - 1, - 0 + 4294967295 ], [ - 2, - 0 + 0, + 2147483647 ], [ - 4, - 0 + 0, + 1073741823 ], [ - 8, - 0 + 0, + 536870911 ], [ - 16, - 0 + 0, + 268435455 ], [ - 32, - 0 + 0, + 134217727 ], [ - 64, - 0 + 0, + 67108863 ], [ - 128, - 0 + 0, + 33554431 ], [ - 256, - 0 + 0, + 16777215 ], [ - 512, - 0 + 0, + 8388607 ], [ - 1024, - 0 + 0, + 4194303 ], [ - 2048, - 0 + 0, + 2097151 ], [ - 4096, - 0 + 0, + 1048575 ], [ - 8192, - 0 + 0, + 524287 ], [ - 16384, - 0 + 0, + 262143 ], [ - 32768, - 0 + 0, + 131071 ], [ - 65536, - 0 + 0, + 65535 ], [ - 131072, - 0 + 0, + 32767 ], [ - 262144, - 0 + 0, + 16383 ], [ - 524288, - 0 + 0, + 8191 ], [ - 1048576, - 0 + 0, + 4095 ], [ - 2097152, - 0 + 0, + 2047 ], [ - 4194304, - 0 + 0, + 1023 ], [ - 8388608, - 0 + 0, + 511 ], [ - 16777216, - 0 + 0, + 255 ], [ - 33554432, - 0 + 0, + 127 ], [ - 67108864, - 0 + 0, + 63 ], [ - 134217728, - 0 + 0, + 31 ], [ - 268435456, - 0 + 0, + 15 ], [ - 536870912, - 0 + 0, + 7 ], [ - 1073741824, - 0 + 0, + 3 ], - Caml_int64.min_int + Caml_int64.one ] - }; - }) - ], - tl: { - hd: [ - "lsr", - (function () { - return { - TAG: "Eq", - _0: $$Array.map((function (x) { - return Caml_int64.lsr_(Caml_int64.neg_one, x); - }), $$Array.init(64, (function (i) { - return i; - }))), - _1: [ - Caml_int64.neg_one, - Caml_int64.max_int, - [ - 1073741823, - 4294967295 - ], - [ - 536870911, - 4294967295 - ], - [ - 268435455, - 4294967295 - ], - [ - 134217727, - 4294967295 - ], - [ - 67108863, - 4294967295 - ], - [ - 33554431, - 4294967295 - ], - [ - 16777215, - 4294967295 - ], - [ - 8388607, - 4294967295 - ], - [ - 4194303, - 4294967295 - ], - [ - 2097151, - 4294967295 - ], - [ - 1048575, - 4294967295 - ], - [ - 524287, - 4294967295 - ], - [ - 262143, - 4294967295 - ], - [ - 131071, - 4294967295 - ], - [ - 65535, - 4294967295 - ], - [ - 32767, - 4294967295 - ], - [ - 16383, - 4294967295 - ], - [ - 8191, - 4294967295 - ], - [ - 4095, - 4294967295 - ], - [ - 2047, - 4294967295 - ], - [ - 1023, - 4294967295 - ], - [ - 511, - 4294967295 - ], - [ - 255, - 4294967295 - ], - [ - 127, - 4294967295 - ], - [ - 63, - 4294967295 - ], - [ - 31, - 4294967295 - ], - [ - 15, - 4294967295 - ], - [ - 7, - 4294967295 - ], - [ - 3, - 4294967295 - ], - [ - 1, - 4294967295 - ], - [ - 0, - 4294967295 - ], - [ - 0, - 2147483647 - ], - [ - 0, - 1073741823 - ], - [ - 0, - 536870911 - ], - [ - 0, - 268435455 - ], - [ - 0, - 134217727 - ], - [ - 0, - 67108863 - ], - [ - 0, - 33554431 - ], - [ - 0, - 16777215 - ], - [ - 0, - 8388607 - ], - [ - 0, - 4194303 - ], - [ - 0, - 2097151 - ], - [ - 0, - 1048575 - ], - [ - 0, - 524287 - ], - [ - 0, - 262143 - ], - [ - 0, - 131071 - ], - [ - 0, - 65535 - ], - [ - 0, - 32767 - ], - [ - 0, - 16383 - ], - [ - 0, - 8191 - ], - [ - 0, - 4095 - ], - [ - 0, - 2047 - ], - [ - 0, - 1023 - ], - [ - 0, - 511 - ], - [ - 0, - 255 - ], - [ - 0, - 127 - ], - [ - 0, - 63 - ], - [ - 0, - 31 - ], - [ - 0, - 15 - ], - [ - 0, - 7 - ], - [ - 0, - 3 - ], - Caml_int64.one - ] - }; }) ], tl: { hd: [ "asr", - (function () { - return { - TAG: "Eq", - _0: $$Array.map((function (x) { - return Caml_int64.asr_(Caml_int64.neg_one, x); - }), $$Array.init(64, (function (i) { - return i; - }))), - _1: [ - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one, - Caml_int64.neg_one - ] - }; + () => ({ + TAG: "Eq", + _0: $$Array.map(x => Caml_int64.asr_(Caml_int64.neg_one, x), $$Array.init(64, i => i)), + _1: [ + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one, + Caml_int64.neg_one + ] }) ], tl: { hd: [ "mul simple", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 6 - ], - _1: [ - 0, - 6 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 6 + ], + _1: [ + 0, + 6 + ] }) ], tl: { hd: [ "of_int32", - (function () { - return { - TAG: "Eq", - _0: $$Array.map(Caml_int64.of_int32, [ - 0, - -2147483648 - ]), - _1: [ - Caml_int64.zero, - [ - -1, - 2147483648 - ] + () => ({ + TAG: "Eq", + _0: $$Array.map(Caml_int64.of_int32, [ + 0, + -2147483648 + ]), + _1: [ + Caml_int64.zero, + [ + -1, + 2147483648 ] - }; + ] }) ], tl: { hd: [ "of_int32_singleton", - (function () { - return { - TAG: "Eq", - _0: [ - -1, - 4294967293 - ], - _1: [ - -1, - 4294967293 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + -1, + 4294967293 + ], + _1: [ + -1, + 4294967293 + ] }) ], tl: { hd: [ "File \"int64_test.res\", line 526, characters 7-14", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 3 - ], - _1: [ - 0, - 3 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 3 + ], + _1: [ + 0, + 3 + ] }) ], tl: { hd: [ "to_int32", - (function () { - return { - TAG: "Eq", - _0: $$Array.map(Caml_int64.to_int32, [ - Caml_int64.zero, - [ - 0, - 2147483648 - ] - ]), - _1: [ + () => ({ + TAG: "Eq", + _0: $$Array.map(Caml_int64.to_int32, [ + Caml_int64.zero, + [ 0, - -2147483648 + 2147483648 ] - }; + ]), + _1: [ + 0, + -2147483648 + ] }) ], tl: { hd: [ "discard_sign", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.discard_sign(Caml_int64.neg_one), - _1: Caml_int64.max_int - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.discard_sign(Caml_int64.neg_one), + _1: Caml_int64.max_int }) ], tl: { hd: [ "div_mod", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.div_mod([ - 0, - 7 - ], [ + () => ({ + TAG: "Eq", + _0: Caml_int64.div_mod([ + 0, + 7 + ], [ + 0, + 3 + ]), + _1: [ + [ 0, - 3 - ]), - _1: [ - [ - 0, - 2 - ], - Caml_int64.one - ] - }; + 2 + ], + Caml_int64.one + ] }) ], tl: { hd: [ "to_hex", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.to_hex(Caml_int64.neg_one), - _1: "ffffffffffffffff" - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.to_hex(Caml_int64.neg_one), + _1: "ffffffffffffffff" }) ], tl: { hd: [ "generic_compare", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare([ - 1, - 0 - ], Caml_int64.one) > 0, - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare([ + 1, + 0 + ], Caml_int64.one) > 0, + _1: true }) ], tl: { hd: [ "test_compier_literal", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4294967295 - ], - _1: [ - 0, - 4294967295 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967295 + ], + _1: [ + 0, + 4294967295 + ] }) ], tl: { hd: [ "generic_compare2", - (function () { - return { - TAG: "Eq", - _0: Caml_obj.compare([ - 0, - 2147483648 - ], Caml_int64.one) > 0, - _1: true - }; + () => ({ + TAG: "Eq", + _0: Caml_obj.compare([ + 0, + 2147483648 + ], Caml_int64.one) > 0, + _1: true }) ], tl: { hd: [ "shift_left", - (function () { - return { - TAG: "Eq", - _0: [ - 0, - 4294967040 - ], - _1: [ - 0, - 4294967040 - ] - }; + () => ({ + TAG: "Eq", + _0: [ + 0, + 4294967040 + ], + _1: [ + 0, + 4294967040 + ] }) ], tl: { hd: [ "fib_int64", - (function () { - return { - TAG: "Eq", - _0: fib(1000, Caml_int64.one, [ - 0, - 2 - ]), - _1: [ - -1990564327, - 2874523960 - ] - }; + () => ({ + TAG: "Eq", + _0: fib(1000, Caml_int64.one, [ + 0, + 2 + ]), + _1: [ + -1990564327, + 2874523960 + ] }) ], tl: { hd: [ "fac_int64", - (function () { - return { - TAG: "Eq", - _0: fac(30, Caml_int64.one), - _1: [ - -2040662563, - 1409286144 - ] - }; + () => ({ + TAG: "Eq", + _0: fac(30, Caml_int64.one), + _1: [ + -2040662563, + 1409286144 + ] }) ], tl: { hd: [ "File \"int64_test.res\", line 553, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.add(Int64.max_int, Int64.max_int), - _1: [ - -1, - 4294967294 - ] - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.add(Int64.max_int, Int64.max_int), + _1: [ + -1, + 4294967294 + ] }) ], tl: { hd: [ "File \"int64_test.res\", line 563, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.add(Int64.min_int, Int64.min_int), - _1: Caml_int64.zero - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.add(Int64.min_int, Int64.min_int), + _1: Caml_int64.zero }) ], tl: { hd: [ "File \"int64_test.res\", line 573, characters 8-15", - (function () { - return { - TAG: "Eq", - _0: Caml_int64.neg_one, - _1: Caml_int64.neg_one - }; + () => ({ + TAG: "Eq", + _0: Caml_int64.neg_one, + _1: Caml_int64.neg_one }) ], tl: /* [] */0 @@ -2098,40 +1996,28 @@ let suites = Pervasives.$at({ } } } -}, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_left_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; -}), shift_left_tests_0, shift_left_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; -}), shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((function (i, a, b) { - return [ - "shift_right_logical_cases " + i, - (function () { - return { - TAG: "Eq", - _0: a, - _1: b - }; - }) - ]; -}), shift_right_logical_suites_0, shift_right_logical_suites_1))))); +}, Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_left_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) +], shift_left_tests_0, shift_left_tests_1)), Pervasives.$at($$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) +], shift_right_tests_0, shift_right_tests_1)), $$Array.to_list(Ext_array_test.map2i((i, a, b) => [ + "shift_right_logical_cases " + i, + () => ({ + TAG: "Eq", + _0: a, + _1: b + }) +], shift_right_logical_suites_0, shift_right_logical_suites_1))))); let suites$1 = { contents: suites diff --git a/jscomp/test/int_hashtbl_test.js b/jscomp/test/int_hashtbl_test.js index 837abb1369..27976bf186 100644 --- a/jscomp/test/int_hashtbl_test.js +++ b/jscomp/test/int_hashtbl_test.js @@ -11,18 +11,14 @@ function f(H) { let tbl = H.create(17); H.add(tbl, 1, /* '1' */49); H.add(tbl, 2, /* '2' */50); - let extra = H.fold((function (k, v, acc) { - return { - hd: [ - k, - v - ], - tl: acc - }; + let extra = H.fold((k, v, acc) => ({ + hd: [ + k, + v + ], + tl: acc }), tbl, /* [] */0); - return List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), extra); + return List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), extra); } function g(H, count) { @@ -33,18 +29,14 @@ function g(H, count) { for (let i$1 = 0; i$1 <= count; ++i$1) { H.replace(tbl, (i$1 << 1), String(i$1)); } - let v = H.fold((function (k, v, acc) { - return { - hd: [ - k, - v - ], - tl: acc - }; + let v = H.fold((k, v, acc) => ({ + hd: [ + k, + v + ], + tl: acc }), tbl, /* [] */0); - return $$Array.of_list(List.sort((function (param, param$1) { - return Caml.int_compare(param[0], param$1[0]); - }), v)); + return $$Array.of_list(List.sort((param, param$1) => Caml.int_compare(param[0], param$1[0]), v)); } let hash = Hashtbl.hash; @@ -60,41 +52,35 @@ let Int_hash = Hashtbl.Make({ let suites_0 = [ "simple", - (function (param) { - return { - TAG: "Eq", - _0: { + param => ({ + TAG: "Eq", + _0: { + hd: [ + 1, + /* '1' */49 + ], + tl: { hd: [ - 1, - /* '1' */49 + 2, + /* '2' */50 ], - tl: { - hd: [ - 2, - /* '2' */50 - ], - tl: /* [] */0 - } - }, - _1: f(Int_hash) - }; + tl: /* [] */0 + } + }, + _1: f(Int_hash) }) ]; let suites_1 = { hd: [ "more_iterations", - (function (param) { - return { - TAG: "Eq", - _0: $$Array.init(1001, (function (i) { - return [ - (i << 1), - String(i) - ]; - })), - _1: g(Int_hash, 1000) - }; + param => ({ + TAG: "Eq", + _0: $$Array.init(1001, i => [ + (i << 1), + String(i) + ]), + _1: g(Int_hash, 1000) }) ], tl: /* [] */0 diff --git a/jscomp/test/int_overflow_test.js b/jscomp/test/int_overflow_test.js index e8c7c42cee..5b5bd932d0 100644 --- a/jscomp/test/int_overflow_test.js +++ b/jscomp/test/int_overflow_test.js @@ -41,155 +41,127 @@ function fib(x) { Mt.from_pair_suites("Int_overflow_test", { hd: [ "plus_overflow", - (function () { - return { - TAG: "Eq", - _0: true, - _1: (Int32.max_int + 1 | 0) === Int32.min_int - }; + () => ({ + TAG: "Eq", + _0: true, + _1: (Int32.max_int + 1 | 0) === Int32.min_int }) ], tl: { hd: [ "minus_overflow", - (function () { - return { - TAG: "Eq", - _0: true, - _1: (Int32.min_int - Int32.one | 0) === Int32.max_int - }; + () => ({ + TAG: "Eq", + _0: true, + _1: (Int32.min_int - Int32.one | 0) === Int32.max_int }) ], tl: { hd: [ "flow_again", - (function () { - return { - TAG: "Eq", - _0: 2147483646, - _1: (Int32.max_int + Int32.max_int | 0) + Int32.min_int | 0 - }; + () => ({ + TAG: "Eq", + _0: 2147483646, + _1: (Int32.max_int + Int32.max_int | 0) + Int32.min_int | 0 }) ], tl: { hd: [ "flow_again", - (function () { - return { - TAG: "Eq", - _0: -2, - _1: Int32.max_int + Int32.max_int | 0 - }; + () => ({ + TAG: "Eq", + _0: -2, + _1: Int32.max_int + Int32.max_int | 0 }) ], tl: { hd: [ "hash_test", - (function () { - return { - TAG: "Eq", - _0: hash_variant("xxyyzzuuxxzzyy00112233"), - _1: 544087776 - }; + () => ({ + TAG: "Eq", + _0: hash_variant("xxyyzzuuxxzzyy00112233"), + _1: 544087776 }) ], tl: { hd: [ "hash_test2", - (function () { - return { - TAG: "Eq", - _0: hash_variant("xxyyzxzzyy"), - _1: -449896130 - }; + () => ({ + TAG: "Eq", + _0: hash_variant("xxyyzxzzyy"), + _1: -449896130 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 88, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: hash_variant2("xxyyzzuuxxzzyy00112233"), - _1: 544087776 - }; + () => ({ + TAG: "Eq", + _0: hash_variant2("xxyyzzuuxxzzyy00112233"), + _1: 544087776 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 89, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: hash_variant2("xxyyzxzzyy"), - _1: -449896130 - }; + () => ({ + TAG: "Eq", + _0: hash_variant2("xxyyzxzzyy"), + _1: -449896130 }) ], tl: { hd: [ "int_literal_flow", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 }) ], tl: { hd: [ "int_literal_flow2", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 }) ], tl: { hd: [ "int_literal_flow3", - (function () { - return { - TAG: "Eq", - _0: -1, - _1: -1 - }; + () => ({ + TAG: "Eq", + _0: -1, + _1: -1 }) ], tl: { hd: [ "int32_mul", - (function () { - return { - TAG: "Eq", - _0: -33554431, - _1: -33554431 - }; + () => ({ + TAG: "Eq", + _0: -33554431, + _1: -33554431 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 94, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Number("3") | 0, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: Number("3") | 0, + _1: 3 }) ], tl: { hd: [ "File \"int_overflow_test.res\", line 96, characters 5-12", - (function () { - return { - TAG: "Eq", - _0: Number("3.2") | 0, - _1: 3 - }; + () => ({ + TAG: "Eq", + _0: Number("3.2") | 0, + _1: 3 }) ], tl: /* [] */0 diff --git a/jscomp/test/int_switch_test.js b/jscomp/test/int_switch_test.js index 2a0e0e9b34..54e513b7bf 100644 --- a/jscomp/test/int_switch_test.js +++ b/jscomp/test/int_switch_test.js @@ -61,25 +61,15 @@ function f33(x) { } } -eq("File \"int_switch_test.res\", line 32, characters 3-10", f(function () { - return 1; -}), /* 'a' */97); +eq("File \"int_switch_test.res\", line 32, characters 3-10", f(() => 1), /* 'a' */97); -eq("File \"int_switch_test.res\", line 33, characters 3-10", f(function () { - return 2; -}), /* 'b' */98); +eq("File \"int_switch_test.res\", line 33, characters 3-10", f(() => 2), /* 'b' */98); -eq("File \"int_switch_test.res\", line 34, characters 3-10", f(function () { - return 3; -}), /* 'c' */99); +eq("File \"int_switch_test.res\", line 34, characters 3-10", f(() => 3), /* 'c' */99); -eq("File \"int_switch_test.res\", line 35, characters 3-10", f(function () { - return 0; -}), /* 'x' */120); +eq("File \"int_switch_test.res\", line 35, characters 3-10", f(() => 0), /* 'x' */120); -eq("File \"int_switch_test.res\", line 36, characters 3-10", f(function () { - return -1; -}), /* 'x' */120); +eq("File \"int_switch_test.res\", line 36, characters 3-10", f(() => -1), /* 'x' */120); Mt.from_pair_suites("Int_switch_test", suites.contents); diff --git a/jscomp/test/js_array_test.js b/jscomp/test/js_array_test.js index 926b544782..fa7a168a30 100644 --- a/jscomp/test/js_array_test.js +++ b/jscomp/test/js_array_test.js @@ -6,53 +6,67 @@ let Caml_option = require("../../lib/js/caml_option.js"); let suites_0 = [ "isArray_array", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Array.isArray([]) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Array.isArray([]) }) ]; let suites_1 = { hd: [ "isArray_int", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Array.isArray(34) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Array.isArray(34) }) ], tl: { hd: [ "length", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: [ - 1, - 2, - 3 - ].length - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: [ + 1, + 2, + 3 + ].length }) ], tl: { hd: [ "copyWithin", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 1, + 2 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].copyWithin(-2) + }) + ], + tl: { + hd: [ + "copyWithinFrom", + param => ({ TAG: "Eq", _0: [ - 1, - 2, + 4, + 5, 3, - 1, - 2 + 4, + 5 ], _1: [ 1, @@ -60,19 +74,17 @@ let suites_1 = { 3, 4, 5 - ].copyWithin(-2) - }; - }) - ], - tl: { - hd: [ - "copyWithinFrom", - (function (param) { - return { + ].copyWithin(0, 3) + }) + ], + tl: { + hd: [ + "copyWithinFromRange", + param => ({ TAG: "Eq", _0: [ 4, - 5, + 2, 3, 4, 5 @@ -83,41 +95,33 @@ let suites_1 = { 3, 4, 5 - ].copyWithin(0, 3) - }; - }) - ], - tl: { - hd: [ - "copyWithinFromRange", - (function (param) { - return { + ].copyWithin(0, 3, 4) + }) + ], + tl: { + hd: [ + "fillInPlace", + param => ({ TAG: "Eq", _0: [ 4, - 2, - 3, 4, - 5 + 4 ], _1: [ 1, 2, - 3, - 4, - 5 - ].copyWithin(0, 3, 4) - }; - }) - ], - tl: { - hd: [ - "fillInPlace", - (function (param) { - return { + 3 + ].fill(4) + }) + ], + tl: { + hd: [ + "fillFromInPlace", + param => ({ TAG: "Eq", _0: [ - 4, + 1, 4, 4 ], @@ -125,193 +129,151 @@ let suites_1 = { 1, 2, 3 - ].fill(4) - }; - }) - ], - tl: { - hd: [ - "fillFromInPlace", - (function (param) { - return { + ].fill(4, 1) + }) + ], + tl: { + hd: [ + "fillRangeInPlace", + param => ({ TAG: "Eq", _0: [ 1, 4, - 4 + 3 ], _1: [ 1, 2, 3 - ].fill(4, 1) - }; - }) - ], - tl: { - hd: [ - "fillRangeInPlace", - (function (param) { - return { - TAG: "Eq", - _0: [ - 1, - 4, - 3 - ], - _1: [ - 1, - 2, - 3 - ].fill(4, 1, 2) - }; + ].fill(4, 1, 2) }) ], tl: { hd: [ "pop", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Caml_option.undefined_to_opt([ - 1, - 2, - 3 - ].pop()) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Caml_option.undefined_to_opt([ + 1, + 2, + 3 + ].pop()) }) ], tl: { hd: [ "pop - empty array", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Caml_option.undefined_to_opt([].pop()) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Caml_option.undefined_to_opt([].pop()) }) ], tl: { hd: [ "push", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: [ - 1, - 2, - 3 - ].push(4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: [ + 1, + 2, + 3 + ].push(4) }) ], tl: { hd: [ "pushMany", - (function (param) { - return { - TAG: "Eq", - _0: 5, - _1: [ - 1, - 2, - 3 - ].push(4, 5) - }; + param => ({ + TAG: "Eq", + _0: 5, + _1: [ + 1, + 2, + 3 + ].push(4, 5) }) ], tl: { hd: [ "reverseInPlace", - (function (param) { - return { - TAG: "Eq", - _0: [ - 3, - 2, - 1 - ], - _1: [ - 1, - 2, - 3 - ].reverse() - }; + param => ({ + TAG: "Eq", + _0: [ + 3, + 2, + 1 + ], + _1: [ + 1, + 2, + 3 + ].reverse() }) ], tl: { hd: [ "shift", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: Caml_option.undefined_to_opt([ - 1, - 2, - 3 - ].shift()) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: Caml_option.undefined_to_opt([ + 1, + 2, + 3 + ].shift()) }) ], tl: { hd: [ "shift - empty array", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Caml_option.undefined_to_opt([].shift()) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Caml_option.undefined_to_opt([].shift()) }) ], tl: { hd: [ "sortInPlace", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3 + ], + _1: [ + 3, + 1, + 2 + ].sort() + }) + ], + tl: { + hd: [ + "sortInPlaceWith", + param => ({ TAG: "Eq", _0: [ - 1, + 3, 2, - 3 + 1 ], _1: [ 3, 1, 2 - ].sort() - }; - }) - ], - tl: { - hd: [ - "sortInPlaceWith", - (function (param) { - return { - TAG: "Eq", - _0: [ - 3, - 2, - 1 - ], - _1: [ - 3, - 1, - 2 - ].sort(function (a, b) { - return b - a | 0; - }) - }; + ].sort((a, b) => b - a | 0) }) ], tl: { hd: [ "spliceInPlace", - (function (param) { + param => { let arr = [ 1, 2, @@ -336,12 +298,12 @@ let suites_1 = { removed ] }; - }) + } ], tl: { hd: [ "removeFromInPlace", - (function (param) { + param => { let arr = [ 1, 2, @@ -366,12 +328,12 @@ let suites_1 = { removed ] }; - }) + } ], tl: { hd: [ "removeCountInPlace", - (function (param) { + param => { let arr = [ 1, 2, @@ -394,70 +356,87 @@ let suites_1 = { removed ] }; - }) + } ], tl: { hd: [ "unshift", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: [ - 1, - 2, - 3 - ].unshift(4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: [ + 1, + 2, + 3 + ].unshift(4) }) ], tl: { hd: [ "unshiftMany", - (function (param) { - return { - TAG: "Eq", - _0: 5, - _1: [ - 1, - 2, - 3 - ].unshift(4, 5) - }; + param => ({ + TAG: "Eq", + _0: 5, + _1: [ + 1, + 2, + 3 + ].unshift(4, 5) }) ], tl: { hd: [ "append", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 1, + 2, + 3, + 4 + ], + _1: [ + 1, + 2, + 3 + ].concat([4]) + }) + ], + tl: { + hd: [ + "concat", + param => ({ TAG: "Eq", _0: [ 1, 2, 3, - 4 + 4, + 5 ], _1: [ 1, 2, 3 - ].concat([4]) - }; - }) - ], - tl: { - hd: [ - "concat", - (function (param) { - return { + ].concat([ + 4, + 5 + ]) + }) + ], + tl: { + hd: [ + "concatMany", + param => ({ TAG: "Eq", _0: [ 1, 2, 3, 4, - 5 + 5, + 6, + 7 ], _1: [ 1, @@ -466,155 +445,134 @@ let suites_1 = { ].concat([ 4, 5 + ], [ + 6, + 7 ]) - }; - }) - ], - tl: { - hd: [ - "concatMany", - (function (param) { - return { - TAG: "Eq", - _0: [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], - _1: [ - 1, - 2, - 3 - ].concat([ - 4, - 5 - ], [ - 6, - 7 - ]) - }; }) ], tl: { hd: [ "includes", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3 - ].includes(3) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: [ + 1, + 2, + 3 + ].includes(3) }) ], tl: { hd: [ "indexOf", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3 - ].indexOf(2) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3 + ].indexOf(2) }) ], tl: { hd: [ "indexOfFrom", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: [ - 1, - 2, - 3, - 2 - ].indexOf(2, 2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: [ + 1, + 2, + 3, + 2 + ].indexOf(2, 2) }) ], tl: { hd: [ "join", - (function (param) { - return { - TAG: "Eq", - _0: "1,2,3", - _1: [ - 1, - 2, - 3 - ].join() - }; + param => ({ + TAG: "Eq", + _0: "1,2,3", + _1: [ + 1, + 2, + 3 + ].join() }) ], tl: { hd: [ "joinWith", - (function (param) { - return { - TAG: "Eq", - _0: "1;2;3", - _1: [ - 1, - 2, - 3 - ].join(";") - }; + param => ({ + TAG: "Eq", + _0: "1;2;3", + _1: [ + 1, + 2, + 3 + ].join(";") }) ], tl: { hd: [ "lastIndexOf", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3 - ].lastIndexOf(2) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3 + ].lastIndexOf(2) }) ], tl: { hd: [ "lastIndexOfFrom", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: [ - 1, - 2, - 3, - 2 - ].lastIndexOf(2, 2) - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3, + 2 + ].lastIndexOf(2, 2) }) ], tl: { hd: [ "slice", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 2, + 3 + ], + _1: [ + 1, + 2, + 3, + 4, + 5 + ].slice(1, 3) + }) + ], + tl: { + hd: [ + "copy", + param => ({ TAG: "Eq", _0: [ + 1, 2, - 3 + 3, + 4, + 5 ], _1: [ 1, @@ -622,19 +580,15 @@ let suites_1 = { 3, 4, 5 - ].slice(1, 3) - }; - }) - ], - tl: { - hd: [ - "copy", - (function (param) { - return { + ].slice() + }) + ], + tl: { + hd: [ + "sliceFrom", + param => ({ TAG: "Eq", _0: [ - 1, - 2, 3, 4, 5 @@ -645,249 +599,183 @@ let suites_1 = { 3, 4, 5 - ].slice() - }; - }) - ], - tl: { - hd: [ - "sliceFrom", - (function (param) { - return { - TAG: "Eq", - _0: [ - 3, - 4, - 5 - ], - _1: [ - 1, - 2, - 3, - 4, - 5 - ].slice(2) - }; + ].slice(2) }) ], tl: { hd: [ "toString", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: "1,2,3", + _1: [ + 1, + 2, + 3 + ].toString() + }) + ], + tl: { + hd: [ + "toLocaleString", + param => ({ TAG: "Eq", _0: "1,2,3", _1: [ 1, 2, 3 - ].toString() - }; - }) - ], - tl: { - hd: [ - "toLocaleString", - (function (param) { - return { - TAG: "Eq", - _0: "1,2,3", - _1: [ - 1, - 2, - 3 - ].toLocaleString() - }; + ].toLocaleString() }) ], tl: { hd: [ "every", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3 - ].every(function (n) { - return n > 0; - }) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: [ + 1, + 2, + 3 + ].every(n => n > 0) }) ], tl: { hd: [ "everyi", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: [ - 1, - 2, - 3 - ].every(function (param, i) { - return i > 0; - }) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: [ + 1, + 2, + 3 + ].every((param, i) => i > 0) }) ], tl: { hd: [ "filter", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 2, + 4 + ], + _1: [ + 1, + 2, + 3, + 4 + ].filter(n => n % 2 === 0) + }) + ], + tl: { + hd: [ + "filteri", + param => ({ TAG: "Eq", _0: [ - 2, - 4 + 1, + 3 ], _1: [ 1, 2, 3, 4 - ].filter(function (n) { - return n % 2 === 0; - }) - }; - }) - ], - tl: { - hd: [ - "filteri", - (function (param) { - return { - TAG: "Eq", - _0: [ - 1, - 3 - ], - _1: [ - 1, - 2, - 3, - 4 - ].filter(function (param, i) { - return i % 2 === 0; - }) - }; + ].filter((param, i) => i % 2 === 0) }) ], tl: { hd: [ "find", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: 2, + _1: Caml_option.undefined_to_opt([ + 1, + 2, + 3, + 4 + ].find(n => n % 2 === 0)) + }) + ], + tl: { + hd: [ + "find - no match", + param => ({ TAG: "Eq", - _0: 2, + _0: undefined, _1: Caml_option.undefined_to_opt([ 1, 2, 3, 4 - ].find(function (n) { - return n % 2 === 0; - })) - }; - }) - ], - tl: { - hd: [ - "find - no match", - (function (param) { - return { + ].find(n => n % 2 === 5)) + }) + ], + tl: { + hd: [ + "findi", + param => ({ TAG: "Eq", - _0: undefined, + _0: 1, _1: Caml_option.undefined_to_opt([ 1, 2, 3, 4 - ].find(function (n) { - return n % 2 === 5; - })) - }; - }) - ], - tl: { - hd: [ - "findi", - (function (param) { - return { + ].find((param, i) => i % 2 === 0)) + }) + ], + tl: { + hd: [ + "findi - no match", + param => ({ TAG: "Eq", - _0: 1, + _0: undefined, _1: Caml_option.undefined_to_opt([ 1, 2, 3, 4 - ].find(function (param, i) { - return i % 2 === 0; - })) - }; - }) - ], - tl: { - hd: [ - "findi - no match", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Caml_option.undefined_to_opt([ - 1, - 2, - 3, - 4 - ].find(function (param, i) { - return i % 2 === 5; - })) - }; + ].find((param, i) => i % 2 === 5)) }) ], tl: { hd: [ "findIndex", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: 1, + _1: [ + 1, + 2, + 3, + 4 + ].findIndex(n => n % 2 === 0) + }) + ], + tl: { + hd: [ + "findIndexi", + param => ({ TAG: "Eq", - _0: 1, + _0: 0, _1: [ 1, 2, 3, 4 - ].findIndex(function (n) { - return n % 2 === 0; - }) - }; - }) - ], - tl: { - hd: [ - "findIndexi", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: [ - 1, - 2, - 3, - 4 - ].findIndex(function (param, i) { - return i % 2 === 0; - }) - }; + ].findIndex((param, i) => i % 2 === 0) }) ], tl: { hd: [ "forEach", - (function (param) { + param => { let sum = { contents: 0 }; @@ -895,7 +783,7 @@ let suites_1 = { 1, 2, 3 - ].forEach(function (n) { + ].forEach(n => { sum.contents = sum.contents + n | 0; }); return { @@ -903,12 +791,12 @@ let suites_1 = { _0: 6, _1: sum.contents }; - }) + } ], tl: { hd: [ "forEachi", - (function (param) { + param => { let sum = { contents: 0 }; @@ -916,7 +804,7 @@ let suites_1 = { 1, 2, 3 - ].forEach(function (param, i) { + ].forEach((param, i) => { sum.contents = sum.contents + i | 0; }); return { @@ -924,160 +812,128 @@ let suites_1 = { _0: 3, _1: sum.contents }; - }) + } ], tl: { hd: [ "map", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + 2, + 4, + 6, + 8 + ], + _1: [ + 1, + 2, + 3, + 4 + ].map(n => (n << 1)) + }) + ], + tl: { + hd: [ + "map", + param => ({ TAG: "Eq", _0: [ + 0, 2, 4, - 6, - 8 + 6 ], _1: [ 1, 2, 3, 4 - ].map(function (n) { - return (n << 1); - }) - }; - }) - ], - tl: { - hd: [ - "map", - (function (param) { - return { + ].map((param, i) => (i << 1)) + }) + ], + tl: { + hd: [ + "reduce", + param => ({ TAG: "Eq", - _0: [ - 0, - 2, - 4, - 6 - ], + _0: -10, _1: [ 1, 2, 3, 4 - ].map(function (param, i) { - return (i << 1); - }) - }; - }) - ], - tl: { - hd: [ - "reduce", - (function (param) { - return { + ].reduce((acc, n) => acc - n | 0, 0) + }) + ], + tl: { + hd: [ + "reducei", + param => ({ TAG: "Eq", - _0: -10, + _0: -6, _1: [ 1, 2, 3, 4 - ].reduce((function (acc, n) { - return acc - n | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "reducei", - (function (param) { - return { + ].reduce((acc, param, i) => acc - i | 0, 0) + }) + ], + tl: { + hd: [ + "reduceRight", + param => ({ TAG: "Eq", - _0: -6, + _0: -10, _1: [ 1, 2, 3, 4 - ].reduce((function (acc, param, i) { - return acc - i | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "reduceRight", - (function (param) { - return { + ].reduceRight((acc, n) => acc - n | 0, 0) + }) + ], + tl: { + hd: [ + "reduceRighti", + param => ({ TAG: "Eq", - _0: -10, + _0: -6, _1: [ 1, 2, 3, 4 - ].reduceRight((function (acc, n) { - return acc - n | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "reduceRighti", - (function (param) { - return { + ].reduceRight((acc, param, i) => acc - i | 0, 0) + }) + ], + tl: { + hd: [ + "some", + param => ({ TAG: "Eq", - _0: -6, + _0: false, _1: [ 1, 2, 3, 4 - ].reduceRight((function (acc, param, i) { - return acc - i | 0; - }), 0) - }; - }) - ], - tl: { - hd: [ - "some", - (function (param) { - return { + ].some(n => n <= 0) + }) + ], + tl: { + hd: [ + "somei", + param => ({ TAG: "Eq", - _0: false, + _0: true, _1: [ 1, 2, 3, 4 - ].some(function (n) { - return n <= 0; - }) - }; - }) - ], - tl: { - hd: [ - "somei", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: [ - 1, - 2, - 3, - 4 - ].some(function (param, i) { - return i <= 0; - }) - }; + ].some((param, i) => i <= 0) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_bool_test.js b/jscomp/test/js_bool_test.js index 1c1f6bd5fe..50bd8edab0 100644 --- a/jscomp/test/js_bool_test.js +++ b/jscomp/test/js_bool_test.js @@ -33,35 +33,29 @@ let v = true; let suites_0 = [ "?bool_eq_caml_bool", - (function (param) { - return { - TAG: "Eq", - _0: u, - _1: true - }; + param => ({ + TAG: "Eq", + _0: u, + _1: true }) ]; let suites_1 = { hd: [ "js_bool_eq_js_bool", - (function (param) { - return { - TAG: "Eq", - _0: v, - _1: true - }; + param => ({ + TAG: "Eq", + _0: v, + _1: true }) ], tl: { hd: [ "js_bool_neq_acml_bool", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true === true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true === true }) ], tl: /* [] */0 diff --git a/jscomp/test/js_cast_test.js b/jscomp/test/js_cast_test.js index ba86ae998f..c392fd4587 100644 --- a/jscomp/test/js_cast_test.js +++ b/jscomp/test/js_cast_test.js @@ -24,12 +24,10 @@ function add_test(loc, test) { } function eq(loc, x, y) { - add_test(loc, (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y })); } diff --git a/jscomp/test/js_date_test.js b/jscomp/test/js_date_test.js index ae4924ef81..eb79311a2c 100644 --- a/jscomp/test/js_date_test.js +++ b/jscomp/test/js_date_test.js @@ -10,82 +10,68 @@ function date() { let suites_0 = [ "valueOf", - (function (param) { - return { - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").valueOf() - }; + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").valueOf() }) ]; let suites_1 = { hd: [ "make", - (function (param) { - return { - TAG: "Ok", - _0: new Date().getTime() > 1487223505382 - }; + param => ({ + TAG: "Ok", + _0: new Date().getTime() > 1487223505382 }) ], tl: { hd: [ "parseAsFloat", - (function (param) { - return { - TAG: "Eq", - _0: Date.parse("1976-03-08T12:34:56.789+01:23"), - _1: 195131516789 - }; + param => ({ + TAG: "Eq", + _0: Date.parse("1976-03-08T12:34:56.789+01:23"), + _1: 195131516789 }) ], tl: { hd: [ "parseAsFloat_invalid", - (function (param) { - return { - TAG: "Ok", - _0: Number.isNaN(Date.parse("gibberish")) - }; + param => ({ + TAG: "Ok", + _0: Number.isNaN(Date.parse("gibberish")) }) ], tl: { hd: [ "fromFloat", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date(195131516789).toISOString() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date(195131516789).toISOString() }) ], tl: { hd: [ "fromString_valid", - (function (param) { - return { - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() - }; + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() }) ], tl: { hd: [ "fromString_invalid", - (function (param) { - return { - TAG: "Ok", - _0: Number.isNaN(new Date("gibberish").getTime()) - }; + param => ({ + TAG: "Ok", + _0: Number.isNaN(new Date("gibberish").getTime()) }) ], tl: { hd: [ "makeWithYM", - (function (param) { + param => { let d = new Date(1984, 4); return { TAG: "Eq", @@ -98,12 +84,12 @@ let suites_1 = { d.getMonth() ] }; - }) + } ], tl: { hd: [ "makeWithYMD", - (function (param) { + param => { let d = new Date(1984, 4, 6); return { TAG: "Eq", @@ -118,12 +104,12 @@ let suites_1 = { d.getDate() ] }; - }) + } ], tl: { hd: [ "makeWithYMDH", - (function (param) { + param => { let d = new Date(1984, 4, 6, 3); return { TAG: "Eq", @@ -140,12 +126,12 @@ let suites_1 = { d.getHours() ] }; - }) + } ], tl: { hd: [ "makeWithYMDHM", - (function (param) { + param => { let d = new Date(1984, 4, 6, 3, 59); return { TAG: "Eq", @@ -164,12 +150,12 @@ let suites_1 = { d.getMinutes() ] }; - }) + } ], tl: { hd: [ "makeWithYMDHMS", - (function (param) { + param => { let d = new Date(1984, 4, 6, 3, 59, 27); return { TAG: "Eq", @@ -190,12 +176,12 @@ let suites_1 = { d.getSeconds() ] }; - }) + } ], tl: { hd: [ "utcWithYM", - (function (param) { + param => { let d = Date.UTC(1984, 4); let d$1 = new Date(d); return { @@ -209,12 +195,12 @@ let suites_1 = { d$1.getUTCMonth() ] }; - }) + } ], tl: { hd: [ "utcWithYMD", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6); let d$1 = new Date(d); return { @@ -230,12 +216,12 @@ let suites_1 = { d$1.getUTCDate() ] }; - }) + } ], tl: { hd: [ "utcWithYMDH", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6, 3); let d$1 = new Date(d); return { @@ -253,12 +239,12 @@ let suites_1 = { d$1.getUTCHours() ] }; - }) + } ], tl: { hd: [ "utcWithYMDHM", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6, 3, 59); let d$1 = new Date(d); return { @@ -278,12 +264,12 @@ let suites_1 = { d$1.getUTCMinutes() ] }; - }) + } ], tl: { hd: [ "utcWithYMDHMS", - (function (param) { + param => { let d = Date.UTC(1984, 4, 6, 3, 59, 27); let d$1 = new Date(d); return { @@ -305,155 +291,129 @@ let suites_1 = { d$1.getUTCSeconds() ] }; - }) + } ], tl: { hd: [ "getFullYear", - (function (param) { - return { - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() - }; + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() }) ], tl: { hd: [ "getMilliseconds", - (function (param) { - return { - TAG: "Eq", - _0: 789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getMilliseconds() - }; + param => ({ + TAG: "Eq", + _0: 789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getMilliseconds() }) ], tl: { hd: [ "getSeconds", - (function (param) { - return { - TAG: "Eq", - _0: 56, - _1: new Date("1976-03-08T12:34:56.789+01:23").getSeconds() - }; + param => ({ + TAG: "Eq", + _0: 56, + _1: new Date("1976-03-08T12:34:56.789+01:23").getSeconds() }) ], tl: { hd: [ "getTime", - (function (param) { - return { - TAG: "Eq", - _0: 195131516789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() - }; + param => ({ + TAG: "Eq", + _0: 195131516789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getTime() }) ], tl: { hd: [ "getUTCDate", - (function (param) { - return { - TAG: "Eq", - _0: 8, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDate() - }; + param => ({ + TAG: "Eq", + _0: 8, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDate() }) ], tl: { hd: [ "getUTCDay", - (function (param) { - return { - TAG: "Eq", - _0: 1, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDay() - }; + param => ({ + TAG: "Eq", + _0: 1, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCDay() }) ], tl: { hd: [ "getUTCFUllYear", - (function (param) { - return { - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCFullYear() - }; + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCFullYear() }) ], tl: { hd: [ "getUTCHours", - (function (param) { - return { - TAG: "Eq", - _0: 11, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCHours() - }; + param => ({ + TAG: "Eq", + _0: 11, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCHours() }) ], tl: { hd: [ "getUTCMilliseconds", - (function (param) { - return { - TAG: "Eq", - _0: 789, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMilliseconds() - }; + param => ({ + TAG: "Eq", + _0: 789, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMilliseconds() }) ], tl: { hd: [ "getUTCMinutes", - (function (param) { - return { - TAG: "Eq", - _0: 11, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMinutes() - }; + param => ({ + TAG: "Eq", + _0: 11, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMinutes() }) ], tl: { hd: [ "getUTCMonth", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMonth() - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCMonth() }) ], tl: { hd: [ "getUTCSeconds", - (function (param) { - return { - TAG: "Eq", - _0: 56, - _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCSeconds() - }; + param => ({ + TAG: "Eq", + _0: 56, + _1: new Date("1976-03-08T12:34:56.789+01:23").getUTCSeconds() }) ], tl: { hd: [ "getYear", - (function (param) { - return { - TAG: "Eq", - _0: 1976, - _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() - }; + param => ({ + TAG: "Eq", + _0: 1976, + _1: new Date("1976-03-08T12:34:56.789+01:23").getFullYear() }) ], tl: { hd: [ "setDate", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setDate(12); return { @@ -461,12 +421,12 @@ let suites_1 = { _0: 12, _1: d.getDate() }; - }) + } ], tl: { hd: [ "setFullYear", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setFullYear(1986); return { @@ -474,12 +434,12 @@ let suites_1 = { _0: 1986, _1: d.getFullYear() }; - }) + } ], tl: { hd: [ "setFullYearM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setFullYear(1986, 7); return { @@ -493,12 +453,12 @@ let suites_1 = { d.getMonth() ] }; - }) + } ], tl: { hd: [ "setFullYearMD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setFullYear(1986, 7, 23); return { @@ -514,12 +474,12 @@ let suites_1 = { d.getDate() ] }; - }) + } ], tl: { hd: [ "setHours", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setHours(22); return { @@ -527,12 +487,12 @@ let suites_1 = { _0: 22, _1: d.getHours() }; - }) + } ], tl: { hd: [ "setHoursM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setHours(22, 48); return { @@ -546,12 +506,12 @@ let suites_1 = { d.getMinutes() ] }; - }) + } ], tl: { hd: [ "setHoursMS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setHours(22, 48, 54); return { @@ -567,12 +527,12 @@ let suites_1 = { d.getSeconds() ] }; - }) + } ], tl: { hd: [ "setMilliseconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMilliseconds(543); return { @@ -580,12 +540,12 @@ let suites_1 = { _0: 543, _1: d.getMilliseconds() }; - }) + } ], tl: { hd: [ "setMinutes", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMinutes(18); return { @@ -593,12 +553,12 @@ let suites_1 = { _0: 18, _1: d.getMinutes() }; - }) + } ], tl: { hd: [ "setMinutesS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMinutes(18, 42); return { @@ -612,12 +572,12 @@ let suites_1 = { d.getSeconds() ] }; - }) + } ], tl: { hd: [ "setMinutesSMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMinutes(18, 42, 311); return { @@ -633,12 +593,12 @@ let suites_1 = { d.getMilliseconds() ] }; - }) + } ], tl: { hd: [ "setMonth", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMonth(10); return { @@ -646,12 +606,12 @@ let suites_1 = { _0: 10, _1: d.getMonth() }; - }) + } ], tl: { hd: [ "setMonthD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setMonth(10, 14); return { @@ -665,12 +625,12 @@ let suites_1 = { d.getDate() ] }; - }) + } ], tl: { hd: [ "setSeconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setSeconds(36); return { @@ -678,12 +638,12 @@ let suites_1 = { _0: 36, _1: d.getSeconds() }; - }) + } ], tl: { hd: [ "setSecondsMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setSeconds(36, 420); return { @@ -697,12 +657,12 @@ let suites_1 = { d.getMilliseconds() ] }; - }) + } ], tl: { hd: [ "setUTCDate", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCDate(12); return { @@ -710,12 +670,12 @@ let suites_1 = { _0: 12, _1: d.getUTCDate() }; - }) + } ], tl: { hd: [ "setUTCFullYear", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCFullYear(1986); return { @@ -723,12 +683,12 @@ let suites_1 = { _0: 1986, _1: d.getUTCFullYear() }; - }) + } ], tl: { hd: [ "setUTCFullYearM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCFullYear(1986, 7); return { @@ -742,12 +702,12 @@ let suites_1 = { d.getUTCMonth() ] }; - }) + } ], tl: { hd: [ "setUTCFullYearMD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCFullYear(1986, 7, 23); return { @@ -763,12 +723,12 @@ let suites_1 = { d.getUTCDate() ] }; - }) + } ], tl: { hd: [ "setUTCHours", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCHours(22); return { @@ -776,12 +736,12 @@ let suites_1 = { _0: 22, _1: d.getUTCHours() }; - }) + } ], tl: { hd: [ "setUTCHoursM", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCHours(22, 48); return { @@ -795,12 +755,12 @@ let suites_1 = { d.getUTCMinutes() ] }; - }) + } ], tl: { hd: [ "setUTCHoursMS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCHours(22, 48, 54); return { @@ -816,12 +776,12 @@ let suites_1 = { d.getUTCSeconds() ] }; - }) + } ], tl: { hd: [ "setUTCMilliseconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMilliseconds(543); return { @@ -829,12 +789,12 @@ let suites_1 = { _0: 543, _1: d.getUTCMilliseconds() }; - }) + } ], tl: { hd: [ "setUTCMinutes", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMinutes(18); return { @@ -842,12 +802,12 @@ let suites_1 = { _0: 18, _1: d.getUTCMinutes() }; - }) + } ], tl: { hd: [ "setUTCMinutesS", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMinutes(18, 42); return { @@ -861,12 +821,12 @@ let suites_1 = { d.getUTCSeconds() ] }; - }) + } ], tl: { hd: [ "setUTCMinutesSMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMinutes(18, 42, 311); return { @@ -882,12 +842,12 @@ let suites_1 = { d.getUTCMilliseconds() ] }; - }) + } ], tl: { hd: [ "setUTCMonth", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMonth(10); return { @@ -895,12 +855,12 @@ let suites_1 = { _0: 10, _1: d.getUTCMonth() }; - }) + } ], tl: { hd: [ "setUTCMonthD", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCMonth(10, 14); return { @@ -914,12 +874,12 @@ let suites_1 = { d.getUTCDate() ] }; - }) + } ], tl: { hd: [ "setUTCSeconds", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCSeconds(36); return { @@ -927,12 +887,12 @@ let suites_1 = { _0: 36, _1: d.getUTCSeconds() }; - }) + } ], tl: { hd: [ "setUTCSecondsMs", - (function (param) { + param => { let d = new Date("1976-03-08T12:34:56.789+01:23"); d.setUTCSeconds(36, 420); return { @@ -946,78 +906,66 @@ let suites_1 = { d.getUTCMilliseconds() ] }; - }) + } ], tl: { hd: [ "toDateString", - (function (param) { - return { - TAG: "Eq", - _0: "Mon Mar 08 1976", - _1: new Date("1976-03-08T12:34:56.789+01:23").toDateString() - }; + param => ({ + TAG: "Eq", + _0: "Mon Mar 08 1976", + _1: new Date("1976-03-08T12:34:56.789+01:23").toDateString() }) ], tl: { hd: [ "toGMTString", - (function (param) { - return { - TAG: "Eq", - _0: "Mon, 08 Mar 1976 11:11:56 GMT", - _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() - }; + param => ({ + TAG: "Eq", + _0: "Mon, 08 Mar 1976 11:11:56 GMT", + _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() }) ], tl: { hd: [ "toISOString", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toISOString() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toISOString() }) ], tl: { hd: [ "toJSON", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() }) ], tl: { hd: [ "toJSONUnsafe", - (function (param) { - return { - TAG: "Eq", - _0: "1976-03-08T11:11:56.789Z", - _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() - }; + param => ({ + TAG: "Eq", + _0: "1976-03-08T11:11:56.789Z", + _1: new Date("1976-03-08T12:34:56.789+01:23").toJSON() }) ], tl: { hd: [ "toUTCString", - (function (param) { - return { - TAG: "Eq", - _0: "Mon, 08 Mar 1976 11:11:56 GMT", - _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() - }; + param => ({ + TAG: "Eq", + _0: "Mon, 08 Mar 1976 11:11:56 GMT", + _1: new Date("1976-03-08T12:34:56.789+01:23").toUTCString() }) ], tl: { hd: [ "eq", - (function (param) { + param => { let a = new Date("2013-03-01T01:10:00"); let b = new Date("2013-03-01T01:10:00"); let c = new Date("2013-03-01T01:10:01"); @@ -1025,7 +973,7 @@ let suites_1 = { TAG: "Ok", _0: Caml_obj.equal(a, b) && Caml_obj.notequal(b, c) && Caml_obj.greaterthan(c, b) }; - }) + } ], tl: /* [] */0 } diff --git a/jscomp/test/js_dict_test.js b/jscomp/test/js_dict_test.js index e9085c3ca6..231646783a 100644 --- a/jscomp/test/js_dict_test.js +++ b/jscomp/test/js_dict_test.js @@ -13,61 +13,53 @@ function obj() { let suites_0 = [ "empty", - (function (param) { - return { - TAG: "Eq", - _0: [], - _1: Object.keys({}) - }; + param => ({ + TAG: "Eq", + _0: [], + _1: Object.keys({}) }) ]; let suites_1 = { hd: [ "get", - (function (param) { - return { - TAG: "Eq", - _0: 43, - _1: Js_dict.get({ - foo: 43, - bar: 86 - }, "foo") - }; + param => ({ + TAG: "Eq", + _0: 43, + _1: Js_dict.get({ + foo: 43, + bar: 86 + }, "foo") }) ], tl: { hd: [ "get - property not in object", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_dict.get({ - foo: 43, - bar: 86 - }, "baz") - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_dict.get({ + foo: 43, + bar: 86 + }, "baz") }) ], tl: { hd: [ "unsafe_get", - (function (param) { - return { - TAG: "Eq", - _0: 43, - _1: ({ - foo: 43, - bar: 86 - })["foo"] - }; + param => ({ + TAG: "Eq", + _0: 43, + _1: ({ + foo: 43, + bar: 86 + })["foo"] }) ], tl: { hd: [ "set", - (function (param) { + param => { let o = { foo: 43, bar: 86 @@ -78,165 +70,147 @@ let suites_1 = { _0: 36, _1: Js_dict.get(o, "foo") }; - }) + } ], tl: { hd: [ "keys", - (function (param) { - return { + param => ({ + TAG: "Eq", + _0: [ + "foo", + "bar" + ], + _1: Object.keys({ + foo: 43, + bar: 86 + }) + }) + ], + tl: { + hd: [ + "entries", + param => ({ TAG: "Eq", _0: [ - "foo", - "bar" + [ + "foo", + 43 + ], + [ + "bar", + 86 + ] ], - _1: Object.keys({ + _1: Js_dict.entries({ foo: 43, bar: 86 }) - }; - }) - ], - tl: { - hd: [ - "entries", - (function (param) { - return { + }) + ], + tl: { + hd: [ + "values", + param => ({ TAG: "Eq", _0: [ - [ - "foo", - 43 - ], - [ - "bar", - 86 - ] + 43, + 86 ], - _1: Js_dict.entries({ + _1: Js_dict.values({ foo: 43, bar: 86 }) - }; - }) - ], - tl: { - hd: [ - "values", - (function (param) { - return { - TAG: "Eq", - _0: [ - 43, - 86 - ], - _1: Js_dict.values({ - foo: 43, - bar: 86 - }) - }; }) ], tl: { hd: [ "fromList - []", - (function (param) { - return { - TAG: "Eq", - _0: {}, - _1: Js_dict.fromList(/* [] */0) - }; + param => ({ + TAG: "Eq", + _0: {}, + _1: Js_dict.fromList(/* [] */0) }) ], tl: { hd: [ "fromList", - (function (param) { - return { - TAG: "Eq", - _0: [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] + param => ({ + TAG: "Eq", + _0: [ + [ + "x", + 23 + ], + [ + "y", + 46 + ] + ], + _1: Js_dict.entries(Js_dict.fromList({ + hd: [ + "x", + 23 ], - _1: Js_dict.entries(Js_dict.fromList({ + tl: { hd: [ - "x", - 23 + "y", + 46 ], - tl: { - hd: [ - "y", - 46 - ], - tl: /* [] */0 - } - })) - }; + tl: /* [] */0 + } + })) }) ], tl: { hd: [ "fromArray - []", - (function (param) { - return { - TAG: "Eq", - _0: {}, - _1: Js_dict.fromArray([]) - }; + param => ({ + TAG: "Eq", + _0: {}, + _1: Js_dict.fromArray([]) }) ], tl: { hd: [ "fromArray", - (function (param) { - return { - TAG: "Eq", - _0: [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] + param => ({ + TAG: "Eq", + _0: [ + [ + "x", + 23 ], - _1: Js_dict.entries(Js_dict.fromArray([ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ])) - }; + [ + "y", + 46 + ] + ], + _1: Js_dict.entries(Js_dict.fromArray([ + [ + "x", + 23 + ], + [ + "y", + 46 + ] + ])) }) ], tl: { hd: [ "map", - (function (param) { - return { - TAG: "Eq", - _0: { - foo: "43", - bar: "86" - }, - _1: Js_dict.map((function (i) { - return String(i); - }), { - foo: 43, - bar: 86 - }) - }; + param => ({ + TAG: "Eq", + _0: { + foo: "43", + bar: "86" + }, + _1: Js_dict.map(i => String(i), { + foo: 43, + bar: 86 + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_exception_catch_test.js b/jscomp/test/js_exception_catch_test.js index 4f0fa303d2..f4580b614a 100644 --- a/jscomp/test/js_exception_catch_test.js +++ b/jscomp/test/js_exception_catch_test.js @@ -27,30 +27,24 @@ function add_test(loc, test) { } function eq(loc, x, y) { - add_test(loc, (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y })); } function false_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } function true_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: true - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: true })); } @@ -64,11 +58,9 @@ try { } catch (raw_x) { let x = Caml_js_exceptions.internalToOCamlException(raw_x); if (x.RE_EXN_ID === Js_exn.$$Error) { - add_test("File \"js_exception_catch_test.res\", line 18, characters 37-44", (function () { - return { - TAG: "Ok", - _0: true - }; + add_test("File \"js_exception_catch_test.res\", line 18, characters 37-44", () => ({ + TAG: "Ok", + _0: true })); } else { throw new Error(x.RE_EXN_ID, { @@ -78,11 +70,9 @@ try { } if (exit === 1) { - add_test("File \"js_exception_catch_test.res\", line 19, characters 14-21", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_exception_catch_test.res\", line 19, characters 14-21", () => ({ + TAG: "Ok", + _0: false })); } @@ -128,11 +118,9 @@ function test(f) { } } -eq("File \"js_exception_catch_test.res\", line 44, characters 5-12", test(function () { - -}), "No_error"); +eq("File \"js_exception_catch_test.res\", line 44, characters 5-12", test(() => {}), "No_error"); -eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(() => { throw new Error("Not_found", { cause: { RE_EXN_ID: "Not_found" @@ -140,7 +128,7 @@ eq("File \"js_exception_catch_test.res\", line 45, characters 5-12", test(functi }); }), "Not_found"); -eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(() => { throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", @@ -149,7 +137,7 @@ eq("File \"js_exception_catch_test.res\", line 46, characters 5-12", test(functi }); }), "Invalid_argument"); -eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(() => { throw new Error("Invalid_argument", { cause: { RE_EXN_ID: "Invalid_argument", @@ -158,7 +146,7 @@ eq("File \"js_exception_catch_test.res\", line 47, characters 5-12", test(functi }); }), "Invalid_any"); -eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(() => { throw new Error(A, { cause: { RE_EXN_ID: A, @@ -167,7 +155,7 @@ eq("File \"js_exception_catch_test.res\", line 48, characters 5-12", test(functi }); }), "A2"); -eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(() => { throw new Error(A, { cause: { RE_EXN_ID: A, @@ -176,7 +164,7 @@ eq("File \"js_exception_catch_test.res\", line 49, characters 5-12", test(functi }); }), "A_any"); -eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(() => { throw new Error(B, { cause: { RE_EXN_ID: B @@ -184,7 +172,7 @@ eq("File \"js_exception_catch_test.res\", line 50, characters 5-12", test(functi }); }), "B"); -eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(() => { throw new Error(C, { cause: { RE_EXN_ID: C, @@ -194,7 +182,7 @@ eq("File \"js_exception_catch_test.res\", line 51, characters 5-12", test(functi }); }), "C"); -eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(() => { throw new Error(C, { cause: { RE_EXN_ID: C, @@ -204,13 +192,13 @@ eq("File \"js_exception_catch_test.res\", line 52, characters 5-12", test(functi }); }), "C_any"); -eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 53, characters 5-12", test(() => { throw new Error(new Error("x").RE_EXN_ID, { cause: new Error("x") }); }), "Js_error"); -eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(function () { +eq("File \"js_exception_catch_test.res\", line 54, characters 5-12", test(() => { throw new Error("Failure", { cause: { RE_EXN_ID: "Failure", diff --git a/jscomp/test/js_float_test.js b/jscomp/test/js_float_test.js index 28a31f0f7a..9c7bd025d5 100644 --- a/jscomp/test/js_float_test.js +++ b/jscomp/test/js_float_test.js @@ -6,484 +6,398 @@ let Pervasives = require("../../lib/js/pervasives.js"); let suites_0 = [ "_NaN <> _NaN", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: NaN === NaN - }; + param => ({ + TAG: "Eq", + _0: false, + _1: NaN === NaN }) ]; let suites_1 = { hd: [ "isNaN - _NaN", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Number.isNaN(NaN) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isNaN(NaN) }) ], tl: { hd: [ "isNaN - 0.", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isNaN(0) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isNaN(0) }) ], tl: { hd: [ "isFinite - infinity", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isFinite(Pervasives.infinity) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(Pervasives.infinity) }) ], tl: { hd: [ "isFinite - neg_infinity", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isFinite(Pervasives.neg_infinity) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(Pervasives.neg_infinity) }) ], tl: { hd: [ "isFinite - _NaN", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Number.isFinite(NaN) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Number.isFinite(NaN) }) ], tl: { hd: [ "isFinite - 0.", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Number.isFinite(0) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isFinite(0) }) ], tl: { hd: [ "toExponential", - (function (param) { - return { - TAG: "Eq", - _0: "1.23456e+2", - _1: (123.456).toExponential() - }; + param => ({ + TAG: "Eq", + _0: "1.23456e+2", + _1: (123.456).toExponential() }) ], tl: { hd: [ "toExponential - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toExponential() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toExponential() }) ], tl: { hd: [ "toExponentialWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.23e+2", - _1: (123.456).toExponential(2) - }; + param => ({ + TAG: "Eq", + _0: "1.23e+2", + _1: (123.456).toExponential(2) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "1.2346e+2", - _1: (123.456).toExponential(4) - }; + param => ({ + TAG: "Eq", + _0: "1.2346e+2", + _1: (123.456).toExponential(4) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.00000000000000000000e+0", - _1: (0).toExponential(20) - }; + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000e+0", + _1: (0).toExponential(20) }) ], tl: { hd: [ "File \"js_float_test.res\", line 27, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(101); + } }) ], tl: { hd: [ "toExponentialWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(-1); + } }) ], tl: { hd: [ "toFixed", - (function (param) { - return { - TAG: "Eq", - _0: "123", - _1: (123.456).toFixed() - }; + param => ({ + TAG: "Eq", + _0: "123", + _1: (123.456).toFixed() }) ], tl: { hd: [ "toFixed - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toFixed() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toFixed() }) ], tl: { hd: [ "toFixedWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "123.46", - _1: (123.456).toFixed(2) - }; + param => ({ + TAG: "Eq", + _0: "123.46", + _1: (123.456).toFixed(2) }) ], tl: { hd: [ "toFixedWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "123.4560", - _1: (123.456).toFixed(4) - }; + param => ({ + TAG: "Eq", + _0: "123.4560", + _1: (123.456).toFixed(4) }) ], tl: { hd: [ "toFixedWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.00000000000000000000", - _1: (0).toFixed(20) - }; + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000", + _1: (0).toFixed(20) }) ], tl: { hd: [ "toFixedWithPrecision - digits:101", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toFixed(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toFixed(101); + } }) ], tl: { hd: [ "toFixedWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toFixed(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toFixed(-1); + } }) ], tl: { hd: [ "toPrecision", - (function (param) { - return { - TAG: "Eq", - _0: "123.456", - _1: (123.456).toPrecision() - }; + param => ({ + TAG: "Eq", + _0: "123.456", + _1: (123.456).toPrecision() }) ], tl: { hd: [ "toPrecision - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toPrecision() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toPrecision() }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+2", - _1: (123.456).toPrecision(2) - }; + param => ({ + TAG: "Eq", + _0: "1.2e+2", + _1: (123.456).toPrecision(2) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "123.5", - _1: (123.456).toPrecision(4) - }; + param => ({ + TAG: "Eq", + _0: "123.5", + _1: (123.456).toPrecision(4) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.0000000000000000000", - _1: (0).toPrecision(20) - }; + param => ({ + TAG: "Eq", + _0: "0.0000000000000000000", + _1: (0).toPrecision(20) }) ], tl: { hd: [ "File \"js_float_test.res\", line 68, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(101); + } }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(-1); + } }) ], tl: { hd: [ "toString", - (function (param) { - return { - TAG: "Eq", - _0: "1.23", - _1: (1.23).toString() - }; + param => ({ + TAG: "Eq", + _0: "1.23", + _1: (1.23).toString() }) ], tl: { hd: [ "toString - large number", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+21", - _1: (1.2e21).toString() - }; + param => ({ + TAG: "Eq", + _0: "1.2e+21", + _1: (1.2e21).toString() }) ], tl: { hd: [ "toStringWithRadix - radix:2", - (function (param) { - return { - TAG: "Eq", - _0: "1111011.0111010010111100011010100111111011111001110111", - _1: (123.456).toString(2) - }; + param => ({ + TAG: "Eq", + _0: "1111011.0111010010111100011010100111111011111001110111", + _1: (123.456).toString(2) }) ], tl: { hd: [ "toStringWithRadix - radix:16", - (function (param) { - return { - TAG: "Eq", - _0: "7b.74bc6a7ef9dc", - _1: (123.456).toString(16) - }; + param => ({ + TAG: "Eq", + _0: "7b.74bc6a7ef9dc", + _1: (123.456).toString(16) }) ], tl: { hd: [ "toStringWithRadix - radix:36", - (function (param) { - return { - TAG: "Eq", - _0: "3f", - _1: (123).toString(36) - }; + param => ({ + TAG: "Eq", + _0: "3f", + _1: (123).toString(36) }) ], tl: { hd: [ "toStringWithRadix - radix:37", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(37); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(37); + } }) ], tl: { hd: [ "toStringWithRadix - radix:1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(1); + } }) ], tl: { hd: [ "toStringWithRadix - radix:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(-1); + } }) ], tl: { hd: [ "fromString - 123", - (function (param) { - return { - TAG: "Eq", - _0: 123, - _1: Number("123") - }; + param => ({ + TAG: "Eq", + _0: 123, + _1: Number("123") }) ], tl: { hd: [ "fromString - 12.3", - (function (param) { - return { - TAG: "Eq", - _0: 12.3, - _1: Number("12.3") - }; + param => ({ + TAG: "Eq", + _0: 12.3, + _1: Number("12.3") }) ], tl: { hd: [ "fromString - empty string", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Number("") - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Number("") }) ], tl: { hd: [ "fromString - 0x11", - (function (param) { - return { - TAG: "Eq", - _0: 17, - _1: Number("0x11") - }; + param => ({ + TAG: "Eq", + _0: 17, + _1: Number("0x11") }) ], tl: { hd: [ "fromString - 0b11", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Number("0b11") - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Number("0b11") }) ], tl: { hd: [ "fromString - 0o11", - (function (param) { - return { - TAG: "Eq", - _0: 9, - _1: Number("0o11") - }; + param => ({ + TAG: "Eq", + _0: 9, + _1: Number("0o11") }) ], tl: { hd: [ "fromString - invalid string", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Number.isNaN(Number("foo")) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Number.isNaN(Number("foo")) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_global_test.js b/jscomp/test/js_global_test.js index 298af9a7c6..8a77b3aef1 100644 --- a/jscomp/test/js_global_test.js +++ b/jscomp/test/js_global_test.js @@ -5,74 +5,62 @@ let Mt = require("./mt.js"); let suites_0 = [ "setTimeout/clearTimeout sanity check", - (function (param) { - let handle = setTimeout((function () { - - }), 0); + param => { + let handle = setTimeout(() => {}, 0); clearTimeout(handle); return { TAG: "Ok", _0: true }; - }) + } ]; let suites_1 = { hd: [ "setInerval/clearInterval sanity check", - (function (param) { - let handle = setInterval((function () { - - }), 0); + param => { + let handle = setInterval(() => {}, 0); clearInterval(handle); return { TAG: "Ok", _0: true }; - }) + } ], tl: { hd: [ "encodeURI", - (function (param) { - return { - TAG: "Eq", - _0: encodeURI("[-=-]"), - _1: "%5B-=-%5D" - }; + param => ({ + TAG: "Eq", + _0: encodeURI("[-=-]"), + _1: "%5B-=-%5D" }) ], tl: { hd: [ "decodeURI", - (function (param) { - return { - TAG: "Eq", - _0: decodeURI("%5B-=-%5D"), - _1: "[-=-]" - }; + param => ({ + TAG: "Eq", + _0: decodeURI("%5B-=-%5D"), + _1: "[-=-]" }) ], tl: { hd: [ "encodeURIComponent", - (function (param) { - return { - TAG: "Eq", - _0: encodeURIComponent("[-=-]"), - _1: "%5B-%3D-%5D" - }; + param => ({ + TAG: "Eq", + _0: encodeURIComponent("[-=-]"), + _1: "%5B-%3D-%5D" }) ], tl: { hd: [ "decodeURIComponent", - (function (param) { - return { - TAG: "Eq", - _0: decodeURIComponent("%5B-%3D-%5D"), - _1: "[-=-]" - }; + param => ({ + TAG: "Eq", + _0: decodeURIComponent("%5B-%3D-%5D"), + _1: "[-=-]" }) ], tl: /* [] */0 diff --git a/jscomp/test/js_int_test.js b/jscomp/test/js_int_test.js index bb6fb5d699..e7a41d3a1f 100644 --- a/jscomp/test/js_int_test.js +++ b/jscomp/test/js_int_test.js @@ -5,218 +5,180 @@ let Mt = require("./mt.js"); let suites_0 = [ "toExponential", - (function (param) { - return { - TAG: "Eq", - _0: "1.23456e+5", - _1: (123456).toExponential() - }; + param => ({ + TAG: "Eq", + _0: "1.23456e+5", + _1: (123456).toExponential() }) ]; let suites_1 = { hd: [ "toExponentialWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.23e+5", - _1: (123456).toExponential(2) - }; + param => ({ + TAG: "Eq", + _0: "1.23e+5", + _1: (123456).toExponential(2) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "1.2346e+5", - _1: (123456).toExponential(4) - }; + param => ({ + TAG: "Eq", + _0: "1.2346e+5", + _1: (123456).toExponential(4) }) ], tl: { hd: [ "toExponentialWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.00000000000000000000e+0", - _1: (0).toExponential(20) - }; + param => ({ + TAG: "Eq", + _0: "0.00000000000000000000e+0", + _1: (0).toExponential(20) }) ], tl: { hd: [ "File \"js_int_test.res\", line 19, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(101); + } }) ], tl: { hd: [ "toExponentialWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toExponential(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toExponential(-1); + } }) ], tl: { hd: [ "toPrecision", - (function (param) { - return { - TAG: "Eq", - _0: "123456", - _1: (123456).toPrecision() - }; + param => ({ + TAG: "Eq", + _0: "123456", + _1: (123456).toPrecision() }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:2", - (function (param) { - return { - TAG: "Eq", - _0: "1.2e+5", - _1: (123456).toPrecision(2) - }; + param => ({ + TAG: "Eq", + _0: "1.2e+5", + _1: (123456).toPrecision(2) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:4", - (function (param) { - return { - TAG: "Eq", - _0: "1.235e+5", - _1: (123456).toPrecision(4) - }; + param => ({ + TAG: "Eq", + _0: "1.235e+5", + _1: (123456).toPrecision(4) }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:20", - (function (param) { - return { - TAG: "Eq", - _0: "0.0000000000000000000", - _1: (0).toPrecision(20) - }; + param => ({ + TAG: "Eq", + _0: "0.0000000000000000000", + _1: (0).toPrecision(20) }) ], tl: { hd: [ "File \"js_int_test.res\", line 37, characters 5-12", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(101); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(101); + } }) ], tl: { hd: [ "toPrecisionWithPrecision - digits:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toPrecision(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toPrecision(-1); + } }) ], tl: { hd: [ "toString", - (function (param) { - return { - TAG: "Eq", - _0: "123", - _1: (123).toString() - }; + param => ({ + TAG: "Eq", + _0: "123", + _1: (123).toString() }) ], tl: { hd: [ "toStringWithRadix - radix:2", - (function (param) { - return { - TAG: "Eq", - _0: "11110001001000000", - _1: (123456).toString(2) - }; + param => ({ + TAG: "Eq", + _0: "11110001001000000", + _1: (123456).toString(2) }) ], tl: { hd: [ "toStringWithRadix - radix:16", - (function (param) { - return { - TAG: "Eq", - _0: "1e240", - _1: (123456).toString(16) - }; + param => ({ + TAG: "Eq", + _0: "1e240", + _1: (123456).toString(16) }) ], tl: { hd: [ "toStringWithRadix - radix:36", - (function (param) { - return { - TAG: "Eq", - _0: "2n9c", - _1: (123456).toString(36) - }; + param => ({ + TAG: "Eq", + _0: "2n9c", + _1: (123456).toString(36) }) ], tl: { hd: [ "toStringWithRadix - radix:37", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(37); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(37); + } }) ], tl: { hd: [ "toStringWithRadix - radix:1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(1); + } }) ], tl: { hd: [ "toStringWithRadix - radix:-1", - (function (param) { - return { - TAG: "ThrowAny", - _0: (function () { - (0).toString(-1); - }) - }; + param => ({ + TAG: "ThrowAny", + _0: () => { + (0).toString(-1); + } }) ], tl: /* [] */0 diff --git a/jscomp/test/js_json_test.js b/jscomp/test/js_json_test.js index 98d00e1596..e9af1d1c3b 100644 --- a/jscomp/test/js_json_test.js +++ b/jscomp/test/js_json_test.js @@ -31,36 +31,30 @@ function add_test(loc, test) { } function eq(loc, x, y) { - add_test(loc, (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + add_test(loc, () => ({ + TAG: "Eq", + _0: x, + _1: y })); } function false_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } function true_(loc) { - add_test(loc, (function () { - return { - TAG: "Ok", - _0: true - }; + add_test(loc, () => ({ + TAG: "Ok", + _0: true })); } let v = JSON.parse(" { \"x\" : [1, 2, 3 ] } "); -add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { +add_test("File \"js_json_test.res\", line 22, characters 11-18", () => { let ty = Js_json.classify(v); if (typeof ty !== "object") { return { @@ -94,7 +88,7 @@ add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { _0: false }; } - ty2._0.forEach(function (x) { + ty2._0.forEach(x => { let ty3 = Js_json.classify(x); if (typeof ty3 !== "object") { throw new Error("Assert_failure", { @@ -126,7 +120,7 @@ add_test("File \"js_json_test.res\", line 22, characters 11-18", (function () { TAG: "Ok", _0: true }; -})); +}); eq("File \"js_json_test.res\", line 48, characters 5-12", Js_json.test(v, "Object"), true); @@ -136,28 +130,22 @@ let ty = Js_json.classify(json); if (typeof ty !== "object") { if (ty === "JSONNull") { - add_test("File \"js_json_test.res\", line 55, characters 24-31", (function () { - return { - TAG: "Ok", - _0: true - }; + add_test("File \"js_json_test.res\", line 55, characters 24-31", () => ({ + TAG: "Ok", + _0: true })); } else { console.log(ty); - add_test("File \"js_json_test.res\", line 58, characters 11-18", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 58, characters 11-18", () => ({ + TAG: "Ok", + _0: false })); } } else { console.log(ty); - add_test("File \"js_json_test.res\", line 58, characters 11-18", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 58, characters 11-18", () => ({ + TAG: "Ok", + _0: false })); } @@ -166,20 +154,16 @@ let json$1 = JSON.parse(JSON.stringify("test string")); let ty$1 = Js_json.classify(json$1); if (typeof ty$1 !== "object") { - add_test("File \"js_json_test.res\", line 68, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 68, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONString") { eq("File \"js_json_test.res\", line 67, characters 26-33", ty$1._0, "test string"); } else { - add_test("File \"js_json_test.res\", line 68, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 68, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } @@ -196,11 +180,9 @@ if (typeof ty$2 !== "object" || ty$2.TAG !== "JSONNumber") { } if (exit === 1) { - add_test("File \"js_json_test.res\", line 78, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 78, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } @@ -217,11 +199,9 @@ if (typeof ty$3 !== "object" || ty$3.TAG !== "JSONNumber") { } if (exit$1 === 1) { - add_test("File \"js_json_test.res\", line 88, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 88, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } @@ -229,11 +209,9 @@ function test(v) { let json = JSON.parse(JSON.stringify(v)); let ty = Js_json.classify(json); if (typeof ty === "object") { - return add_test("File \"js_json_test.res\", line 100, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test("File \"js_json_test.res\", line 100, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } switch (ty) { @@ -242,11 +220,9 @@ function test(v) { case "JSONTrue" : return eq("File \"js_json_test.res\", line 98, characters 23-30", true, v); default: - return add_test("File \"js_json_test.res\", line 100, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test("File \"js_json_test.res\", line 100, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } } @@ -282,173 +258,135 @@ let json$4 = JSON.parse(JSON.stringify(dict)); let ty$4 = Js_json.classify(json$4); if (typeof ty$4 !== "object") { - add_test("File \"js_json_test.res\", line 142, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 142, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$4.TAG === "JSONObject") { let x = ty$4._0; let ta = Js_json.classify(option_get(Js_dict.get(x, "a"))); if (typeof ta !== "object") { - add_test("File \"js_json_test.res\", line 140, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 140, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } else if (ta.TAG === "JSONString") { if (ta._0 !== "test string") { - add_test("File \"js_json_test.res\", line 131, characters 15-22", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 131, characters 15-22", () => ({ + TAG: "Ok", + _0: false })); } else { let ty$5 = Js_json.classify(option_get(Js_dict.get(x, "b"))); if (typeof ty$5 !== "object") { - add_test("File \"js_json_test.res\", line 137, characters 22-29", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 137, characters 22-29", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$5.TAG === "JSONNumber") { let b = ty$5._0; - add_test("File \"js_json_test.res\", line 136, characters 38-45", (function () { - return { - TAG: "Approx", - _0: 123.0, - _1: b - }; + add_test("File \"js_json_test.res\", line 136, characters 38-45", () => ({ + TAG: "Approx", + _0: 123.0, + _1: b })); } else { - add_test("File \"js_json_test.res\", line 137, characters 22-29", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 137, characters 22-29", () => ({ + TAG: "Ok", + _0: false })); } } } else { - add_test("File \"js_json_test.res\", line 140, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 140, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } } else { - add_test("File \"js_json_test.res\", line 142, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 142, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } function eq_at_i(loc, json, i, kind, expected) { let ty = Js_json.classify(json); if (typeof ty !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } if (ty.TAG !== "JSONArray") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } let ty$1 = Js_json.classify(Caml_array.get(ty._0, i)); switch (kind) { case "String" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONString") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Number" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONNumber") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Object" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONObject") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Array" : if (typeof ty$1 !== "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } else if (ty$1.TAG === "JSONArray") { return eq(loc, ty$1._0, expected); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Boolean" : if (typeof ty$1 === "object") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } switch (ty$1) { @@ -457,44 +395,34 @@ function eq_at_i(loc, json, i, kind, expected) { case "JSONTrue" : return eq(loc, true, expected); default: - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } case "Null" : if (typeof ty$1 !== "object") { if (ty$1 === "JSONNull") { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: true - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: true })); } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } } else { - return add_test(loc, (function () { - return { - TAG: "Ok", - _0: false - }; + return add_test(loc, () => ({ + TAG: "Ok", + _0: false })); } } } -let json$5 = JSON.parse(JSON.stringify($$Array.map((function (prim) { - return prim; -}), [ +let json$5 = JSON.parse(JSON.stringify($$Array.map(prim => prim, [ "string 0", "string 1", "string 2" @@ -538,9 +466,7 @@ let a$1 = [ -268391749 ]; -let json$8 = JSON.parse(JSON.stringify($$Array.map((function (prim) { - return prim; -}), a$1))); +let json$8 = JSON.parse(JSON.stringify($$Array.map(prim => prim, a$1))); eq_at_i("File \"js_json_test.res\", line 230, characters 10-17", json$8, 0, "Number", Caml_array.get(a$1, 0)); @@ -579,71 +505,55 @@ let json$10 = JSON.parse(JSON.stringify(a$3)); let ty$6 = Js_json.classify(json$10); if (typeof ty$6 !== "object") { - add_test("File \"js_json_test.res\", line 271, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$6.TAG === "JSONArray") { let ty$7 = Js_json.classify(Caml_array.get(ty$6._0, 1)); if (typeof ty$7 !== "object") { - add_test("File \"js_json_test.res\", line 269, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$7.TAG === "JSONObject") { let ty$8 = Js_json.classify(option_get(Js_dict.get(ty$7._0, "a"))); if (typeof ty$8 !== "object") { - add_test("File \"js_json_test.res\", line 267, characters 20-27", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ + TAG: "Ok", + _0: false })); } else if (ty$8.TAG === "JSONString") { eq("File \"js_json_test.res\", line 266, characters 35-42", ty$8._0, "bbb"); } else { - add_test("File \"js_json_test.res\", line 267, characters 20-27", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 267, characters 20-27", () => ({ + TAG: "Ok", + _0: false })); } } else { - add_test("File \"js_json_test.res\", line 269, characters 18-25", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 269, characters 18-25", () => ({ + TAG: "Ok", + _0: false })); } } else { - add_test("File \"js_json_test.res\", line 271, characters 16-23", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 271, characters 16-23", () => ({ + TAG: "Ok", + _0: false })); } try { JSON.parse("{{ A}"); - add_test("File \"js_json_test.res\", line 279, characters 11-18", (function () { - return { - TAG: "Ok", - _0: false - }; + add_test("File \"js_json_test.res\", line 279, characters 11-18", () => ({ + TAG: "Ok", + _0: false })); } catch (exn) { - add_test("File \"js_json_test.res\", line 281, characters 17-24", (function () { - return { - TAG: "Ok", - _0: true - }; + add_test("File \"js_json_test.res\", line 281, characters 17-24", () => ({ + TAG: "Ok", + _0: true })); } @@ -756,21 +666,21 @@ idtest({ tl: /* [] */0 }); -idtest(Belt_List.makeBy(500, (function (i) { +idtest(Belt_List.makeBy(500, i => { if (i % 2 === 0) { return; } else { return 1; } -}))); +})); -idtest(Belt_Array.makeBy(500, (function (i) { +idtest(Belt_Array.makeBy(500, i => { if (i % 2 === 0) { return; } else { return 1; } -}))); +})); Mt.from_pair_suites("Js_json_test", suites.contents); diff --git a/jscomp/test/js_math_test.js b/jscomp/test/js_math_test.js index 1d1ab94d30..fc2059ea26 100644 --- a/jscomp/test/js_math_test.js +++ b/jscomp/test/js_math_test.js @@ -6,670 +6,558 @@ let Js_math = require("../../lib/js/js_math.js"); let suites_0 = [ "_E", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 2.718, - _2: Math.E - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 2.718, + _2: Math.E }) ]; let suites_1 = { hd: [ "_LN2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.693, - _2: Math.LN2 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.693, + _2: Math.LN2 }) ], tl: { hd: [ "_LN10", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 2.303, - _2: Math.LN10 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 2.303, + _2: Math.LN10 }) ], tl: { hd: [ "_LOG2E", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.443, - _2: Math.LOG2E - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.443, + _2: Math.LOG2E }) ], tl: { hd: [ "_LOG10E", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.434, - _2: Math.LOG10E - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.434, + _2: Math.LOG10E }) ], tl: { hd: [ "_PI", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.00001, - _1: 3.14159, - _2: Math.PI - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.00001, + _1: 3.14159, + _2: Math.PI }) ], tl: { hd: [ "_SQRT1_2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.707, - _2: Math.SQRT1_2 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.707, + _2: Math.SQRT1_2 }) ], tl: { hd: [ "_SQRT2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.414, - _2: Math.SQRT2 - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.414, + _2: Math.SQRT2 }) ], tl: { hd: [ "abs_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.abs(-4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.abs(-4) }) ], tl: { hd: [ "abs_float", - (function (param) { - return { - TAG: "Eq", - _0: 1.2, - _1: Math.abs(-1.2) - }; + param => ({ + TAG: "Eq", + _0: 1.2, + _1: Math.abs(-1.2) }) ], tl: { hd: [ "acos", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.159, - _2: Math.acos(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.159, + _2: Math.acos(0.4) }) ], tl: { hd: [ "acosh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.622, - _2: Math.acosh(1.2) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.622, + _2: Math.acosh(1.2) }) ], tl: { hd: [ "asin", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.411, - _2: Math.asin(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.411, + _2: Math.asin(0.4) }) ], tl: { hd: [ "asinh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.390, - _2: Math.asinh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.390, + _2: Math.asinh(0.4) }) ], tl: { hd: [ "atan", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.380, - _2: Math.atan(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.380, + _2: Math.atan(0.4) }) ], tl: { hd: [ "atanh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.423, - _2: Math.atanh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.423, + _2: Math.atanh(0.4) }) ], tl: { hd: [ "atan2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.588, - _2: Math.atan2(0.4, 0.6) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.588, + _2: Math.atan2(0.4, 0.6) }) ], tl: { hd: [ "cbrt", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Math.cbrt(8) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.cbrt(8) }) ], tl: { hd: [ "unsafe_ceil_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.ceil(3.2) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.ceil(3.2) }) ], tl: { hd: [ "ceil_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Js_math.ceil_int(3.2) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_math.ceil_int(3.2) }) ], tl: { hd: [ "ceil_float", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.ceil(3.2) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.ceil(3.2) }) ], tl: { hd: [ "cos", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.921, - _2: Math.cos(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.921, + _2: Math.cos(0.4) }) ], tl: { hd: [ "cosh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.081, - _2: Math.cosh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.081, + _2: Math.cosh(0.4) }) ], tl: { hd: [ "exp", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.491, - _2: Math.exp(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.491, + _2: Math.exp(0.4) }) ], tl: { hd: [ "expm1", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.491, - _2: Math.expm1(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.491, + _2: Math.expm1(0.4) }) ], tl: { hd: [ "unsafe_floor_int", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.floor(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.floor(3.2) }) ], tl: { hd: [ "floor_int", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Js_math.floor_int(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Js_math.floor_int(3.2) }) ], tl: { hd: [ "floor_float", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.floor(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.floor(3.2) }) ], tl: { hd: [ "fround", - (function (param) { - return { - TAG: "Approx", - _0: 3.2, - _1: Math.fround(3.2) - }; + param => ({ + TAG: "Approx", + _0: 3.2, + _1: Math.fround(3.2) }) ], tl: { hd: [ "hypot", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.721, - _2: Math.hypot(0.4, 0.6) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.721, + _2: Math.hypot(0.4, 0.6) }) ], tl: { hd: [ "hypotMany", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 1.077, - _2: Math.hypot(0.4, 0.6, 0.8) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 1.077, + _2: Math.hypot(0.4, 0.6, 0.8) }) ], tl: { hd: [ "imul", - (function (param) { - return { - TAG: "Eq", - _0: 8, - _1: Math.imul(4, 2) - }; + param => ({ + TAG: "Eq", + _0: 8, + _1: Math.imul(4, 2) }) ], tl: { hd: [ "log", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: -0.916, - _2: Math.log(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -0.916, + _2: Math.log(0.4) }) ], tl: { hd: [ "log1p", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.336, - _2: Math.log1p(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.336, + _2: Math.log1p(0.4) }) ], tl: { hd: [ "log10", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: -0.397, - _2: Math.log10(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -0.397, + _2: Math.log10(0.4) }) ], tl: { hd: [ "log2", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: -1.321, - _2: Math.log2(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: -1.321, + _2: Math.log2(0.4) }) ], tl: { hd: [ "max_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.max(2, 4) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.max(2, 4) }) ], tl: { hd: [ "maxMany_int", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.max(2, 4, 3) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.max(2, 4, 3) }) ], tl: { hd: [ "max_float", - (function (param) { - return { - TAG: "Eq", - _0: 4.2, - _1: Math.max(2.7, 4.2) - }; + param => ({ + TAG: "Eq", + _0: 4.2, + _1: Math.max(2.7, 4.2) }) ], tl: { hd: [ "maxMany_float", - (function (param) { - return { - TAG: "Eq", - _0: 4.2, - _1: Math.max(2.7, 4.2, 3.9) - }; + param => ({ + TAG: "Eq", + _0: 4.2, + _1: Math.max(2.7, 4.2, 3.9) }) ], tl: { hd: [ "min_int", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Math.min(2, 4) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.min(2, 4) }) ], tl: { hd: [ "minMany_int", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Math.min(2, 4, 3) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Math.min(2, 4, 3) }) ], tl: { hd: [ "min_float", - (function (param) { - return { - TAG: "Eq", - _0: 2.7, - _1: Math.min(2.7, 4.2) - }; + param => ({ + TAG: "Eq", + _0: 2.7, + _1: Math.min(2.7, 4.2) }) ], tl: { hd: [ "minMany_float", - (function (param) { - return { - TAG: "Eq", - _0: 2.7, - _1: Math.min(2.7, 4.2, 3.9) - }; + param => ({ + TAG: "Eq", + _0: 2.7, + _1: Math.min(2.7, 4.2, 3.9) }) ], tl: { hd: [ "random", - (function (param) { + param => { let a = Math.random(); return { TAG: "Ok", _0: a >= 0 && a < 1 }; - }) + } ], tl: { hd: [ "random_int", - (function (param) { + param => { let a = Js_math.random_int(1, 3); return { TAG: "Ok", _0: a >= 1 && a < 3 }; - }) + } ], tl: { hd: [ "unsafe_round", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.round(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.round(3.2) }) ], tl: { hd: [ "round", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Math.round(3.2) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Math.round(3.2) }) ], tl: { hd: [ "sign_int", - (function (param) { - return { - TAG: "Eq", - _0: -1, - _1: Math.sign(-4) - }; + param => ({ + TAG: "Eq", + _0: -1, + _1: Math.sign(-4) }) ], tl: { hd: [ "sign_float", - (function (param) { - return { - TAG: "Eq", - _0: -1, - _1: Math.sign(-4.2) - }; + param => ({ + TAG: "Eq", + _0: -1, + _1: Math.sign(-4.2) }) ], tl: { hd: [ "sign_float -0", - (function (param) { - return { - TAG: "Eq", - _0: -0, - _1: Math.sign(-0) - }; + param => ({ + TAG: "Eq", + _0: -0, + _1: Math.sign(-0) }) ], tl: { hd: [ "sin", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.389, - _2: Math.sin(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.389, + _2: Math.sin(0.4) }) ], tl: { hd: [ "sinh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.410, - _2: Math.sinh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.410, + _2: Math.sinh(0.4) }) ], tl: { hd: [ "sqrt", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.632, - _2: Math.sqrt(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.632, + _2: Math.sqrt(0.4) }) ], tl: { hd: [ "tan", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.422, - _2: Math.tan(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.422, + _2: Math.tan(0.4) }) ], tl: { hd: [ "tanh", - (function (param) { - return { - TAG: "ApproxThreshold", - _0: 0.001, - _1: 0.379, - _2: Math.tanh(0.4) - }; + param => ({ + TAG: "ApproxThreshold", + _0: 0.001, + _1: 0.379, + _2: Math.tanh(0.4) }) ], tl: { hd: [ "unsafe_trunc", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.trunc(4.2156) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.trunc(4.2156) }) ], tl: { hd: [ "trunc", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Math.trunc(4.2156) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Math.trunc(4.2156) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_null_test.js b/jscomp/test/js_null_test.js index 1e3b56e403..abcceec261 100644 --- a/jscomp/test/js_null_test.js +++ b/jscomp/test/js_null_test.js @@ -7,139 +7,117 @@ let Caml_option = require("../../lib/js/caml_option.js"); let suites_0 = [ "toOption - empty", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ]; let suites_1 = { hd: [ "toOption - 'a", - (function (param) { - return { - TAG: "Eq", - _0: Caml_option.some(undefined), - _1: Caml_option.some() - }; + param => ({ + TAG: "Eq", + _0: Caml_option.some(undefined), + _1: Caml_option.some() }) ], tl: { hd: [ "return", - (function (param) { - return { - TAG: "Eq", - _0: "something", - _1: Caml_option.null_to_opt("something") - }; + param => ({ + TAG: "Eq", + _0: "something", + _1: Caml_option.null_to_opt("something") }) ], tl: { hd: [ "test - empty", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "test - 'a", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: false - }; + param => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "bind - empty", - (function (param) { - return { - TAG: "StrictEq", - _0: null, - _1: Js_null.bind(null, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: null, + _1: Js_null.bind(null, v => v) }) ], tl: { hd: [ "bind - 'a", - (function (param) { - return { - TAG: "StrictEq", - _0: 4, - _1: Js_null.bind(2, (function (n) { - return (n << 1); - })) - }; + param => ({ + TAG: "StrictEq", + _0: 4, + _1: Js_null.bind(2, n => (n << 1)) }) ], tl: { hd: [ "iter - empty", - (function (param) { + param => { let hit = { contents: false }; - Js_null.iter(null, (function (param) { + Js_null.iter(null, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - 'a", - (function (param) { + param => { let hit = { contents: 0 }; - Js_null.iter(2, (function (v) { + Js_null.iter(2, v => { hit.contents = v; - })); + }); return { TAG: "Eq", _0: 2, _1: hit.contents }; - }) + } ], tl: { hd: [ "fromOption - None", - (function (param) { - return { - TAG: "Eq", - _0: null, - _1: Js_null.fromOption(undefined) - }; + param => ({ + TAG: "Eq", + _0: null, + _1: Js_null.fromOption(undefined) }) ], tl: { hd: [ "fromOption - Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_null.fromOption(2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_null.fromOption(2) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_null_undefined_test.js b/jscomp/test/js_null_undefined_test.js index 74c496f7d8..b57628e898 100644 --- a/jscomp/test/js_null_undefined_test.js +++ b/jscomp/test/js_null_undefined_test.js @@ -7,283 +7,237 @@ let Js_null_undefined = require("../../lib/js/js_null_undefined.js"); let suites_0 = [ "toOption - null", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ]; let suites_1 = { hd: [ "toOption - undefined", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ], tl: { hd: [ "toOption - empty", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: undefined - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: undefined }) ], tl: { hd: [ "File \"js_null_undefined_test.res\", line 9, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: "foo", - _1: Caml_option.nullable_to_opt("foo") - }; + param => ({ + TAG: "Eq", + _0: "foo", + _1: Caml_option.nullable_to_opt("foo") }) ], tl: { hd: [ "return", - (function (param) { - return { - TAG: "Eq", - _0: "something", - _1: Caml_option.nullable_to_opt("something") - }; + param => ({ + TAG: "Eq", + _0: "something", + _1: Caml_option.nullable_to_opt("something") }) ], tl: { hd: [ "test - null", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "test - undefined", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "test - empty", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "File \"js_null_undefined_test.res\", line 14, characters 5-12", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "bind - null", - (function (param) { - return { - TAG: "StrictEq", - _0: null, - _1: Js_null_undefined.bind(null, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: null, + _1: Js_null_undefined.bind(null, v => v) }) ], tl: { hd: [ "bind - undefined", - (function (param) { - return { - TAG: "StrictEq", - _0: undefined, - _1: Js_null_undefined.bind(undefined, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: undefined, + _1: Js_null_undefined.bind(undefined, v => v) }) ], tl: { hd: [ "bind - empty", - (function (param) { - return { - TAG: "StrictEq", - _0: undefined, - _1: Js_null_undefined.bind(undefined, (function (v) { - return v; - })) - }; + param => ({ + TAG: "StrictEq", + _0: undefined, + _1: Js_null_undefined.bind(undefined, v => v) }) ], tl: { hd: [ "bind - 'a", - (function (param) { - return { - TAG: "Eq", - _0: 4, - _1: Js_null_undefined.bind(2, (function (n) { - return (n << 1); - })) - }; + param => ({ + TAG: "Eq", + _0: 4, + _1: Js_null_undefined.bind(2, n => (n << 1)) }) ], tl: { hd: [ "iter - null", - (function (param) { + param => { let hit = { contents: false }; - Js_null_undefined.iter(null, (function (param) { + Js_null_undefined.iter(null, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - undefined", - (function (param) { + param => { let hit = { contents: false }; - Js_null_undefined.iter(undefined, (function (param) { + Js_null_undefined.iter(undefined, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - empty", - (function (param) { + param => { let hit = { contents: false }; - Js_null_undefined.iter(undefined, (function (param) { + Js_null_undefined.iter(undefined, param => { hit.contents = true; - })); + }); return { TAG: "Eq", _0: false, _1: hit.contents }; - }) + } ], tl: { hd: [ "iter - 'a", - (function (param) { + param => { let hit = { contents: 0 }; - Js_null_undefined.iter(2, (function (v) { + Js_null_undefined.iter(2, v => { hit.contents = v; - })); + }); return { TAG: "Eq", _0: 2, _1: hit.contents }; - }) + } ], tl: { hd: [ "fromOption - None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_null_undefined.fromOption(undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_null_undefined.fromOption(undefined) }) ], tl: { hd: [ "fromOption - Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_null_undefined.fromOption(2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_null_undefined.fromOption(2) }) ], tl: { hd: [ "null <> undefined", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: { hd: [ "null <> empty", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: { hd: [ "undefined = empty", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: { hd: [ "File \"js_null_undefined_test.res\", line 57, characters 6-13", - (function (param) { - return { - TAG: "Ok", - _0: true - }; + param => ({ + TAG: "Ok", + _0: true }) ], tl: /* [] */0 diff --git a/jscomp/test/js_nullable_test.js b/jscomp/test/js_nullable_test.js index ba64e5e938..15f396e862 100644 --- a/jscomp/test/js_nullable_test.js +++ b/jscomp/test/js_nullable_test.js @@ -16,12 +16,10 @@ function eq(loc, x, y) { suites.contents = { hd: [ loc + (" id " + String(test_id.contents)), - (function () { - return { - TAG: "Eq", - _0: x, - _1: y - }; + () => ({ + TAG: "Eq", + _0: x, + _1: y }) ], tl: suites.contents diff --git a/jscomp/test/js_obj_test.js b/jscomp/test/js_obj_test.js index 8b535ae7a5..b39bb04e02 100644 --- a/jscomp/test/js_obj_test.js +++ b/jscomp/test/js_obj_test.js @@ -5,28 +5,24 @@ let Mt = require("./mt.js"); let suites_0 = [ "empty", - (function (param) { - return { - TAG: "Eq", - _0: 0, - _1: Object.keys({}).length - }; + param => ({ + TAG: "Eq", + _0: 0, + _1: Object.keys({}).length }) ]; let suites_1 = { hd: [ "assign", - (function (param) { - return { - TAG: "Eq", - _0: { - a: 1 - }, - _1: Object.assign({}, { - a: 1 - }) - }; + param => ({ + TAG: "Eq", + _0: { + a: 1 + }, + _1: Object.assign({}, { + a: 1 + }) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_option_test.js b/jscomp/test/js_option_test.js index 1159c4c2fd..c1052a0514 100644 --- a/jscomp/test/js_option_test.js +++ b/jscomp/test/js_option_test.js @@ -10,269 +10,209 @@ function simpleEq(a, b) { let option_suites_0 = [ "option_isSome_Some", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ]; let option_suites_1 = { hd: [ "option_isSome_None", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: false - }; + param => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "option_isNone_Some", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: false - }; + param => ({ + TAG: "Eq", + _0: false, + _1: false }) ], tl: { hd: [ "option_isNone_None", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: true - }; + param => ({ + TAG: "Eq", + _0: true, + _1: true }) ], tl: { hd: [ "option_isSomeValue_Eq", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, 2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, 2) }) ], tl: { hd: [ "option_isSomeValue_Diff", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 1, 2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 1, 2) }) ], tl: { hd: [ "option_isSomeValue_DiffNone", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 1, undefined) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 1, undefined) }) ], tl: { hd: [ "option_getExn_Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_option.getExn(2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_option.getExn(2) }) ], tl: { hd: [ "option_equal_Eq", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.equal(simpleEq, 2, 2) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.equal(simpleEq, 2, 2) }) ], tl: { hd: [ "option_equal_Diff", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.equal(simpleEq, 1, 2) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.equal(simpleEq, 1, 2) }) ], tl: { hd: [ "option_equal_DiffNone", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.equal(simpleEq, 1, undefined) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.equal(simpleEq, 1, undefined) }) ], tl: { hd: [ "option_andThen_SomeSome", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen((function (a) { - return a + 1 | 0; - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(a => a + 1 | 0, 2)) }) ], tl: { hd: [ "option_andThen_SomeNone", - (function (param) { - return { - TAG: "Eq", - _0: false, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen((function (param) { - - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: false, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(param => {}, 2)) }) ], tl: { hd: [ "option_map_Some", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.map((function (a) { - return a + 1 | 0; - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.map(a => a + 1 | 0, 2)) }) ], tl: { hd: [ "option_map_None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.map((function (a) { - return a + 1 | 0; - }), undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.map(a => a + 1 | 0, undefined) }) ], tl: { hd: [ "option_default_Some", - (function (param) { - return { - TAG: "Eq", - _0: 2, - _1: Js_option.getWithDefault(3, 2) - }; + param => ({ + TAG: "Eq", + _0: 2, + _1: Js_option.getWithDefault(3, 2) }) ], tl: { hd: [ "option_default_None", - (function (param) { - return { - TAG: "Eq", - _0: 3, - _1: Js_option.getWithDefault(3, undefined) - }; + param => ({ + TAG: "Eq", + _0: 3, + _1: Js_option.getWithDefault(3, undefined) }) ], tl: { hd: [ "option_filter_Pass", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, Js_option.filter((function (a) { - return a % 2 === 0; - }), 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, Js_option.filter(a => a % 2 === 0, 2)) }) ], tl: { hd: [ "option_filter_Reject", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.filter((function (a) { - return a % 3 === 0; - }), 2) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.filter(a => a % 3 === 0, 2) }) ], tl: { hd: [ "option_filter_None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.filter((function (a) { - return a % 3 === 0; - }), undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.filter(a => a % 3 === 0, undefined) }) ], tl: { hd: [ "option_firstSome_First", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 3, Js_option.firstSome(3, 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 3, Js_option.firstSome(3, 2)) }) ], tl: { hd: [ "option_firstSome_First", - (function (param) { - return { - TAG: "Eq", - _0: true, - _1: Js_option.isSomeValue(simpleEq, 2, Js_option.firstSome(undefined, 2)) - }; + param => ({ + TAG: "Eq", + _0: true, + _1: Js_option.isSomeValue(simpleEq, 2, Js_option.firstSome(undefined, 2)) }) ], tl: { hd: [ "option_firstSome_None", - (function (param) { - return { - TAG: "Eq", - _0: undefined, - _1: Js_option.firstSome(undefined, undefined) - }; + param => ({ + TAG: "Eq", + _0: undefined, + _1: Js_option.firstSome(undefined, undefined) }) ], tl: /* [] */0 diff --git a/jscomp/test/js_re_test.js b/jscomp/test/js_re_test.js index 32dab9fbaf..2fdc4f2d08 100644 --- a/jscomp/test/js_re_test.js +++ b/jscomp/test/js_re_test.js @@ -7,7 +7,7 @@ let Caml_option = require("../../lib/js/caml_option.js"); let suites_0 = [ "captures", - (function (param) { + param => { let re = /(\d+)-(?:(\d+))?/g; let result = re.exec("3-"); if (result === null) { @@ -29,14 +29,14 @@ let suites_0 = [ $$undefined ] }; - }) + } ]; let suites_1 = { hd: [ "fromString", - (function (param) { - let contentOf = function (tag, xmlString) { + param => { + let contentOf = (tag, xmlString) => { let x = Caml_option.null_to_opt(new RegExp("<" + (tag + (">(.*?)<\\/" + (tag + ">")))).exec(xmlString)); if (x !== undefined) { return Caml_option.nullable_to_opt(Caml_array.get(Caml_option.valFromOption(x), 1)); @@ -48,12 +48,12 @@ let suites_1 = { _0: contentOf("div", "