diff --git a/changes/formatter-multiline-item-spacing.polish.md b/changes/formatter-multiline-item-spacing.polish.md new file mode 100644 index 00000000000..35142e74164 --- /dev/null +++ b/changes/formatter-multiline-item-spacing.polish.md @@ -0,0 +1 @@ +- Format a blank line before and after a top-level or module-level item that spans several lines. diff --git a/compiler/syntax/src/res_doc.ml b/compiler/syntax/src/res_doc.ml index 5ba1a50e8cf..5f1b3440d01 100644 --- a/compiler/syntax/src/res_doc.ml +++ b/compiler/syntax/src/res_doc.ml @@ -23,6 +23,8 @@ type t = | Group of {mutable should_break: bool; doc: t} | CustomLayout of t list | BreakParent + | ItemSeparator of {prev: t; next: t} (* see [item_separator] *) + | Comment of t (* see [comment] *) let nil = Nil let line = LineBreak Classic @@ -52,6 +54,8 @@ let group d = Group {should_break = false; doc = d} let breakable_group ~force_break d = Group {should_break = force_break; doc = d} let custom_layout gs = CustomLayout gs let break_parent = BreakParent +let item_separator ~prev ~next = ItemSeparator {prev; next} +let comment d = Comment d let space = Text " " let comma = Text "," @@ -75,9 +79,9 @@ let propagate_forced_breaks doc = match doc with | Text _ | Nil | LineSuffix _ -> false | BreakParent -> true - | LineBreak (Hard | Literal) -> true + | LineBreak (Hard | Literal) | ItemSeparator _ -> true | LineBreak (Classic | Soft) -> false - | Indent children -> + | Indent children | Comment children -> let child_forces_break = walk children in child_forces_break | IfBreaks ({yes = true_doc; no = false_doc} as ib) -> @@ -115,9 +119,12 @@ let propagate_forced_breaks doc = (* See documentation in interface file *) let rec will_break doc = match doc with - | LineBreak (Hard | Literal) | BreakParent | Group {should_break = true} -> + | LineBreak (Hard | Literal) + | BreakParent | ItemSeparator _ + | Group {should_break = true} -> true - | Group {doc} | Indent doc | CustomLayout (doc :: _) -> will_break doc + | Group {doc} | Indent doc | Comment doc | CustomLayout (doc :: _) -> + will_break doc | Concat docs -> List.exists will_break docs | IfBreaks {yes; no} -> will_break yes || will_break no | _ -> false @@ -129,9 +136,9 @@ let has_pending_line_suffix doc = let rec walk ~broken pending doc = match doc with | LineSuffix _ -> true - | LineBreak _ -> pending && not broken + | LineBreak _ | ItemSeparator _ -> pending && not broken | Nil | Text _ | BreakParent -> pending - | Indent doc -> walk ~broken pending doc + | Indent doc | Comment doc -> walk ~broken pending doc | Concat docs -> List.fold_left (walk ~broken) pending docs | Group {should_break; doc} -> walk ~broken:(should_break || will_break doc) pending doc @@ -170,10 +177,12 @@ let fits w stack = | _, Nil | _, LineSuffix _ | _, BreakParent -> () | _, Text txt -> width := width.contents - String.length txt | _, Indent doc -> calculate (indent + 2) mode doc + | _, Comment doc -> calculate indent mode doc | Flat, LineBreak Hard | Flat, LineBreak Literal -> result := Some true | Flat, LineBreak Classic -> width := width.contents - 1 | Flat, LineBreak Soft -> () | Break, LineBreak _ -> result := Some true + | _, ItemSeparator _ -> result := Some true | _, Group {should_break = true; doc} -> calculate indent Break doc | _, Group {doc} -> calculate indent mode doc | _, IfBreaks {yes = break_doc; broken = true} -> @@ -203,6 +212,61 @@ let fits w stack = in calculate_all stack +let select_custom_layout ~width ~pos ind rest docs = + let rec find_group_that_fits groups = + match groups with + | [] -> Nil + | [last_group] -> last_group + | doc :: docs -> + if fits (width - pos) ((ind, Flat, doc) :: rest) then doc + else find_group_that_fits docs + in + find_group_that_fits docs + +(* Whether [doc], printed from the start of a line indented by [ind], spans more + than one line. Takes the layout decisions of [to_string] up to the first line + break. Comments and line suffixes do not count. *) +let spans_lines ~width ind mode doc = + let rec loop ~pos stack = + match stack with + | [] -> false + | (ind, mode, doc) :: rest -> ( + match doc with + | Nil | BreakParent | LineSuffix _ | Comment _ -> loop ~pos rest + | Text txt -> + String.contains txt '\n' || loop ~pos:(pos + String.length txt) rest + | Concat docs -> + loop ~pos (List.map (fun doc -> (ind, mode, doc)) docs @ rest) + | Indent doc -> loop ~pos ((ind + 2, mode, doc) :: rest) + | IfBreaks {yes; no; broken} -> + let doc = if broken || mode = Break then yes else no in + loop ~pos ((ind, mode, doc) :: rest) + | LineBreak (Hard | Literal) | ItemSeparator _ -> true + | LineBreak Classic -> mode = Break || loop ~pos:(pos + 1) rest + | LineBreak Soft -> mode = Break || loop ~pos rest + | Group {should_break; doc} -> + let flat = (ind, Flat, doc) :: rest in + if should_break || not (fits (width - pos) flat) then + loop ~pos ((ind, Break, doc) :: rest) + else loop ~pos flat + | CustomLayout docs -> + let doc = select_custom_layout ~width ~pos ind rest docs in + loop ~pos ((ind, Flat, doc) :: rest)) + in + loop ~pos:ind [(ind, mode, doc)] + +(* Own-line trailing comments are line suffixes that start with a hard line. *) +let starts_with_hard_line doc = + match doc with + | LineBreak Hard | Concat (LineBreak Hard :: _) -> true + | _ -> false + +let rec drop_leading_hard_lines doc = + match doc with + | LineBreak Hard -> Nil + | Concat (LineBreak Hard :: docs) -> drop_leading_hard_lines (Concat docs) + | doc -> doc + let to_string ~width doc = propagate_forced_breaks doc; let buffer = Mini_buffer.create 1000 in @@ -220,6 +284,7 @@ let to_string ~width doc = let ops = List.map (fun doc -> (ind, mode, doc)) docs in process ~pos line_suffices (List.append ops rest) | Indent doc -> process ~pos line_suffices ((ind + 2, mode, doc) :: rest) + | Comment doc -> process ~pos line_suffices ((ind, mode, doc) :: rest) | IfBreaks {yes = break_doc; broken = true} -> process ~pos line_suffices ((ind, mode, break_doc) :: rest) | IfBreaks {yes = break_doc; no = flat_doc} -> @@ -262,16 +327,28 @@ let to_string ~width doc = then process ~pos line_suffices ((ind, Break, doc) :: rest) else process ~pos line_suffices ((ind, Flat, doc) :: rest) | CustomLayout docs -> - let rec find_group_that_fits groups = - match groups with - | [] -> Nil - | [last_group] -> last_group - | doc :: docs -> - if fits (width - pos) ((ind, Flat, doc) :: rest) then doc - else find_group_that_fits docs - in - let doc = find_group_that_fits docs in - process ~pos line_suffices ((ind, Flat, doc) :: rest)) + let doc = select_custom_layout ~width ~pos ind rest docs in + process ~pos line_suffices ((ind, Flat, doc) :: rest) + | ItemSeparator {prev; next} -> + if spans_lines ~width ind mode prev || spans_lines ~width ind mode next + then + (* Own-line trailing comments of [prev] go below the blank line, where + they print once they are leading comments of [next]. *) + let separator = (ind, mode, hard_line) in + let same_line, below = + List.partition + (fun (_, _, doc) -> not (starts_with_hard_line doc)) + (List.rev line_suffices) + in + let rest = + match below with + | [] -> rest + | (ind, mode, doc) :: below -> + ((ind, mode, drop_leading_hard_lines doc) :: below) + @ (separator :: rest) + in + process ~pos (List.rev same_line) (separator :: separator :: rest) + else process ~pos line_suffices ((ind, mode, hard_line) :: rest)) | [] -> ( match line_suffices with | [] -> () @@ -351,6 +428,8 @@ let debug t = | Literal -> "Literal" in text ("LineBreak(" ^ break_txt ^ ")") + | ItemSeparator _ -> text "ItemSeparator" + | Comment doc -> concat [text "comment("; to_doc doc; text ")"] | Group {should_break; doc} -> group (concat @@ -375,5 +454,5 @@ let is_nil doc = match doc with | Nil -> true | Text _ | LineSuffix _ | Concat _ | Indent _ | IfBreaks _ | LineBreak _ - | Group _ | CustomLayout _ | BreakParent -> + | Group _ | CustomLayout _ | BreakParent | ItemSeparator _ | Comment _ -> false diff --git a/compiler/syntax/src/res_doc.mli b/compiler/syntax/src/res_doc.mli index 13caa1a0c25..841088299c4 100644 --- a/compiler/syntax/src/res_doc.mli +++ b/compiler/syntax/src/res_doc.mli @@ -18,6 +18,15 @@ val breakable_group : force_break:bool -> t -> t * will be checked until one fits. *) val custom_layout : t list -> t val break_parent : t + +val item_separator : prev:t -> next:t -> t +(** A hard line, and a blank line when [prev] or [next], the documents printed + on each side of it, span several lines. It measures them but does not print + them. *) + +val comment : t -> t +(** Prints like its argument, which [item_separator] does not measure. *) + val join : sep:t -> t list -> t (* [(doc1, sep1); (doc2,sep2)] joins as doc1 sep1 doc2 *) diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index a319ad34b36..57f59fe97a7 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -326,10 +326,8 @@ let print_leading_comments node tbl loc = else if diff > 1 then Doc.concat [Doc.hard_line; Doc.hard_line] else Doc.hard_line in - let doc = - Doc.group - (Doc.concat [Doc.concat (List.rev (cmt_doc :: acc)); separator; node]) - in + let comments = Doc.concat (List.rev (separator :: cmt_doc :: acc)) in + let doc = Doc.group (Doc.concat [Doc.comment comments; node]) in doc | comment :: (next_comment :: _comments as rest) -> let cmt_doc = print_leading_comment ~next_comment comment in @@ -387,7 +385,9 @@ let print_comments_before_marker doc (tbl : Comment_table.t) loc marker = Hashtbl.replace tbl.trailing loc after_marker; print_trailing_comments doc tbl.trailing loc -let print_list ~get_loc ~nodes ~print ?(force_break = false) t = +(* [~space_multiline] adds a blank line next to nodes printed on several lines *) +let print_list ~get_loc ~nodes ~print ?(force_break = false) + ?(space_multiline = false) t = let rec loop first_loc_opt prev_loc_opt acc nodes = match nodes with | [] -> (first_loc_opt, prev_loc_opt, Doc.concat (List.rev acc)) @@ -403,15 +403,17 @@ let print_list ~get_loc ~nodes ~print ?(force_break = false) t = else let doc = print_comments raw_doc t loc in let acc = - match prev_loc_opt with - | None -> [doc] - | Some prev_loc -> + match (prev_loc_opt, acc) with + | Some prev_loc, prev_doc :: _ -> let sep = if start_pos.pos_lnum - prev_loc.Location.loc_end.pos_lnum > 1 then Doc.concat [Doc.hard_line; Doc.hard_line] + else if space_multiline then + Doc.item_separator ~prev:prev_doc ~next:doc else Doc.hard_line in doc :: sep :: acc + | _ -> [doc] in let first_loc_opt = match first_loc_opt with @@ -690,7 +692,7 @@ let rec print_structure ~state (s : Parsetree.structure) t = | [] -> print_comments_inside_file t | structure -> let previous_can_continue = ref false in - print_list + print_list ~space_multiline:true ~get_loc:(fun s -> s.Parsetree.pstr_loc) ~nodes:structure ~print:(fun item cmt_tbl -> @@ -1108,7 +1110,7 @@ and print_signature ~state signature cmt_tbl = match signature with | [] -> print_comments_inside_file cmt_tbl | signature -> - print_list + print_list ~space_multiline:true ~get_loc:(fun s -> s.Parsetree.psig_loc) ~nodes:signature ~print:(print_signature_item ~state) diff --git a/packages/@rescript/belt/src/Belt_Array.resi b/packages/@rescript/belt/src/Belt_Array.resi index 75cd9fb4b21..745f357c113 100644 --- a/packages/@rescript/belt/src/Belt_Array.resi +++ b/packages/@rescript/belt/src/Belt_Array.resi @@ -191,6 +191,7 @@ let rangeBy: (int, int, ~step: int) => array @deprecated("Use `makeBy` instead") let makeByU: (int, int => 'a) => t<'a> + /** `makeBy(n, f)` return an empty array when n is negative return an array of size n populated by `f(i)` start from `0` to `n - 1`. @@ -207,6 +208,7 @@ let makeBy: (int, int => 'a) => t<'a> @deprecated("Use `makeByAndShuffle` instead") let makeByAndShuffleU: (int, int => 'a) => t<'a> + /** Equivalent to `shuffle(makeBy(n, f))` */ @@ -226,6 +228,7 @@ let zip: (t<'a>, array<'b>) => array<('a, 'b)> @deprecated("Use `zipBy` instead") let zipByU: (t<'a>, array<'b>, ('a, 'b) => 'c) => array<'c> + /** `zipBy(xs, ys, f)` create an array by applying `f` to corresponding elements of `xs` and `ys`. Stops with shorter array. @@ -382,6 +385,7 @@ let blitUnsafe: (~src: t<'a>, ~srcOffset: int, ~dst: t<'a>, ~dstOffset: int, ~le @deprecated("Use `forEach` instead") let forEachU: (t<'a>, 'a => unit) => unit + /** `forEach(xs, f)` @@ -411,6 +415,7 @@ let forEach: (t<'a>, 'a => unit) => unit @deprecated("Use `map` instead") let mapU: (t<'a>, 'a => 'b) => array<'b> + /** `map(xs, f)` returns a new array by calling `f` for each element of `xs` from the beginning to end. @@ -425,6 +430,7 @@ let map: (t<'a>, 'a => 'b) => array<'b> @deprecated("Use `flatMap` instead") let flatMapU: (t<'a>, 'a => array<'b>) => array<'b> + /** `flatMap(xs, f)` returns a new array by calling `f` for each element of `xs` from the beginning to end, concatenating the results. @@ -439,6 +445,7 @@ let flatMap: (t<'a>, 'a => array<'b>) => array<'b> @deprecated("Use `getBy` instead") let getByU: (t<'a>, 'a => bool) => option<'a> + /** `getBy(xs, p)` returns `Some(value)` for the first value in `xs` that satisifies the predicate function `p`; returns `None` if no element satisifies the function. @@ -454,6 +461,7 @@ let getBy: (t<'a>, 'a => bool) => option<'a> @deprecated("Use `getIndexBy` instead") let getIndexByU: (t<'a>, 'a => bool) => option + /** `getIndexBy(xs, p)` returns `Some(index)` for the first value in `xs` that satisifies the predicate function `p`; returns `None` if no element satisifies @@ -470,6 +478,7 @@ let getIndexBy: (t<'a>, 'a => bool) => option @deprecated("Use `keep` instead") let keepU: (t<'a>, 'a => bool) => t<'a> + /** `keep(xs, p)` returns a new array that keep all elements satisfy `p`. */ @@ -477,6 +486,7 @@ let keep: (t<'a>, 'a => bool) => t<'a> @deprecated("Use `keepWithIndex` instead") let keepWithIndexU: (t<'a>, ('a, int) => bool) => t<'a> + /** `keepWithIndex(xs, p)` returns a new array that keep all elements satisfy `p`. @@ -490,6 +500,7 @@ let keepWithIndex: (t<'a>, ('a, int) => bool) => t<'a> @deprecated("Use `keepMap` instead") let keepMapU: (t<'a>, 'a => option<'b>) => array<'b> + /** `keepMap(xs, p)` returns a new array that keep all elements that return a non None applied `p`. @@ -510,6 +521,7 @@ let keepMap: (t<'a>, 'a => option<'b>) => array<'b> @deprecated("Use `forEachWithIndex` instead") let forEachWithIndexU: (t<'a>, (int, 'a) => unit) => unit + /** `forEachWithIndex(xs, f)` same as `Belt.Array.forEach`, except that `f` is supplied two arguments: the index starting from 0 and the element from `xs`. @@ -538,6 +550,7 @@ let forEachWithIndex: (t<'a>, (int, 'a) => unit) => unit @deprecated("Use `mapWithIndex` instead") let mapWithIndexU: (t<'a>, (int, 'a) => 'b) => array<'b> + /** `mapWithIndex(xs, f)` applies `f` to each element of `xs`. Function `f` takes two arguments: the index starting from 0 and the element from `xs`. @@ -552,6 +565,7 @@ let mapWithIndex: (t<'a>, (int, 'a) => 'b) => array<'b> @deprecated("Use `partition` instead") let partitionU: (t<'a>, 'a => bool) => (t<'a>, t<'a>) + /** `partition(f, a)` split array into tuple of two arrays based on predicate `f`; first of tuple where predicate cause true, second where predicate cause false @@ -568,6 +582,7 @@ let partition: (t<'a>, 'a => bool) => (t<'a>, t<'a>) @deprecated("Use `reduce` instead") let reduceU: (array<'b>, 'a, ('a, 'b) => 'a) => 'a + /** `reduce(xs, init, f)` applies `f` to each element of `xs` from beginning to end. Function `f` has two parameters: the item from the list and an “accumulator”; @@ -586,6 +601,7 @@ let reduce: (array<'b>, 'a, ('a, 'b) => 'a) => 'a @deprecated("Use `reduceReverse` instead") let reduceReverseU: (array<'b>, 'a, ('a, 'b) => 'a) => 'a + /** `reduceReverse(xs, init, f)` works like `Belt.Array.reduce` except that function `f` is applied to each item of `xs` from the last back to the first. @@ -600,6 +616,7 @@ let reduceReverse: (array<'b>, 'a, ('a, 'b) => 'a) => 'a @deprecated("Use `reduceReverse2` instead") let reduceReverse2U: (t<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c + /** `reduceReverse2(xs, ys, init, f)` reduces two arrays xs and ys;taking items starting at `min(length(xs), length(ys))` down to and including zero. @@ -614,6 +631,7 @@ let reduceReverse2: (t<'a>, array<'b>, 'c, ('c, 'a, 'b) => 'c) => 'c @deprecated("Use `reduceWithIndex` instead") let reduceWithIndexU: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b + /** Applies `f` to each element of `xs` from beginning to end. Function `f` has three parameters: the item from the array and an “accumulator”, which starts @@ -630,6 +648,7 @@ let reduceWithIndex: (t<'a>, 'b, ('b, 'a, int) => 'b) => 'b @deprecated("Use `joinWith` instead") let joinWithU: (t<'a>, string, 'a => string) => string + /** `joinWith(xs, sep, toString)` @@ -650,6 +669,7 @@ let joinWith: (t<'a>, string, 'a => string) => string @deprecated("Use `some` instead") let someU: (t<'a>, 'a => bool) => bool + /** `some(xs, p)` returns true if at least one of the elements in `xs` satifies `p`; where `p` is a predicate: a function taking an element and returning a `bool`. @@ -666,6 +686,7 @@ let some: (t<'a>, 'a => bool) => bool @deprecated("Use `every` instead") let everyU: (t<'a>, 'a => bool) => bool + /** `every(xs, p)` returns `true` if all elements satisfy `p`; where `p` is a predicate: a function taking an element and returning a `bool`. @@ -682,6 +703,7 @@ let every: (t<'a>, 'a => bool) => bool @deprecated("Use `every2` instead") let every2U: (t<'a>, array<'b>, ('a, 'b) => bool) => bool + /** `every2(xs, ys, p)` returns true if `p(xi, yi)` is true for all pairs of elements up to the shorter length (i.e. `min(length(xs), length(ys))`) @@ -702,6 +724,7 @@ let every2: (t<'a>, array<'b>, ('a, 'b) => bool) => bool @deprecated("Use `some2` instead") let some2U: (t<'a>, array<'b>, ('a, 'b) => bool) => bool + /** `some2(xs, ys, p)` returns true if `p(xi, yi)` is true for any pair of elements up to the shorter length (i.e. `min(length(xs), length(ys))`) @@ -720,6 +743,7 @@ let some2: (t<'a>, array<'b>, ('a, 'b) => bool) => bool @deprecated("Use `cmp` instead") let cmpU: (t<'a>, t<'a>, ('a, 'a) => int) => int + /** `cmp(xs, ys, f)` compared by length if `length(xs) != length(ys)`; returning `-1` if `length(xs) < length(ys)` or 1 if `length(xs) > length(ys)`. Otherwise @@ -742,6 +766,7 @@ let cmp: (t<'a>, t<'a>, ('a, 'a) => int) => int @deprecated("Use `eq` instead") let eqU: (t<'a>, t<'a>, ('a, 'a) => bool) => bool + /** `eq(xs, ys)` return `false` if length is not the same otherwise compare items one by one using `f(xi, yi)`; and return true if all results are true false otherwise @@ -774,6 +799,7 @@ external truncateToLengthUnsafe: (t<'a>, int) => unit = "length" @deprecated("Use `init` instead") let initU: (int, int => 'a) => t<'a> + let init: (int, int => 'a) => t<'a> /** diff --git a/packages/@rescript/belt/src/Belt_HashMap.resi b/packages/@rescript/belt/src/Belt_HashMap.resi index 5a69ba4f036..7b34781a42c 100644 --- a/packages/@rescript/belt/src/Belt_HashMap.resi +++ b/packages/@rescript/belt/src/Belt_HashMap.resi @@ -249,6 +249,7 @@ let forEach: (t<'key, 'value, 'id>, ('key, 'value) => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t<'key, 'value, 'id>, 'c, ('c, 'key, 'value) => 'c) => 'c + /** `reduce(tbl, init, f)` computes `(f(kN, dN) ... (f(k1, d1, init))...)`, where `k1 ... kN` are the keys of all bindings in `tbl`, and `d1 ... dN` are the associated values. Each binding is presented exactly once to `f`. diff --git a/packages/@rescript/belt/src/Belt_HashMapInt.resi b/packages/@rescript/belt/src/Belt_HashMapInt.resi index 79a4700e0da..b576ecfd2af 100644 --- a/packages/@rescript/belt/src/Belt_HashMapInt.resi +++ b/packages/@rescript/belt/src/Belt_HashMapInt.resi @@ -23,14 +23,17 @@ let remove: (t<'a>, key) => unit @deprecated("Use `forEach` instead") let forEachU: (t<'b>, (key, 'b) => unit) => unit + let forEach: (t<'b>, (key, 'b) => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c + let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c @deprecated("Use `keepMapInPlace` instead") let keepMapInPlaceU: (t<'a>, (key, 'a) => option<'a>) => unit + let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit let size: t<_> => int diff --git a/packages/@rescript/belt/src/Belt_HashMapString.resi b/packages/@rescript/belt/src/Belt_HashMapString.resi index a45b37233cf..9d38ba353b3 100644 --- a/packages/@rescript/belt/src/Belt_HashMapString.resi +++ b/packages/@rescript/belt/src/Belt_HashMapString.resi @@ -23,14 +23,17 @@ let remove: (t<'a>, key) => unit @deprecated("Use `forEach` instead") let forEachU: (t<'b>, (key, 'b) => unit) => unit + let forEach: (t<'b>, (key, 'b) => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c + let reduce: (t<'b>, 'c, ('c, key, 'b) => 'c) => 'c @deprecated("Use `keepMapInPlace` instead") let keepMapInPlaceU: (t<'a>, (key, 'a) => option<'a>) => unit + let keepMapInPlace: (t<'a>, (key, 'a) => option<'a>) => unit let size: t<_> => int diff --git a/packages/@rescript/belt/src/Belt_HashSet.resi b/packages/@rescript/belt/src/Belt_HashSet.resi index 9dac3b66c98..698e411e393 100644 --- a/packages/@rescript/belt/src/Belt_HashSet.resi +++ b/packages/@rescript/belt/src/Belt_HashSet.resi @@ -75,11 +75,13 @@ let remove: (t<'a, 'id>, 'a) => unit @deprecated("Use `forEach` instead") let forEachU: (t<'a, 'id>, 'a => unit) => unit + /** Order unspecified. */ let forEach: (t<'a, 'id>, 'a => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c + /** Order unspecified. */ let reduce: (t<'a, 'id>, 'c, ('c, 'a) => 'c) => 'c diff --git a/packages/@rescript/belt/src/Belt_HashSetInt.resi b/packages/@rescript/belt/src/Belt_HashSetInt.resi index 8c04f80819d..6e84fbb859a 100644 --- a/packages/@rescript/belt/src/Belt_HashSetInt.resi +++ b/packages/@rescript/belt/src/Belt_HashSetInt.resi @@ -33,10 +33,12 @@ let remove: (t, key) => unit @deprecated("Use `forEach` instead") let forEachU: (t, key => unit) => unit + let forEach: (t, key => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t, 'c, ('c, key) => 'c) => 'c + let reduce: (t, 'c, ('c, key) => 'c) => 'c let size: t => int diff --git a/packages/@rescript/belt/src/Belt_HashSetString.resi b/packages/@rescript/belt/src/Belt_HashSetString.resi index 1418dbebd34..bd9c19b1db3 100644 --- a/packages/@rescript/belt/src/Belt_HashSetString.resi +++ b/packages/@rescript/belt/src/Belt_HashSetString.resi @@ -33,10 +33,12 @@ let remove: (t, key) => unit @deprecated("Use `forEach` instead") let forEachU: (t, key => unit) => unit + let forEach: (t, key => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t, 'c, ('c, key) => 'c) => 'c + let reduce: (t, 'c, ('c, key) => 'c) => 'c let size: t => int diff --git a/packages/@rescript/belt/src/Belt_List.res b/packages/@rescript/belt/src/Belt_List.res index a000e415d4c..1bcc9b2b103 100644 --- a/packages/@rescript/belt/src/Belt_List.res +++ b/packages/@rescript/belt/src/Belt_List.res @@ -316,6 +316,7 @@ let take = (lst, n) => } } } + /* invariant `n >= 0 ` */ let rec dropAux = (l, n) => if n == 0 { diff --git a/packages/@rescript/belt/src/Belt_Map.res b/packages/@rescript/belt/src/Belt_Map.res index ed34be5a221..a01283a30ee 100644 --- a/packages/@rescript/belt/src/Belt_Map.res +++ b/packages/@rescript/belt/src/Belt_Map.res @@ -62,6 +62,7 @@ let update = (m, key, f) => { let cmp = m.cmp {cmp, data: Dict.update(~cmp, m.data, key, f)} } + let split = (m, x) => { let cmp = m.cmp let ((l, r), b) = Dict.split(~cmp, m.data, x) diff --git a/packages/@rescript/belt/src/Belt_Map.resi b/packages/@rescript/belt/src/Belt_Map.resi index 78dd3482db0..2ff36890c4e 100644 --- a/packages/@rescript/belt/src/Belt_Map.resi +++ b/packages/@rescript/belt/src/Belt_Map.resi @@ -90,6 +90,7 @@ let has: (t<'k, 'v, 'id>, 'k) => bool @deprecated("Use `cmp` instead") let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int + /** `cmp(m0, m1, vcmp);` @@ -101,6 +102,7 @@ let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => int) => int @deprecated("Use `eq` instead") let eqU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool + /** eq(m1, m2, veq)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `veq` is the @@ -110,6 +112,7 @@ let eq: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ('v, 'v) => bool) => bool @deprecated("Use `findFirstBy` instead") let findFirstByU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> + /** ` findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. @@ -130,6 +133,7 @@ let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> @deprecated("Use `forEach` instead") let forEachU: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit + /** `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The @@ -157,6 +161,7 @@ let forEach: (t<'k, 'v, 'id>, ('k, 'v) => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc + /** `reduce(m, a, f)` computes `(f(kN, dN) ... (f(k1, d1, a))...)`, where `k1 ... kN` are the keys of all bindings in m (in increasing order), and `d1 @@ -180,6 +185,7 @@ let reduce: (t<'k, 'v, 'id>, 'acc, ('acc, 'k, 'v) => 'acc) => 'acc @deprecated("Use `every` instead") let everyU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool + /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified @@ -188,6 +194,7 @@ let every: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool @deprecated("Use `some` instead") let someU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => bool + /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified */ @@ -407,6 +414,7 @@ let set: (t<'k, 'v, 'id>, 'k, 'v) => t<'k, 'v, 'id> @deprecated("Use `update` instead") let updateU: (t<'k, 'v, 'id>, 'k, option<'v> => option<'v>) => t<'k, 'v, 'id> + /** `update(m, x, f)` returns a map containing the same bindings as `m`, except for the binding of `x`. Depending on the value of `y` where `y` is @@ -430,6 +438,7 @@ let mergeU: ( t<'k, 'v2, 'id>, ('k, option<'v>, option<'v2>) => option<'v3>, ) => t<'k, 'v3, 'id> + /** `merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding @@ -443,6 +452,7 @@ let merge: ( @deprecated("Use `keep` instead") let keepU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id> + /** `keep(m, p)` returns the map with all the bindings in m that satisfy predicate `p`. @@ -451,6 +461,7 @@ let keep: (t<'k, 'v, 'id>, ('k, 'v) => bool) => t<'k, 'v, 'id> @deprecated("Use `partition` instead") let partitionU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => (t<'k, 'v, 'id>, t<'k, 'v, 'id>) + /** `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map @@ -469,6 +480,7 @@ let split: (t<'k, 'v, 'id>, 'k) => ((t<'k, 'v, 'id>, t<'k, 'v, 'id>), option<'v> @deprecated("Use `map` instead") let mapU: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id> + /** `map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the application of `f` @@ -479,6 +491,7 @@ let map: (t<'k, 'v, 'id>, 'v => 'v2) => t<'k, 'v2, 'id> @deprecated("Use `mapWithKey` instead") let mapWithKeyU: (t<'k, 'v, 'id>, ('k, 'v) => 'v2) => t<'k, 'v2, 'id> + /** `mapWithKey(m, f)` diff --git a/packages/@rescript/belt/src/Belt_MapDict.res b/packages/@rescript/belt/src/Belt_MapDict.res index ea2b5b4997d..0fc99292c99 100644 --- a/packages/@rescript/belt/src/Belt_MapDict.res +++ b/packages/@rescript/belt/src/Belt_MapDict.res @@ -45,6 +45,7 @@ let map = N.map let keep = N.keepShared let partition = N.partitionShared let checkInvariantInternal = N.checkInvariantInternal + let rec set = (t: t<_>, newK, newD, ~cmp) => switch t { | None => N.singleton(newK, newD) diff --git a/packages/@rescript/belt/src/Belt_MapDict.resi b/packages/@rescript/belt/src/Belt_MapDict.resi index a9b50a30f80..22d08d1ff6b 100644 --- a/packages/@rescript/belt/src/Belt_MapDict.resi +++ b/packages/@rescript/belt/src/Belt_MapDict.resi @@ -33,10 +33,12 @@ let has: (t<'k, 'a, 'id>, 'k, ~cmp: cmp<'k, 'id>) => bool @deprecated("Use `cmp` instead") let cmpU: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int + let cmp: (t<'k, 'v, 'id>, t<'k, 'v, 'id>, ~kcmp: cmp<'k, 'id>, ~vcmp: ('v, 'v) => int) => int @deprecated("Use `eq` instead") let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => bool) => bool + /** `eq(m1, m2, cmp)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `cmp` is the @@ -46,6 +48,7 @@ let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ~kcmp: cmp<'k, 'id>, ~veq: ('a, 'a) => @deprecated("Use `findFirstBy` instead") let findFirstByU: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> + /** `findFirstBy(m, p)` uses function `f` to find the first key value pair to match predicate `p`. @@ -67,6 +70,7 @@ let findFirstBy: (t<'k, 'v, 'id>, ('k, 'v) => bool) => option<('k, 'v)> @deprecated("Use `forEach` instead") let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit + /** `forEach(m, f)` applies `f` to all bindings in map `m`. `f` receives the key as first argument, and the associated value as second argument. The @@ -77,6 +81,7 @@ let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b + /** `reduce(m, a, f)` computes `f(kN, dN ... f(k1, d1, a)...)`, where `k1 ... kN` are the keys of all bindings in `m` (in increasing order), and `d1 ... dN` @@ -86,6 +91,7 @@ let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b @deprecated("Use `every` instead") let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool + /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. Order unspecified @@ -94,6 +100,7 @@ let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool @deprecated("Use `some` instead") let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool + /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. Order unspecified @@ -148,6 +155,7 @@ let set: (t<'a, 'b, 'id>, 'a, 'b, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> @deprecated("Use `update` instead") let updateU: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> + let update: (t<'a, 'b, 'id>, 'a, option<'b> => option<'b>, ~cmp: cmp<'a, 'id>) => t<'a, 'b, 'id> @deprecated("Use `merge` instead") @@ -157,6 +165,7 @@ let mergeU: ( ('a, option<'b>, option<'c>) => option<'d>, ~cmp: cmp<'a, 'id>, ) => t<'a, 'd, 'id> + /** `merge(m1, m2, f)` computes a map whose keys is a subset of keys of `m1` and of `m2`. The presence of each such binding, and the corresponding @@ -173,6 +182,7 @@ let mergeMany: (t<'a, 'b, 'id>, array<('a, 'b)>, ~cmp: cmp<'a, 'id>) => t<'a, 'b @deprecated("Use `keep` instead") let keepU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id> + /** `keep(m, p)` returns the map with all the bindings in `m` that satisfy predicate `p`. @@ -181,6 +191,7 @@ let keep: (t<'k, 'a, 'id>, ('k, 'a) => bool) => t<'k, 'a, 'id> @deprecated("Use `partition` instead") let partitionU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => (t<'k, 'a, 'id>, t<'k, 'a, 'id>) + /** `partition(m, p)` returns a pair of maps `(m1, m2)`, where `m1` contains all the bindings of `s` that satisfy the predicate `p`, and `m2` is the map @@ -203,6 +214,7 @@ let split: ( @deprecated("Use `map` instead") let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> + /** `map(m, f)` returns a map with same domain as `m`, where the associated value `a` of all bindings of `m` has been replaced by the result of the @@ -213,4 +225,5 @@ let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> @deprecated("Use `mapWithKey` instead") let mapWithKeyU: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> + let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> diff --git a/packages/@rescript/belt/src/Belt_MapInt.resi b/packages/@rescript/belt/src/Belt_MapInt.resi index 42b2e1de683..da86440d10c 100644 --- a/packages/@rescript/belt/src/Belt_MapInt.resi +++ b/packages/@rescript/belt/src/Belt_MapInt.resi @@ -11,6 +11,7 @@ let has: (t<'v>, key) => bool @deprecated("Use `cmp` instead") let cmpU: (t<'v>, t<'v>, ('v, 'v) => int) => int + let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int @deprecated("Use `eq` instead") @@ -126,6 +127,7 @@ let set: (t<'v>, key, 'v) => t<'v> @deprecated("Use `update` instead") let updateU: (t<'v>, key, option<'v> => option<'v>) => t<'v> + let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> @deprecated("Use `merge` instead") @@ -180,4 +182,5 @@ let map: (t<'v>, 'v => 'v2) => t<'v2> @deprecated("Use `mapWithKey` instead") let mapWithKeyU: (t<'v>, (key, 'v) => 'v2) => t<'v2> + let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> diff --git a/packages/@rescript/belt/src/Belt_MapString.resi b/packages/@rescript/belt/src/Belt_MapString.resi index 0469496376e..c4fed2ad113 100644 --- a/packages/@rescript/belt/src/Belt_MapString.resi +++ b/packages/@rescript/belt/src/Belt_MapString.resi @@ -11,6 +11,7 @@ let has: (t<'v>, key) => bool @deprecated("Use `cmp` instead") let cmpU: (t<'v>, t<'v>, ('v, 'v) => int) => int + let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int @deprecated("Use `eq` instead") @@ -126,6 +127,7 @@ let set: (t<'v>, key, 'v) => t<'v> @deprecated("Use `update` instead") let updateU: (t<'v>, key, option<'v> => option<'v>) => t<'v> + let update: (t<'v>, key, option<'v> => option<'v>) => t<'v> @deprecated("Use `merge` instead") @@ -180,4 +182,5 @@ let map: (t<'v>, 'v => 'v2) => t<'v2> @deprecated("Use `mapWithKey` instead") let mapWithKeyU: (t<'v>, (key, 'v) => 'v2) => t<'v2> + let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2> diff --git a/packages/@rescript/belt/src/Belt_MutableMap.res b/packages/@rescript/belt/src/Belt_MutableMap.res index 2ad66f79be4..99f3664488a 100644 --- a/packages/@rescript/belt/src/Belt_MutableMap.res +++ b/packages/@rescript/belt/src/Belt_MutableMap.res @@ -118,6 +118,7 @@ let rec updateDone = (t, x, f, ~cmp) => Some(N.balMutate(nt)) } } + let update = (t, x, f) => { let oldRoot = t.data let newRoot = updateDone(oldRoot, x, f, ~cmp=t.cmp) diff --git a/packages/@rescript/belt/src/Belt_MutableMap.resi b/packages/@rescript/belt/src/Belt_MutableMap.resi index 106d7ac9e8c..8b48c48a88e 100644 --- a/packages/@rescript/belt/src/Belt_MutableMap.resi +++ b/packages/@rescript/belt/src/Belt_MutableMap.resi @@ -33,6 +33,7 @@ let has: (t<'k, _, _>, 'k) => bool @deprecated("Use `cmp` instead") let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int + /** `cmp(m1, m2, cmp)` First compare by size, if size is the same, compare by key, value pair. @@ -41,6 +42,7 @@ let cmp: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int @deprecated("Use `eq` instead") let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool + /** `eq(m1, m2, eqf)` tests whether the maps `m1` and `m2` are equal, that is, contain equal keys and associate them with equal data. `eqf` is the @@ -50,6 +52,7 @@ let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool @deprecated("Use `forEach` instead") let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit + /** `forEach(m, f)` applies f to all bindings in map `m`. `f` receives the `'k` as first argument, and the associated value as second argument. The @@ -60,6 +63,7 @@ let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit @deprecated("Use `reduce` instead") let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b + /** `reduce(m, a, f), computes`(f(kN, dN) ... (f(k1, d1, a))...)`, where`k1 ... kN`are the keys of all bindings in`m`(in increasing order), and`d1 ... dN` @@ -69,6 +73,7 @@ let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b @deprecated("Use `every` instead") let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool + /** `every(m, p)` checks if all the bindings of the map satisfy the predicate `p`. */ @@ -76,6 +81,7 @@ let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool @deprecated("Use `some` instead") let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool + /** `some(m, p)` checks if at least one binding of the map satisfy the predicate `p`. */ @@ -99,6 +105,7 @@ let get: (t<'k, 'a, 'id>, 'k) => option<'a> let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a let getExn: (t<'k, 'a, 'id>, 'k) => 'a let getOrThrow: (t<'k, 'a, 'id>, 'k) => 'a + /** Throw when invariant is not held. */ let checkInvariantInternal: t<_> => unit @@ -116,12 +123,14 @@ let set: (t<'k, 'a, 'id>, 'k, 'a) => unit @deprecated("Use `update` instead") let updateU: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit + let update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit let mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unit @deprecated("Use `map` instead") let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> + /** `map(m, f)` returns a map with same domain as `m`, where the associated value a of all bindings of `m` has been replaced by the result of the @@ -132,4 +141,5 @@ let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id> @deprecated("Use `mapWithKey` instead") let mapWithKeyU: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> + let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id> diff --git a/packages/@rescript/belt/src/Belt_MutableMapInt.resi b/packages/@rescript/belt/src/Belt_MutableMapInt.resi index cc588d991c3..d2a68170910 100644 --- a/packages/@rescript/belt/src/Belt_MutableMapInt.resi +++ b/packages/@rescript/belt/src/Belt_MutableMapInt.resi @@ -107,6 +107,7 @@ let set: (t<'a>, key, 'a) => unit @deprecated("Use `update` instead") let updateU: (t<'a>, key, option<'a> => option<'a>) => unit + let update: (t<'a>, key, option<'a> => option<'a>) => unit @deprecated("Use `map` instead") @@ -121,4 +122,5 @@ let map: (t<'a>, 'a => 'b) => t<'b> @deprecated("Use `mapWithKey` instead") let mapWithKeyU: (t<'a>, (key, 'a) => 'b) => t<'b> + let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> diff --git a/packages/@rescript/belt/src/Belt_MutableMapString.resi b/packages/@rescript/belt/src/Belt_MutableMapString.resi index 921c52c24b2..b221010f967 100644 --- a/packages/@rescript/belt/src/Belt_MutableMapString.resi +++ b/packages/@rescript/belt/src/Belt_MutableMapString.resi @@ -107,6 +107,7 @@ let set: (t<'a>, key, 'a) => unit @deprecated("Use `update` instead") let updateU: (t<'a>, key, option<'a> => option<'a>) => unit + let update: (t<'a>, key, option<'a> => option<'a>) => unit @deprecated("Use `map` instead") @@ -121,4 +122,5 @@ let map: (t<'a>, 'a => 'b) => t<'b> @deprecated("Use `mapWithKey` instead") let mapWithKeyU: (t<'a>, (key, 'a) => 'b) => t<'b> + let mapWithKey: (t<'a>, (key, 'a) => 'b) => t<'b> diff --git a/packages/@rescript/belt/src/Belt_MutableQueue.resi b/packages/@rescript/belt/src/Belt_MutableQueue.resi index d5f5dbefcae..fe5d8d38e36 100644 --- a/packages/@rescript/belt/src/Belt_MutableQueue.resi +++ b/packages/@rescript/belt/src/Belt_MutableQueue.resi @@ -80,7 +80,9 @@ let size: t<'a> => int @deprecated("Use `map` instead") let mapU: (t<'a>, 'a => 'b) => t<'b> + let map: (t<'a>, 'a => 'b) => t<'b> + @deprecated("Use `forEach` instead") let forEachU: (t<'a>, 'a => unit) => unit diff --git a/packages/@rescript/belt/src/Belt_MutableSet.resi b/packages/@rescript/belt/src/Belt_MutableSet.resi index a8b31510864..d4c12d19bfa 100644 --- a/packages/@rescript/belt/src/Belt_MutableSet.resi +++ b/packages/@rescript/belt/src/Belt_MutableSet.resi @@ -195,6 +195,7 @@ s0->Belt.MutableSet.toArray == [2, 4, 5] let remove: (t<'value, 'id>, 'value) => unit let removeCheck: (t<'value, 'id>, 'value) => bool + /* `b = removeCheck s e` `b` is true means one element removed */ /** diff --git a/packages/@rescript/belt/src/Belt_MutableSetInt.res b/packages/@rescript/belt/src/Belt_MutableSetInt.res index 01b0feac7f5..fde18573bab 100644 --- a/packages/@rescript/belt/src/Belt_MutableSetInt.res +++ b/packages/@rescript/belt/src/Belt_MutableSetInt.res @@ -232,6 +232,7 @@ let partition = (d, p) => { } let subset = (a, b) => I.subset(a.data, b.data) + let intersect = (dataa, datab) => { let (dataa, datab) = (dataa.data, datab.data) switch (dataa, datab) { diff --git a/packages/@rescript/belt/src/Belt_MutableSetString.res b/packages/@rescript/belt/src/Belt_MutableSetString.res index 27557a4e28f..9b71a4bf792 100644 --- a/packages/@rescript/belt/src/Belt_MutableSetString.res +++ b/packages/@rescript/belt/src/Belt_MutableSetString.res @@ -232,6 +232,7 @@ let partition = (d, p) => { } let subset = (a, b) => I.subset(a.data, b.data) + let intersect = (dataa, datab) => { let (dataa, datab) = (dataa.data, datab.data) switch (dataa, datab) { diff --git a/packages/@rescript/belt/src/Belt_MutableStack.resi b/packages/@rescript/belt/src/Belt_MutableStack.resi index 33ba0017236..984020d5f3e 100644 --- a/packages/@rescript/belt/src/Belt_MutableStack.resi +++ b/packages/@rescript/belt/src/Belt_MutableStack.resi @@ -32,9 +32,12 @@ let popOrThrow: t<'a> => 'a let top: t<'a> => option<'a> let isEmpty: t<'a> => bool let size: t<'a> => int + @deprecated("Use `forEach` instead") let forEachU: (t<'a>, 'a => unit) => unit + let forEach: (t<'a>, 'a => unit) => unit + @deprecated("Use `dynamicPopIter` instead") let dynamicPopIterU: (t<'a>, 'a => unit) => unit diff --git a/packages/@rescript/belt/src/Belt_Result.resi b/packages/@rescript/belt/src/Belt_Result.resi index 8bb7bde1bfb..faf0b18593d 100644 --- a/packages/@rescript/belt/src/Belt_Result.resi +++ b/packages/@rescript/belt/src/Belt_Result.resi @@ -51,6 +51,7 @@ let getOrThrow: t<'a, 'b> => 'a @deprecated("Use `mapWithDefault` instead") let mapWithDefaultU: (t<'a, 'c>, 'b, 'a => 'b) => 'b + /** `mapWithDefault(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, otherwise `default`. @@ -69,6 +70,7 @@ let mapWithDefault: (t<'a, 'c>, 'b, 'a => 'b) => 'b @deprecated("Use `map` instead") let mapU: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> + /** `map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res unchanged. Function `f` takes a value of the same type as `n` and returns an @@ -88,6 +90,7 @@ let map: (t<'a, 'c>, 'a => 'b) => t<'b, 'c> @deprecated("Use `flatMap` instead") let flatMapU: (t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c> + /** `flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res unchanged. Function `f` takes a value of the same type as `n` and returns a @@ -140,6 +143,7 @@ let isError: t<'a, 'b> => bool @deprecated("Use `eq` instead") let eqU: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool + /** `eq(res1, res2, f)`: Determine if two `Belt.Result` variables are equal with respect to an equality function. If `res1` and `res2` are of the form `Ok(n)` @@ -173,6 +177,7 @@ let eq: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => bool) => bool @deprecated("Use `cmp` instead") let cmpU: (t<'a, 'c>, t<'b, 'd>, ('a, 'b) => int) => int + /** `cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a comparison function. The comparison function returns -1 if the first variable diff --git a/packages/@rescript/belt/src/Belt_SortArray.resi b/packages/@rescript/belt/src/Belt_SortArray.resi index 96c92675555..29ced46529c 100644 --- a/packages/@rescript/belt/src/Belt_SortArray.resi +++ b/packages/@rescript/belt/src/Belt_SortArray.resi @@ -40,6 +40,7 @@ let strictlySortedLength: (array<'a>, ('a, 'a) => bool) => int @deprecated("Use `isSorted` instead") let isSortedU: (array<'a>, ('a, 'a) => int) => bool + /** `isSorted(arr, cmp)`: Returns true if array is increasingly sorted (equal is okay) */ @@ -47,10 +48,12 @@ let isSorted: (array<'a>, ('a, 'a) => int) => bool @deprecated("Use `stableSortInPlaceBy` instead") let stableSortInPlaceByU: (array<'a>, ('a, 'a) => int) => unit + let stableSortInPlaceBy: (array<'a>, ('a, 'a) => int) => unit @deprecated("Use `stableSortBy` instead") let stableSortByU: (array<'a>, ('a, 'a) => int) => array<'a> + /** `stableSortBy(xs, cmp)`: Returns a fresh array Sort `xs` in place using comparator `cmp`, the stable means if the elements are equal, their order will @@ -84,6 +87,7 @@ let binarySearchBy: (array<'a>, 'a, ('a, 'a) => int) => int @deprecated("Use `union` instead") let unionU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int + /** `union src src1ofs src1len src2 src2ofs src2len dst dstofs cmp` assume `src` and `src2` is strictly sorted. for equivalent elements, it is picked from `src` @@ -93,6 +97,7 @@ let union: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) = @deprecated("Use `intersect` instead") let intersectU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int + /** `union src src1ofs src1len src2 src2ofs src2len dst dstofs cmp` @@ -102,4 +107,5 @@ let intersect: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, ' @deprecated("Use `diff` instead") let diffU: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int + let diff: (array<'a>, int, int, array<'a>, int, int, array<'a>, int, ('a, 'a) => int) => int diff --git a/packages/@rescript/belt/src/Belt_internalAVLset.res b/packages/@rescript/belt/src/Belt_internalAVLset.res index 1d11d4cda43..bb924b5803f 100644 --- a/packages/@rescript/belt/src/Belt_internalAVLset.res +++ b/packages/@rescript/belt/src/Belt_internalAVLset.res @@ -4,6 +4,7 @@ * SPDX-License-Identifier: MIT */ @@config({flags: ["-bs-noassertfalse"]}) + type rec node<'value> = { @as("v") mutable value: 'value, @as("h") mutable height: int, @@ -66,6 +67,7 @@ let heightGe = (l, r) => | (Some(hl), Some(hr)) => hl.height >= hr.height | (None, Some(_)) => false } + /* Same as create, but performs one step of rebalancing if necessary. Assumes l and r balanced and | treeHeight l - treeHeight r | <= 3. Inline expansion of create for better speed in the most frequent case @@ -575,6 +577,7 @@ let rotateWithLeftChild = k2 => k1.height = Pervasives.max(hlk1, hk2) + 1 k1 } + /* right rotation */ let rotateWithRightChild = k1 => switch k1.right { diff --git a/packages/@rescript/belt/src/Belt_internalAVLset.resi b/packages/@rescript/belt/src/Belt_internalAVLset.resi index 3703c0f31ec..e9ce7c88b1c 100644 --- a/packages/@rescript/belt/src/Belt_internalAVLset.resi +++ b/packages/@rescript/belt/src/Belt_internalAVLset.resi @@ -80,6 +80,7 @@ let fromArray: (array<'a>, ~cmp: cmp<'a, 'b>) => t<'a> let addMutate: (~cmp: cmp<'a, 'b>, t<'a>, 'a) => t<'a> let balMutate: node<'a> => node<'a> + /** `removeMinAuxWithRootMutate(root, n)` remove the minimum of n in place and store its value in the `key root` diff --git a/packages/@rescript/belt/src/Belt_internalAVLtree.res b/packages/@rescript/belt/src/Belt_internalAVLtree.res index 80f3ded37c1..1b4254f46b7 100644 --- a/packages/@rescript/belt/src/Belt_internalAVLtree.res +++ b/packages/@rescript/belt/src/Belt_internalAVLtree.res @@ -7,6 +7,7 @@ /* Almost rewritten by authors of ReScript */ @@config({flags: ["-bs-noassertfalse"]}) + type rec node<'k, 'v> = { @as("k") mutable key: 'k, @as("v") mutable value: 'v, @@ -264,6 +265,7 @@ let rec some = (n, p) => | None => false | Some(n) => p(n.key, n.value) || (some(n.left, p) || some(n.right, p)) } + /* Beware: those two functions assume that the added k is *strictly* smaller (or bigger) than all the present keys in the tree; it does not test for equality with the current min (or max) key. @@ -737,6 +739,7 @@ let rotateWithLeftChild = k2 => k1.height = Pervasives.max(hlk1, hk2) + 1 k1 } + /* right rotation */ let rotateWithRightChild = k1 => switch k1.right { diff --git a/packages/@rescript/belt/src/Belt_internalAVLtree.resi b/packages/@rescript/belt/src/Belt_internalAVLtree.resi index c204c8db792..7fccf7020e9 100644 --- a/packages/@rescript/belt/src/Belt_internalAVLtree.resi +++ b/packages/@rescript/belt/src/Belt_internalAVLtree.resi @@ -69,6 +69,7 @@ let lengthNode: node<'a, 'b> => int let size: t<'a, 'b> => int let toList: t<'a, 'b> => list<('a, 'b)> + /** **throw** when invariant is not held */ diff --git a/packages/@rescript/belt/src/Belt_internalBuckets.res b/packages/@rescript/belt/src/Belt_internalBuckets.res index 373385c8f35..e4823764db5 100644 --- a/packages/@rescript/belt/src/Belt_internalBuckets.res +++ b/packages/@rescript/belt/src/Belt_internalBuckets.res @@ -13,6 +13,7 @@ /* We do dynamic hashing, and resize the table and rehash the elements when buckets become too long. */ module C = Belt_internalBucketsType + /* TODO: the current implementation relies on the fact that bucket empty value is `undefined` in both places, diff --git a/packages/@rescript/belt/src/Belt_internalBucketsType.res b/packages/@rescript/belt/src/Belt_internalBucketsType.res index 6e9b5818eb4..02bbc33351d 100644 --- a/packages/@rescript/belt/src/Belt_internalBucketsType.res +++ b/packages/@rescript/belt/src/Belt_internalBucketsType.res @@ -17,6 +17,7 @@ external toOpt: opt<'a> => option<'a> = "%identity" external return: 'a => opt<'a> = "%identity" let emptyOpt = Primitive_js_extern.undefined + let rec power_2_above = (x, n) => if x >= n { x diff --git a/packages/@rescript/belt/src/Belt_internalBucketsType.resi b/packages/@rescript/belt/src/Belt_internalBucketsType.resi index b0092639ea1..a688ce4ad8d 100644 --- a/packages/@rescript/belt/src/Belt_internalBucketsType.resi +++ b/packages/@rescript/belt/src/Belt_internalBucketsType.resi @@ -5,6 +5,7 @@ */ type opt<'a> = Primitive_js_extern.undefined<'a> + type container<'hash, 'eq, 'c> = { mutable size: int /* number of entries */, mutable buckets: array> /* the buckets */, diff --git a/packages/@rescript/belt/src/Belt_internalSetBuckets.res b/packages/@rescript/belt/src/Belt_internalSetBuckets.res index 5be597e040c..68d7f40b921 100644 --- a/packages/@rescript/belt/src/Belt_internalSetBuckets.res +++ b/packages/@rescript/belt/src/Belt_internalSetBuckets.res @@ -7,6 +7,7 @@ /* We do dynamic hashing, and resize the table and rehash the elements when buckets become too long. */ module C = Belt_internalBucketsType + /* TODO: the current implementation relies on the fact that bucket empty value is `undefined` in both places, diff --git a/packages/@rescript/runtime/Dom.res b/packages/@rescript/runtime/Dom.res index 3667459e78b..b3d092f6ad3 100644 --- a/packages/@rescript/runtime/Dom.res +++ b/packages/@rescript/runtime/Dom.res @@ -281,6 +281,7 @@ type domSettableTokenList type nodeFilter = { acceptNode: element => int /* return type should be NodeFilter.action, but that would create a cycle */, } + type nodeIterator type treeWalker diff --git a/packages/@rescript/runtime/JsxDOM.res b/packages/@rescript/runtime/JsxDOM.res index de9d04575ee..e9c76c8973e 100644 --- a/packages/@rescript/runtime/JsxDOM.res +++ b/packages/@rescript/runtime/JsxDOM.res @@ -6,10 +6,12 @@ type style = JsxDOMStyle.t type domRef + /** [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover) */ type popover = | @as("auto") Auto | @as("manual") Manual | @as("hint") Hint + /** [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#popovertargetaction) */ diff --git a/packages/@rescript/runtime/Primitive_object.res b/packages/@rescript/runtime/Primitive_object.res index 6e87a714042..e254bb60ac8 100644 --- a/packages/@rescript/runtime/Primitive_object.res +++ b/packages/@rescript/runtime/Primitive_object.res @@ -19,6 +19,7 @@ let typeof = Primitive_js_extern.typeof module O = { @val external isArray: 'a => bool = "Array.isArray" type key = string + let for_in: (t, key => unit) => unit = %raw(`function(o,foo){ for (var x in o) { foo(x) }} `) diff --git a/packages/@rescript/runtime/Stdlib.res b/packages/@rescript/runtime/Stdlib.res index c9eca2b2138..471c34e546f 100644 --- a/packages/@rescript/runtime/Stdlib.res +++ b/packages/@rescript/runtime/Stdlib.res @@ -169,6 +169,7 @@ null->Nullable.toOption == None ``` */ external null: nullable<'a> = "#null" + /** `undefined` returns the JavaScript `undefined` value as a `nullable<'a>`. Use the `Nullable` helpers to convert it into an `option` or to read the value. @@ -180,6 +181,7 @@ undefined->Nullable.toOption == None ``` */ external undefined: nullable<'a> = "#undefined" + /** `typeof(value)` exposes JavaScript's `typeof` operator and returns a `Type.t` enum. It helps you inspect values that come from JavaScript APIs. diff --git a/packages/@rescript/runtime/Stdlib_Array.res b/packages/@rescript/runtime/Stdlib_Array.res index 91f393ea304..c3678811580 100644 --- a/packages/@rescript/runtime/Stdlib_Array.res +++ b/packages/@rescript/runtime/Stdlib_Array.res @@ -10,7 +10,9 @@ external asIterable: array<'a> => Stdlib_Iterable.t<'a> = "%identity" @val external fromIterable: Stdlib_Iterable.t<'a> => array<'a> = "Array.from" + @val external fromArrayLike: arrayLike<'a> => array<'a> = "Array.from" + @val external fromArrayLikeWithMap: (arrayLike<'a>, 'a => 'b) => array<'b> = "Array.from" @@ -100,6 +102,7 @@ external copyWithin: (array<'a>, ~target: int, ~start: int, ~end: int=?) => arra @variadic @send external splice: (array<'a>, ~start: int, ~remove: int, ~insert: array<'a>) => unit = "splice" + @variadic @send external toSpliced: (array<'a>, ~start: int, ~remove: int, ~insert: array<'a>) => array<'a> = "toSpliced" @@ -122,6 +125,7 @@ let concatAll = arrays => concatMany([], arrays) @send external includes: (array<'a>, 'a) => bool = "includes" @send external indexOf: (array<'a>, 'a, ~from: int=?) => int = "indexOf" + let indexOfOpt = (arr, item) => switch arr->indexOf(item) { | -1 => None @@ -133,6 +137,7 @@ let indexOfOpt = (arr, item) => @send external joinUnsafe: (array<'a>, string) => string = "join" @send external lastIndexOf: (array<'a>, 'a, ~from: int=?) => int = "lastIndexOf" + let lastIndexOfOpt = (arr, item) => switch arr->lastIndexOf(item) { | -1 => None @@ -177,11 +182,15 @@ let lastIndexOfOpt = (arr, item) => let reduce = (arr, init, f) => reduce(arr, f, init) @send external reduceWithIndex: (array<'b>, ('a, 'b, int) => 'a, 'a) => 'a = "reduce" let reduceWithIndex = (arr, init, f) => reduceWithIndex(arr, f, init) + @send external reduceRight: (array<'b>, ('a, 'b) => 'a, 'a) => 'a = "reduceRight" + let reduceRight = (arr, init, f) => reduceRight(arr, f, init) + @send external reduceRightWithIndex: (array<'b>, ('a, 'b, int) => 'a, 'a) => 'a = "reduceRight" + let reduceRightWithIndex = (arr, init, f) => reduceRightWithIndex(arr, f, init) @send external some: (array<'a>, 'a => bool) => bool = "some" diff --git a/packages/@rescript/runtime/Stdlib_Array.resi b/packages/@rescript/runtime/Stdlib_Array.resi index 6c6769807cf..3613709935c 100644 --- a/packages/@rescript/runtime/Stdlib_Array.resi +++ b/packages/@rescript/runtime/Stdlib_Array.resi @@ -625,6 +625,7 @@ See [`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScrip ``` */ @send external lastIndexOf: (array<'a>, 'a, ~from: int=?) => int = "lastIndexOf" + let lastIndexOfOpt: (array<'a>, 'a) => option /** @@ -1118,6 +1119,7 @@ array[1] == Some("Hello") */ @set_index external set: (array<'a>, int, 'a) => unit = "" + /** `getSymbol(array, key)` retrieves the value stored under the symbol `key`, if present. diff --git a/packages/@rescript/runtime/Stdlib_AsyncGenerator.res b/packages/@rescript/runtime/Stdlib_AsyncGenerator.res index 440ed4b4f20..6e1e6be10d7 100644 --- a/packages/@rescript/runtime/Stdlib_AsyncGenerator.res +++ b/packages/@rescript/runtime/Stdlib_AsyncGenerator.res @@ -1,11 +1,13 @@ type t<+'yield, +'return, -'next> = Stdlib_AsyncIterable.t<'yield> external asAsyncIterable: t<'yield, 'return, 'next> => Stdlib_AsyncIterable.t<'yield> = "%identity" + external asAsyncIterableIterator: t<'yield, 'return, 'next> => Stdlib_AsyncIterableIterator.t< 'yield, 'return, 'next, > = "%identity" + external asAsyncIterator: t<'yield, 'return, 'next> => Stdlib_AsyncIterator.t< 'yield, 'return, diff --git a/packages/@rescript/runtime/Stdlib_AsyncIterableIterator.res b/packages/@rescript/runtime/Stdlib_AsyncIterableIterator.res index 3b36a2c0cf0..029452cc470 100644 --- a/packages/@rescript/runtime/Stdlib_AsyncIterableIterator.res +++ b/packages/@rescript/runtime/Stdlib_AsyncIterableIterator.res @@ -14,6 +14,7 @@ let make: (unit => promise>) => t< }`) external asAsyncIterable: t<'yield, 'return, 'next> => Stdlib_AsyncIterable.t<'yield> = "%identity" + external asAsyncIterator: t<'yield, 'return, 'next> => Stdlib_AsyncIterator.t< 'yield, 'return, diff --git a/packages/@rescript/runtime/Stdlib_Console.res b/packages/@rescript/runtime/Stdlib_Console.res index 465f520e78e..1eaab9b99fa 100644 --- a/packages/@rescript/runtime/Stdlib_Console.res +++ b/packages/@rescript/runtime/Stdlib_Console.res @@ -24,6 +24,7 @@ type dirOptions = { depth?: Stdlib_Nullable.t, showHidden?: bool, } + @val external dir: ('a, ~options: dirOptions=?) => unit = "console.dir" @val external dirxml: 'a => unit = "console.dirxml" diff --git a/packages/@rescript/runtime/Stdlib_Console.resi b/packages/@rescript/runtime/Stdlib_Console.resi index 0af09b17764..c78cfe8333c 100644 --- a/packages/@rescript/runtime/Stdlib_Console.resi +++ b/packages/@rescript/runtime/Stdlib_Console.resi @@ -247,6 +247,7 @@ type dirOptions = { depth?: Stdlib_Nullable.t, showHidden?: bool, } + /** `dir(object, options)` displays an interactive view of the object in the console. diff --git a/packages/@rescript/runtime/Stdlib_Date.res b/packages/@rescript/runtime/Stdlib_Date.res index 4d77a320fbb..7523193396c 100644 --- a/packages/@rescript/runtime/Stdlib_Date.res +++ b/packages/@rescript/runtime/Stdlib_Date.res @@ -24,9 +24,11 @@ type localeOptions = { @new external makeWithYM: (~year: int, ~month: int) => t = "Date" @new external makeWithYMD: (~year: int, ~month: int, ~day: int) => t = "Date" @new external makeWithYMDH: (~year: int, ~month: int, ~day: int, ~hours: int) => t = "Date" + @new external makeWithYMDHM: (~year: int, ~month: int, ~day: int, ~hours: int, ~minutes: int) => t = "Date" + @new external makeWithYMDHMS: ( ~year: int, @@ -36,6 +38,7 @@ external makeWithYMDHMS: ( ~minutes: int, ~seconds: int, ) => t = "Date" + @new external makeWithYMDHMSM: ( ~year: int, @@ -50,9 +53,11 @@ external makeWithYMDHMSM: ( module UTC = { @val external makeWithYM: (~year: int, ~month: int) => msSinceEpoch = "Date.UTC" @val external makeWithYMD: (~year: int, ~month: int, ~day: int) => msSinceEpoch = "Date.UTC" + @val external makeWithYMDH: (~year: int, ~month: int, ~day: int, ~hours: int) => msSinceEpoch = "Date.UTC" + @val external makeWithYMDHM: ( ~year: int, @@ -61,6 +66,7 @@ module UTC = { ~hours: int, ~minutes: int, ) => msSinceEpoch = "Date.UTC" + @val external makeWithYMDHMS: ( ~year: int, @@ -70,6 +76,7 @@ module UTC = { ~minutes: int, ~seconds: int, ) => msSinceEpoch = "Date.UTC" + @val external makeWithYMDHMSM: ( ~year: int, @@ -109,13 +116,17 @@ let compare = (a, b) => Stdlib_Float.compare(a->getTime, b->getTime) @send external setHours: (t, int) => unit = "setHours" @send external setHoursM: (t, ~hours: int, ~minutes: int) => unit = "setHours" @send external setHoursMS: (t, ~hours: int, ~minutes: int, ~seconds: int) => unit = "setHours" + @send external setHoursMSMs: (t, ~hours: int, ~minutes: int, ~seconds: int, ~milliseconds: int) => unit = "setHours" + @send external setMinutes: (t, int) => unit = "setMinutes" @send external setMinutesS: (t, ~minutes: int, ~seconds: int) => unit = "setMinutes" + @send external setMinutesSMs: (t, ~minutes: int, ~seconds: int, ~milliseconds: int) => unit = "setMinutes" + @send external setSeconds: (t, int) => unit = "setSeconds" @send external setSecondsMs: (t, ~seconds: int, ~milliseconds: int) => unit = "setSeconds" @send external setMilliseconds: (t, int) => unit = "setMilliseconds" @@ -132,14 +143,18 @@ external setMinutesSMs: (t, ~minutes: int, ~seconds: int, ~milliseconds: int) => @send external setUTCFullYear: (t, int) => unit = "setUTCFullYear" @send external setUTCFullYearM: (t, ~year: int, ~month: int) => unit = "setUTCFullYear" + @send external setUTCFullYearMD: (t, ~year: int, ~month: int, ~day: int) => unit = "setUTCFullYear" + @send external setUTCMonth: (t, int) => unit = "setUTCMonth" @send external setUTCDate: (t, int) => unit = "setUTCDate" @send external setUTCHours: (t, int) => unit = "setUTCHours" @send external setUTCHoursM: (t, ~hours: int, ~minutes: int) => unit = "setUTCHours" + @send external setUTCHoursMS: (t, ~hours: int, ~minutes: int, ~seconds: int) => unit = "setUTCHours" + @send external setUTCHoursMSMs: ( t, @@ -148,11 +163,14 @@ external setUTCHoursMSMs: ( ~seconds: int, ~milliseconds: int, ) => unit = "setUTCHours" + @send external setUTCMinutes: (t, int) => unit = "setUTCMinutes" @send external setUTCMinutesS: (t, ~minutes: int, ~seconds: int) => unit = "setUTCMinutes" + @send external setUTCMinutesSMs: (t, ~minutes: int, ~seconds: int, ~milliseconds: int) => unit = "setUTCMinutes" + @send external setUTCSeconds: (t, int) => unit = "setUTCSeconds" @send external setUTCSecondsMs: (t, ~seconds: int, ~milliseconds: int) => unit = "setUTCSeconds" @send external setUTCMilliseconds: (t, int) => unit = "setUTCMilliseconds" @@ -163,15 +181,20 @@ external setUTCMinutesSMs: (t, ~minutes: int, ~seconds: int, ~milliseconds: int) @send external toLocaleDateString: t => string = "toLocaleDateString" @send external toLocaleDateStringWithLocale: (t, string) => string = "toLocaleDateString" + @send external toLocaleDateStringWithLocaleAndOptions: (t, string, localeOptions) => string = "toLocaleDateString" + @send external toLocaleString: t => string = "toLocaleString" @send external toLocaleStringWithLocale: (t, string) => string = "toLocaleString" + @send external toLocaleStringWithLocaleAndOptions: (t, string, localeOptions) => string = "toLocaleString" + @send external toLocaleTimeString: t => string = "toLocaleTimeString" @send external toLocaleTimeStringWithLocale: (t, string) => string = "toLocaleTimeString" + @send external toLocaleTimeStringWithLocaleAndOptions: (t, string, localeOptions) => string = "toLocaleTimeString" diff --git a/packages/@rescript/runtime/Stdlib_Date.resi b/packages/@rescript/runtime/Stdlib_Date.resi index 1efa181161b..ab8be56965d 100644 --- a/packages/@rescript/runtime/Stdlib_Date.resi +++ b/packages/@rescript/runtime/Stdlib_Date.resi @@ -286,6 +286,7 @@ external makeWithYMDHMSM: ( ~seconds: int, ~milliseconds: int, ) => t = "Date" + module UTC: { /** Returns the time, in milliseconds, since UNIX epoch (January 1, 1970 00:00:00 UTC). diff --git a/packages/@rescript/runtime/Stdlib_Dict.res b/packages/@rescript/runtime/Stdlib_Dict.res index 04f1b56281a..ad2f3e77ef2 100644 --- a/packages/@rescript/runtime/Stdlib_Dict.res +++ b/packages/@rescript/runtime/Stdlib_Dict.res @@ -12,6 +12,7 @@ let delete = (dict, string) => { @obj external make: unit => dict<'a> = "" @val external fromArray: array<(string, 'a)> => dict<'a> = "Object.fromEntries" + @val external fromIterable: Stdlib_Iterable.t<(string, 'a)> => dict<'a> = "Object.fromEntries" diff --git a/packages/@rescript/runtime/Stdlib_Generator.res b/packages/@rescript/runtime/Stdlib_Generator.res index be7e6152067..e813261ff1c 100644 --- a/packages/@rescript/runtime/Stdlib_Generator.res +++ b/packages/@rescript/runtime/Stdlib_Generator.res @@ -2,7 +2,9 @@ type t<+'yield, +'return, -'next> = Stdlib_Iterable.t<'yield> external asIterator: t<'yield, 'return, 'next> => Stdlib_Iterator.t<'yield, 'return, 'next> = "%identity" + external asIterable: t<'yield, 'return, 'next> => Stdlib_Iterable.t<'yield> = "%identity" + external asIteratorObject: t<'yield, 'return, 'next> => Stdlib_IteratorObject.t< 'yield, 'return, diff --git a/packages/@rescript/runtime/Stdlib_Int.resi b/packages/@rescript/runtime/Stdlib_Int.resi index 0b95289be97..08677589157 100644 --- a/packages/@rescript/runtime/Stdlib_Int.resi +++ b/packages/@rescript/runtime/Stdlib_Int.resi @@ -28,6 +28,7 @@ on MDN. */ @inline let minValue: int + /** The largest positive number represented in JavaScript. See [`Number.MAX_VALUE`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE) diff --git a/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res b/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res index 94c8225d3f7..439e5064e37 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res +++ b/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res @@ -104,6 +104,7 @@ type dateTimePart = { } type dateTimeRangeSource = [#startRange | #shared | #endRange] + type dateTimeRangePart = { \"type": dateTimeComponent, value: string, diff --git a/packages/@rescript/runtime/Stdlib_Intl_ListFormat.res b/packages/@rescript/runtime/Stdlib_Intl_ListFormat.res index 03b4e45c584..e11161756e8 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_ListFormat.res +++ b/packages/@rescript/runtime/Stdlib_Intl_ListFormat.res @@ -6,6 +6,7 @@ type listType = [ | #disjunction | #unit ] + type style = [ | #long | #short diff --git a/packages/@rescript/runtime/Stdlib_Intl_NumberFormat.res b/packages/@rescript/runtime/Stdlib_Intl_NumberFormat.res index a26a3f8d128..148ecfd6152 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_NumberFormat.res +++ b/packages/@rescript/runtime/Stdlib_Intl_NumberFormat.res @@ -7,6 +7,7 @@ type t An ISO 4217 currency code. e.g. USD, EUR, CNY */ type currency = string + type currencyDisplay = [#symbol | #narrowSymbol | #code | #name] type currencySign = [#accounting | #standard] type notation = [#scientific | #standard | #engineering | #compact] @@ -219,6 +220,7 @@ formatter->Intl.NumberFormat.format(1234.5) == "1,234.5" ``` */ @send external format: (t, float) => string = "format" + /** `formatRange(formatter, ~start, ~end)` formats numbers representing a range. @@ -231,6 +233,7 @@ formatter->Intl.NumberFormat.formatRange(~start=1., ~end=2.)->String.length > 0 */ @send external formatRange: (t, ~start: float, ~end: float) => string = "formatRange" + /** `formatToParts(formatter, value)` breaks the formatted result into parts. @@ -243,6 +246,7 @@ formatter->Intl.NumberFormat.formatToParts(123)->Array.length > 0 */ @send external formatToParts: (t, float) => array = "formatToParts" + /** `formatRangeToParts(formatter, ~start, ~end)` returns how the range would be rendered. @@ -281,6 +285,7 @@ formatter->Intl.NumberFormat.formatIntRange(~start=1, ~end=3)->String.length > 0 */ @send external formatIntRange: (t, ~start: int, ~end: int) => string = "formatRange" + /** `formatIntToParts(formatter, value)` returns formatting parts for an integer. @@ -325,6 +330,7 @@ formatter->Intl.NumberFormat.formatBigIntRange(~start=1n, ~end=2n) == "1–2" */ @send external formatBigIntRange: (t, ~start: bigint, ~end: bigint) => string = "formatRange" + /** `formatBigIntToParts(formatter, value)` returns the bigint formatting broken into parts. diff --git a/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res b/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res index 6503c224111..47d72a5fb67 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res +++ b/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res @@ -3,6 +3,7 @@ Represents the `useGrouping` option accepted by `Intl.NumberFormat`. See [`Intl.NumberFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) on MDN for full option details. */ + @notUndefined type t @@ -23,6 +24,7 @@ formatter->Intl.NumberFormat.format(1234.) == "1234" ``` */ external fromBool: bool => t = "%identity" + /** Constructs a grouping setting from a string literal. diff --git a/packages/@rescript/runtime/Stdlib_Intl_PluralRules.res b/packages/@rescript/runtime/Stdlib_Intl_PluralRules.res index 688ad7f1b2b..23a1e11a93c 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_PluralRules.res +++ b/packages/@rescript/runtime/Stdlib_Intl_PluralRules.res @@ -94,6 +94,7 @@ rules->Intl.PluralRules.select(1.) == #one ``` */ @send external select: (t, float) => rule = "select" + /** `selectInt(rules, value)` is like `select` but accepts an integer. diff --git a/packages/@rescript/runtime/Stdlib_Intl_RelativeTimeFormat.res b/packages/@rescript/runtime/Stdlib_Intl_RelativeTimeFormat.res index 5d1da8af913..9e64b545775 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_RelativeTimeFormat.res +++ b/packages/@rescript/runtime/Stdlib_Intl_RelativeTimeFormat.res @@ -3,6 +3,7 @@ Bindings to JavaScript's `Intl.RelativeTimeFormat`. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat) for API details. */ + @instanceOf("Intl.RelativeTimeFormat") type t @@ -26,6 +27,7 @@ type resolvedOptions = { } type relativeTimePartComponent = [#literal | #integer] + type relativeTimePart = { \"type": relativeTimePartComponent, value: string, diff --git a/packages/@rescript/runtime/Stdlib_Intl_Segmenter.res b/packages/@rescript/runtime/Stdlib_Intl_Segmenter.res index 63a14731fe0..a0256f75c5a 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_Segmenter.res +++ b/packages/@rescript/runtime/Stdlib_Intl_Segmenter.res @@ -3,6 +3,7 @@ Bindings to JavaScript's `Intl.Segmenter`. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) for API details. */ + @instanceOf("Intl.Segmenter") type t diff --git a/packages/@rescript/runtime/Stdlib_Intl_Segments.res b/packages/@rescript/runtime/Stdlib_Intl_Segments.res index 319046c9489..816c2f2ab43 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_Segments.res +++ b/packages/@rescript/runtime/Stdlib_Intl_Segments.res @@ -5,6 +5,7 @@ https://tc39.es/ecma402/#sec-segments-objects. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment) for API details and the [ECMA-402 specification](https://tc39.es/ecma402/#sec-segments-objects) for the object shape. */ + @notUndefined type t diff --git a/packages/@rescript/runtime/Stdlib_IterableIterator.res b/packages/@rescript/runtime/Stdlib_IterableIterator.res index 11a4d9c6139..b672e5dfeee 100644 --- a/packages/@rescript/runtime/Stdlib_IterableIterator.res +++ b/packages/@rescript/runtime/Stdlib_IterableIterator.res @@ -15,6 +15,7 @@ let make: (unit => Stdlib_Iterator.result<'yield, 'return>) => t< external asIterator: t<'yield, 'return, 'next> => Stdlib_Iterator.t<'yield, 'return, 'next> = "%identity" + external asIterable: t<'yield, 'return, 'next> => Stdlib_Iterable.t<'yield> = "%identity" let next = iterator => iterator->asIterator->Stdlib_Iterator.next diff --git a/packages/@rescript/runtime/Stdlib_IteratorObject.res b/packages/@rescript/runtime/Stdlib_IteratorObject.res index 427a54a3045..5f854723123 100644 --- a/packages/@rescript/runtime/Stdlib_IteratorObject.res +++ b/packages/@rescript/runtime/Stdlib_IteratorObject.res @@ -4,6 +4,7 @@ type result<'yield, 'return> = Stdlib_Iterator.result<'yield, 'return> external asIterator: t<'yield, 'return, 'next> => Stdlib_Iterator.t<'yield, 'return, 'next> = "%identity" + external asIterable: t<'yield, 'return, 'next> => Stdlib_Iterable.t<'yield> = "%identity" let next = iteratorObject => iteratorObject->asIterator->Stdlib_Iterator.next diff --git a/packages/@rescript/runtime/Stdlib_JsError.resi b/packages/@rescript/runtime/Stdlib_JsError.resi index 1580f3ac784..ef4a489cc61 100644 --- a/packages/@rescript/runtime/Stdlib_JsError.resi +++ b/packages/@rescript/runtime/Stdlib_JsError.resi @@ -91,6 +91,7 @@ module EvalError: { */ let throwWithMessage: string => 'a } + module RangeError: { /** Creates a new `RangeError` with the provided `message`. @@ -109,6 +110,7 @@ module RangeError: { */ let throwWithMessage: string => 'a } + module ReferenceError: { /** Creates a new `ReferenceError` with the provided `message`. @@ -127,6 +129,7 @@ module ReferenceError: { */ let throwWithMessage: string => 'a } + module SyntaxError: { /** Creates a new `SyntaxError` with the provided `message`. @@ -145,6 +148,7 @@ module SyntaxError: { */ let throwWithMessage: string => 'a } + module TypeError: { /** Creates a new `TypeError` with the provided `message`. @@ -163,6 +167,7 @@ module TypeError: { */ let throwWithMessage: string => 'a } + module URIError: { /** Creates a new `URIError` with the provided `message`. diff --git a/packages/@rescript/runtime/Stdlib_List.res b/packages/@rescript/runtime/Stdlib_List.res index 1b5866f1858..b96cb9136ed 100644 --- a/packages/@rescript/runtime/Stdlib_List.res +++ b/packages/@rescript/runtime/Stdlib_List.res @@ -302,6 +302,7 @@ let take = (lst, n) => } } } + /* invariant `n >= 0 ` */ let rec dropAux = (l, n) => if n == 0 { diff --git a/packages/@rescript/runtime/Stdlib_Map.res b/packages/@rescript/runtime/Stdlib_Map.res index b7321c2249f..6b41f11b74d 100644 --- a/packages/@rescript/runtime/Stdlib_Map.res +++ b/packages/@rescript/runtime/Stdlib_Map.res @@ -5,6 +5,7 @@ external asIterable: t<'k, 'v> => Stdlib_Iterable.t<('k, 'v)> = "%identity" @new external make: unit => t<'k, 'v> = "Map" @new external fromArray: array<('k, 'v)> => t<'k, 'v> = "Map" + @new external fromIterable: Stdlib_Iterable.t<('k, 'v)> => t<'k, 'v> = "Map" @@ -24,6 +25,7 @@ let isEmpty = map => map->size === 0 @send external keys: t<'k, 'v> => Stdlib_IteratorObject.t<'k, unit, unknown> = "keys" @send external values: t<'k, 'v> => Stdlib_IteratorObject.t<'v, unit, unknown> = "values" + @send external entries: t<'k, 'v> => Stdlib_IteratorObject.t<('k, 'v), unit, unknown> = "entries" diff --git a/packages/@rescript/runtime/Stdlib_Math.res b/packages/@rescript/runtime/Stdlib_Math.res index 58e01e70fd1..6303b949cda 100644 --- a/packages/@rescript/runtime/Stdlib_Math.res +++ b/packages/@rescript/runtime/Stdlib_Math.res @@ -58,6 +58,7 @@ module Int = { @val external sign: int => int = "Math.sign" let floor: float => int = f => f->floor->Stdlib_Float.toInt let ceil: float => int = f => f->ceil->Stdlib_Float.toInt + let random: (int, int) => int = (min, max) => floor(random() *. Stdlib_Int.toFloat(max - min)) + min } diff --git a/packages/@rescript/runtime/Stdlib_Math.resi b/packages/@rescript/runtime/Stdlib_Math.resi index 8f865b1f792..637ba225ebf 100644 --- a/packages/@rescript/runtime/Stdlib_Math.resi +++ b/packages/@rescript/runtime/Stdlib_Math.resi @@ -77,6 +77,7 @@ See [`Math.LOG10E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe */ @val external log10e: float = "Math.LOG10E" + /** `Math.Constants.pi` returns Pi - ratio of the circumference to the diameter of a circle, ≈ 3.141592653589793. @@ -90,6 +91,7 @@ See [`Math.PI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc */ @val external pi: float = "Math.PI" + /** `Math.Constants.sqrt1_2` returns Square root of 1/2, ≈ 0.7071067811865476. See [`Math.SQRT1_2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2) on MDN. @@ -102,6 +104,7 @@ See [`Math.SQRT1_2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Ref */ @val external sqrt1_2: float = "Math.SQRT1_2" + /** `Math.Constants.e` returns Absolute value for integer argument. See [`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) on MDN. diff --git a/packages/@rescript/runtime/Stdlib_RegExp.resi b/packages/@rescript/runtime/Stdlib_RegExp.resi index 0254af0f573..dbefbdb6901 100644 --- a/packages/@rescript/runtime/Stdlib_RegExp.resi +++ b/packages/@rescript/runtime/Stdlib_RegExp.resi @@ -54,6 +54,7 @@ module Result: { */ @send external matches: (t, @as(1) _) => array> = "slice" + @get external index: t => int = "index" /** diff --git a/packages/@rescript/runtime/Stdlib_String.res b/packages/@rescript/runtime/Stdlib_String.res index 3860eb96367..f423b19ecaf 100644 --- a/packages/@rescript/runtime/Stdlib_String.res +++ b/packages/@rescript/runtime/Stdlib_String.res @@ -21,6 +21,7 @@ external compare: (string, string) => Stdlib_Ordering.t = "%compare" @val @scope("Number") external isNaN: float => bool = "isNaN" @send external charCodeAt: (string, int) => float = "charCodeAt" + let charCodeAt = (s, i) => { let c = charCodeAt(s, i) isNaN(c) ? None : Some(c->Stdlib_Int.fromFloat) @@ -38,19 +39,23 @@ let charCodeAt = (s, i) => { @send external includesFrom: (string, string, int) => bool = "includes" @send external indexOf: (string, string) => int = "indexOf" + let indexOfOpt = (s, search) => switch indexOf(s, search) { | -1 => None | index => Some(index) } + @send external indexOfFrom: (string, string, int) => int = "indexOf" @send external lastIndexOf: (string, string) => int = "lastIndexOf" + let lastIndexOfOpt = (s, search) => switch lastIndexOf(s, search) { | -1 => None | index => Some(index) } + @send external lastIndexOfFrom: (string, string, int) => int = "lastIndexOf" @return(nullable) @send @@ -103,6 +108,7 @@ external replaceRegExpBy3Unsafe: ( ) => string = "replace" @send external search: (string, Stdlib_RegExp.t) => int = "search" + let searchOpt = (s, re) => switch search(s, re) { | -1 => None @@ -114,6 +120,7 @@ let searchOpt = (s, re) => @send external split: (string, string) => array = "split" @send external splitAtMost: (string, string, ~limit: int) => array = "split" @send external splitByRegExp: (string, Stdlib_RegExp.t) => array> = "split" + @send external splitByRegExpAtMost: (string, Stdlib_RegExp.t, ~limit: int) => array> = "split" diff --git a/packages/@rescript/runtime/Stdlib_String.resi b/packages/@rescript/runtime/Stdlib_String.resi index b42ab332b8f..5dfa62e5ded 100644 --- a/packages/@rescript/runtime/Stdlib_String.resi +++ b/packages/@rescript/runtime/Stdlib_String.resi @@ -510,6 +510,7 @@ Console.log(normalizeString1 == normalizeString2) // true ``` */ type normalizeForm = [#NFC | #NFD | #NFKC | #NFKD] + @send external normalizeByForm: (string, normalizeForm) => string = "normalize" diff --git a/packages/@rescript/runtime/Stdlib_Symbol.res b/packages/@rescript/runtime/Stdlib_Symbol.res index af37431e7fe..3ad30338230 100644 --- a/packages/@rescript/runtime/Stdlib_Symbol.res +++ b/packages/@rescript/runtime/Stdlib_Symbol.res @@ -2,17 +2,23 @@ type t @val external make: string => t = "Symbol" + @val @scope("Symbol") external getFor: string => option = "for" + @val @scope("Symbol") external keyFor: t => option = "keyFor" + @get external description: t => option = "description" + @send external toString: t => string = "toString" @val @scope("Symbol") external asyncIterator: t = "asyncIterator" + @val @scope("Symbol") external hasInstance: t = "hasInstance" + @val @scope("Symbol") external isConcatSpreadable: t = "isConcatSpreadable" @val @scope("Symbol") external iterator: t = "iterator" @val @scope("Symbol") external match: t = "match" diff --git a/packages/@rescript/runtime/Stdlib_TypedArray.res b/packages/@rescript/runtime/Stdlib_TypedArray.res index fb0e71bcdc3..d35cf066d5a 100644 --- a/packages/@rescript/runtime/Stdlib_TypedArray.res +++ b/packages/@rescript/runtime/Stdlib_TypedArray.res @@ -126,6 +126,7 @@ TypedArray.toString(view) == "10,10,20" ``` */ @send external copyAllWithin: (t<'a>, ~target: int) => array<'a> = "copyWithin" + /** `copyWithin(typedArray, ~target, ~start, ~end)` copies the section `[start, end)` onto the range beginning at `target`. @@ -211,6 +212,7 @@ Beware this will *mutate* the typed array. See [`TypedArray.prototype.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/sort) on MDN. */ @send external sort: (t<'a>, ('a, 'a) => Stdlib_Ordering.t) => unit = "sort" + /** `toSorted(typedArray, comparator)` returns a new typed array containing the sorted values, leaving the original untouched. @@ -264,6 +266,7 @@ TypedArray.includes(view, 10) == false See [`TypedArray.prototype.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/indexOf) on MDN. */ @send external indexOf: (t<'a>, 'a) => int = "indexOf" + /** `indexOfFrom(typedArray, value, fromIndex)` searches for `value` starting at `fromIndex`. */ @@ -289,6 +292,7 @@ TypedArray.joinWith(view, "-") == "1-2-3" See [`TypedArray.prototype.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/lastIndexOf) on MDN. */ @send external lastIndexOf: (t<'a>, 'a) => int = "lastIndexOf" + /** `lastIndexOfFrom(typedArray, value, fromIndex)` searches backwards starting at `fromIndex`. */ @@ -300,6 +304,7 @@ See [`TypedArray.prototype.lastIndexOf`](https://developer.mozilla.org/en-US/doc See [`TypedArray.prototype.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice) on MDN. */ @send external slice: (t<'a>, ~start: int, ~end: int=?) => t<'a> = "slice" + /** `copy(typedArray)` produces a shallow copy of the typed array. */ @@ -324,6 +329,7 @@ See [`TypedArray.prototype.toString`](https://developer.mozilla.org/en-US/docs/W ``` */ @send external toString: t<'a> => string = "toString" + /** `toLocaleString(typedArray)` concatenates the elements using locale-aware formatting. @@ -337,6 +343,7 @@ See [`TypedArray.prototype.toLocaleString`](https://developer.mozilla.org/en-US/ See [`TypedArray.prototype.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/every) on MDN. */ @send external every: (t<'a>, 'a => bool) => bool = "every" + /** `everyWithIndex(typedArray, checker)` is like `every` but provides the element index to `checker`. */ @@ -348,6 +355,7 @@ See [`TypedArray.prototype.every`](https://developer.mozilla.org/en-US/docs/Web/ See [`TypedArray.prototype.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/filter) on MDN. */ @send external filter: (t<'a>, 'a => bool) => t<'a> = "filter" + /** `filterWithIndex(typedArray, predicate)` behaves like `filter` but also passes the index to `predicate`. */ @@ -359,6 +367,7 @@ See [`TypedArray.prototype.filter`](https://developer.mozilla.org/en-US/docs/Web See [`TypedArray.prototype.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/find) on MDN. */ @send external find: (t<'a>, 'a => bool) => option<'a> = "find" + /** `findWithIndex(typedArray, predicate)` behaves like `find`, but `predicate` also receives the index. */ @@ -370,6 +379,7 @@ See [`TypedArray.prototype.find`](https://developer.mozilla.org/en-US/docs/Web/J See [`TypedArray.prototype.findLast`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findLast) on MDN. */ @send external findLast: (t<'a>, 'a => bool) => option<'a> = "findLast" + /** `findLastWithIndex(typedArray, predicate)` is the indexed variant of `findLast`. */ @@ -381,6 +391,7 @@ See [`TypedArray.prototype.findLast`](https://developer.mozilla.org/en-US/docs/W See [`TypedArray.prototype.findIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findIndex) on MDN. */ @send external findIndex: (t<'a>, 'a => bool) => int = "findIndex" + /** `findIndexWithIndex(typedArray, predicate)` is the indexed variant of `findIndex`. */ @@ -392,6 +403,7 @@ See [`TypedArray.prototype.findIndex`](https://developer.mozilla.org/en-US/docs/ See [`TypedArray.prototype.findLastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/findLastIndex) on MDN. */ @send external findLastIndex: (t<'a>, 'a => bool) => int = "findLastIndex" + /** `findLastIndexWithIndex(typedArray, predicate)` is the indexed variant of `findLastIndex`. */ @@ -403,6 +415,7 @@ See [`TypedArray.prototype.findLastIndex`](https://developer.mozilla.org/en-US/d See [`TypedArray.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/forEach) on MDN. */ @send external forEach: (t<'a>, 'a => unit) => unit = "forEach" + /** `forEachWithIndex(typedArray, f)` runs `f` for every element, also providing the index. */ @@ -414,6 +427,7 @@ See [`TypedArray.prototype.forEach`](https://developer.mozilla.org/en-US/docs/We See [`TypedArray.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/map) on MDN. */ @send external map: (t<'a>, 'a => 'b) => t<'b> = "map" + /** `mapWithIndex(typedArray, f)` behaves like `map`, but `f` also receives the index. */ @@ -425,6 +439,7 @@ See [`TypedArray.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/Ja See [`TypedArray.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduce) on MDN. */ @send external reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduce" + /** `reduceWithIndex(typedArray, reducer, initial)` is the indexed variant of `reduce`. */ @@ -436,6 +451,7 @@ See [`TypedArray.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web See [`TypedArray.prototype.reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight) on MDN. */ @send external reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduceRight" + /** `reduceRightWithIndex(typedArray, reducer, initial)` is the indexed variant of `reduceRight`. */ @@ -447,6 +463,7 @@ See [`TypedArray.prototype.reduceRight`](https://developer.mozilla.org/en-US/doc See [`TypedArray.prototype.some`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/some) on MDN. */ @send external some: (t<'a>, 'a => bool) => bool = "some" + /** `someWithIndex(typedArray, predicate)` behaves like `some`, but `predicate` also receives the element index. */ diff --git a/packages/dev-playground/src/Bindings.res b/packages/dev-playground/src/Bindings.res index ecca8b32b79..e7f3ec784fb 100644 --- a/packages/dev-playground/src/Bindings.res +++ b/packages/dev-playground/src/Bindings.res @@ -9,9 +9,12 @@ module Env = { @val external viteDefaultCompilerVersion: option = "import.meta.env.VITE_DEFAULT_COMPILER_VERSION" + @val external viteCompilerVersions: option = "import.meta.env.VITE_COMPILER_VERSIONS" + @val external viteCompilerPreviewRoot: option = "import.meta.env.VITE_COMPILER_PREVIEW_ROOT" + @val external viteBaseUrl: option = "import.meta.env.BASE_URL" } @@ -32,13 +35,17 @@ module Instance = { @send external setJsxPreserveMode: (compilerInstance, bool) => unit = "setJsxPreserveMode" @send external setGentypeEnabled: (compilerInstance, bool) => unit = "setGentypeEnabled" @send external setSourceMapMode: (compilerInstance, string) => unit = "setSourceMapMode" + @send external setSourceMapSourcesContent: (compilerInstance, bool) => unit = "setSourceMapSourcesContent" + @send external setSourceMapRoot: (compilerInstance, string) => unit = "setSourceMapRoot" + @send external setExperimentalFeatures: (compilerInstance, array) => unit = "setExperimentalFeatures" + @get external rescript: compilerInstance => rescriptCompiler = "rescript" @send external getConfig: compilerInstance => compilerConfig = "getConfig" @get external version: compilerInstance => option = "version" @@ -55,12 +62,16 @@ module Config = { @get external moduleSystem: compilerConfig => option = "module_system" @get external warnFlags: compilerConfig => option = "warn_flags" @get external jsxPreserveMode: compilerConfig => option = "jsx_preserve_mode" + @get external experimentalFeatures: compilerConfig => option> = "experimental_features" + @get external gentypeEnabled: compilerConfig => option = "gentype_enabled" @get external sourceMapMode: compilerConfig => option = "source_map_mode" + @get external sourceMapSourcesContent: compilerConfig => option = "source_map_sources_content" + @get external sourceMapRoot: compilerConfig => option = "source_map_root" } @@ -142,6 +153,7 @@ module EventTarget = { let setValue = (target: {..}, value: string) => target["value"] = value let selectionStart = (target: {..}): int => target["selectionStart"] let selectionEnd = (target: {..}): int => target["selectionEnd"] + let setSelectionRange = (target: {..}, start, end_) => { let setSelectionRange: (int, int) => unit = target["setSelectionRange"] setSelectionRange(start, end_) @@ -178,11 +190,14 @@ module ClassList = { module Element = { @send external setAttribute: (Dom.element, string, string) => unit = "setAttribute" + @send external addEventListener: (Dom.element, string, Dom.event => unit) => unit = "addEventListener" + @send external removeEventListener: (Dom.element, string, Dom.event => unit) => unit = "removeEventListener" + @send external appendChild: (Dom.element, Dom.element) => unit = "appendChild" @send external removeChild: (Dom.element, Dom.element) => unit = "removeChild" @send external focus: Dom.element => unit = "focus" @@ -191,16 +206,22 @@ module Element = { @send external hasPointerCapture: (Dom.element, int) => bool = "hasPointerCapture" @send external getBoundingClientRect: Dom.element => boundingRect = "getBoundingClientRect" @get external classList: Dom.element => classList = "classList" + @send @return(nullable) external querySelector: (Dom.element, string) => option = "querySelector" + @get @return(nullable) external parentElement: Dom.element => option = "parentElement" + @send external scrollIntoView: (Dom.element, scrollIntoViewOptions) => unit = "scrollIntoView" + @get external style: Dom.element => CssStyle.t = "style" + @get @return(nullable) external getScrollHandler: Dom.element => option unit> = "__devPlaygroundScrollHandler" + @set external setScrollHandler: (Dom.element, Dom.event => unit) => unit = "__devPlaygroundScrollHandler" @@ -243,8 +264,10 @@ module Document = { @get external body: {..} => Dom.element = "body" @send external createScriptElement: ({..}, @as("script") _) => Dom.element = "createElement" @send external createTextAreaElement: ({..}, @as("textarea") _) => Dom.element = "createElement" + @send @return(nullable) external getElementById: ({..}, string) => option = "getElementById" + @send external execCommand: ({..}, string) => bool = "execCommand" } diff --git a/packages/dev-playground/src/CompilerApi.res b/packages/dev-playground/src/CompilerApi.res index 798999609cb..f1d5272a2bc 100644 --- a/packages/dev-playground/src/CompilerApi.res +++ b/packages/dev-playground/src/CompilerApi.res @@ -139,10 +139,12 @@ let parseCompilerVersions = defaultVersion => { let compilerVersions = parseCompilerVersions(defaultConfig.compilerVersion) let availableCompilerVersions = compilerVersions->Array.map(Version.toPublic) let compilerRoot = pathFromBase("playground-bundles") + let compilerPreviewRoot = switch Env.viteCompilerPreviewRoot { | Some(root) => root === "" ? None : Some(root->Version.normalizeRoot) | None => None } + let loadedScripts: Map.t> = Map.make() let compilerApis: Map.t = Map.make() let compilers: Map.t = Map.make() diff --git a/rewatch/testrepo/packages/dep02/src/Array.res b/rewatch/testrepo/packages/dep02/src/Array.res index 0f4ee137cb0..9bcee00fbd3 100644 --- a/rewatch/testrepo/packages/dep02/src/Array.res +++ b/rewatch/testrepo/packages/dep02/src/Array.res @@ -173,4 +173,5 @@ module Int = { module Float = { let sum = xs => reduce(xs, 0., (a, b) => a +. b) } + let clear = t => truncateToLengthUnsafe(t, 0) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt index 678ca9ed6ce..31a01159cde 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt @@ -41,9 +41,9 @@ addDeclaration_ Value +make ContextOptionalArgs.res:41:6 path:+ContextOptionalArgs.ComponentNotUsingAction addDeclaration_ Value +make ContextOptionalArgs.res:55:4 path:+ContextOptionalArgs addDeclaration_ RecordLabel children ContextOptionalArgs.res:12:14 path:+ContextOptionalArgs.NotificationProvider.props - add_value_reference ContextOptionalArgs.res:2:6 --> React.res:81:0 + add_value_reference ContextOptionalArgs.res:2:6 --> React.res:87:0 add_value_reference ContextOptionalArgs.res:8:8 --> ContextOptionalArgs.res:2:6 - add_value_reference ContextOptionalArgs.res:8:8 --> React.res:77:2 + add_value_reference ContextOptionalArgs.res:8:8 --> React.res:83:2 addDeclaration_ RecordLabel children ContextOptionalArgs.res:12:14 path:+ContextOptionalArgs.NotificationProvider.props addDeclaration_ Value +dispatchNotification ContextOptionalArgs.res:13:8 path:+ContextOptionalArgs.NotificationProvider add_value_reference ContextOptionalArgs.res:13:8 --> ContextOptionalArgs.res:13:43 @@ -56,20 +56,20 @@ add_type_reference _none_:1:-1 --> ContextOptionalArgs.res:12:14 add_value_reference ContextOptionalArgs.res:12:6 --> React.res:16:0 add_value_reference ContextOptionalArgs.res:22:6 --> ContextOptionalArgs.res:2:6 - add_value_reference ContextOptionalArgs.res:22:6 --> React.res:250:0 + add_value_reference ContextOptionalArgs.res:22:6 --> React.res:274:0 addDeclaration_ Value +dispatchNotification ContextOptionalArgs.res:28:8 path:+ContextOptionalArgs.ComponentUsingAction add_value_reference ContextOptionalArgs.res:28:8 --> ContextOptionalArgs.res:22:6 add_value_reference ContextOptionalArgs.res:35:4 --> React.res:3:0 DeadOptionalArgs.addReferences dispatchNotification called with optional argNames:action argNamesMaybe: ContextOptionalArgs.res:31:6 add_value_reference ContextOptionalArgs.res:31:6 --> ContextOptionalArgs.res:28:8 - add_value_reference ContextOptionalArgs.res:30:4 --> React.res:150:0 + add_value_reference ContextOptionalArgs.res:30:4 --> React.res:157:0 add_value_reference ContextOptionalArgs.res:27:6 --> React.res:16:0 addDeclaration_ Value +dispatchNotification ContextOptionalArgs.res:42:8 path:+ContextOptionalArgs.ComponentNotUsingAction add_value_reference ContextOptionalArgs.res:42:8 --> ContextOptionalArgs.res:22:6 add_value_reference ContextOptionalArgs.res:49:4 --> React.res:3:0 DeadOptionalArgs.addReferences dispatchNotification called with optional argNames: argNamesMaybe: ContextOptionalArgs.res:45:6 add_value_reference ContextOptionalArgs.res:45:6 --> ContextOptionalArgs.res:42:8 - add_value_reference ContextOptionalArgs.res:44:4 --> React.res:150:0 + add_value_reference ContextOptionalArgs.res:44:4 --> React.res:157:0 add_value_reference ContextOptionalArgs.res:41:6 --> React.res:16:0 add_value_reference ContextOptionalArgs.res:56:3 --> ContextOptionalArgs.res:12:6 add_value_reference ContextOptionalArgs.res:57:5 --> ContextOptionalArgs.res:27:6 @@ -431,7 +431,7 @@ addDeclaration_ Value +make Hooks.res:66:6 path:+Hooks.RenderPropRequiresConversion addDeclaration_ RecordLabel name Hooks.res:1:16 path:+Hooks.vehicle addDeclaration_ RecordLabel vehicle Hooks.res:4:12 path:+Hooks.props - add_value_reference Hooks.res:5:26 --> React.res:134:0 + add_value_reference Hooks.res:5:26 --> React.res:140:0 add_type_reference Hooks.res:10:29 --> Hooks.res:1:16 add_value_reference Hooks.res:10:29 --> Hooks.res:4:12 add_value_reference Hooks.res:10:75 --> Hooks.res:5:7 diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index 446bdac5984..3774dca4b40 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -2371,7 +2371,7 @@ Hover src/Completion.res 349:14 { "contents": { "kind": "markdown", - "value": "```rescript\nJsxDOM.domProps\n```\n\n---\n\n```\n \n```\n```rescript\ntype JsxDOM.domProps = {\n key?: string,\n children?: Jsx.element,\n ref?: domRef,\n allow?: string,\n ariaCurrent?: [\n | #date\n | #\"false\"\n | #location\n | #page\n | #step\n | #time\n | #\"true\"\n ],\n ariaDetails?: string,\n ariaDisabled?: bool,\n ariaHidden?: bool,\n ariaInvalid?: [#\"false\" | #grammar | #spelling | #\"true\"],\n ariaKeyshortcuts?: string,\n ariaLabel?: string,\n ariaRoledescription?: string,\n ariaAutocomplete?: [#both | #inline | #list | #none],\n ariaChecked?: [#\"false\" | #mixed | #\"true\"],\n ariaExpanded?: bool,\n ariaHaspopup?: [\n | #dialog\n | #\"false\"\n | #grid\n | #listbox\n | #menu\n | #tree\n | #\"true\"\n ],\n ariaLevel?: int,\n ariaModal?: bool,\n ariaMultiline?: bool,\n ariaMultiselectable?: bool,\n ariaOrientation?: [#horizontal | #undefined | #vertical],\n ariaPlaceholder?: string,\n ariaPressed?: [#\"false\" | #mixed | #\"true\"],\n ariaReadonly?: bool,\n ariaRequired?: bool,\n ariaSelected?: bool,\n ariaSort?: string,\n ariaValuemax?: float,\n ariaValuemin?: float,\n ariaValuenow?: float,\n ariaValuetext?: string,\n ariaAtomic?: bool,\n ariaBusy?: bool,\n ariaLive?: [#assertive | #off | #polite | #rude],\n ariaRelevant?: string,\n ariaDropeffect?: [\n | #copy\n | #execute\n | #link\n | #move\n | #none\n | #popup\n ],\n ariaGrabbed?: bool,\n ariaActivedescendant?: string,\n ariaColcount?: int,\n ariaColindex?: int,\n ariaColspan?: int,\n ariaControls?: string,\n ariaDescribedby?: string,\n ariaErrormessage?: string,\n ariaFlowto?: string,\n ariaLabelledby?: string,\n ariaOwns?: string,\n ariaPosinset?: int,\n ariaRowcount?: int,\n ariaRowindex?: int,\n ariaRowspan?: int,\n ariaSetsize?: int,\n defaultChecked?: bool,\n defaultValue?: string,\n accessKey?: string,\n capture?: [#environment | #user],\n className?: string,\n contentEditable?: bool,\n contextMenu?: string,\n dataTestId?: string,\n dir?: string,\n draggable?: bool,\n hidden?: bool,\n id?: string,\n inert?: bool,\n lang?: string,\n popover?: popover,\n popoverTarget?: string,\n popoverTargetAction?: popoverTargetAction,\n role?: string,\n style?: style,\n spellCheck?: bool,\n tabIndex?: int,\n title?: string,\n itemID?: string,\n itemProp?: string,\n itemRef?: string,\n itemScope?: bool,\n itemType?: string,\n accept?: string,\n acceptCharset?: string,\n action?: string,\n allowFullScreen?: bool,\n alt?: string,\n as_?: string,\n async?: bool,\n autoComplete?: string,\n autoCapitalize?: string,\n autoFocus?: bool,\n autoPlay?: bool,\n challenge?: string,\n charSet?: string,\n checked?: bool,\n cite?: string,\n crossOrigin?: string,\n cols?: int,\n colSpan?: int,\n content?: string,\n controls?: bool,\n coords?: string,\n data?: string,\n dateTime?: string,\n default?: bool,\n defer?: bool,\n disabled?: bool,\n download?: string,\n encType?: string,\n form?: string,\n formAction?: string,\n formTarget?: string,\n formMethod?: string,\n frameBorder?: int,\n headers?: string,\n height?: string,\n high?: int,\n href?: string,\n hrefLang?: string,\n htmlFor?: string,\n httpEquiv?: string,\n icon?: string,\n inputMode?: string,\n integrity?: string,\n keyType?: string,\n kind?: string,\n label?: string,\n list?: string,\n loading?: [#eager | #lazy],\n loop?: bool,\n low?: int,\n manifest?: string,\n max?: string,\n maxLength?: int,\n media?: string,\n mediaGroup?: string,\n method?: string,\n min?: string,\n minLength?: int,\n multiple?: bool,\n muted?: bool,\n name?: string,\n nonce?: string,\n noValidate?: bool,\n open_?: bool,\n optimum?: int,\n pattern?: string,\n placeholder?: string,\n playsInline?: bool,\n poster?: string,\n preload?: string,\n radioGroup?: string,\n readOnly?: bool,\n rel?: string,\n required?: bool,\n reversed?: bool,\n rows?: int,\n rowSpan?: int,\n sandbox?: string,\n scope?: string,\n scoped?: bool,\n scrolling?: string,\n selected?: bool,\n shape?: string,\n size?: int,\n sizes?: string,\n span?: int,\n src?: string,\n srcDoc?: string,\n srcLang?: string,\n srcSet?: string,\n start?: int,\n step?: float,\n summary?: string,\n target?: string,\n type_?: string,\n useMap?: string,\n value?: string,\n width?: string,\n wrap?: string,\n onCopy?: JsxEvent.Clipboard.t => unit,\n onCut?: JsxEvent.Clipboard.t => unit,\n onPaste?: JsxEvent.Clipboard.t => unit,\n onCompositionEnd?: JsxEvent.Composition.t => unit,\n onCompositionStart?: JsxEvent.Composition.t => unit,\n onCompositionUpdate?: JsxEvent.Composition.t => unit,\n onKeyDown?: JsxEvent.Keyboard.t => unit,\n onKeyPress?: JsxEvent.Keyboard.t => unit,\n onKeyUp?: JsxEvent.Keyboard.t => unit,\n onFocus?: JsxEvent.Focus.t => unit,\n onBlur?: JsxEvent.Focus.t => unit,\n onBeforeInput?: JsxEvent.Form.t => unit,\n onChange?: JsxEvent.Form.t => unit,\n onInput?: JsxEvent.Form.t => unit,\n onReset?: JsxEvent.Form.t => unit,\n onSubmit?: JsxEvent.Form.t => unit,\n onInvalid?: JsxEvent.Form.t => unit,\n onClick?: JsxEvent.Mouse.t => unit,\n onContextMenu?: JsxEvent.Mouse.t => unit,\n onDoubleClick?: JsxEvent.Mouse.t => unit,\n onDrag?: JsxEvent.Mouse.t => unit,\n onDragEnd?: JsxEvent.Mouse.t => unit,\n onDragEnter?: JsxEvent.Mouse.t => unit,\n onDragExit?: JsxEvent.Mouse.t => unit,\n onDragLeave?: JsxEvent.Mouse.t => unit,\n onDragOver?: JsxEvent.Mouse.t => unit,\n onDragStart?: JsxEvent.Mouse.t => unit,\n onDrop?: JsxEvent.Mouse.t => unit,\n onMouseDown?: JsxEvent.Mouse.t => unit,\n onMouseEnter?: JsxEvent.Mouse.t => unit,\n onMouseLeave?: JsxEvent.Mouse.t => unit,\n onMouseMove?: JsxEvent.Mouse.t => unit,\n onMouseOut?: JsxEvent.Mouse.t => unit,\n onMouseOver?: JsxEvent.Mouse.t => unit,\n onMouseUp?: JsxEvent.Mouse.t => unit,\n onSelect?: JsxEvent.Selection.t => unit,\n onTouchCancel?: JsxEvent.Touch.t => unit,\n onTouchEnd?: JsxEvent.Touch.t => unit,\n onTouchMove?: JsxEvent.Touch.t => unit,\n onTouchStart?: JsxEvent.Touch.t => unit,\n onPointerOver?: JsxEvent.Pointer.t => unit,\n onPointerEnter?: JsxEvent.Pointer.t => unit,\n onPointerDown?: JsxEvent.Pointer.t => unit,\n onPointerMove?: JsxEvent.Pointer.t => unit,\n onPointerUp?: JsxEvent.Pointer.t => unit,\n onPointerCancel?: JsxEvent.Pointer.t => unit,\n onPointerOut?: JsxEvent.Pointer.t => unit,\n onPointerLeave?: JsxEvent.Pointer.t => unit,\n onGotPointerCapture?: JsxEvent.Pointer.t => unit,\n onLostPointerCapture?: JsxEvent.Pointer.t => unit,\n onScroll?: JsxEvent.UI.t => unit,\n onWheel?: JsxEvent.Wheel.t => unit,\n onAbort?: JsxEvent.Media.t => unit,\n onCanPlay?: JsxEvent.Media.t => unit,\n onCanPlayThrough?: JsxEvent.Media.t => unit,\n onDurationChange?: JsxEvent.Media.t => unit,\n onEmptied?: JsxEvent.Media.t => unit,\n onEncrypted?: JsxEvent.Media.t => unit,\n onEnded?: JsxEvent.Media.t => unit,\n onError?: JsxEvent.Media.t => unit,\n onLoadedData?: JsxEvent.Media.t => unit,\n onLoadedMetadata?: JsxEvent.Media.t => unit,\n onLoadStart?: JsxEvent.Media.t => unit,\n onPause?: JsxEvent.Media.t => unit,\n onPlay?: JsxEvent.Media.t => unit,\n onPlaying?: JsxEvent.Media.t => unit,\n onProgress?: JsxEvent.Media.t => unit,\n onRateChange?: JsxEvent.Media.t => unit,\n onSeeked?: JsxEvent.Media.t => unit,\n onSeeking?: JsxEvent.Media.t => unit,\n onStalled?: JsxEvent.Media.t => unit,\n onSuspend?: JsxEvent.Media.t => unit,\n onTimeUpdate?: JsxEvent.Media.t => unit,\n onVolumeChange?: JsxEvent.Media.t => unit,\n onWaiting?: JsxEvent.Media.t => unit,\n onLoad?: JsxEvent.Image.t => unit,\n onAnimationStart?: JsxEvent.Animation.t => unit,\n onAnimationEnd?: JsxEvent.Animation.t => unit,\n onAnimationIteration?: JsxEvent.Animation.t => unit,\n onTransitionEnd?: JsxEvent.Transition.t => unit,\n accentHeight?: string,\n accumulate?: string,\n additive?: string,\n alignmentBaseline?: string,\n allowReorder?: string,\n alphabetic?: string,\n amplitude?: string,\n arabicForm?: string,\n ascent?: string,\n attributeName?: string,\n attributeType?: string,\n autoReverse?: string,\n azimuth?: string,\n baseFrequency?: string,\n baseProfile?: string,\n baselineShift?: string,\n bbox?: string,\n begin?: string,\n bias?: string,\n by?: string,\n calcMode?: string,\n capHeight?: string,\n clip?: string,\n clipPath?: string,\n clipPathUnits?: string,\n clipRule?: string,\n colorInterpolation?: string,\n colorInterpolationFilters?: string,\n colorProfile?: string,\n colorRendering?: string,\n contentScriptType?: string,\n contentStyleType?: string,\n cursor?: string,\n cx?: string,\n cy?: string,\n d?: string,\n decelerate?: string,\n descent?: string,\n diffuseConstant?: string,\n direction?: string,\n display?: string,\n divisor?: string,\n dominantBaseline?: string,\n dur?: string,\n dx?: string,\n dy?: string,\n edgeMode?: string,\n elevation?: string,\n enableBackground?: string,\n end?: string,\n exponent?: string,\n externalResourcesRequired?: string,\n fill?: string,\n fillOpacity?: string,\n fillRule?: string,\n filter?: string,\n filterRes?: string,\n filterUnits?: string,\n floodColor?: string,\n floodOpacity?: string,\n focusable?: string,\n fontFamily?: string,\n fontSize?: string,\n fontSizeAdjust?: string,\n fontStretch?: string,\n fontStyle?: string,\n fontVariant?: string,\n fontWeight?: string,\n fomat?: string,\n from?: string,\n fx?: string,\n fy?: string,\n g1?: string,\n g2?: string,\n glyphName?: string,\n glyphOrientationHorizontal?: string,\n glyphOrientationVertical?: string,\n glyphRef?: string,\n gradientTransform?: string,\n gradientUnits?: string,\n hanging?: string,\n horizAdvX?: string,\n horizOriginX?: string,\n ideographic?: string,\n imageRendering?: string,\n in_?: string,\n in2?: string,\n intercept?: string,\n k?: string,\n k1?: string,\n k2?: string,\n k3?: string,\n k4?: string,\n kernelMatrix?: string,\n kernelUnitLength?: string,\n kerning?: string,\n keyPoints?: string,\n keySplines?: string,\n keyTimes?: string,\n lengthAdjust?: string,\n letterSpacing?: string,\n lightingColor?: string,\n limitingConeAngle?: string,\n local?: string,\n markerEnd?: string,\n markerHeight?: string,\n markerMid?: string,\n markerStart?: string,\n markerUnits?: string,\n markerWidth?: string,\n mask?: string,\n maskContentUnits?: string,\n maskUnits?: string,\n mathematical?: string,\n mode?: string,\n numOctaves?: string,\n offset?: string,\n opacity?: string,\n operator?: string,\n order?: string,\n orient?: string,\n orientation?: string,\n origin?: string,\n overflow?: string,\n overflowX?: string,\n overflowY?: string,\n overlinePosition?: string,\n overlineThickness?: string,\n paintOrder?: string,\n panose1?: string,\n pathLength?: string,\n patternContentUnits?: string,\n patternTransform?: string,\n patternUnits?: string,\n pointerEvents?: string,\n points?: string,\n pointsAtX?: string,\n pointsAtY?: string,\n pointsAtZ?: string,\n preserveAlpha?: string,\n preserveAspectRatio?: string,\n primitiveUnits?: string,\n r?: string,\n radius?: string,\n referrerPolicy?: string,\n refX?: string,\n refY?: string,\n renderingIntent?: string,\n repeatCount?: string,\n repeatDur?: string,\n requiredExtensions?: string,\n requiredFeatures?: string,\n restart?: string,\n result?: string,\n rotate?: string,\n rx?: string,\n ry?: string,\n scale?: string,\n seed?: string,\n shapeRendering?: string,\n slope?: string,\n slot?: string,\n spacing?: string,\n specularConstant?: string,\n specularExponent?: string,\n speed?: string,\n spreadMethod?: string,\n startOffset?: string,\n stdDeviation?: string,\n stemh?: string,\n stemv?: string,\n stitchTiles?: string,\n stopColor?: string,\n stopOpacity?: string,\n strikethroughPosition?: string,\n strikethroughThickness?: string,\n string?: string,\n stroke?: string,\n strokeDasharray?: string,\n strokeDashoffset?: string,\n strokeLinecap?: string,\n strokeLinejoin?: string,\n strokeMiterlimit?: string,\n strokeOpacity?: string,\n strokeWidth?: string,\n surfaceScale?: string,\n systemLanguage?: string,\n tableValues?: string,\n targetX?: string,\n targetY?: string,\n textAnchor?: string,\n textDecoration?: string,\n textLength?: string,\n textRendering?: string,\n to?: string,\n transform?: string,\n u1?: string,\n u2?: string,\n underlinePosition?: string,\n underlineThickness?: string,\n unicode?: string,\n unicodeBidi?: string,\n unicodeRange?: string,\n unitsPerEm?: string,\n vAlphabetic?: string,\n vHanging?: string,\n vIdeographic?: string,\n vMathematical?: string,\n values?: string,\n vectorEffect?: string,\n version?: string,\n vertAdvX?: string,\n vertAdvY?: string,\n vertOriginX?: string,\n vertOriginY?: string,\n viewBox?: string,\n viewTarget?: string,\n visibility?: string,\n widths?: string,\n wordSpacing?: string,\n writingMode?: string,\n x?: string,\n x1?: string,\n x2?: string,\n xChannelSelector?: string,\n xHeight?: string,\n xlinkActuate?: string,\n xlinkArcrole?: string,\n xlinkHref?: string,\n xlinkRole?: string,\n xlinkShow?: string,\n xlinkTitle?: string,\n xlinkType?: string,\n xmlns?: string,\n xmlnsXlink?: string,\n xmlBase?: string,\n xmlLang?: string,\n xmlSpace?: string,\n y?: string,\n y1?: string,\n y2?: string,\n yChannelSelector?: string,\n z?: string,\n zoomAndPan?: string,\n about?: string,\n datatype?: string,\n inlist?: string,\n prefix?: string,\n property?: string,\n resource?: string,\n typeof?: string,\n vocab?: string,\n dangerouslySetInnerHTML?: {\"__html\": string},\n suppressContentEditableWarning?: bool,\n}\n```\nGo to: [Type definition](JsxDOM.res#L21,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype Jsx.element\n```\nGo to: [Type definition](Jsx.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype domRef\n```\nGo to: [Type definition](JsxDOM.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popover =\n | @as(\"auto\") Auto\n | @as(\"manual\") Manual\n | @as(\"hint\") Hint\n```\nGo to: [Type definition](JsxDOM.res#L12,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popoverTargetAction =\n | @as(\"toggle\") Toggle\n | @as(\"show\") Show\n | @as(\"hide\") Hide\n```\nGo to: [Type definition](JsxDOM.res#L16,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype style = JsxDOMStyle.t\n```\nGo to: [Type definition](JsxDOM.res#L7,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Clipboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L78,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Composition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L88,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Keyboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L97,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Focus.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L119,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Form.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L129,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Mouse.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L136,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Selection.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L213,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Touch.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L220,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Pointer.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L165,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.UI.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L243,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Wheel.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L254,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Media.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L266,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Image.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L273,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Animation.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L280,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Transition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L291,3)\n" + "value": "```rescript\nJsxDOM.domProps\n```\n\n---\n\n```\n \n```\n```rescript\ntype JsxDOM.domProps = {\n key?: string,\n children?: Jsx.element,\n ref?: domRef,\n allow?: string,\n ariaCurrent?: [\n | #date\n | #\"false\"\n | #location\n | #page\n | #step\n | #time\n | #\"true\"\n ],\n ariaDetails?: string,\n ariaDisabled?: bool,\n ariaHidden?: bool,\n ariaInvalid?: [#\"false\" | #grammar | #spelling | #\"true\"],\n ariaKeyshortcuts?: string,\n ariaLabel?: string,\n ariaRoledescription?: string,\n ariaAutocomplete?: [#both | #inline | #list | #none],\n ariaChecked?: [#\"false\" | #mixed | #\"true\"],\n ariaExpanded?: bool,\n ariaHaspopup?: [\n | #dialog\n | #\"false\"\n | #grid\n | #listbox\n | #menu\n | #tree\n | #\"true\"\n ],\n ariaLevel?: int,\n ariaModal?: bool,\n ariaMultiline?: bool,\n ariaMultiselectable?: bool,\n ariaOrientation?: [#horizontal | #undefined | #vertical],\n ariaPlaceholder?: string,\n ariaPressed?: [#\"false\" | #mixed | #\"true\"],\n ariaReadonly?: bool,\n ariaRequired?: bool,\n ariaSelected?: bool,\n ariaSort?: string,\n ariaValuemax?: float,\n ariaValuemin?: float,\n ariaValuenow?: float,\n ariaValuetext?: string,\n ariaAtomic?: bool,\n ariaBusy?: bool,\n ariaLive?: [#assertive | #off | #polite | #rude],\n ariaRelevant?: string,\n ariaDropeffect?: [\n | #copy\n | #execute\n | #link\n | #move\n | #none\n | #popup\n ],\n ariaGrabbed?: bool,\n ariaActivedescendant?: string,\n ariaColcount?: int,\n ariaColindex?: int,\n ariaColspan?: int,\n ariaControls?: string,\n ariaDescribedby?: string,\n ariaErrormessage?: string,\n ariaFlowto?: string,\n ariaLabelledby?: string,\n ariaOwns?: string,\n ariaPosinset?: int,\n ariaRowcount?: int,\n ariaRowindex?: int,\n ariaRowspan?: int,\n ariaSetsize?: int,\n defaultChecked?: bool,\n defaultValue?: string,\n accessKey?: string,\n capture?: [#environment | #user],\n className?: string,\n contentEditable?: bool,\n contextMenu?: string,\n dataTestId?: string,\n dir?: string,\n draggable?: bool,\n hidden?: bool,\n id?: string,\n inert?: bool,\n lang?: string,\n popover?: popover,\n popoverTarget?: string,\n popoverTargetAction?: popoverTargetAction,\n role?: string,\n style?: style,\n spellCheck?: bool,\n tabIndex?: int,\n title?: string,\n itemID?: string,\n itemProp?: string,\n itemRef?: string,\n itemScope?: bool,\n itemType?: string,\n accept?: string,\n acceptCharset?: string,\n action?: string,\n allowFullScreen?: bool,\n alt?: string,\n as_?: string,\n async?: bool,\n autoComplete?: string,\n autoCapitalize?: string,\n autoFocus?: bool,\n autoPlay?: bool,\n challenge?: string,\n charSet?: string,\n checked?: bool,\n cite?: string,\n crossOrigin?: string,\n cols?: int,\n colSpan?: int,\n content?: string,\n controls?: bool,\n coords?: string,\n data?: string,\n dateTime?: string,\n default?: bool,\n defer?: bool,\n disabled?: bool,\n download?: string,\n encType?: string,\n form?: string,\n formAction?: string,\n formTarget?: string,\n formMethod?: string,\n frameBorder?: int,\n headers?: string,\n height?: string,\n high?: int,\n href?: string,\n hrefLang?: string,\n htmlFor?: string,\n httpEquiv?: string,\n icon?: string,\n inputMode?: string,\n integrity?: string,\n keyType?: string,\n kind?: string,\n label?: string,\n list?: string,\n loading?: [#eager | #lazy],\n loop?: bool,\n low?: int,\n manifest?: string,\n max?: string,\n maxLength?: int,\n media?: string,\n mediaGroup?: string,\n method?: string,\n min?: string,\n minLength?: int,\n multiple?: bool,\n muted?: bool,\n name?: string,\n nonce?: string,\n noValidate?: bool,\n open_?: bool,\n optimum?: int,\n pattern?: string,\n placeholder?: string,\n playsInline?: bool,\n poster?: string,\n preload?: string,\n radioGroup?: string,\n readOnly?: bool,\n rel?: string,\n required?: bool,\n reversed?: bool,\n rows?: int,\n rowSpan?: int,\n sandbox?: string,\n scope?: string,\n scoped?: bool,\n scrolling?: string,\n selected?: bool,\n shape?: string,\n size?: int,\n sizes?: string,\n span?: int,\n src?: string,\n srcDoc?: string,\n srcLang?: string,\n srcSet?: string,\n start?: int,\n step?: float,\n summary?: string,\n target?: string,\n type_?: string,\n useMap?: string,\n value?: string,\n width?: string,\n wrap?: string,\n onCopy?: JsxEvent.Clipboard.t => unit,\n onCut?: JsxEvent.Clipboard.t => unit,\n onPaste?: JsxEvent.Clipboard.t => unit,\n onCompositionEnd?: JsxEvent.Composition.t => unit,\n onCompositionStart?: JsxEvent.Composition.t => unit,\n onCompositionUpdate?: JsxEvent.Composition.t => unit,\n onKeyDown?: JsxEvent.Keyboard.t => unit,\n onKeyPress?: JsxEvent.Keyboard.t => unit,\n onKeyUp?: JsxEvent.Keyboard.t => unit,\n onFocus?: JsxEvent.Focus.t => unit,\n onBlur?: JsxEvent.Focus.t => unit,\n onBeforeInput?: JsxEvent.Form.t => unit,\n onChange?: JsxEvent.Form.t => unit,\n onInput?: JsxEvent.Form.t => unit,\n onReset?: JsxEvent.Form.t => unit,\n onSubmit?: JsxEvent.Form.t => unit,\n onInvalid?: JsxEvent.Form.t => unit,\n onClick?: JsxEvent.Mouse.t => unit,\n onContextMenu?: JsxEvent.Mouse.t => unit,\n onDoubleClick?: JsxEvent.Mouse.t => unit,\n onDrag?: JsxEvent.Mouse.t => unit,\n onDragEnd?: JsxEvent.Mouse.t => unit,\n onDragEnter?: JsxEvent.Mouse.t => unit,\n onDragExit?: JsxEvent.Mouse.t => unit,\n onDragLeave?: JsxEvent.Mouse.t => unit,\n onDragOver?: JsxEvent.Mouse.t => unit,\n onDragStart?: JsxEvent.Mouse.t => unit,\n onDrop?: JsxEvent.Mouse.t => unit,\n onMouseDown?: JsxEvent.Mouse.t => unit,\n onMouseEnter?: JsxEvent.Mouse.t => unit,\n onMouseLeave?: JsxEvent.Mouse.t => unit,\n onMouseMove?: JsxEvent.Mouse.t => unit,\n onMouseOut?: JsxEvent.Mouse.t => unit,\n onMouseOver?: JsxEvent.Mouse.t => unit,\n onMouseUp?: JsxEvent.Mouse.t => unit,\n onSelect?: JsxEvent.Selection.t => unit,\n onTouchCancel?: JsxEvent.Touch.t => unit,\n onTouchEnd?: JsxEvent.Touch.t => unit,\n onTouchMove?: JsxEvent.Touch.t => unit,\n onTouchStart?: JsxEvent.Touch.t => unit,\n onPointerOver?: JsxEvent.Pointer.t => unit,\n onPointerEnter?: JsxEvent.Pointer.t => unit,\n onPointerDown?: JsxEvent.Pointer.t => unit,\n onPointerMove?: JsxEvent.Pointer.t => unit,\n onPointerUp?: JsxEvent.Pointer.t => unit,\n onPointerCancel?: JsxEvent.Pointer.t => unit,\n onPointerOut?: JsxEvent.Pointer.t => unit,\n onPointerLeave?: JsxEvent.Pointer.t => unit,\n onGotPointerCapture?: JsxEvent.Pointer.t => unit,\n onLostPointerCapture?: JsxEvent.Pointer.t => unit,\n onScroll?: JsxEvent.UI.t => unit,\n onWheel?: JsxEvent.Wheel.t => unit,\n onAbort?: JsxEvent.Media.t => unit,\n onCanPlay?: JsxEvent.Media.t => unit,\n onCanPlayThrough?: JsxEvent.Media.t => unit,\n onDurationChange?: JsxEvent.Media.t => unit,\n onEmptied?: JsxEvent.Media.t => unit,\n onEncrypted?: JsxEvent.Media.t => unit,\n onEnded?: JsxEvent.Media.t => unit,\n onError?: JsxEvent.Media.t => unit,\n onLoadedData?: JsxEvent.Media.t => unit,\n onLoadedMetadata?: JsxEvent.Media.t => unit,\n onLoadStart?: JsxEvent.Media.t => unit,\n onPause?: JsxEvent.Media.t => unit,\n onPlay?: JsxEvent.Media.t => unit,\n onPlaying?: JsxEvent.Media.t => unit,\n onProgress?: JsxEvent.Media.t => unit,\n onRateChange?: JsxEvent.Media.t => unit,\n onSeeked?: JsxEvent.Media.t => unit,\n onSeeking?: JsxEvent.Media.t => unit,\n onStalled?: JsxEvent.Media.t => unit,\n onSuspend?: JsxEvent.Media.t => unit,\n onTimeUpdate?: JsxEvent.Media.t => unit,\n onVolumeChange?: JsxEvent.Media.t => unit,\n onWaiting?: JsxEvent.Media.t => unit,\n onLoad?: JsxEvent.Image.t => unit,\n onAnimationStart?: JsxEvent.Animation.t => unit,\n onAnimationEnd?: JsxEvent.Animation.t => unit,\n onAnimationIteration?: JsxEvent.Animation.t => unit,\n onTransitionEnd?: JsxEvent.Transition.t => unit,\n accentHeight?: string,\n accumulate?: string,\n additive?: string,\n alignmentBaseline?: string,\n allowReorder?: string,\n alphabetic?: string,\n amplitude?: string,\n arabicForm?: string,\n ascent?: string,\n attributeName?: string,\n attributeType?: string,\n autoReverse?: string,\n azimuth?: string,\n baseFrequency?: string,\n baseProfile?: string,\n baselineShift?: string,\n bbox?: string,\n begin?: string,\n bias?: string,\n by?: string,\n calcMode?: string,\n capHeight?: string,\n clip?: string,\n clipPath?: string,\n clipPathUnits?: string,\n clipRule?: string,\n colorInterpolation?: string,\n colorInterpolationFilters?: string,\n colorProfile?: string,\n colorRendering?: string,\n contentScriptType?: string,\n contentStyleType?: string,\n cursor?: string,\n cx?: string,\n cy?: string,\n d?: string,\n decelerate?: string,\n descent?: string,\n diffuseConstant?: string,\n direction?: string,\n display?: string,\n divisor?: string,\n dominantBaseline?: string,\n dur?: string,\n dx?: string,\n dy?: string,\n edgeMode?: string,\n elevation?: string,\n enableBackground?: string,\n end?: string,\n exponent?: string,\n externalResourcesRequired?: string,\n fill?: string,\n fillOpacity?: string,\n fillRule?: string,\n filter?: string,\n filterRes?: string,\n filterUnits?: string,\n floodColor?: string,\n floodOpacity?: string,\n focusable?: string,\n fontFamily?: string,\n fontSize?: string,\n fontSizeAdjust?: string,\n fontStretch?: string,\n fontStyle?: string,\n fontVariant?: string,\n fontWeight?: string,\n fomat?: string,\n from?: string,\n fx?: string,\n fy?: string,\n g1?: string,\n g2?: string,\n glyphName?: string,\n glyphOrientationHorizontal?: string,\n glyphOrientationVertical?: string,\n glyphRef?: string,\n gradientTransform?: string,\n gradientUnits?: string,\n hanging?: string,\n horizAdvX?: string,\n horizOriginX?: string,\n ideographic?: string,\n imageRendering?: string,\n in_?: string,\n in2?: string,\n intercept?: string,\n k?: string,\n k1?: string,\n k2?: string,\n k3?: string,\n k4?: string,\n kernelMatrix?: string,\n kernelUnitLength?: string,\n kerning?: string,\n keyPoints?: string,\n keySplines?: string,\n keyTimes?: string,\n lengthAdjust?: string,\n letterSpacing?: string,\n lightingColor?: string,\n limitingConeAngle?: string,\n local?: string,\n markerEnd?: string,\n markerHeight?: string,\n markerMid?: string,\n markerStart?: string,\n markerUnits?: string,\n markerWidth?: string,\n mask?: string,\n maskContentUnits?: string,\n maskUnits?: string,\n mathematical?: string,\n mode?: string,\n numOctaves?: string,\n offset?: string,\n opacity?: string,\n operator?: string,\n order?: string,\n orient?: string,\n orientation?: string,\n origin?: string,\n overflow?: string,\n overflowX?: string,\n overflowY?: string,\n overlinePosition?: string,\n overlineThickness?: string,\n paintOrder?: string,\n panose1?: string,\n pathLength?: string,\n patternContentUnits?: string,\n patternTransform?: string,\n patternUnits?: string,\n pointerEvents?: string,\n points?: string,\n pointsAtX?: string,\n pointsAtY?: string,\n pointsAtZ?: string,\n preserveAlpha?: string,\n preserveAspectRatio?: string,\n primitiveUnits?: string,\n r?: string,\n radius?: string,\n referrerPolicy?: string,\n refX?: string,\n refY?: string,\n renderingIntent?: string,\n repeatCount?: string,\n repeatDur?: string,\n requiredExtensions?: string,\n requiredFeatures?: string,\n restart?: string,\n result?: string,\n rotate?: string,\n rx?: string,\n ry?: string,\n scale?: string,\n seed?: string,\n shapeRendering?: string,\n slope?: string,\n slot?: string,\n spacing?: string,\n specularConstant?: string,\n specularExponent?: string,\n speed?: string,\n spreadMethod?: string,\n startOffset?: string,\n stdDeviation?: string,\n stemh?: string,\n stemv?: string,\n stitchTiles?: string,\n stopColor?: string,\n stopOpacity?: string,\n strikethroughPosition?: string,\n strikethroughThickness?: string,\n string?: string,\n stroke?: string,\n strokeDasharray?: string,\n strokeDashoffset?: string,\n strokeLinecap?: string,\n strokeLinejoin?: string,\n strokeMiterlimit?: string,\n strokeOpacity?: string,\n strokeWidth?: string,\n surfaceScale?: string,\n systemLanguage?: string,\n tableValues?: string,\n targetX?: string,\n targetY?: string,\n textAnchor?: string,\n textDecoration?: string,\n textLength?: string,\n textRendering?: string,\n to?: string,\n transform?: string,\n u1?: string,\n u2?: string,\n underlinePosition?: string,\n underlineThickness?: string,\n unicode?: string,\n unicodeBidi?: string,\n unicodeRange?: string,\n unitsPerEm?: string,\n vAlphabetic?: string,\n vHanging?: string,\n vIdeographic?: string,\n vMathematical?: string,\n values?: string,\n vectorEffect?: string,\n version?: string,\n vertAdvX?: string,\n vertAdvY?: string,\n vertOriginX?: string,\n vertOriginY?: string,\n viewBox?: string,\n viewTarget?: string,\n visibility?: string,\n widths?: string,\n wordSpacing?: string,\n writingMode?: string,\n x?: string,\n x1?: string,\n x2?: string,\n xChannelSelector?: string,\n xHeight?: string,\n xlinkActuate?: string,\n xlinkArcrole?: string,\n xlinkHref?: string,\n xlinkRole?: string,\n xlinkShow?: string,\n xlinkTitle?: string,\n xlinkType?: string,\n xmlns?: string,\n xmlnsXlink?: string,\n xmlBase?: string,\n xmlLang?: string,\n xmlSpace?: string,\n y?: string,\n y1?: string,\n y2?: string,\n yChannelSelector?: string,\n z?: string,\n zoomAndPan?: string,\n about?: string,\n datatype?: string,\n inlist?: string,\n prefix?: string,\n property?: string,\n resource?: string,\n typeof?: string,\n vocab?: string,\n dangerouslySetInnerHTML?: {\"__html\": string},\n suppressContentEditableWarning?: bool,\n}\n```\nGo to: [Type definition](JsxDOM.res#L23,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype Jsx.element\n```\nGo to: [Type definition](Jsx.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype domRef\n```\nGo to: [Type definition](JsxDOM.res#L8,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popover =\n | @as(\"auto\") Auto\n | @as(\"manual\") Manual\n | @as(\"hint\") Hint\n```\nGo to: [Type definition](JsxDOM.res#L13,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype popoverTargetAction =\n | @as(\"toggle\") Toggle\n | @as(\"show\") Show\n | @as(\"hide\") Hide\n```\nGo to: [Type definition](JsxDOM.res#L18,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype style = JsxDOMStyle.t\n```\nGo to: [Type definition](JsxDOM.res#L7,1)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Clipboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L78,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Composition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L88,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Keyboard.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L97,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Focus.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L119,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Form.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L129,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Mouse.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L136,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Selection.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L213,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Touch.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L220,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Pointer.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L165,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.UI.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L243,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Wheel.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L254,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Media.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L266,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Image.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L273,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Animation.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L280,3)\n\n\n---\n\n```\n \n```\n```rescript\ntype JsxEvent.Transition.t = synthetic\n```\nGo to: [Type definition](JsxEvent.res#L291,3)\n" } } diff --git a/tests/analysis_tests/tests/src/expected/Xform.res.txt b/tests/analysis_tests/tests/src/expected/Xform.res.txt index 76d72b55d47..62575462b4b 100644 --- a/tests/analysis_tests/tests/src/expected/Xform.res.txt +++ b/tests/analysis_tests/tests/src/expected/Xform.res.txt @@ -219,6 +219,7 @@ newText: <--here /** Doc comment. */ type t = int + // A comment here let doStuff = a => a + 1 // ^xfm diff --git a/tests/belt_tests/src/bs_array_test.mjs b/tests/belt_tests/src/bs_array_test.mjs index 893b1403c15..9d92dd0e4c1 100644 --- a/tests/belt_tests/src/bs_array_test.mjs +++ b/tests/belt_tests/src/bs_array_test.mjs @@ -25,7 +25,7 @@ Mocha.describe("Bs_array_test", () => { 1, 2 ]; - Test_utils.eq("File \"bs_array_test.res\", line 21, characters 6-13", [ + Test_utils.eq("File \"bs_array_test.res\", line 22, characters 6-13", [ Belt_Array.get(v, 0), Belt_Array.get(v, 1), Belt_Array.get(v, 2), @@ -38,13 +38,13 @@ Mocha.describe("Bs_array_test", () => { undefined, undefined ]); - Test_utils.throws("File \"bs_array_test.res\", line 25, characters 11-18", () => { + Test_utils.throws("File \"bs_array_test.res\", line 26, characters 11-18", () => { Belt_Array.getExn([ 0, 1 ], -1); }); - Test_utils.throws("File \"bs_array_test.res\", line 26, characters 11-18", () => { + Test_utils.throws("File \"bs_array_test.res\", line 27, characters 11-18", () => { Belt_Array.getExn([ 0, 1 @@ -54,22 +54,22 @@ Mocha.describe("Bs_array_test", () => { 0, 1 ]; - Test_utils.ok("File \"bs_array_test.res\", line 28, characters 6-13", Primitive_object.equal([ + Test_utils.ok("File \"bs_array_test.res\", line 29, characters 6-13", Primitive_object.equal([ Belt_Array.getExn(arg, 0), Belt_Array.getExn(arg, 1) ], [ 0, 1 ])); - Test_utils.throws("File \"bs_array_test.res\", line 34, characters 11-18", () => Belt_Array.setExn([ + Test_utils.throws("File \"bs_array_test.res\", line 35, characters 11-18", () => Belt_Array.setExn([ 0, 1 ], -1, 0)); - Test_utils.throws("File \"bs_array_test.res\", line 35, characters 11-18", () => Belt_Array.setExn([ + Test_utils.throws("File \"bs_array_test.res\", line 36, characters 11-18", () => Belt_Array.setExn([ 0, 1 ], 2, 0)); - Test_utils.ok("File \"bs_array_test.res\", line 36, characters 7-14", !Belt_Array.set([ + Test_utils.ok("File \"bs_array_test.res\", line 37, characters 7-14", !Belt_Array.set([ 1, 2 ], 2, 0)); @@ -82,13 +82,13 @@ Mocha.describe("Bs_array_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_array_test.res", - 41, + 42, 8 ], Error: new Error() }; } - Test_utils.ok("File \"bs_array_test.res\", line 38, characters 6-13", Belt_Array.getExn(v$1, 0) === 0); + Test_utils.ok("File \"bs_array_test.res\", line 39, characters 6-13", Belt_Array.getExn(v$1, 0) === 0); let v$2 = [ 1, 2 @@ -98,78 +98,78 @@ Mocha.describe("Bs_array_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_array_test.res", - 49, + 50, 8 ], Error: new Error() }; } - Test_utils.ok("File \"bs_array_test.res\", line 46, characters 6-13", Belt_Array.getExn(v$2, 1) === 0); + Test_utils.ok("File \"bs_array_test.res\", line 47, characters 6-13", Belt_Array.getExn(v$2, 1) === 0); let v$3 = [ 1, 2 ]; - Test_utils.ok("File \"bs_array_test.res\", line 54, characters 6-13", (Belt_Array.setExn(v$3, 0, 0), Belt_Array.getExn(v$3, 0) === 0)); + Test_utils.ok("File \"bs_array_test.res\", line 55, characters 6-13", (Belt_Array.setExn(v$3, 0, 0), Belt_Array.getExn(v$3, 0) === 0)); let v$4 = [ 1, 2 ]; - Test_utils.ok("File \"bs_array_test.res\", line 62, characters 6-13", (Belt_Array.setExn(v$4, 1, 0), Belt_Array.getExn(v$4, 1) === 0)); + Test_utils.ok("File \"bs_array_test.res\", line 63, characters 6-13", (Belt_Array.setExn(v$4, 1, 0), Belt_Array.getExn(v$4, 1) === 0)); }); let add = (x, y) => x + y | 0; Mocha.test("bs_array_test_2", () => { let v = Belt_Array.makeBy(3000, i => i); let u = Belt_Array.shuffle(v); - Test_utils.ok("File \"bs_array_test.res\", line 75, characters 7-14", u !== v); - Test_utils.eq("File \"bs_array_test.res\", line 77, characters 7-14", Belt_Array.reduce(u, 0, add), Belt_Array.reduce(v, 0, add)); + Test_utils.ok("File \"bs_array_test.res\", line 76, characters 7-14", u !== v); + Test_utils.eq("File \"bs_array_test.res\", line 78, characters 7-14", Belt_Array.reduce(u, 0, add), Belt_Array.reduce(v, 0, add)); }); Mocha.test("bs_array_test_3", () => { - Test_utils.ok("File \"bs_array_test.res\", line 82, characters 7-14", Primitive_object.equal(Belt_Array.range(0, 3), [ + Test_utils.ok("File \"bs_array_test.res\", line 83, characters 7-14", Primitive_object.equal(Belt_Array.range(0, 3), [ 0, 1, 2, 3 ])); - Test_utils.ok("File \"bs_array_test.res\", line 83, characters 7-14", Primitive_object.equal(Belt_Array.range(3, 0), [])); - Test_utils.ok("File \"bs_array_test.res\", line 84, characters 7-14", Primitive_object.equal(Belt_Array.range(3, 3), [3])); - Test_utils.ok("File \"bs_array_test.res\", line 86, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(0, 10, 3), [ + Test_utils.ok("File \"bs_array_test.res\", line 84, characters 7-14", Primitive_object.equal(Belt_Array.range(3, 0), [])); + Test_utils.ok("File \"bs_array_test.res\", line 85, characters 7-14", Primitive_object.equal(Belt_Array.range(3, 3), [3])); + Test_utils.ok("File \"bs_array_test.res\", line 87, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(0, 10, 3), [ 0, 3, 6, 9 ])); - Test_utils.ok("File \"bs_array_test.res\", line 87, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(0, 12, 3), [ + Test_utils.ok("File \"bs_array_test.res\", line 88, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(0, 12, 3), [ 0, 3, 6, 9, 12 ])); - Test_utils.ok("File \"bs_array_test.res\", line 88, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(33, 0, 1), [])); - Test_utils.ok("File \"bs_array_test.res\", line 89, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(33, 0, -1), [])); - Test_utils.ok("File \"bs_array_test.res\", line 90, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(3, 12, -1), [])); - Test_utils.ok("File \"bs_array_test.res\", line 91, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 0), [])); - Test_utils.ok("File \"bs_array_test.res\", line 92, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 1), [3])); + Test_utils.ok("File \"bs_array_test.res\", line 89, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(33, 0, 1), [])); + Test_utils.ok("File \"bs_array_test.res\", line 90, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(33, 0, -1), [])); + Test_utils.ok("File \"bs_array_test.res\", line 91, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(3, 12, -1), [])); + Test_utils.ok("File \"bs_array_test.res\", line 92, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 0), [])); + Test_utils.ok("File \"bs_array_test.res\", line 93, characters 7-14", Primitive_object.equal(Belt_Array.rangeBy(3, 3, 1), [3])); }); Mocha.test("bs_array_test_4", () => { - Test_utils.eq("File \"bs_array_test.res\", line 96, characters 7-14", Belt_Array.reduceReverse([], 100, (a, b) => a - b | 0), 100); - Test_utils.eq("File \"bs_array_test.res\", line 97, characters 7-14", Belt_Array.reduceReverse([ + Test_utils.eq("File \"bs_array_test.res\", line 97, characters 7-14", Belt_Array.reduceReverse([], 100, (a, b) => a - b | 0), 100); + Test_utils.eq("File \"bs_array_test.res\", line 98, characters 7-14", Belt_Array.reduceReverse([ 1, 2 ], 100, (a, b) => a - b | 0), 97); - Test_utils.eq("File \"bs_array_test.res\", line 98, characters 7-14", Belt_Array.reduceReverse([ + Test_utils.eq("File \"bs_array_test.res\", line 99, characters 7-14", Belt_Array.reduceReverse([ 1, 2, 3, 4 ], 100, (a, b) => a - b | 0), 90); - Test_utils.eq("File \"bs_array_test.res\", line 99, characters 7-14", Belt_Array.reduceWithIndex([ + Test_utils.eq("File \"bs_array_test.res\", line 100, characters 7-14", Belt_Array.reduceWithIndex([ 1, 2, 3, 4 ], 0, (acc, x, i) => (acc + x | 0) + i | 0), 16); - Test_utils.ok("File \"bs_array_test.res\", line 100, characters 7-14", Belt_Array.reduceReverse2([ + Test_utils.ok("File \"bs_array_test.res\", line 101, characters 7-14", Belt_Array.reduceReverse2([ 1, 2, 3 @@ -184,7 +184,7 @@ Mocha.describe("Bs_array_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_array_test.res", - 106, + 107, 4 ], Error: new Error() @@ -201,13 +201,13 @@ Mocha.describe("Bs_array_test", () => { return res; }; Mocha.test("bs_array_test_make_functions", () => { - Test_utils.eq("File \"bs_array_test.res\", line 119, characters 7-14", Belt_Array.makeBy(0, param => 1), []); - Test_utils.eq("File \"bs_array_test.res\", line 120, characters 7-14", Belt_Array.makeBy(3, i => i), [ + Test_utils.eq("File \"bs_array_test.res\", line 120, characters 7-14", Belt_Array.makeBy(0, param => 1), []); + Test_utils.eq("File \"bs_array_test.res\", line 121, characters 7-14", Belt_Array.makeBy(3, i => i), [ 0, 1, 2 ]); - Test_utils.eq("File \"bs_array_test.res\", line 121, characters 7-14", makeMatrixExn(3, 4, 1), [ + Test_utils.eq("File \"bs_array_test.res\", line 122, characters 7-14", makeMatrixExn(3, 4, 1), [ [ 1, 1, @@ -227,17 +227,17 @@ Mocha.describe("Bs_array_test", () => { 1 ] ]); - Test_utils.eq("File \"bs_array_test.res\", line 122, characters 7-14", makeMatrixExn(3, 0, 0), [ + Test_utils.eq("File \"bs_array_test.res\", line 123, characters 7-14", makeMatrixExn(3, 0, 0), [ [], [], [] ]); - Test_utils.eq("File \"bs_array_test.res\", line 123, characters 7-14", makeMatrixExn(0, 3, 1), []); - Test_utils.eq("File \"bs_array_test.res\", line 124, characters 7-14", makeMatrixExn(1, 1, 1), [[1]]); - Test_utils.eq("File \"bs_array_test.res\", line 125, characters 7-14", [].slice(0), []); - Test_utils.eq("File \"bs_array_test.res\", line 126, characters 7-14", Belt_Array.map([], x => x + 1 | 0), []); - Test_utils.eq("File \"bs_array_test.res\", line 127, characters 7-14", Belt_Array.mapWithIndex([], add), []); - Test_utils.eq("File \"bs_array_test.res\", line 128, characters 7-14", Belt_Array.mapWithIndex([ + Test_utils.eq("File \"bs_array_test.res\", line 124, characters 7-14", makeMatrixExn(0, 3, 1), []); + Test_utils.eq("File \"bs_array_test.res\", line 125, characters 7-14", makeMatrixExn(1, 1, 1), [[1]]); + Test_utils.eq("File \"bs_array_test.res\", line 126, characters 7-14", [].slice(0), []); + Test_utils.eq("File \"bs_array_test.res\", line 127, characters 7-14", Belt_Array.map([], x => x + 1 | 0), []); + Test_utils.eq("File \"bs_array_test.res\", line 128, characters 7-14", Belt_Array.mapWithIndex([], add), []); + Test_utils.eq("File \"bs_array_test.res\", line 129, characters 7-14", Belt_Array.mapWithIndex([ 1, 2, 3 @@ -246,14 +246,14 @@ Mocha.describe("Bs_array_test", () => { 3, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 129, characters 7-14", Belt_List.fromArray([]), /* [] */0); - Test_utils.eq("File \"bs_array_test.res\", line 130, characters 7-14", Belt_List.fromArray([1]), {hd: 1, tl: /* [] */0}); - Test_utils.eq("File \"bs_array_test.res\", line 131, characters 7-14", Belt_List.fromArray([ + Test_utils.eq("File \"bs_array_test.res\", line 130, characters 7-14", Belt_List.fromArray([]), /* [] */0); + Test_utils.eq("File \"bs_array_test.res\", line 131, characters 7-14", Belt_List.fromArray([1]), {hd: 1, tl: /* [] */0}); + Test_utils.eq("File \"bs_array_test.res\", line 132, characters 7-14", Belt_List.fromArray([ 1, 2, 3 ]), {hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}); - Test_utils.eq("File \"bs_array_test.res\", line 132, characters 7-14", Belt_Array.map([ + Test_utils.eq("File \"bs_array_test.res\", line 133, characters 7-14", Belt_Array.map([ 1, 2, 3 @@ -262,13 +262,13 @@ Mocha.describe("Bs_array_test", () => { 3, 4 ]); - Test_utils.eq("File \"bs_array_test.res\", line 133, characters 7-14", Belt_List.toArray(/* [] */0), []); - Test_utils.eq("File \"bs_array_test.res\", line 134, characters 7-14", Belt_List.toArray({hd: 1, tl: /* [] */0}), [1]); - Test_utils.eq("File \"bs_array_test.res\", line 135, characters 7-14", Belt_List.toArray({hd: 1, tl: {hd: 2, tl: /* [] */0}}), [ + Test_utils.eq("File \"bs_array_test.res\", line 134, characters 7-14", Belt_List.toArray(/* [] */0), []); + Test_utils.eq("File \"bs_array_test.res\", line 135, characters 7-14", Belt_List.toArray({hd: 1, tl: /* [] */0}), [1]); + Test_utils.eq("File \"bs_array_test.res\", line 136, characters 7-14", Belt_List.toArray({hd: 1, tl: {hd: 2, tl: /* [] */0}}), [ 1, 2 ]); - Test_utils.eq("File \"bs_array_test.res\", line 136, characters 7-14", Belt_List.toArray({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}), [ + Test_utils.eq("File \"bs_array_test.res\", line 137, characters 7-14", Belt_List.toArray({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}), [ 1, 2, 3 @@ -283,20 +283,20 @@ Mocha.describe("Bs_array_test", () => { return x + 1 | 0; } }); - Test_utils.eq("File \"bs_array_test.res\", line 152, characters 7-14", v0, [ + Test_utils.eq("File \"bs_array_test.res\", line 153, characters 7-14", v0, [ 0, 2, 4, 6, 8 ]); - Test_utils.eq("File \"bs_array_test.res\", line 153, characters 7-14", v1, [ + Test_utils.eq("File \"bs_array_test.res\", line 154, characters 7-14", v1, [ 0, 3, 6, 9 ]); - Test_utils.eq("File \"bs_array_test.res\", line 154, characters 7-14", v2, [ + Test_utils.eq("File \"bs_array_test.res\", line 155, characters 7-14", v2, [ 1, 3, 5, @@ -313,26 +313,26 @@ Mocha.describe("Bs_array_test", () => { 5 ]; let match = Belt_Array.partition(a, x => x % 2 === 0); - Test_utils.eq("File \"bs_array_test.res\", line 160, characters 7-14", match[0], [ + Test_utils.eq("File \"bs_array_test.res\", line 161, characters 7-14", match[0], [ 2, 4 ]); - Test_utils.eq("File \"bs_array_test.res\", line 161, characters 7-14", match[1], [ + Test_utils.eq("File \"bs_array_test.res\", line 162, characters 7-14", match[1], [ 1, 3, 5 ]); let match$1 = Belt_Array.partition(a, x => x === 2); - Test_utils.eq("File \"bs_array_test.res\", line 163, characters 7-14", match$1[0], [2]); - Test_utils.eq("File \"bs_array_test.res\", line 164, characters 7-14", match$1[1], [ + Test_utils.eq("File \"bs_array_test.res\", line 164, characters 7-14", match$1[0], [2]); + Test_utils.eq("File \"bs_array_test.res\", line 165, characters 7-14", match$1[1], [ 1, 3, 4, 5 ]); let match$2 = Belt_Array.partition([], x => false); - Test_utils.eq("File \"bs_array_test.res\", line 166, characters 7-14", match$2[0], []); - Test_utils.eq("File \"bs_array_test.res\", line 167, characters 7-14", match$2[1], []); + Test_utils.eq("File \"bs_array_test.res\", line 167, characters 7-14", match$2[0], []); + Test_utils.eq("File \"bs_array_test.res\", line 168, characters 7-14", match$2[1], []); }); Mocha.test("bs_array_test_slice_functions", () => { let a = [ @@ -342,64 +342,64 @@ Mocha.describe("Bs_array_test", () => { 4, 5 ]; - Test_utils.eq("File \"bs_array_test.res\", line 172, characters 7-14", Belt_Array.slice(a, 0, 2), [ + Test_utils.eq("File \"bs_array_test.res\", line 173, characters 7-14", Belt_Array.slice(a, 0, 2), [ 1, 2 ]); - Test_utils.eq("File \"bs_array_test.res\", line 173, characters 7-14", Belt_Array.slice(a, 0, 5), [ + Test_utils.eq("File \"bs_array_test.res\", line 174, characters 7-14", Belt_Array.slice(a, 0, 5), [ 1, 2, 3, 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 174, characters 7-14", Belt_Array.slice(a, 0, 15), [ + Test_utils.eq("File \"bs_array_test.res\", line 175, characters 7-14", Belt_Array.slice(a, 0, 15), [ 1, 2, 3, 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 175, characters 7-14", Belt_Array.slice(a, 5, 1), []); - Test_utils.eq("File \"bs_array_test.res\", line 176, characters 7-14", Belt_Array.slice(a, 4, 1), [5]); - Test_utils.eq("File \"bs_array_test.res\", line 177, characters 7-14", Belt_Array.slice(a, -1, 1), [5]); - Test_utils.eq("File \"bs_array_test.res\", line 178, characters 7-14", Belt_Array.slice(a, -1, 2), [5]); - Test_utils.eq("File \"bs_array_test.res\", line 179, characters 7-14", Belt_Array.slice(a, -2, 1), [4]); - Test_utils.eq("File \"bs_array_test.res\", line 180, characters 7-14", Belt_Array.slice(a, -2, 2), [ + Test_utils.eq("File \"bs_array_test.res\", line 176, characters 7-14", Belt_Array.slice(a, 5, 1), []); + Test_utils.eq("File \"bs_array_test.res\", line 177, characters 7-14", Belt_Array.slice(a, 4, 1), [5]); + Test_utils.eq("File \"bs_array_test.res\", line 178, characters 7-14", Belt_Array.slice(a, -1, 1), [5]); + Test_utils.eq("File \"bs_array_test.res\", line 179, characters 7-14", Belt_Array.slice(a, -1, 2), [5]); + Test_utils.eq("File \"bs_array_test.res\", line 180, characters 7-14", Belt_Array.slice(a, -2, 1), [4]); + Test_utils.eq("File \"bs_array_test.res\", line 181, characters 7-14", Belt_Array.slice(a, -2, 2), [ 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 181, characters 7-14", Belt_Array.slice(a, -2, 3), [ + Test_utils.eq("File \"bs_array_test.res\", line 182, characters 7-14", Belt_Array.slice(a, -2, 3), [ 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 182, characters 7-14", Belt_Array.slice(a, -10, 3), [ + Test_utils.eq("File \"bs_array_test.res\", line 183, characters 7-14", Belt_Array.slice(a, -10, 3), [ 1, 2, 3 ]); - Test_utils.eq("File \"bs_array_test.res\", line 183, characters 7-14", Belt_Array.slice(a, -10, 4), [ + Test_utils.eq("File \"bs_array_test.res\", line 184, characters 7-14", Belt_Array.slice(a, -10, 4), [ 1, 2, 3, 4 ]); - Test_utils.eq("File \"bs_array_test.res\", line 184, characters 7-14", Belt_Array.slice(a, -10, 5), [ + Test_utils.eq("File \"bs_array_test.res\", line 185, characters 7-14", Belt_Array.slice(a, -10, 5), [ 1, 2, 3, 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 185, characters 7-14", Belt_Array.slice(a, -10, 6), [ + Test_utils.eq("File \"bs_array_test.res\", line 186, characters 7-14", Belt_Array.slice(a, -10, 6), [ 1, 2, 3, 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 186, characters 7-14", Belt_Array.slice(a, 0, 0), []); - Test_utils.eq("File \"bs_array_test.res\", line 187, characters 7-14", Belt_Array.slice(a, 0, -1), []); + Test_utils.eq("File \"bs_array_test.res\", line 187, characters 7-14", Belt_Array.slice(a, 0, 0), []); + Test_utils.eq("File \"bs_array_test.res\", line 188, characters 7-14", Belt_Array.slice(a, 0, -1), []); }); Mocha.test("bs_array_test_sliceToEnd_functions", () => { let a = [ @@ -409,33 +409,33 @@ Mocha.describe("Bs_array_test", () => { 4, 5 ]; - Test_utils.eq("File \"bs_array_test.res\", line 192, characters 7-14", Belt_Array.sliceToEnd(a, 0), [ + Test_utils.eq("File \"bs_array_test.res\", line 193, characters 7-14", Belt_Array.sliceToEnd(a, 0), [ 1, 2, 3, 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 193, characters 7-14", Belt_Array.sliceToEnd(a, 5), []); - Test_utils.eq("File \"bs_array_test.res\", line 194, characters 7-14", Belt_Array.sliceToEnd(a, 4), [5]); - Test_utils.eq("File \"bs_array_test.res\", line 195, characters 7-14", Belt_Array.sliceToEnd(a, -1), [5]); - Test_utils.eq("File \"bs_array_test.res\", line 196, characters 7-14", Belt_Array.sliceToEnd(a, -2), [ + Test_utils.eq("File \"bs_array_test.res\", line 194, characters 7-14", Belt_Array.sliceToEnd(a, 5), []); + Test_utils.eq("File \"bs_array_test.res\", line 195, characters 7-14", Belt_Array.sliceToEnd(a, 4), [5]); + Test_utils.eq("File \"bs_array_test.res\", line 196, characters 7-14", Belt_Array.sliceToEnd(a, -1), [5]); + Test_utils.eq("File \"bs_array_test.res\", line 197, characters 7-14", Belt_Array.sliceToEnd(a, -2), [ 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 197, characters 7-14", Belt_Array.sliceToEnd(a, -10), [ + Test_utils.eq("File \"bs_array_test.res\", line 198, characters 7-14", Belt_Array.sliceToEnd(a, -10), [ 1, 2, 3, 4, 5 ]); - Test_utils.eq("File \"bs_array_test.res\", line 198, characters 7-14", Belt_Array.sliceToEnd(a, 6), []); + Test_utils.eq("File \"bs_array_test.res\", line 199, characters 7-14", Belt_Array.sliceToEnd(a, 6), []); }); Mocha.test("bs_array_test_fill_functions", () => { let a = Belt_Array.makeBy(10, x => x); Belt_Array.fill(a, 0, 3, 0); - Test_utils.eq("File \"bs_array_test.res\", line 204, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 205, characters 7-14", a.slice(0), [ 0, 0, 0, @@ -448,7 +448,7 @@ Mocha.describe("Bs_array_test", () => { 9 ]); Belt_Array.fill(a, 2, 8, 1); - Test_utils.eq("File \"bs_array_test.res\", line 206, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 207, characters 7-14", a.slice(0), [ 0, 0, 1, @@ -461,7 +461,7 @@ Mocha.describe("Bs_array_test", () => { 1 ]); Belt_Array.fill(a, 8, 1, 9); - Test_utils.eq("File \"bs_array_test.res\", line 208, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 209, characters 7-14", a.slice(0), [ 0, 0, 1, @@ -474,7 +474,7 @@ Mocha.describe("Bs_array_test", () => { 1 ]); Belt_Array.fill(a, 8, 2, 9); - Test_utils.eq("File \"bs_array_test.res\", line 210, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 211, characters 7-14", a.slice(0), [ 0, 0, 1, @@ -487,7 +487,7 @@ Mocha.describe("Bs_array_test", () => { 9 ]); Belt_Array.fill(a, 8, 3, 12); - Test_utils.eq("File \"bs_array_test.res\", line 212, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 213, characters 7-14", a.slice(0), [ 0, 0, 1, @@ -500,7 +500,7 @@ Mocha.describe("Bs_array_test", () => { 12 ]); Belt_Array.fill(a, -2, 3, 11); - Test_utils.eq("File \"bs_array_test.res\", line 214, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 215, characters 7-14", a.slice(0), [ 0, 0, 1, @@ -513,7 +513,7 @@ Mocha.describe("Bs_array_test", () => { 11 ]); Belt_Array.fill(a, -3, 3, 10); - Test_utils.eq("File \"bs_array_test.res\", line 216, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 217, characters 7-14", a.slice(0), [ 0, 0, 1, @@ -526,7 +526,7 @@ Mocha.describe("Bs_array_test", () => { 10 ]); Belt_Array.fill(a, -3, 1, 7); - Test_utils.eq("File \"bs_array_test.res\", line 218, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 219, characters 7-14", a.slice(0), [ 0, 0, 1, @@ -539,7 +539,7 @@ Mocha.describe("Bs_array_test", () => { 10 ]); Belt_Array.fill(a, -13, 1, 7); - Test_utils.eq("File \"bs_array_test.res\", line 220, characters 7-14", a.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 221, characters 7-14", a.slice(0), [ 7, 0, 1, @@ -552,22 +552,22 @@ Mocha.describe("Bs_array_test", () => { 10 ]); Belt_Array.fill(a, -13, 12, 7); - Test_utils.eq("File \"bs_array_test.res\", line 222, characters 7-14", a.slice(0), Belt_Array.make(10, 7)); + Test_utils.eq("File \"bs_array_test.res\", line 223, characters 7-14", a.slice(0), Belt_Array.make(10, 7)); Belt_Array.fill(a, 0, -1, 2); - Test_utils.eq("File \"bs_array_test.res\", line 224, characters 7-14", a.slice(0), Belt_Array.make(10, 7)); + Test_utils.eq("File \"bs_array_test.res\", line 225, characters 7-14", a.slice(0), Belt_Array.make(10, 7)); let b = [ 1, 2, 3 ]; Belt_Array.fill(b, 0, 0, 0); - Test_utils.eq("File \"bs_array_test.res\", line 227, characters 7-14", b, [ + Test_utils.eq("File \"bs_array_test.res\", line 228, characters 7-14", b, [ 1, 2, 3 ]); Belt_Array.fill(b, 4, 1, 0); - Test_utils.eq("File \"bs_array_test.res\", line 229, characters 7-14", b, [ + Test_utils.eq("File \"bs_array_test.res\", line 230, characters 7-14", b, [ 1, 2, 3 @@ -577,7 +577,7 @@ Mocha.describe("Bs_array_test", () => { let a0 = Belt_Array.makeBy(10, x => x); let b0 = Belt_Array.make(10, 3); Belt_Array.blit(a0, 1, b0, 2, 5); - Test_utils.eq("File \"bs_array_test.res\", line 236, characters 7-14", b0.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 237, characters 7-14", b0.slice(0), [ 3, 3, 1, @@ -590,7 +590,7 @@ Mocha.describe("Bs_array_test", () => { 3 ]); Belt_Array.blit(a0, -1, b0, 2, 5); - Test_utils.eq("File \"bs_array_test.res\", line 238, characters 7-14", b0.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 239, characters 7-14", b0.slice(0), [ 3, 3, 9, @@ -603,7 +603,7 @@ Mocha.describe("Bs_array_test", () => { 3 ]); Belt_Array.blit(a0, -1, b0, -2, 5); - Test_utils.eq("File \"bs_array_test.res\", line 240, characters 7-14", b0.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 241, characters 7-14", b0.slice(0), [ 3, 3, 9, @@ -616,7 +616,7 @@ Mocha.describe("Bs_array_test", () => { 3 ]); Belt_Array.blit(a0, -2, b0, -2, 2); - Test_utils.eq("File \"bs_array_test.res\", line 242, characters 7-14", b0.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 243, characters 7-14", b0.slice(0), [ 3, 3, 9, @@ -629,12 +629,12 @@ Mocha.describe("Bs_array_test", () => { 9 ]); Belt_Array.blit(a0, -11, b0, -11, 100); - Test_utils.eq("File \"bs_array_test.res\", line 244, characters 7-14", b0.slice(0), a0); + Test_utils.eq("File \"bs_array_test.res\", line 245, characters 7-14", b0.slice(0), a0); Belt_Array.blit(a0, -11, b0, -11, 2); - Test_utils.eq("File \"bs_array_test.res\", line 246, characters 7-14", b0.slice(0), a0); + Test_utils.eq("File \"bs_array_test.res\", line 247, characters 7-14", b0.slice(0), a0); let aa = Belt_Array.makeBy(10, x => x); Belt_Array.blit(aa, -1, aa, 1, 2); - Test_utils.eq("File \"bs_array_test.res\", line 249, characters 7-14", aa.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 250, characters 7-14", aa.slice(0), [ 0, 9, 2, @@ -647,7 +647,7 @@ Mocha.describe("Bs_array_test", () => { 9 ]); Belt_Array.blit(aa, -2, aa, 1, 2); - Test_utils.eq("File \"bs_array_test.res\", line 251, characters 7-14", aa.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 252, characters 7-14", aa.slice(0), [ 0, 8, 9, @@ -660,7 +660,7 @@ Mocha.describe("Bs_array_test", () => { 9 ]); Belt_Array.blit(aa, -5, aa, 4, 3); - Test_utils.eq("File \"bs_array_test.res\", line 253, characters 7-14", aa.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 254, characters 7-14", aa.slice(0), [ 0, 8, 9, @@ -673,7 +673,7 @@ Mocha.describe("Bs_array_test", () => { 9 ]); Belt_Array.blit(aa, 4, aa, 5, 3); - Test_utils.eq("File \"bs_array_test.res\", line 255, characters 7-14", aa.slice(0), [ + Test_utils.eq("File \"bs_array_test.res\", line 256, characters 7-14", aa.slice(0), [ 0, 8, 9, @@ -685,22 +685,22 @@ Mocha.describe("Bs_array_test", () => { 8, 9 ]); - Test_utils.eq("File \"bs_array_test.res\", line 256, characters 7-14", Belt_Array.make(0, 3), []); - Test_utils.eq("File \"bs_array_test.res\", line 257, characters 7-14", Belt_Array.make(-1, 3), []); + Test_utils.eq("File \"bs_array_test.res\", line 257, characters 7-14", Belt_Array.make(0, 3), []); + Test_utils.eq("File \"bs_array_test.res\", line 258, characters 7-14", Belt_Array.make(-1, 3), []); let c = [ 0, 1, 2 ]; Belt_Array.blit(c, 4, c, 1, 1); - Test_utils.eq("File \"bs_array_test.res\", line 260, characters 7-14", c, [ + Test_utils.eq("File \"bs_array_test.res\", line 261, characters 7-14", c, [ 0, 1, 2 ]); }); Mocha.test("bs_array_test_zip_functions", () => { - Test_utils.eq("File \"bs_array_test.res\", line 264, characters 7-14", Belt_Array.zip([ + Test_utils.eq("File \"bs_array_test.res\", line 265, characters 7-14", Belt_Array.zip([ 1, 2, 3 @@ -723,7 +723,7 @@ Mocha.describe("Bs_array_test", () => { 4 ] ]); - Test_utils.eq("File \"bs_array_test.res\", line 265, characters 7-14", Belt_Array.zip([ + Test_utils.eq("File \"bs_array_test.res\", line 266, characters 7-14", Belt_Array.zip([ 2, 3, 4, @@ -746,7 +746,7 @@ Mocha.describe("Bs_array_test", () => { 3 ] ]); - Test_utils.eq("File \"bs_array_test.res\", line 266, characters 7-14", Belt_Array.zipBy([ + Test_utils.eq("File \"bs_array_test.res\", line 267, characters 7-14", Belt_Array.zipBy([ 2, 3, 4, @@ -760,7 +760,7 @@ Mocha.describe("Bs_array_test", () => { 1, 1 ]); - Test_utils.eq("File \"bs_array_test.res\", line 267, characters 7-14", Belt_Array.zipBy([ + Test_utils.eq("File \"bs_array_test.res\", line 268, characters 7-14", Belt_Array.zipBy([ 1, 2, 3 @@ -774,7 +774,7 @@ Mocha.describe("Bs_array_test", () => { 1, 1 ], x => -x | 0)); - Test_utils.eq("File \"bs_array_test.res\", line 268, characters 7-14", Belt_Array.unzip([ + Test_utils.eq("File \"bs_array_test.res\", line 269, characters 7-14", Belt_Array.unzip([ [ 1, 2 @@ -808,37 +808,37 @@ Mocha.describe("Bs_array_test", () => { return v; }; Mocha.test("bs_array_test_iteration_functions", () => { - Test_utils.eq("File \"bs_array_test.res\", line 280, characters 7-14", sumUsingForEach([ + Test_utils.eq("File \"bs_array_test.res\", line 281, characters 7-14", sumUsingForEach([ 0, 1, 2, 3, 4 ]), 10); - Test_utils.ok("File \"bs_array_test.res\", line 281, characters 7-14", !Belt_Array.every([ + Test_utils.ok("File \"bs_array_test.res\", line 282, characters 7-14", !Belt_Array.every([ 0, 1, 2, 3, 4 ], x => x > 2)); - Test_utils.ok("File \"bs_array_test.res\", line 282, characters 7-14", Belt_Array.some([ + Test_utils.ok("File \"bs_array_test.res\", line 283, characters 7-14", Belt_Array.some([ 1, 3, 7, 8 ], x => x % 2 === 0)); - Test_utils.ok("File \"bs_array_test.res\", line 283, characters 7-14", !Belt_Array.some([ + Test_utils.ok("File \"bs_array_test.res\", line 284, characters 7-14", !Belt_Array.some([ 1, 3, 7 ], x => x % 2 === 0)); - Test_utils.ok("File \"bs_array_test.res\", line 284, characters 7-14", !Belt_Array.eq([ + Test_utils.ok("File \"bs_array_test.res\", line 285, characters 7-14", !Belt_Array.eq([ 0, 1 ], [1], (prim0, prim1) => prim0 === prim1)); let c = 0; - Test_utils.ok("File \"bs_array_test.res\", line 286, characters 6-13", (Belt_Array.forEachWithIndex([ + Test_utils.ok("File \"bs_array_test.res\", line 287, characters 6-13", (Belt_Array.forEachWithIndex([ 1, 1, 1 @@ -848,21 +848,21 @@ Mocha.describe("Bs_array_test", () => { }); let id = (loc, x) => { let u = x.slice(0); - Test_utils.eq("File \"bs_array_test.res\", line 297, characters 6-13", Belt_Array.reverse(x), (Belt_Array.reverseInPlace(u), u)); + Test_utils.eq("File \"bs_array_test.res\", line 298, characters 6-13", Belt_Array.reverse(x), (Belt_Array.reverseInPlace(u), u)); }; Mocha.test("bs_array_test_id_functions", () => { - id("File \"bs_array_test.res\", line 307, characters 7-14", []); - id("File \"bs_array_test.res\", line 308, characters 7-14", [1]); - id("File \"bs_array_test.res\", line 309, characters 7-14", [ + id("File \"bs_array_test.res\", line 308, characters 7-14", []); + id("File \"bs_array_test.res\", line 309, characters 7-14", [1]); + id("File \"bs_array_test.res\", line 310, characters 7-14", [ 1, 2 ]); - id("File \"bs_array_test.res\", line 310, characters 7-14", [ + id("File \"bs_array_test.res\", line 311, characters 7-14", [ 1, 2, 3 ]); - id("File \"bs_array_test.res\", line 311, characters 7-14", [ + id("File \"bs_array_test.res\", line 312, characters 7-14", [ 1, 2, 3, @@ -872,19 +872,19 @@ Mocha.describe("Bs_array_test", () => { Mocha.test("bs_array_test_every2_some2", () => { let every2 = (xs, ys, x) => Belt_Array.every2(Belt_List.toArray(xs), Belt_List.toArray(ys), x); let some2 = (xs, ys, x) => Belt_Array.some2(Belt_List.toArray(xs), Belt_List.toArray(ys), x); - Test_utils.eq("File \"bs_array_test.res\", line 319, characters 7-14", every2(/* [] */0, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); - Test_utils.eq("File \"bs_array_test.res\", line 320, characters 7-14", every2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); - Test_utils.eq("File \"bs_array_test.res\", line 321, characters 7-14", every2({hd: 2, tl: /* [] */0}, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); - Test_utils.eq("File \"bs_array_test.res\", line 322, characters 7-14", every2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 4, tl: /* [] */0}}, (x, y) => x > y), false); - Test_utils.eq("File \"bs_array_test.res\", line 323, characters 7-14", every2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 0, tl: /* [] */0}}, (x, y) => x > y), true); - Test_utils.eq("File \"bs_array_test.res\", line 324, characters 7-14", some2(/* [] */0, {hd: 1, tl: /* [] */0}, (x, y) => x > y), false); - Test_utils.eq("File \"bs_array_test.res\", line 325, characters 7-14", some2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); - Test_utils.eq("File \"bs_array_test.res\", line 326, characters 7-14", some2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 4, tl: /* [] */0}}, (x, y) => x > y), true); - Test_utils.eq("File \"bs_array_test.res\", line 327, characters 7-14", some2({hd: 0, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 4, tl: /* [] */0}}, (x, y) => x > y), false); - Test_utils.eq("File \"bs_array_test.res\", line 328, characters 7-14", some2({hd: 0, tl: {hd: 3, tl: /* [] */0}}, {hd: 3, tl: {hd: 2, tl: /* [] */0}}, (x, y) => x > y), true); + Test_utils.eq("File \"bs_array_test.res\", line 320, characters 7-14", every2(/* [] */0, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); + Test_utils.eq("File \"bs_array_test.res\", line 321, characters 7-14", every2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); + Test_utils.eq("File \"bs_array_test.res\", line 322, characters 7-14", every2({hd: 2, tl: /* [] */0}, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); + Test_utils.eq("File \"bs_array_test.res\", line 323, characters 7-14", every2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 4, tl: /* [] */0}}, (x, y) => x > y), false); + Test_utils.eq("File \"bs_array_test.res\", line 324, characters 7-14", every2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 0, tl: /* [] */0}}, (x, y) => x > y), true); + Test_utils.eq("File \"bs_array_test.res\", line 325, characters 7-14", some2(/* [] */0, {hd: 1, tl: /* [] */0}, (x, y) => x > y), false); + Test_utils.eq("File \"bs_array_test.res\", line 326, characters 7-14", some2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: /* [] */0}, (x, y) => x > y), true); + Test_utils.eq("File \"bs_array_test.res\", line 327, characters 7-14", some2({hd: 2, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 4, tl: /* [] */0}}, (x, y) => x > y), true); + Test_utils.eq("File \"bs_array_test.res\", line 328, characters 7-14", some2({hd: 0, tl: {hd: 3, tl: /* [] */0}}, {hd: 1, tl: {hd: 4, tl: /* [] */0}}, (x, y) => x > y), false); + Test_utils.eq("File \"bs_array_test.res\", line 329, characters 7-14", some2({hd: 0, tl: {hd: 3, tl: /* [] */0}}, {hd: 3, tl: {hd: 2, tl: /* [] */0}}, (x, y) => x > y), true); }); Mocha.test("bs_array_test_concat_functions", () => { - Test_utils.eq("File \"bs_array_test.res\", line 332, characters 7-14", Belt_Array.concat([], [ + Test_utils.eq("File \"bs_array_test.res\", line 333, characters 7-14", Belt_Array.concat([], [ 1, 2, 3 @@ -893,8 +893,8 @@ Mocha.describe("Bs_array_test", () => { 2, 3 ]); - Test_utils.eq("File \"bs_array_test.res\", line 333, characters 7-14", Belt_Array.concat([], []), []); - Test_utils.eq("File \"bs_array_test.res\", line 334, characters 7-14", Belt_Array.concat([ + Test_utils.eq("File \"bs_array_test.res\", line 334, characters 7-14", Belt_Array.concat([], []), []); + Test_utils.eq("File \"bs_array_test.res\", line 335, characters 7-14", Belt_Array.concat([ 3, 2 ], [ @@ -908,7 +908,7 @@ Mocha.describe("Bs_array_test", () => { 2, 3 ]); - Test_utils.eq("File \"bs_array_test.res\", line 335, characters 7-14", Belt_Array.concatMany([ + Test_utils.eq("File \"bs_array_test.res\", line 336, characters 7-14", Belt_Array.concatMany([ [ 3, 2 @@ -925,7 +925,7 @@ Mocha.describe("Bs_array_test", () => { 2, 3 ]); - Test_utils.eq("File \"bs_array_test.res\", line 336, characters 7-14", Belt_Array.concatMany([ + Test_utils.eq("File \"bs_array_test.res\", line 337, characters 7-14", Belt_Array.concatMany([ [ 3, 2 @@ -945,7 +945,7 @@ Mocha.describe("Bs_array_test", () => { 3, 0 ]); - Test_utils.eq("File \"bs_array_test.res\", line 337, characters 7-14", Belt_Array.concatMany([ + Test_utils.eq("File \"bs_array_test.res\", line 338, characters 7-14", Belt_Array.concatMany([ [], [ 3, @@ -966,13 +966,13 @@ Mocha.describe("Bs_array_test", () => { 3, 0 ]); - Test_utils.eq("File \"bs_array_test.res\", line 338, characters 7-14", Belt_Array.concatMany([ + Test_utils.eq("File \"bs_array_test.res\", line 339, characters 7-14", Belt_Array.concatMany([ [], [] ]), []); }); Mocha.test("bs_array_test_cmp_functions", () => { - Test_utils.ok("File \"bs_array_test.res\", line 342, characters 7-14", Belt_Array.cmp([ + Test_utils.ok("File \"bs_array_test.res\", line 343, characters 7-14", Belt_Array.cmp([ 1, 2, 3 @@ -982,7 +982,7 @@ Mocha.describe("Bs_array_test", () => { 2, 3 ], Primitive_int.compare) < 0); - Test_utils.ok("File \"bs_array_test.res\", line 343, characters 7-14", Belt_Array.cmp([ + Test_utils.ok("File \"bs_array_test.res\", line 344, characters 7-14", Belt_Array.cmp([ 0, 1, 2, @@ -992,7 +992,7 @@ Mocha.describe("Bs_array_test", () => { 2, 3 ], Primitive_int.compare) > 0); - Test_utils.ok("File \"bs_array_test.res\", line 344, characters 7-14", Belt_Array.cmp([ + Test_utils.ok("File \"bs_array_test.res\", line 345, characters 7-14", Belt_Array.cmp([ 1, 2, 3 @@ -1001,7 +1001,7 @@ Mocha.describe("Bs_array_test", () => { 1, 2 ], Primitive_int.compare) > 0); - Test_utils.ok("File \"bs_array_test.res\", line 345, characters 7-14", Belt_Array.cmp([ + Test_utils.ok("File \"bs_array_test.res\", line 346, characters 7-14", Belt_Array.cmp([ 1, 2, 3 @@ -1010,7 +1010,7 @@ Mocha.describe("Bs_array_test", () => { 2, 3 ], Primitive_int.compare) === 0); - Test_utils.ok("File \"bs_array_test.res\", line 346, characters 7-14", Belt_Array.cmp([ + Test_utils.ok("File \"bs_array_test.res\", line 347, characters 7-14", Belt_Array.cmp([ 1, 2, 4 @@ -1021,24 +1021,24 @@ Mocha.describe("Bs_array_test", () => { ], Primitive_int.compare) > 0); }); Mocha.test("bs_array_test_getBy_functions", () => { - Test_utils.eq("File \"bs_array_test.res\", line 350, characters 7-14", Belt_Array.getBy([ + Test_utils.eq("File \"bs_array_test.res\", line 351, characters 7-14", Belt_Array.getBy([ 1, 2, 3 ], x => x > 1), 2); - Test_utils.eq("File \"bs_array_test.res\", line 351, characters 7-14", Belt_Array.getBy([ + Test_utils.eq("File \"bs_array_test.res\", line 352, characters 7-14", Belt_Array.getBy([ 1, 2, 3 ], x => x > 3), undefined); }); Mocha.test("bs_array_test_getIndexBy_functions", () => { - Test_utils.eq("File \"bs_array_test.res\", line 355, characters 7-14", Belt_Array.getIndexBy([ + Test_utils.eq("File \"bs_array_test.res\", line 356, characters 7-14", Belt_Array.getIndexBy([ 1, 2, 3 ], x => x > 1), 1); - Test_utils.eq("File \"bs_array_test.res\", line 356, characters 7-14", Belt_Array.getIndexBy([ + Test_utils.eq("File \"bs_array_test.res\", line 357, characters 7-14", Belt_Array.getIndexBy([ 1, 2, 3 @@ -1049,7 +1049,7 @@ Mocha.describe("Bs_array_test", () => { arr.push(3); arr.push(2); arr.push(1); - Test_utils.eq("File \"bs_array_test.res\", line 364, characters 7-14", arr, [ + Test_utils.eq("File \"bs_array_test.res\", line 365, characters 7-14", arr, [ 3, 2, 1 diff --git a/tests/belt_tests/src/bs_array_test.res b/tests/belt_tests/src/bs_array_test.res index 210494f4e8a..1f003726a64 100644 --- a/tests/belt_tests/src/bs_array_test.res +++ b/tests/belt_tests/src/bs_array_test.res @@ -7,6 +7,7 @@ module L = Belt.List let {push} = module(A) type t<'a> = array<'a> + let () = [1, 2, 3, 4] ->Array.filter(x => x > 2) diff --git a/tests/belt_tests/src/bs_map_set_dict_test.mjs b/tests/belt_tests/src/bs_map_set_dict_test.mjs index 3ce435a6abd..95714d16554 100644 --- a/tests/belt_tests/src/bs_map_set_dict_test.mjs +++ b/tests/belt_tests/src/bs_map_set_dict_test.mjs @@ -77,7 +77,7 @@ Mocha.describe("Bs_map_set_dict_test", () => { x ]), Icmp); let u1 = Belt_Map.set(u0, 39, 120); - Test_utils.ok("File \"bs_map_set_dict_test.res\", line 71, characters 6-13", Belt_Array.every2(Belt_Map.toArray(u0), Belt_Array.map(Array_data_util.range(0, 39), x => [ + Test_utils.ok("File \"bs_map_set_dict_test.res\", line 75, characters 6-13", Belt_Array.every2(Belt_Map.toArray(u0), Belt_Array.map(Array_data_util.range(0, 39), x => [ x, x ]), (param, param$1) => { @@ -87,7 +87,7 @@ Mocha.describe("Bs_map_set_dict_test", () => { return false; } })); - Test_utils.ok("File \"bs_map_set_dict_test.res\", line 80, characters 6-13", Belt_List.every2(Belt_Map.toList(u0), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), x => [ + Test_utils.ok("File \"bs_map_set_dict_test.res\", line 84, characters 6-13", Belt_List.every2(Belt_Map.toList(u0), Belt_List.fromArray(Belt_Array.map(Array_data_util.range(0, 39), x => [ x, x ])), (param, param$1) => { @@ -97,20 +97,20 @@ Mocha.describe("Bs_map_set_dict_test", () => { return false; } })); - Test_utils.eq("File \"bs_map_set_dict_test.res\", line 87, characters 7-14", Belt_Map.get(u0, 39), 39); - Test_utils.eq("File \"bs_map_set_dict_test.res\", line 88, characters 7-14", Belt_Map.get(u1, 39), 120); + Test_utils.eq("File \"bs_map_set_dict_test.res\", line 91, characters 7-14", Belt_Map.get(u0, 39), 39); + Test_utils.eq("File \"bs_map_set_dict_test.res\", line 92, characters 7-14", Belt_Map.get(u1, 39), 120); }); Mocha.test("bs_map_set_dict_test_large_dataset", () => { let u = Belt_Map.fromArray(Belt_Array.makeByAndShuffle(10000, x => [ x, x ]), Icmp); - Test_utils.eq("File \"bs_map_set_dict_test.res\", line 93, characters 7-14", Belt_Array.makeBy(10000, x => [ + Test_utils.eq("File \"bs_map_set_dict_test.res\", line 97, characters 7-14", Belt_Array.makeBy(10000, x => [ x, x ]), Belt_Map.toArray(u)); }); - Mocha.test("map_set_dict_tests", () => Test_utils.ok("File \"bs_map_set_dict_test.res\", line 98, characters 7-14", true)); + Mocha.test("map_set_dict_tests", () => Test_utils.ok("File \"bs_map_set_dict_test.res\", line 102, characters 7-14", true)); }); let M; diff --git a/tests/belt_tests/src/bs_map_set_dict_test.res b/tests/belt_tests/src/bs_map_set_dict_test.res index 07a105b02a3..02dc8183518 100644 --- a/tests/belt_tests/src/bs_map_set_dict_test.res +++ b/tests/belt_tests/src/bs_map_set_dict_test.res @@ -22,6 +22,7 @@ let m2: M.t = M.make(~id=module(I2)) let vv = MI.empty let vv2 = MI.empty module Md0 = Belt.Map.Dict + let () = { let count = 1_000_00 let data = ref(M.getData(m)) @@ -37,7 +38,9 @@ let () = { let newm = M.packIdData(~data=data.contents, ~id=m_dict) Console.log(newm) } + module ISet = Belt.Set + let () = { let m = Md0.empty let m11 = Md0.set(~cmp=Icmp.cmp, m, 1, 1) @@ -47,6 +50,7 @@ let () = { } module S0 = Belt.Set.Dict + let () = { let count = 100_000 let v = ISet.make(~id=module(Icmp2)) diff --git a/tests/belt_tests/src/bs_poly_map_test.mjs b/tests/belt_tests/src/bs_poly_map_test.mjs index 3e74c6d4d4d..e7d2875de24 100644 --- a/tests/belt_tests/src/bs_poly_map_test.mjs +++ b/tests/belt_tests/src/bs_poly_map_test.mjs @@ -60,10 +60,10 @@ Mocha.describe("Bs_poly_map_test", () => { Mocha.test("bs_poly_map_test_1", () => { let u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); let u1 = Belt_Map.fromArray(randomRange(30, 120), Icmp); - Test_utils.ok("File \"bs_poly_map_test.res\", line 58, characters 7-14", Belt_Set.eq(mergeInter(u0, u1), Belt_Set.fromArray(Array_data_util.range(30, 100), Icmp))); - Test_utils.ok("File \"bs_poly_map_test.res\", line 59, characters 7-14", Belt_Set.eq(mergeUnion(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 120), Icmp))); - Test_utils.ok("File \"bs_poly_map_test.res\", line 60, characters 7-14", Belt_Set.eq(mergeDiff(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 29), Icmp))); - Test_utils.ok("File \"bs_poly_map_test.res\", line 61, characters 7-14", Belt_Set.eq(mergeDiff(u1, u0), Belt_Set.fromArray(Array_data_util.range(101, 120), Icmp))); + Test_utils.ok("File \"bs_poly_map_test.res\", line 59, characters 7-14", Belt_Set.eq(mergeInter(u0, u1), Belt_Set.fromArray(Array_data_util.range(30, 100), Icmp))); + Test_utils.ok("File \"bs_poly_map_test.res\", line 60, characters 7-14", Belt_Set.eq(mergeUnion(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 120), Icmp))); + Test_utils.ok("File \"bs_poly_map_test.res\", line 61, characters 7-14", Belt_Set.eq(mergeDiff(u0, u1), Belt_Set.fromArray(Array_data_util.range(0, 29), Icmp))); + Test_utils.ok("File \"bs_poly_map_test.res\", line 62, characters 7-14", Belt_Set.eq(mergeDiff(u1, u0), Belt_Set.fromArray(Array_data_util.range(101, 120), Icmp))); }); Mocha.test("bs_poly_map_test_2", () => { let a0 = Belt_Map.fromArray(randomRange(0, 10), Icmp); @@ -83,14 +83,14 @@ Mocha.describe("Bs_poly_map_test", () => { }); let a5 = Belt_Map.remove(a0, 3); let a6 = Belt_Map.remove(a5, 3); - Test_utils.ok("File \"bs_poly_map_test.res\", line 88, characters 7-14", a5 === a6); - Test_utils.ok("File \"bs_poly_map_test.res\", line 89, characters 7-14", Belt_Map.has(a0, 3)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 90, characters 7-14", !Belt_Map.has(a5, 3)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 91, characters 7-14", Primitive_object.equal(Belt_Map.get(a0, 3), 3)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 92, characters 7-14", Primitive_object.equal(Belt_Map.get(a1, 3), 33)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 93, characters 7-14", Belt_Map.get(a2, 3) === undefined); - Test_utils.ok("File \"bs_poly_map_test.res\", line 95, characters 7-14", Primitive_object.equal(Belt_Map.get(a3, 3), 11)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 96, characters 7-14", Belt_Map.get(a4, 3) === undefined); + Test_utils.ok("File \"bs_poly_map_test.res\", line 89, characters 7-14", a5 === a6); + Test_utils.ok("File \"bs_poly_map_test.res\", line 90, characters 7-14", Belt_Map.has(a0, 3)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 91, characters 7-14", !Belt_Map.has(a5, 3)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 92, characters 7-14", Primitive_object.equal(Belt_Map.get(a0, 3), 3)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 93, characters 7-14", Primitive_object.equal(Belt_Map.get(a1, 3), 33)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 94, characters 7-14", Belt_Map.get(a2, 3) === undefined); + Test_utils.ok("File \"bs_poly_map_test.res\", line 96, characters 7-14", Primitive_object.equal(Belt_Map.get(a3, 3), 11)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 97, characters 7-14", Belt_Map.get(a4, 3) === undefined); let a7 = Belt_Map.removeMany(a0, [ 7, 8, @@ -104,18 +104,18 @@ Mocha.describe("Bs_poly_map_test", () => { 5, 6 ]); - Test_utils.eq("File \"bs_poly_map_test.res\", line 99, characters 7-14", Belt_Map.keysToArray(a7), [ + Test_utils.eq("File \"bs_poly_map_test.res\", line 100, characters 7-14", Belt_Map.keysToArray(a7), [ 9, 10 ]); let a8 = Belt_Map.removeMany(a7, Array_data_util.randomRange(0, 100)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 101, characters 7-14", Belt_Map.isEmpty(a8)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 102, characters 7-14", Belt_Map.isEmpty(a8)); }); Mocha.test("bs_poly_map_test_3", () => { let u0 = Belt_Map.fromArray(randomRange(0, 100), Icmp); let u1 = Belt_Map.set(u0, 3, 32); - Test_utils.eq("File \"bs_poly_map_test.res\", line 107, characters 7-14", Belt_Map.get(u1, 3), 32); - Test_utils.eq("File \"bs_poly_map_test.res\", line 108, characters 7-14", Belt_Map.get(u0, 3), 3); + Test_utils.eq("File \"bs_poly_map_test.res\", line 108, characters 7-14", Belt_Map.get(u1, 3), 32); + Test_utils.eq("File \"bs_poly_map_test.res\", line 109, characters 7-14", Belt_Map.get(u0, 3), 3); }); let acc = (m, is) => Belt_Array.reduce(is, m, (a, i) => Belt_Map.update(a, i, n => { if (n !== undefined) { @@ -127,7 +127,7 @@ Mocha.describe("Bs_poly_map_test", () => { Mocha.test("bs_poly_map_test_4", () => { let m = Belt_Map.make(Icmp); let m1 = acc(m, Belt_Array.concat(Array_data_util.randomRange(0, 20), Array_data_util.randomRange(10, 30))); - Test_utils.ok("File \"bs_poly_map_test.res\", line 125, characters 6-13", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, i => [ + Test_utils.ok("File \"bs_poly_map_test.res\", line 126, characters 6-13", Belt_Map.eq(m1, Belt_Map.fromArray(Belt_Array.makeBy(31, i => [ i, i >= 10 && i <= 20 ? 2 : 1 ]), Icmp), (x, y) => x === y)); @@ -142,7 +142,7 @@ Mocha.describe("Bs_poly_map_test", () => { x, x ]), Icmp); - Test_utils.ok("File \"bs_poly_map_test.res\", line 152, characters 7-14", Belt_Map.eq(v1, v2, (x, y) => x === y)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 153, characters 7-14", Belt_Map.eq(v1, v2, (x, y) => x === y)); let inc = x => { if (x !== undefined) { return x + 1 | 0; @@ -155,22 +155,22 @@ Mocha.describe("Bs_poly_map_test", () => { let match = Belt_Map.split(v3, 5000); let match$1 = match[0]; let match$2 = Belt_Map.get(v3, 10); - Test_utils.ok("File \"bs_poly_map_test.res\", line 163, characters 6-13", match$2 === 11); + Test_utils.ok("File \"bs_poly_map_test.res\", line 164, characters 6-13", match$2 === 11); let match$3 = Belt_Map.get(v3, -10); - Test_utils.ok("File \"bs_poly_map_test.res\", line 170, characters 6-13", match$3 === undefined); + Test_utils.ok("File \"bs_poly_map_test.res\", line 171, characters 6-13", match$3 === undefined); let match$4 = Belt_Map.get(v4, -10); - Test_utils.ok("File \"bs_poly_map_test.res\", line 177, characters 6-13", match$4 === 0); - Test_utils.ok("File \"bs_poly_map_test.res\", line 183, characters 7-14", Belt_Map.isEmpty(Belt_Map.remove(Belt_Map.make(Icmp), 0))); - Test_utils.ok("File \"bs_poly_map_test.res\", line 184, characters 7-14", Belt_Map.isEmpty(Belt_Map.removeMany(Belt_Map.make(Icmp), [0]))); - Test_utils.ok("File \"bs_poly_map_test.res\", line 186, characters 6-13", match[1] === 5000); - Test_utils.ok("File \"bs_poly_map_test.res\", line 192, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$1[0]), Belt_Array.makeBy(5000, i => i), (a, b) => a === b)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 193, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$1[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (a, b) => a === b)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 178, characters 6-13", match$4 === 0); + Test_utils.ok("File \"bs_poly_map_test.res\", line 184, characters 7-14", Belt_Map.isEmpty(Belt_Map.remove(Belt_Map.make(Icmp), 0))); + Test_utils.ok("File \"bs_poly_map_test.res\", line 185, characters 7-14", Belt_Map.isEmpty(Belt_Map.removeMany(Belt_Map.make(Icmp), [0]))); + Test_utils.ok("File \"bs_poly_map_test.res\", line 187, characters 6-13", match[1] === 5000); + Test_utils.ok("File \"bs_poly_map_test.res\", line 193, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$1[0]), Belt_Array.makeBy(5000, i => i), (a, b) => a === b)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 194, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$1[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (a, b) => a === b)); let v7 = Belt_Map.remove(v3, 5000); let match$5 = Belt_Map.split(v7, 5000); let match$6 = match$5[0]; - Test_utils.ok("File \"bs_poly_map_test.res\", line 198, characters 6-13", match$5[1] === undefined); - Test_utils.ok("File \"bs_poly_map_test.res\", line 204, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$6[0]), Belt_Array.makeBy(5000, i => i), (a, b) => a === b)); - Test_utils.ok("File \"bs_poly_map_test.res\", line 205, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$6[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (a, b) => a === b)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 199, characters 6-13", match$5[1] === undefined); + Test_utils.ok("File \"bs_poly_map_test.res\", line 205, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$6[0]), Belt_Array.makeBy(5000, i => i), (a, b) => a === b)); + Test_utils.ok("File \"bs_poly_map_test.res\", line 206, characters 7-14", Belt_Array.eq(Belt_Map.keysToArray(match$6[1]), Belt_Array.makeBy(5000, i => 5001 + i | 0), (a, b) => a === b)); }); }); diff --git a/tests/belt_tests/src/bs_poly_map_test.res b/tests/belt_tests/src/bs_poly_map_test.res index 42c0ff5438f..230e8ac774a 100644 --- a/tests/belt_tests/src/bs_poly_map_test.res +++ b/tests/belt_tests/src/bs_poly_map_test.res @@ -35,6 +35,7 @@ let mergeUnion = (s1, s2) => ), ), ) + let mergeDiff = (s1, s2) => setOfArray( M.keysToArray( diff --git a/tests/belt_tests/src/bs_queue_test.mjs b/tests/belt_tests/src/bs_queue_test.mjs index ac610f47f8a..8ee291545d3 100644 --- a/tests/belt_tests/src/bs_queue_test.mjs +++ b/tests/belt_tests/src/bs_queue_test.mjs @@ -28,7 +28,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 21, + 22, 4 ], Error: new Error() @@ -39,7 +39,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 22, + 23, 4 ], Error: new Error() @@ -53,7 +53,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 23, + 24, 4 ], Error: new Error() @@ -68,7 +68,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 24, + 25, 4 ], Error: new Error() @@ -84,7 +84,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 25, + 26, 4 ], Error: new Error() @@ -95,7 +95,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 26, + 27, 4 ], Error: new Error() @@ -110,7 +110,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 27, + 28, 4 ], Error: new Error() @@ -121,7 +121,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 28, + 29, 4 ], Error: new Error() @@ -135,7 +135,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 29, + 30, 4 ], Error: new Error() @@ -146,7 +146,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 30, + 31, 4 ], Error: new Error() @@ -157,7 +157,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 31, + 32, 4 ], Error: new Error() @@ -168,7 +168,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 32, + 33, 4 ], Error: new Error() @@ -179,7 +179,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 33, + 34, 4 ], Error: new Error() @@ -192,7 +192,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 34, + 35, 4 ], Error: new Error() @@ -205,7 +205,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 39, + 40, 4 ], Error: new Error() @@ -216,7 +216,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 40, + 41, 4 ], Error: new Error() @@ -227,7 +227,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 41, + 42, 4 ], Error: new Error() @@ -238,7 +238,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 42, + 43, 4 ], Error: new Error() @@ -251,7 +251,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 43, + 44, 4 ], Error: new Error() @@ -264,7 +264,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 48, + 49, 4 ], Error: new Error() @@ -275,7 +275,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 49, + 50, 4 ], Error: new Error() @@ -286,7 +286,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 50, + 51, 4 ], Error: new Error() @@ -297,7 +297,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 51, + 52, 4 ], Error: new Error() @@ -308,7 +308,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 52, + 53, 4 ], Error: new Error() @@ -319,7 +319,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 53, + 54, 4 ], Error: new Error() @@ -330,7 +330,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 54, + 55, 4 ], Error: new Error() @@ -341,7 +341,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 55, + 56, 4 ], Error: new Error() @@ -352,7 +352,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 56, + 57, 4 ], Error: new Error() @@ -363,7 +363,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 57, + 58, 4 ], Error: new Error() @@ -376,7 +376,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 58, + 59, 4 ], Error: new Error() @@ -393,7 +393,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 67, + 68, 4 ], Error: new Error() @@ -404,7 +404,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 68, + 69, 4 ], Error: new Error() @@ -415,7 +415,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 69, + 70, 4 ], Error: new Error() @@ -429,7 +429,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 71, + 72, 4 ], Error: new Error() @@ -457,7 +457,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 80, + 81, 4 ], Error: new Error() @@ -479,7 +479,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 81, + 82, 4 ], Error: new Error() @@ -490,7 +490,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 82, + 83, 4 ], Error: new Error() @@ -501,7 +501,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 83, + 84, 4 ], Error: new Error() @@ -513,7 +513,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 85, + 86, 6 ], Error: new Error() @@ -526,7 +526,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 88, + 89, 6 ], Error: new Error() @@ -541,7 +541,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 94, + 95, 4 ], Error: new Error() @@ -554,7 +554,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 97, + 98, 6 ], Error: new Error() @@ -565,7 +565,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 98, + 99, 6 ], Error: new Error() @@ -578,7 +578,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 101, + 102, 6 ], Error: new Error() @@ -589,7 +589,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 102, + 103, 6 ], Error: new Error() @@ -602,7 +602,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 105, + 106, 4 ], Error: new Error() @@ -615,7 +615,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 106, + 107, 4 ], Error: new Error() @@ -633,7 +633,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 118, + 119, 8 ], Error: new Error() @@ -650,7 +650,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 126, + 127, 4 ], Error: new Error() @@ -661,7 +661,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 127, + 128, 4 ], Error: new Error() @@ -672,7 +672,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 128, + 129, 4 ], Error: new Error() @@ -683,7 +683,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 129, + 130, 4 ], Error: new Error() @@ -695,7 +695,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 131, + 132, 4 ], Error: new Error() @@ -706,7 +706,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 132, + 133, 4 ], Error: new Error() @@ -717,7 +717,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 133, + 134, 4 ], Error: new Error() @@ -730,7 +730,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 134, + 135, 4 ], Error: new Error() @@ -747,7 +747,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 142, + 143, 4 ], Error: new Error() @@ -763,7 +763,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 143, + 144, 4 ], Error: new Error() @@ -774,7 +774,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 144, + 145, 4 ], Error: new Error() @@ -785,7 +785,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 145, + 146, 4 ], Error: new Error() @@ -797,7 +797,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 147, + 148, 4 ], Error: new Error() @@ -808,7 +808,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 148, + 149, 4 ], Error: new Error() @@ -819,7 +819,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 149, + 150, 4 ], Error: new Error() @@ -837,7 +837,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 150, + 151, 4 ], Error: new Error() @@ -854,7 +854,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 158, + 159, 4 ], Error: new Error() @@ -865,7 +865,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 159, + 160, 4 ], Error: new Error() @@ -876,7 +876,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 160, + 161, 4 ], Error: new Error() @@ -892,7 +892,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 161, + 162, 4 ], Error: new Error() @@ -904,7 +904,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 163, + 164, 4 ], Error: new Error() @@ -915,7 +915,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 164, + 165, 4 ], Error: new Error() @@ -926,7 +926,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 165, + 166, 4 ], Error: new Error() @@ -944,7 +944,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 166, + 167, 4 ], Error: new Error() @@ -964,7 +964,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 177, + 178, 4 ], Error: new Error() @@ -980,7 +980,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 178, + 179, 4 ], Error: new Error() @@ -991,7 +991,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 179, + 180, 4 ], Error: new Error() @@ -1007,7 +1007,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 180, + 181, 4 ], Error: new Error() @@ -1019,7 +1019,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 182, + 183, 4 ], Error: new Error() @@ -1030,7 +1030,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 183, + 184, 4 ], Error: new Error() @@ -1051,7 +1051,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 185, + 186, 4 ], Error: new Error() @@ -1062,7 +1062,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 186, + 187, 4 ], Error: new Error() @@ -1075,7 +1075,7 @@ Mocha.describe("Bs_queue_test", () => { RE_EXN_ID: "Assert_failure", _1: [ "bs_queue_test.res", - 188, + 189, 4 ], Error: new Error() @@ -1089,14 +1089,14 @@ Mocha.describe("Bs_queue_test", () => { 4 ]); let q1 = Belt_MutableQueue.map(q, x => x - 1 | 0); - Test_utils.eq("File \"bs_queue_test.res\", line 194, characters 7-14", Belt_MutableQueue.toArray(q1), [ + Test_utils.eq("File \"bs_queue_test.res\", line 195, characters 7-14", Belt_MutableQueue.toArray(q1), [ 0, 1, 2, 3 ]); - Test_utils.ok("File \"bs_queue_test.res\", line 195, characters 7-14", Belt_MutableQueue.isEmpty(Belt_MutableQueue.fromArray([]))); - Test_utils.ok("File \"bs_queue_test.res\", line 196, characters 7-14", Belt_MutableQueue.isEmpty(Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), x => x + 1 | 0))); + Test_utils.ok("File \"bs_queue_test.res\", line 196, characters 7-14", Belt_MutableQueue.isEmpty(Belt_MutableQueue.fromArray([]))); + Test_utils.ok("File \"bs_queue_test.res\", line 197, characters 7-14", Belt_MutableQueue.isEmpty(Belt_MutableQueue.map(Belt_MutableQueue.fromArray([]), x => x + 1 | 0))); }); }); diff --git a/tests/belt_tests/src/bs_queue_test.res b/tests/belt_tests/src/bs_queue_test.res index 1f663f19afc..4028468a5c0 100644 --- a/tests/belt_tests/src/bs_queue_test.res +++ b/tests/belt_tests/src/bs_queue_test.res @@ -10,6 +10,7 @@ let does_raise = (f, q) => } catch { | _ => true } + let queueAdd = (q, x) => { Q.add(q, x) q diff --git a/tests/belt_tests/src/gpr_4265_test.mjs b/tests/belt_tests/src/gpr_4265_test.mjs index ca122c08aa6..48628e8679b 100644 --- a/tests/belt_tests/src/gpr_4265_test.mjs +++ b/tests/belt_tests/src/gpr_4265_test.mjs @@ -26,7 +26,7 @@ Belt_MutableMapInt.remove(mockMap, 1726); let n1 = Belt_MutableMapInt.getExn(mockMap, 6667); Mocha.describe("Gpr_4265_test", () => { - Mocha.test("mutable map operations", () => Test_utils.eq("File \"gpr_4265_test.res\", line 18, characters 42-49", n, n1)); + Mocha.test("mutable map operations", () => Test_utils.eq("File \"gpr_4265_test.res\", line 20, characters 42-49", n, n1)); }); export { diff --git a/tests/belt_tests/src/gpr_4265_test.res b/tests/belt_tests/src/gpr_4265_test.res index c07c02d03e2..2209e3acd7d 100644 --- a/tests/belt_tests/src/gpr_4265_test.res +++ b/tests/belt_tests/src/gpr_4265_test.res @@ -3,10 +3,12 @@ open Test_utils open Belt let mockMap = MutableMap.Int.make() + let add = id => { mockMap->MutableMap.Int.set(id, id) id } + let remove = id => mockMap->MutableMap.Int.remove(id) let _ = add(1726) let n = add(6667) diff --git a/tests/belt_tests/src/node_assert.res b/tests/belt_tests/src/node_assert.res index 3acfbc38ae3..39af0dc874a 100644 --- a/tests/belt_tests/src/node_assert.res +++ b/tests/belt_tests/src/node_assert.res @@ -1,5 +1,7 @@ @module("node:assert") external ok: (bool, ~message: string=?) => unit = "ok" + @module("node:assert") external deepEqual: ('a, 'a, ~message: string=?) => unit = "deepStrictEqual" + @module("node:assert") external throws: (unit => 'a, ~error: 'b=?, ~message: string=?) => unit = "throws" diff --git a/tests/belt_tests/src/rec_module_opt.res b/tests/belt_tests/src/rec_module_opt.res index 19162bb1f59..6a02d2ae333 100644 --- a/tests/belt_tests/src/rec_module_opt.res +++ b/tests/belt_tests/src/rec_module_opt.res @@ -12,6 +12,7 @@ module rec A: { let cmp: (t, t) => int } = { type t = Leaf(string) | Node(AComparable.t) + let cmp = (t1, t2) => switch (t1, t2) { | (Leaf(s1), Leaf(s2)) => Pervasives.compare(s1, s2) @@ -19,6 +20,7 @@ module rec A: { | (Node(_), Leaf(_)) => -1 | (Node(n1), Node(n2)) => Obj.magic(AComparable.cmp)(n1, n2) } + let hello = x => x } and AComparable: Belt.Id.Comparable with type t = A.t = Belt.Id.MakeComparable(A) @@ -35,6 +37,7 @@ and Y0: { } = { type t } + module type S = { let f: int => int } diff --git a/tests/build_tests/gpr_978/src/gpr_978_module.res b/tests/build_tests/gpr_978/src/gpr_978_module.res index 68133a407da..39e394116f1 100644 --- a/tests/build_tests/gpr_978/src/gpr_978_module.res +++ b/tests/build_tests/gpr_978/src/gpr_978_module.res @@ -1,4 +1,5 @@ exception M(int) + module M = { let x = 3 } diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Alias.res b/tests/build_tests/jsx_preserve_semantics/cases/Alias.res index d389cf1ca16..3543309b8ed 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Alias.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Alias.res @@ -11,6 +11,7 @@ let localComp = () => { } } + let localCompResult = localComp() let localCompKeyed = () => { @@ -20,6 +21,7 @@ let localCompKeyed = () => { } } + let localCompKeyedResult = localCompKeyed() let localCompChildren = () => { @@ -29,15 +31,19 @@ let localCompChildren = () => { } } + let localCompChildrenResult = localCompChildren() // Top-level module aliasing a lowercase top-level value let topComp = React.memo(Icon.make) + module T = { let make = topComp } + let topAlias = let topAliasKeyed = + let topAliasMulti =
diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Children.res b/tests/build_tests/jsx_preserve_semantics/cases/Children.res index bea131fbfc4..45d74724ff3 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Children.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Children.res @@ -2,32 +2,40 @@ let cond = ref(true) let items = ["a", "b"] let singleString =
{React.string("a")}
+ let twoStrings =
{React.string("a")} {React.string("b")}
+ let singleElement =
+ let fragmentSingle = <> + let fragmentSingleString = <>{React.string("x")} + let fragmentTwo = <> + let emptyFragment = <> let mapped =
    {items->Array.map(i =>
  • {React.string(i)}
  • )->React.array}
+ let mappedWithSibling =
  • {React.string("first")}
  • {items->Array.map(i =>
  • {React.string(i)}
  • )->React.array}
+ let seqChild =
{ @@ -35,10 +43,12 @@ let seqChild = React.string("s") }
+ let ternaryChild =
{cond.contents ? : }
let nullChild =
{React.null}
let intChild =
{React.int(1)}
let floatChild =
{React.float(1.5)}
+ let nested =
@@ -47,6 +57,7 @@ let nested =
+ let manyChildren =
@@ -60,21 +71,25 @@ module Comp = { @react.component let make = (~children) =>
{children}
} + let componentSingleChild = + let componentChildren = + let componentStringChild = {React.string("t")} module NoChildren = { @react.component let make = () => React.null } + let noChildren = // Children passed explicitly as a prop @@ -83,6 +98,7 @@ let childrenProp = } /> // Element bound to a variable and used as a child let el = let varChild =
{el}
+ let varChildren =
+ let keyedSingleChild = + let keyedNoChild =
let optKey: option = Some("ok") let optionalKey =
let optionalKeyNone =
+ let keyedComponent = diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Copy.res b/tests/build_tests/jsx_preserve_semantics/cases/Copy.res index 81225b864ee..2c7332b21ed 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Copy.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Copy.res @@ -1,5 +1,6 @@ module Req = { type props = {a: string, b: string} + @react.componentWithProps let make = (props: props) =>
} diff --git a/tests/build_tests/jsx_preserve_semantics/cases/CustomExt.res b/tests/build_tests/jsx_preserve_semantics/cases/CustomExt.res index e1a5d184b6b..e4527de563a 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/CustomExt.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/CustomExt.res @@ -3,30 +3,40 @@ module MyJsx = { type element = Jsx.element type component<'props> = Jsx.component<'props> + external component: Jsx.componentLike<'props, element> => component<'props> = "%component_identity" @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" + @module("react/jsx-runtime") external jsxs: (component<'props>, 'props) => element = "jsxs" + @module("react/jsx-runtime") external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsx" + @module("react/jsx-runtime") external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs" + external array: array => element = "%identity" type fragmentProps = {children?: element} @module("react/jsx-runtime") external jsxFragment: component = "Fragment" type domProps = {children?: element, title?: string} + module Elements = { external someElement: element => option = "%identity" + @module("react/jsx-runtime") external jsx: (string, domProps) => element = "jsx" + @module("react/jsx-runtime") external jsxs: (string, domProps) => element = "jsxs" + @module("react/jsx-runtime") external jsxKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "jsx" + @module("react/jsx-runtime") external jsxsKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "jsxs" } @@ -41,15 +51,18 @@ let element =
+ let fragment = <> + let fragmentSingle = <> + let emptyFragment = <> let component = let keyed =
diff --git a/tests/build_tests/jsx_preserve_semantics/cases/CustomFn.res b/tests/build_tests/jsx_preserve_semantics/cases/CustomFn.res index 42277033a42..a1d176e751a 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/CustomFn.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/CustomFn.res @@ -4,41 +4,51 @@ module MyJsx = { type element = Jsx.element type component<'props> = Jsx.component<'props> + external component: Jsx.componentLike<'props, element> => component<'props> = "%component_identity" @module("react/jsx-runtime") external rawJsx: (component<'props>, 'props) => element = "jsx" + @module("react/jsx-runtime") external rawJsxs: (component<'props>, 'props) => element = "jsxs" + @module("react/jsx-runtime") external rawStrJsx: (string, 'props) => element = "jsx" + @module("react/jsx-runtime") external rawStrJsxs: (string, 'props) => element = "jsxs" let jsx = (c, p) => rawJsx(c, p) let jsxs = (c, p) => rawJsxs(c, p) + let jsxKeyed = (c, p, ~key: option=?, ()) => { ignore(key) rawJsx(c, p) } + let jsxsKeyed = (c, p, ~key: option=?, ()) => { ignore(key) rawJsxs(c, p) } + external array: array => element = "%identity" type fragmentProps = {children?: element} @module("react/jsx-runtime") external jsxFragment: component = "Fragment" type domProps = {children?: element, title?: string} + module Elements = { external someElement: element => option = "%identity" let jsx = (s: string, p: domProps) => rawStrJsx(s, p) let jsxs = (s: string, p: domProps) => rawStrJsxs(s, p) + let jsxKeyed = (s: string, p: domProps, ~key: option=?, ()) => { ignore(key) rawStrJsx(s, p) } + let jsxsKeyed = (s: string, p: domProps, ~key: option=?, ()) => { ignore(key) rawStrJsxs(s, p) @@ -55,10 +65,12 @@ let element =
+ let fragment = <> + let component = let keyed =
diff --git a/tests/build_tests/jsx_preserve_semantics/cases/CustomRenamed.res b/tests/build_tests/jsx_preserve_semantics/cases/CustomRenamed.res index d9d91db3031..62b01255506 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/CustomRenamed.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/CustomRenamed.res @@ -3,30 +3,40 @@ module MyJsx = { type element = Jsx.element type component<'props> = Jsx.component<'props> + external component: Jsx.componentLike<'props, element> => component<'props> = "%component_identity" @module("some-runtime") external jsx: (component<'props>, 'props) => element = "j" + @module("some-runtime") external jsxs: (component<'props>, 'props) => element = "js" + @module("some-runtime") external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "j" + @module("some-runtime") external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "js" + external array: array => element = "%identity" type fragmentProps = {children?: element} @module("some-runtime") external jsxFragment: component = "Frag" type domProps = {children?: element, title?: string} + module Elements = { external someElement: element => option = "%identity" + @module("some-runtime") external jsx: (string, domProps) => element = "j" + @module("some-runtime") external jsxs: (string, domProps) => element = "js" + @module("some-runtime") external jsxKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "j" + @module("some-runtime") external jsxsKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "js" } @@ -41,15 +51,18 @@ let element =
+ let fragment = <> + let fragmentSingle = <> + let emptyFragment = <> let component = let keyed =
@@ -61,18 +74,22 @@ let localComp = () => { } } + let localCompResult = localComp() module Top = { let make = Comp.make } + let top = @module("react") external memo: MyJsx.component<'p> => MyJsx.component<'p> = "memo" let memoComp = memo(Comp.make) + module TopMemo = { let make = memoComp } + let topMemo = let localMemo = () => { @@ -82,4 +99,5 @@ let localMemo = () => { } } + let localMemoResult = localMemo() diff --git a/tests/build_tests/jsx_preserve_semantics/cases/CustomUnit.res b/tests/build_tests/jsx_preserve_semantics/cases/CustomUnit.res index 16e8e766b35..9cb746824b0 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/CustomUnit.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/CustomUnit.res @@ -1,33 +1,44 @@ @@jsxConfig({version: 4, module_: "MyJsx"}) + // A JSX module whose elements are unit: the calls return undefined module MyJsx = { type element = unit type component<'props> = Jsx.component<'props> + external component: Jsx.componentLike<'props, element> => component<'props> = "%component_identity" @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" + @module("react/jsx-runtime") external jsxs: (component<'props>, 'props) => element = "jsxs" + @module("react/jsx-runtime") external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsx" + @module("react/jsx-runtime") external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs" + external array: array => element = "%identity" type fragmentProps = {children?: element} @module("react/jsx-runtime") external jsxFragment: component = "Fragment" type domProps = {children?: element, title?: string} + module Elements = { external someElement: element => option = "%identity" + @module("react/jsx-runtime") external jsx: (string, domProps) => element = "jsx" + @module("react/jsx-runtime") external jsxs: (string, domProps) => element = "jsxs" + @module("react/jsx-runtime") external jsxKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "jsx" + @module("react/jsx-runtime") external jsxsKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "jsxs" } @@ -42,15 +53,18 @@ let element =
+ let fragment = <> + let fragmentSingle = <> + let emptyFragment = <> let component = let keyed =
diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Dict.res b/tests/build_tests/jsx_preserve_semantics/cases/Dict.res index bc603fd4e01..9547af21776 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Dict.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Dict.res @@ -6,6 +6,7 @@ let twoSpreads = Obj.magic, ...otherProps->Obj.mag let spacedKey = Obj.magic, "foo bar": "x"}->Obj.magic} /> let protoKey = Obj.magic, "__proto__": "x"}->Obj.magic} /> let hyphenatedKey = Obj.magic, "aria-label": "x"}->Obj.magic} /> + let repeatedChildren =
Obj.magic} /> + let repeatedKey = Obj.magic, "title": "x", "title": "y"}->Obj.magic} /> + let keyProp = Obj.magic, "key": "inner"}->Obj.magic} key="outer" /> + let keyPropAfter = Obj.magic, "key": "inner"}->Obj.magic} /> diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Optim.res b/tests/build_tests/jsx_preserve_semantics/cases/Optim.res index 4c74c8cbd15..2fb9171e325 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Optim.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Optim.res @@ -14,6 +14,7 @@ let localProvider = () => {

} + let localProviderResult = localProvider() let localMemoOnce = () => { @@ -22,6 +23,7 @@ let localMemoOnce = () => { } } + let localMemoOnceResult = localMemoOnce() // Local function component referenced directly through a local module @@ -32,6 +34,7 @@ let localFn = () => { } } + let localFnResult = localFn() // Props record bound once and inlined @@ -39,14 +42,17 @@ let inlinedProps = () => { let p: JsxDOM.domProps = {title: "a", className: "b"}
} + let inlinedPropsResult = inlinedProps() // Props bound once with a non-constant field let dyn = ref("d") + let inlinedDynProps = () => { let p: JsxDOM.domProps = {title: dyn.contents}
} + let inlinedDynPropsResult = inlinedDynProps() // Element used through an inlined helper @@ -59,14 +65,17 @@ let pick = n => | 0 => | _ => } + let picked = pick(0) // Key from a computation with side effects and props with side effects let counter = ref(0) + let next = () => { counter := counter.contents + 1 Int.toString(counter.contents) } + let orderKeyed =
let orderProps =
@@ -75,10 +84,12 @@ module Default = { @react.component @module("some-lib") external make: (~x: int) => React.element = "default" } + let defaultImport = module LowerNamed = { @react.component @module("some-lib") external make: (~x: int) => React.element = "head" } + let lowerNamed = diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Order.res b/tests/build_tests/jsx_preserve_semantics/cases/Order.res index 44d16e45f71..f2885495c92 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Order.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Order.res @@ -12,15 +12,18 @@ Object.defineProperty(globalThis, "LoggedComp", { `) type props = {a: string, b: string} + module Logged = { @val external make: React.component = "LoggedComp" } let log: array = %raw(`orderLog`) + let getProps = (): props => { log->Array.push("props") {a: "a", b: "b"} } + let note = (s: string) => { log->Array.push(s) s @@ -40,6 +43,8 @@ module LoggedDict = { // A dict spread is one props object: its children are evaluated before the // fields after them let dictBase: dict = dict{} + let dictChildren = + let dictChildrenOrder = log->Array.copy diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Props.res b/tests/build_tests/jsx_preserve_semantics/cases/Props.res index 149cc6d5276..eaa5ad0341b 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Props.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Props.res @@ -4,12 +4,15 @@ module AsProp = { @as("data-x") dataX: string, @as("class") klass: string, } + @react.componentWithProps let make = (_: props) => React.null } + let asProp = let sideEffect = ref(0) + let seqValue =
el } + let elementValue = } /> let optTitle: option = Some("x") @@ -59,6 +63,7 @@ module Opt = {
} } + let optComponent = let optComponentSome = let optComponentWithOpt = @@ -69,9 +74,11 @@ module ArrayProps = { @as("0") first: string, @as("1") second: string, } + @react.componentWithProps let make = (_: props) => React.null } + let arrayProps = // Prop value that is an await-free conditional element diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Spread.res b/tests/build_tests/jsx_preserve_semantics/cases/Spread.res index 82b330b2de4..13d79a86fae 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Spread.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Spread.res @@ -9,11 +9,13 @@ let spreadCall =
let spreadCallOverride =
let spreadField =
let spreadFieldOverride =
+ let spreadChildren =
+ let spreadKeyed =
let spreadOnlyKeyed =
let spreadCallKeyed =
@@ -23,12 +25,14 @@ let localConst = () => { let p: JsxDOM.domProps = {title: "local"}
} + let localConstResult = localConst() let localConstOnly = () => { let p: JsxDOM.domProps = {title: "local"}
} + let localConstOnlyResult = localConstOnly() // Spread record built with record spread syntax @@ -36,18 +40,22 @@ let localSpread = () => { let p: JsxDOM.domProps = {...base, title: "x"}
} + let localSpreadResult = localSpread() // Spread inside a component of its props parameter module Pass = { type props = {title?: string, className?: string} + @react.componentWithProps let make = (props: props) =>
} + module Wrap = { @react.componentWithProps let make = (props: Pass.props) => } + let wrap = // Spread of a record value coming from an optional @@ -56,6 +64,7 @@ let fromOpt = (o: option) => | Some(p) =>
| None => React.null } + let fromOptResult = fromOpt(Some({title: "o"})) // An optional prop that is None overrides the spread's value diff --git a/tests/build_tests/jsx_preserve_semantics/cases/Tags.res b/tests/build_tests/jsx_preserve_semantics/cases/Tags.res index 6dbf5a5c39d..def862b11cd 100644 --- a/tests/build_tests/jsx_preserve_semantics/cases/Tags.res +++ b/tests/build_tests/jsx_preserve_semantics/cases/Tags.res @@ -15,6 +15,7 @@ let localModule = () => { } } + let localModuleResult = localModule() // Local module whose make is a memo @@ -22,10 +23,12 @@ let localMemo = () => { module L = { @react.component let make = () => + let make = React.memo(make) } } + let localMemoResult = localMemo() // External bound to a lowercase global @@ -33,6 +36,7 @@ module Lower = { @react.component @val external make: (~x: int) => React.element = "lowerComp" } + let lowerExternal = // Module alias @@ -44,14 +48,17 @@ module F = (X: {}) => { @react.component let make = () => } + module G = F() let functor = // First-class component stored in a module let iconMake = Icon.make + module C = { let make = iconMake } + let firstClass = // Component passed as a function argument and rebound in a local module @@ -61,6 +68,7 @@ let withComponent = (comp: React.component) => { } } + let withComponentResult = withComponent(Icon.make) // React.Fragment component with key @@ -68,6 +76,7 @@ let keyedFragment =
+ let plainReactFragment =
@@ -76,9 +85,11 @@ let plainReactFragment = // Context provider let ctx = React.createContext(0) + module Provider = { let make = React.Context.provider(ctx) } + let provider =
@@ -91,6 +102,7 @@ module Outer = { let make = (~a) =>
} } + let nested = // A component whose name is the JSX module's fragment name is not a fragment @@ -98,4 +110,5 @@ module Widgets = { type props = {} let jsxFragment: React.component = React.component(_ => ) } + let notFragment = diff --git a/tests/build_tests/option_transitive_dependency/dep/A.res b/tests/build_tests/option_transitive_dependency/dep/A.res index 9eca7efc0b0..08a7ebbade5 100644 --- a/tests/build_tests/option_transitive_dependency/dep/A.res +++ b/tests/build_tests/option_transitive_dependency/dep/A.res @@ -22,7 +22,9 @@ module Abstract = { module Unboxed = { @unboxed type t = Value(option) + let value = Value(None) + let isUndefined = value => { let Value(inner) = value Option.isNone(inner) diff --git a/tests/build_tests/option_transitive_dependency/dep/A.resi b/tests/build_tests/option_transitive_dependency/dep/A.resi index 9f83772ac3b..87f901d582d 100644 --- a/tests/build_tests/option_transitive_dependency/dep/A.resi +++ b/tests/build_tests/option_transitive_dependency/dep/A.resi @@ -22,6 +22,7 @@ module Abstract: { module Unboxed: { @unboxed type t = Value(option) + let value: t let isUndefined: t => bool } diff --git a/tests/build_tests/react_ppx/src/React.res b/tests/build_tests/react_ppx/src/React.res index cb5168fc595..30ef2938ba8 100644 --- a/tests/build_tests/react_ppx/src/React.res +++ b/tests/build_tests/react_ppx/src/React.res @@ -49,12 +49,16 @@ external createRef: unit => Ref.t> = "createRef" module Children = { @module("react") @scope("Children") @val external map: (element, element => element) => element = "map" + @module("react") @scope("Children") @val external forEach: (element, element => unit) => unit = "forEach" + @module("react") @scope("Children") @val external count: element => int = "count" + @module("react") @scope("Children") @val external only: element => element = "only" + @module("react") @scope("Children") @val external toArray: element => array = "toArray" } @@ -124,64 +128,88 @@ external useReducerWithMapState: ( @module("react") external useEffect: (unit => option unit>) => unit = "useEffect" + @module("react") external useEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useEffect" + @module("react") external useEffect1: (unit => option unit>, array<'a>) => unit = "useEffect" + @module("react") external useEffect2: (unit => option unit>, ('a, 'b)) => unit = "useEffect" + @module("react") external useEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useEffect" + @module("react") external useEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useEffect" + @module("react") external useEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" + @module("react") external useEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" + @module("react") external useEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = "useEffect" @module("react") external useLayoutEffect: (unit => option unit>) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect0: (unit => option unit>, @as(json`[]`) _) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect1: (unit => option unit>, array<'a>) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect2: (unit => option unit>, ('a, 'b)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect3: (unit => option unit>, ('a, 'b, 'c)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect4: (unit => option unit>, ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect5: (unit => option unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect6: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect7: (unit => option unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = "useLayoutEffect" @module("react") external useMemo: (unit => 'any) => 'any = "useMemo" + @module("react") external useMemo0: (unit => 'any, @as(json`[]`) _) => 'any = "useMemo" + @module("react") external useMemo1: (unit => 'any, array<'a>) => 'any = "useMemo" + @module("react") external useMemo2: (unit => 'any, ('a, 'b)) => 'any = "useMemo" + @module("react") external useMemo3: (unit => 'any, ('a, 'b, 'c)) => 'any = "useMemo" + @module("react") external useMemo4: (unit => 'any, ('a, 'b, 'c, 'd)) => 'any = "useMemo" + @module("react") external useMemo5: (unit => 'any, ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo" + @module("react") external useMemo6: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo" + @module("react") external useMemo7: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo" @@ -190,25 +218,33 @@ type callback<'input, 'output> = 'input => 'output @module("react") external useCallback: ('input => 'output) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback0: ('input => 'output, @as(json`[]`) _) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback1: ('input => 'output, array<'a>) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback2: ('input => 'output, ('a, 'b)) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback3: ('input => 'output, ('a, 'b, 'c)) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback4: ('input => 'output, ('a, 'b, 'c, 'd)) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback5: ('input => 'output, ('a, 'b, 'c, 'd, 'e)) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback6: ('input => 'output, ('a, 'b, 'c, 'd, 'e, 'f)) => callback<'input, 'output> = "useCallback" + @module("react") external useCallback7: ( 'input => 'output, diff --git a/tests/build_tests/react_ppx/src/nested_component_producer.res b/tests/build_tests/react_ppx/src/nested_component_producer.res index bbd5762d0ed..14f98882f6d 100644 --- a/tests/build_tests/react_ppx/src/nested_component_producer.res +++ b/tests/build_tests/react_ppx/src/nested_component_producer.res @@ -6,6 +6,7 @@ module Provider = { module Trigger = { @react.component let make = (~label: string) => React.string(label) + let make = React.memo(make) } diff --git a/tests/build_tests/react_ppx/src/recursive_component_test.res b/tests/build_tests/react_ppx/src/recursive_component_test.res index bdf0dcee2a9..8402a245511 100644 --- a/tests/build_tests/react_ppx/src/recursive_component_test.res +++ b/tests/build_tests/react_ppx/src/recursive_component_test.res @@ -1,4 +1,5 @@ @@warning("-39") + // https://github.com/rescript-lang/rescript-compiler/issues/4511 /* [@config { diff --git a/tests/build_tests/super_errors/expected/UntaggedAtMostOneObject.res.expected b/tests/build_tests/super_errors/expected/UntaggedAtMostOneObject.res.expected index c1a32783d83..36c17ab480e 100644 --- a/tests/build_tests/super_errors/expected/UntaggedAtMostOneObject.res.expected +++ b/tests/build_tests/super_errors/expected/UntaggedAtMostOneObject.res.expected @@ -1,10 +1,10 @@ We've found a bug for you! - /.../fixtures/UntaggedAtMostOneObject.res:4:15-20 + /.../fixtures/UntaggedAtMostOneObject.res:5:15-20 - 2 │ type b = {y: int} - 3 │ @unboxed - 4 │ type t = A(a) | B(b) - 5 │ + 3 │ + 4 │ @unboxed + 5 │ type t = A(a) | B(b) + 6 │ This untagged variant definition is invalid: At most one case can be an object type. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/access_record_field_on_array.res.expected b/tests/build_tests/super_errors/expected/access_record_field_on_array.res.expected index 56dbdea9061..dc73dbad612 100644 --- a/tests/build_tests/super_errors/expected/access_record_field_on_array.res.expected +++ b/tests/build_tests/super_errors/expected/access_record_field_on_array.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/access_record_field_on_array.res:12:15 + /.../fixtures/access_record_field_on_array.res:13:15 - 10 │ } - 11 │ - 12 │ let f = X.x.c.d - 13 │ + 11 │ } + 12 │ + 13 │ let f = X.x.c.d + 14 │ You're trying to access the record field d, but the value you're trying to access it on is an array. You need to access an individual element of the array if you want to access an individual record field. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/access_record_field_on_option.res.expected b/tests/build_tests/super_errors/expected/access_record_field_on_option.res.expected index aaf398ff7db..30051b84528 100644 --- a/tests/build_tests/super_errors/expected/access_record_field_on_option.res.expected +++ b/tests/build_tests/super_errors/expected/access_record_field_on_option.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/access_record_field_on_option.res:12:15 + /.../fixtures/access_record_field_on_option.res:13:15 - 10 │ } - 11 │ - 12 │ let f = X.x.c.d - 13 │ + 11 │ } + 12 │ + 13 │ let f = X.x.c.d + 14 │ You're trying to access the record field d, but the value you're trying to access it on is an option. You need to unwrap the option first before accessing the record field. diff --git a/tests/build_tests/super_errors/expected/await.res.expected b/tests/build_tests/super_errors/expected/await.res.expected index bbea40f278a..5b7ef9f1595 100644 --- a/tests/build_tests/super_errors/expected/await.res.expected +++ b/tests/build_tests/super_errors/expected/await.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/await.res:4:9-17 + /.../fixtures/await.res:5:9-17 - 2 │ let foo = async () => { - 3 │ let _ = () - 4 │ () => await a() - 5 │ } - 6 │ + 3 │ let foo = async () => { + 4 │ let _ = () + 5 │ () => await a() + 6 │ } + 7 │ Await on expression not in an async context \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/for_of_type_mismatch.res.expected b/tests/build_tests/super_errors/expected/for_of_type_mismatch.res.expected index 5e28439cba9..b4ba7340258 100644 --- a/tests/build_tests/super_errors/expected/for_of_type_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/for_of_type_mismatch.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/for_of_type_mismatch.res:4:19 + /.../fixtures/for_of_type_mismatch.res:5:19 - 2 │ let numbers: array = [1, 2, 3] - 3 │ for x of numbers->Array.asIterable { - 4 │ let y: string = x - 5 │ Console.log(y) - 6 │ } + 3 │ + 4 │ for x of numbers->Array.asIterable { + 5 │ let y: string = x + 6 │ Console.log(y) + 7 │ } This has type: int But it's expected to have type: string diff --git a/tests/build_tests/super_errors/expected/function_call_mismatch.res.expected b/tests/build_tests/super_errors/expected/function_call_mismatch.res.expected index da64a4f475e..1bb3d2153a9 100644 --- a/tests/build_tests/super_errors/expected/function_call_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/function_call_mismatch.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/function_call_mismatch.res:6:3-10 + /.../fixtures/function_call_mismatch.res:7:3-10 - 4 │ - 5 │ let cloneInTemp = (temp: string): string => { - 6 │ cd(temp) - 7 │ exec("git clone git@github.com:myorg/myrepo.git") - 8 │ } + 5 │ + 6 │ let cloneInTemp = (temp: string): string => { + 7 │ cd(temp) + 8 │ exec("git clone git@github.com:myorg/myrepo.git") + 9 │ } This function call returns: string But it's expected to return: unit diff --git a/tests/build_tests/super_errors/expected/highlighting4.res.expected b/tests/build_tests/super_errors/expected/highlighting4.res.expected index 0b3ce13291f..0bfa9afd915 100644 --- a/tests/build_tests/super_errors/expected/highlighting4.res.expected +++ b/tests/build_tests/super_errors/expected/highlighting4.res.expected @@ -1,10 +1,10 @@ Warning number 3 (configured as error) - /.../fixtures/highlighting4.res:5:10 + /.../fixtures/highlighting4.res:7:10 - 3 │ @deprecated - 4 │ type a = int - 5 │ type b = a + 5 │ type a = int 6 │ + 7 │ type b = a + 8 │ deprecated: a \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/js_name_clash_module.res.expected b/tests/build_tests/super_errors/expected/js_name_clash_module.res.expected index 1851d2151b2..8b7496f764b 100644 --- a/tests/build_tests/super_errors/expected/js_name_clash_module.res.expected +++ b/tests/build_tests/super_errors/expected/js_name_clash_module.res.expected @@ -1,12 +1,13 @@ We've found a bug for you! - /.../fixtures/js_name_clash_module.res:2:8-4:1 + /.../fixtures/js_name_clash_module.res:3:8-5:1 1 │ exception Foo - 2 │ module Foo = { - 3 │  let x = 1 - 4 │ } - 5 │ + 2 │ + 3 │ module Foo = { + 4 │  let x = 1 + 5 │ } + 6 │ This module has the same JavaScript name Foo as the extension constructor at /.../fixtures/js_name_clash_module.res:1:1-13. diff --git a/tests/build_tests/super_errors/expected/jsx_component_prop_plain_function.res.expected b/tests/build_tests/super_errors/expected/jsx_component_prop_plain_function.res.expected index 9258619424b..74308847960 100644 --- a/tests/build_tests/super_errors/expected/jsx_component_prop_plain_function.res.expected +++ b/tests/build_tests/super_errors/expected/jsx_component_prop_plain_function.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/jsx_component_prop_plain_function.res:19:46-58 + /.../fixtures/jsx_component_prop_plain_function.res:20:46-58 - 17 │ } - 18 │ - 19 │ let _ = React.null} /> - 20 │ + 18 │ } + 19 │ + 20 │ let _ = React.null} /> + 21 │ This has type: 'a => 'b But it's expected to have type: diff --git a/tests/build_tests/super_errors/expected/jsx_invalid_prop_ast0_conversion.res.expected b/tests/build_tests/super_errors/expected/jsx_invalid_prop_ast0_conversion.res.expected index 54417e7cc55..e8366343797 100644 --- a/tests/build_tests/super_errors/expected/jsx_invalid_prop_ast0_conversion.res.expected +++ b/tests/build_tests/super_errors/expected/jsx_invalid_prop_ast0_conversion.res.expected @@ -1,10 +1,10 @@ We've found a bug for you! - /.../fixtures/jsx_invalid_prop_ast0_conversion.res:18:20-22 + /.../fixtures/jsx_invalid_prop_ast0_conversion.res:19:20-22 - 16 │ } - 17 │ - 18 │ let _ = - 19 │ + 17 │ } + 18 │ + 19 │ let _ = + 20 │ The prop bar does not belong to the JSX component  \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/jsx_plain_function_component.res.expected b/tests/build_tests/super_errors/expected/jsx_plain_function_component.res.expected index c4c1c500e29..64d891b165b 100644 --- a/tests/build_tests/super_errors/expected/jsx_plain_function_component.res.expected +++ b/tests/build_tests/super_errors/expected/jsx_plain_function_component.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/jsx_plain_function_component.res:26:10-16 + /.../fixtures/jsx_plain_function_component.res:28:10-16 - 24 │ } - 25 │ - 26 │ let _ = <Wrapper value="hello" /> + 26 │ } 27 │ + 28 │ let _ = <Wrapper value="hello" /> + 29 │ This JSX tag has type: Wrapper.props => Jsx.element But JSX component positions require: diff --git a/tests/build_tests/super_errors/expected/jsx_unboxed_props.res.expected b/tests/build_tests/super_errors/expected/jsx_unboxed_props.res.expected index d703d3287c8..eae14d12588 100644 --- a/tests/build_tests/super_errors/expected/jsx_unboxed_props.res.expected +++ b/tests/build_tests/super_errors/expected/jsx_unboxed_props.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/jsx_unboxed_props.res:15:10-28 + /.../fixtures/jsx_unboxed_props.res:16:10-28 - 13 │ } - 14 │ - 15 │ let el =  - 16 │ + 14 │ } + 15 │ + 16 │ let el = <Title title="x" /> + 17 │ The props of this JSX element have type props, which is an @unboxed record. diff --git a/tests/build_tests/super_errors/expected/jsx_unboxed_props_spread.res.expected b/tests/build_tests/super_errors/expected/jsx_unboxed_props_spread.res.expected index f41beccdf60..e1140cf80a6 100644 --- a/tests/build_tests/super_errors/expected/jsx_unboxed_props_spread.res.expected +++ b/tests/build_tests/super_errors/expected/jsx_unboxed_props_spread.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/jsx_unboxed_props_spread.res:19:10-29 + /.../fixtures/jsx_unboxed_props_spread.res:22:10-29 - 17 │ - 18 │ let props = {title: "x"} - 19 │ let el = <Title {...props} /> 20 │ + 21 │ let props = {title: "x"} + 22 │ let el = <Title {...props} /> + 23 │ The props of this JSX element have type props, which is an @unboxed record. diff --git a/tests/build_tests/super_errors/expected/missing_required_prop.res.expected b/tests/build_tests/super_errors/expected/missing_required_prop.res.expected index b969d40ef2e..02fb785ae12 100644 --- a/tests/build_tests/super_errors/expected/missing_required_prop.res.expected +++ b/tests/build_tests/super_errors/expected/missing_required_prop.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/missing_required_prop.res:28:7-35 + /.../fixtures/missing_required_prop.res:32:7-35 - 26 ┆ let make = () => { - 27 ┆ <Wrapper> - 28 ┆ <div>{""->React.string}</div> - 29 ┆ </Wrapper> - 30 ┆ } + 30 ┆ let make = () => { + 31 ┆ <Wrapper> + 32 ┆ <div>{""->React.string}</div> + 33 ┆ </Wrapper> + 34 ┆ } This JSX component does not accept child elements. It has no children prop <Wrapper /> \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/missing_required_prop_when_children.res.expected b/tests/build_tests/super_errors/expected/missing_required_prop_when_children.res.expected index ad47150c414..c893fc090d6 100644 --- a/tests/build_tests/super_errors/expected/missing_required_prop_when_children.res.expected +++ b/tests/build_tests/super_errors/expected/missing_required_prop_when_children.res.expected @@ -1,13 +1,13 @@ We've found a bug for you! - /.../fixtures/missing_required_prop_when_children.res:31:7-32:35 + /.../fixtures/missing_required_prop_when_children.res:36:7-37:35 - 29 ┆ let make = () => { - 30 ┆ <Wrapper> - 31 ┆ <button>{"yo"->React.string}</button> - 32 ┆  <div>{""->React.string}</div> - 33 ┆ </Wrapper> - 34 ┆ } + 34 ┆ let make = () => { + 35 ┆ <Wrapper> + 36 ┆ <button>{"yo"->React.string}</button> + 37 ┆  <div>{""->React.string}</div> + 38 ┆ </Wrapper> + 39 ┆ } The component <Wrapper /> is missing these required props: value \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/missing_required_prop_when_single_child.res.expected b/tests/build_tests/super_errors/expected/missing_required_prop_when_single_child.res.expected index b700a9b3cf3..81d5e1eae34 100644 --- a/tests/build_tests/super_errors/expected/missing_required_prop_when_single_child.res.expected +++ b/tests/build_tests/super_errors/expected/missing_required_prop_when_single_child.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/missing_required_prop_when_single_child.res:28:7-35 + /.../fixtures/missing_required_prop_when_single_child.res:32:7-35 - 26 ┆ let make = () => { - 27 ┆ <Wrapper> - 28 ┆ <div>{""->React.string}</div> - 29 ┆ </Wrapper> - 30 ┆ } + 30 ┆ let make = () => { + 31 ┆ <Wrapper> + 32 ┆ <div>{""->React.string}</div> + 33 ┆ </Wrapper> + 34 ┆ } The component <Wrapper /> is missing these required props: value \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/module_alias_coercion_printed_once.res.expected b/tests/build_tests/super_errors/expected/module_alias_coercion_printed_once.res.expected index 3b34c88c9da..abadc11f4b6 100644 --- a/tests/build_tests/super_errors/expected/module_alias_coercion_printed_once.res.expected +++ b/tests/build_tests/super_errors/expected/module_alias_coercion_printed_once.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/module_alias_coercion_printed_once.res:5:28-46 + /.../fixtures/module_alias_coercion_printed_once.res:6:28-46 - 3 │ } - 4 │ module A = Inner - 5 │ let m = (x: A.t<[#X]>) => (x :> A.t<[#X | #Y]>) - 6 │ + 4 │ + 5 │ module A = Inner + 6 │ let m = (x: A.t<[#X]>) => (x :> A.t<[#X | #Y]>) + 7 │ Type A.t<[#X]> is not a subtype of A.t<[#X | #Y]> diff --git a/tests/build_tests/super_errors/expected/moreArguments5.res.expected b/tests/build_tests/super_errors/expected/moreArguments5.res.expected index 16c7f7e2195..db837e4f93d 100644 --- a/tests/build_tests/super_errors/expected/moreArguments5.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments5.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/moreArguments5.res:5:9 + /.../fixtures/moreArguments5.res:6:9 - 3 │ } - 4 │ let x = (a, b, c, d) => {Sub.a: 2} - 5 │ let y = x(2).Sub.a - 6 │ + 4 │ + 5 │ let x = (a, b, c, d) => {Sub.a: 2} + 6 │ let y = x(2).Sub.a + 7 │ This function call is incorrect. The function has type: diff --git a/tests/build_tests/super_errors/expected/newtype_group_warning_scope.res.expected b/tests/build_tests/super_errors/expected/newtype_group_warning_scope.res.expected index c6bdf128bc0..43b010caa33 100644 --- a/tests/build_tests/super_errors/expected/newtype_group_warning_scope.res.expected +++ b/tests/build_tests/super_errors/expected/newtype_group_warning_scope.res.expected @@ -1,12 +1,12 @@ Warning number 26 - /.../fixtures/newtype_group_warning_scope.res:6:7-12 + /.../fixtures/newtype_group_warning_scope.res:7:7-12 - 4 │ } - 5 │ let unsuppressed = (type a, x: a) => { - 6 │ let unused = 1 - 7 │ x - 8 │ } + 5 │ + 6 │ let unsuppressed = (type a, x: a) => { + 7 │ let unused = 1 + 8 │ x + 9 │ } unused variable unused. diff --git a/tests/build_tests/super_errors/expected/not_allowed_in_functor_body.res.expected b/tests/build_tests/super_errors/expected/not_allowed_in_functor_body.res.expected index c1ded55de1f..a461b6f1843 100644 --- a/tests/build_tests/super_errors/expected/not_allowed_in_functor_body.res.expected +++ b/tests/build_tests/super_errors/expected/not_allowed_in_functor_body.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/not_allowed_in_functor_body.res:17:14-25 + /.../fixtures/not_allowed_in_functor_body.res:18:14-25 - 15 │ } 16 │ ) - 17 │ module M = unpack(pack) - 18 │ let _ = M.v - 19 │ } + 17 │ + 18 │ module M = unpack(pack) + 19 │ let _ = M.v + 20 │ } This expression creates fresh types. It is not allowed inside applicative functors. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/object_private_row_write_through_signature.res.expected b/tests/build_tests/super_errors/expected/object_private_row_write_through_signature.res.expected index f1fdf4f3166..c1a3ae4f1b2 100644 --- a/tests/build_tests/super_errors/expected/object_private_row_write_through_signature.res.expected +++ b/tests/build_tests/super_errors/expected/object_private_row_write_through_signature.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/object_private_row_write_through_signature.res:8:26-35 + /.../fixtures/object_private_row_write_through_signature.res:9:26-35 - 6 │ type t = private {.."x": int} - 7 │ } - 8 │ let mutate = (o: M.t) => o["x"] = 1 - 9 │ + 7 │ } + 8 │ + 9 │ let mutate = (o: M.t) => o["x"] = 1 + 10 │ This expression has type M.t The field x is not settable. Only fields annotated with @set, e.g. {@set "x": int}, can be assigned. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/object_value_signature_set_mismatch.res.expected b/tests/build_tests/super_errors/expected/object_value_signature_set_mismatch.res.expected index 23c1042053f..2ec94c9e288 100644 --- a/tests/build_tests/super_errors/expected/object_value_signature_set_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/object_value_signature_set_mismatch.res.expected @@ -1,13 +1,13 @@ We've found a bug for you! - /.../fixtures/object_value_signature_set_mismatch.res:7:5-9:1 + /.../fixtures/object_value_signature_set_mismatch.res:8:5-10:1 - 5 │ module M: { - 6 │ let v: {"x": int} - 7 │ } = { - 8 │  let v = impl - 9 │ } - 10 │ + 6 │ module M: { + 7 │ let v: {"x": int} + 8 │ } = { + 9 │  let v = impl + 10 │ } + 11 │ Signature mismatch: Modules do not match: @@ -22,7 +22,7 @@ let v: {@set "x": int} is not included in let v: {"x": int} - /.../fixtures/object_value_signature_set_mismatch.res:6:3-19: + /.../fixtures/object_value_signature_set_mismatch.res:7:3-19: Expected declaration - /.../fixtures/object_value_signature_set_mismatch.res:8:7: + /.../fixtures/object_value_signature_set_mismatch.res:9:7: Actual declaration \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/object_write_after_open_target_coercion.res.expected b/tests/build_tests/super_errors/expected/object_write_after_open_target_coercion.res.expected index e4bc3854d96..413d0b6aa04 100644 --- a/tests/build_tests/super_errors/expected/object_write_after_open_target_coercion.res.expected +++ b/tests/build_tests/super_errors/expected/object_write_after_open_target_coercion.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/object_write_after_open_target_coercion.res:12:3-19 + /.../fixtures/object_write_after_open_target_coercion.res:13:3-19 - 10 │ let p = (v: {"x": wide}) => { - 11 │ let r = (v :> {.."x": narrow}) - 12 │ r["x"] = {"a": 1} - 13 │ } - 14 │ + 11 │ let p = (v: {"x": wide}) => { + 12 │ let r = (v :> {.."x": narrow}) + 13 │ r["x"] = {"a": 1} + 14 │ } + 15 │ This expression has type {"x": narrow} The field x is not settable. Only fields annotated with @set, e.g. {@set "x": int}, can be assigned. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/object_write_poly_field_less_general.res.expected b/tests/build_tests/super_errors/expected/object_write_poly_field_less_general.res.expected index bcbcd492f7d..e785ac048a0 100644 --- a/tests/build_tests/super_errors/expected/object_write_poly_field_less_general.res.expected +++ b/tests/build_tests/super_errors/expected/object_write_poly_field_less_general.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/object_write_poly_field_less_general.res:6:13-19 + /.../fixtures/object_write_poly_field_less_general.res:7:13-19 - 4 │ type t = {@set "id": 'a. 'a => 'a} - 5 │ let f = (o: t) => { - 6 │ o["id"] = _x => 1 - 7 │ o["id"]("hello") - 8 │ } + 5 │ + 6 │ let f = (o: t) => { + 7 │ o["id"] = _x => 1 + 8 │ o["id"]("hello") + 9 │ } This field value has type int => int which is less general than 'a. 'a => 'a \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_both.res.expected b/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_both.res.expected index 10c0da9df8a..bac13d93eb7 100644 --- a/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_both.res.expected +++ b/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_both.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/record_coercion_as_payload_mismatch_both.res:15:10-15 + /.../fixtures/record_coercion_as_payload_mismatch_both.res:16:10-15 - 13 │ } - 14 │ - 15 │ let y = (x :> y) - 16 │ + 14 │ } + 15 │ + 16 │ let y = (x :> y) + 17 │ Type x is not a subtype of y diff --git a/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_left.res.expected b/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_left.res.expected index 4b7d00d1f63..4b0a538ad50 100644 --- a/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_left.res.expected +++ b/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_left.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/record_coercion_as_payload_mismatch_left.res:15:10-15 + /.../fixtures/record_coercion_as_payload_mismatch_left.res:16:10-15 - 13 │ } - 14 │ - 15 │ let y = (x :> y) - 16 │ + 14 │ } + 15 │ + 16 │ let y = (x :> y) + 17 │ Type x is not a subtype of y diff --git a/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_right.res.expected b/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_right.res.expected index 7c0d45dd3d0..202528c634c 100644 --- a/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_right.res.expected +++ b/tests/build_tests/super_errors/expected/record_coercion_as_payload_mismatch_right.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/record_coercion_as_payload_mismatch_right.res:15:10-15 + /.../fixtures/record_coercion_as_payload_mismatch_right.res:16:10-15 - 13 │ } - 14 │ - 15 │ let y = (x :> y) - 16 │ + 14 │ } + 15 │ + 16 │ let y = (x :> y) + 17 │ Type x is not a subtype of y diff --git a/tests/build_tests/super_errors/expected/record_coercion_missing_field.res.expected b/tests/build_tests/super_errors/expected/record_coercion_missing_field.res.expected index 017d5714c8c..8c2bb96ab91 100644 --- a/tests/build_tests/super_errors/expected/record_coercion_missing_field.res.expected +++ b/tests/build_tests/super_errors/expected/record_coercion_missing_field.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/record_coercion_missing_field.res:16:10-15 + /.../fixtures/record_coercion_missing_field.res:17:10-15 - 14 │ } - 15 │ - 16 │ let y = (x :> y) - 17 │ + 15 │ } + 16 │ + 17 │ let y = (x :> y) + 18 │ Type x is not a subtype of y diff --git a/tests/build_tests/super_errors/expected/record_coercion_optional_mismatch.res.expected b/tests/build_tests/super_errors/expected/record_coercion_optional_mismatch.res.expected index 7b8c1399f7e..b46c71341b5 100644 --- a/tests/build_tests/super_errors/expected/record_coercion_optional_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/record_coercion_optional_mismatch.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/record_coercion_optional_mismatch.res:14:10-15 + /.../fixtures/record_coercion_optional_mismatch.res:15:10-15 - 12 │ } - 13 │ - 14 │ let y = (x :> y) - 15 │ + 13 │ } + 14 │ + 15 │ let y = (x :> y) + 16 │ Type x is not a subtype of y diff --git a/tests/build_tests/super_errors/expected/record_type_spreads_deep_sub.res.expected b/tests/build_tests/super_errors/expected/record_type_spreads_deep_sub.res.expected index aa0178907f7..8e394e8839d 100644 --- a/tests/build_tests/super_errors/expected/record_type_spreads_deep_sub.res.expected +++ b/tests/build_tests/super_errors/expected/record_type_spreads_deep_sub.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/record_type_spreads_deep_sub.res:8:9-21 + /.../fixtures/record_type_spreads_deep_sub.res:9:9-21 - 6 │ - 7 │ let d: d = { - 8 │ x: Ok("this errors"), - 9 │ } - 10 │ + 7 │ + 8 │ let d: d = { + 9 │ x: Ok("this errors"), + 10 │ } + 11 │ This has type: string But it's expected to have type: int diff --git a/tests/build_tests/super_errors/expected/recursive_component_create_element_requires_component.res.expected b/tests/build_tests/super_errors/expected/recursive_component_create_element_requires_component.res.expected index f531ae3fbb0..589f6f962fa 100644 --- a/tests/build_tests/super_errors/expected/recursive_component_create_element_requires_component.res.expected +++ b/tests/build_tests/super_errors/expected/recursive_component_create_element_requires_component.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/recursive_component_create_element_requires_component.res:13:46-49 + /.../fixtures/recursive_component_create_element_requires_component.res:14:46-49 - 11 │ - 12 │ @react.component - 13 │ let rec make = (~foo) => React.createElement(make, {foo: foo}) - 14 │ + 12 │ + 13 │ @react.component + 14 │ let rec make = (~foo) => React.createElement(make, {foo: foo}) + 15 │ This has type: props<'a> => React.element But this function argument is expecting: diff --git a/tests/build_tests/super_errors/expected/recursive_type.res.expected b/tests/build_tests/super_errors/expected/recursive_type.res.expected index 3f8d203968c..f8c0ad43b68 100644 --- a/tests/build_tests/super_errors/expected/recursive_type.res.expected +++ b/tests/build_tests/super_errors/expected/recursive_type.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/recursive_type.res:34:11-14 + /.../fixtures/recursive_type.res:35:11-14 - 32 │ /* parse atom */ - 33 │ and atom = (k, t) => { - 34 │ let _ = atom(k) - 35 │ assert(false) - 36 │ } + 33 │ /* parse atom */ + 34 │ and atom = (k, t) => { + 35 │ let _ = atom(k) + 36 │ assert(false) + 37 │ } This function call is incorrect. The function has type: diff --git a/tests/build_tests/super_errors/expected/syntaxErrors_invalid_ordinary_template_escape.res.expected b/tests/build_tests/super_errors/expected/syntaxErrors_invalid_ordinary_template_escape.res.expected index 30b734054f6..b2f55647b33 100644 --- a/tests/build_tests/super_errors/expected/syntaxErrors_invalid_ordinary_template_escape.res.expected +++ b/tests/build_tests/super_errors/expected/syntaxErrors_invalid_ordinary_template_escape.res.expected @@ -7,4 +7,4 @@ 3 │ let after = "ok" 4 │ let fartherAfter = "ok" - Invalid string escape sequence + Invalid string escape sequence \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/type2.res.expected b/tests/build_tests/super_errors/expected/type2.res.expected index 59a05b86eb4..ae2c6a9faae 100644 --- a/tests/build_tests/super_errors/expected/type2.res.expected +++ b/tests/build_tests/super_errors/expected/type2.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/type2.res:6:11-13 + /.../fixtures/type2.res:7:11-13 - 4 │ let () = { - 5 │ push(a, 3)->ignore - 6 │ push(a, "3")->ignore - 7 │ } - 8 │ + 5 │ let () = { + 6 │ push(a, 3)->ignore + 7 │ push(a, "3")->ignore + 8 │ } + 9 │ This has type: string But this function argument is expecting: int diff --git a/tests/build_tests/super_errors/expected/typemod_signature_expected.res.expected b/tests/build_tests/super_errors/expected/typemod_signature_expected.res.expected index b709aa97502..561e2e19771 100644 --- a/tests/build_tests/super_errors/expected/typemod_signature_expected.res.expected +++ b/tests/build_tests/super_errors/expected/typemod_signature_expected.res.expected @@ -1,10 +1,10 @@ We've found a bug for you! - /.../fixtures/typemod_signature_expected.res:4:18-38 + /.../fixtures/typemod_signature_expected.res:5:18-38 - 2 │ module M: (X: {}) => {} 3 │ } - 4 │ module type T2 = T with type M.t = int - 5 │ + 4 │ + 5 │ module type T2 = T with type M.t = int + 6 │ This module type is not a signature \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected b/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected index ab526fe3a72..99d1ab316e9 100644 --- a/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected +++ b/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/uncurried_wrong_label.res:6:16 + /.../fixtures/uncurried_wrong_label.res:7:16 - 4 │ } - 5 │ // This looks too far into the return type - 6 │ let d = foo(~y=3) - 7 │ + 5 │ + 6 │ // This looks too far into the return type + 7 │ let d = foo(~y=3) + 8 │ This function does not take the argument ~y. This function has type: (~x: int) => (~y: int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/variant_coercion_mismatching_types.res.expected b/tests/build_tests/super_errors/expected/variant_coercion_mismatching_types.res.expected index 1c5958d741d..3bfb333c070 100644 --- a/tests/build_tests/super_errors/expected/variant_coercion_mismatching_types.res.expected +++ b/tests/build_tests/super_errors/expected/variant_coercion_mismatching_types.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/variant_coercion_mismatching_types.res:9:10-15 + /.../fixtures/variant_coercion_mismatching_types.res:10:10-15 - 7 │ let x: x = One(true) - 8 │ - 9 │ let y = (x :> y) - 10 │ + 8 │ let x: x = One(true) + 9 │ + 10 │ let y = (x :> y) + 11 │ Type x is not a subtype of y diff --git a/tests/build_tests/super_errors/expected/variant_payload_tag_mismatch.res.expected b/tests/build_tests/super_errors/expected/variant_payload_tag_mismatch.res.expected index ce553258fa5..e012335ef19 100644 --- a/tests/build_tests/super_errors/expected/variant_payload_tag_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/variant_payload_tag_mismatch.res.expected @@ -8,8 +8,8 @@ 6 │  type t = | @as("C") A({x: int}) | @as("A") C({x: int}) 7 │  let a = A({x: 1}) 8 │ } - 9 │ Console.log( - 10 │ switch M.a { + 9 │ + 10 │ Console.log( Signature mismatch: ... diff --git a/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_bigint.res.expected b/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_bigint.res.expected index 97df3e9b061..73cd47cb2a0 100644 --- a/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_bigint.res.expected +++ b/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_bigint.res.expected @@ -1,28 +1,28 @@ Warning number 4 - /.../fixtures/warning_11_untagged_literal_shadows_bigint.res:3:3-7:3 + /.../fixtures/warning_11_untagged_literal_shadows_bigint.res:4:3-8:3 - 1 │ @unboxed type t = | @as(2n) Two | BI(bigint) | S(string) - 2 │ let f = (v: t) => - 3 │ switch v { - 4 │  | BI(02n) => "dead" - 5 │  | BI(_) => "bigint" - 6 │  | _ => "other" - 7 │  } - 8 │ + 2 │ + 3 │ let f = (v: t) => + 4 │ switch v { + 5 │  | BI(02n) => "dead" + 6 │  | BI(_) => "bigint" + 7 │  | _ => "other" + 8 │  } + 9 │ this pattern-matching is fragile. It will remain exhaustive when constructors are added to type t. Warning number 11 - /.../fixtures/warning_11_untagged_literal_shadows_bigint.res:4:5-11 + /.../fixtures/warning_11_untagged_literal_shadows_bigint.res:5:5-11 - 2 │ let f = (v: t) => - 3 │ switch v { - 4 │ | BI(02n) => "dead" - 5 │ | BI(_) => "bigint" - 6 │ | _ => "other" + 3 │ let f = (v: t) => + 4 │ switch v { + 5 │ | BI(02n) => "dead" + 6 │ | BI(_) => "bigint" + 7 │ | _ => "other" this match case is unused. 2n is the runtime value of constructor Two, so it is always matched as Two, never as BI. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload.res.expected b/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload.res.expected index a4157f9042f..791d47b346a 100644 --- a/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload.res.expected +++ b/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload.res.expected @@ -52,13 +52,13 @@ Warning number 11 - /.../fixtures/warning_11_untagged_literal_shadows_payload.res:42:5-21 + /.../fixtures/warning_11_untagged_literal_shadows_payload.res:43:5-21 - 40 │ let allAlternatives = x => - 41 │ switch x { - 42 │ | US("a") | US("b") => 1 - 43 │ | US(_) | UA | UB => 2 - 44 │ } + 41 │ let allAlternatives = x => + 42 │ switch x { + 43 │ | US("a") | US("b") => 1 + 44 │ | US(_) | UA | UB => 2 + 45 │ } this match case is unused. "a" is the runtime value of constructor UA, so it is always matched as UA, never as US. diff --git a/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload_kinds.res.expected b/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload_kinds.res.expected index 8d7b6b7fbc0..4c71d5e3c49 100644 --- a/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload_kinds.res.expected +++ b/tests/build_tests/super_errors/expected/warning_11_untagged_literal_shadows_payload_kinds.res.expected @@ -1,38 +1,38 @@ Warning number 11 - /.../fixtures/warning_11_untagged_literal_shadows_payload_kinds.res:7:5-20 + /.../fixtures/warning_11_untagged_literal_shadows_payload_kinds.res:8:5-20 - 5 │ let byName = x => - 6 │ switch x { - 7 │ | Color("Primary") => 1 - 8 │ | Color(_) | Primary => 2 - 9 │ } + 6 │ let byName = x => + 7 │ switch x { + 8 │ | Color("Primary") => 1 + 9 │ | Color(_) | Primary => 2 + 10 │ } this match case is unused. "Primary" is the runtime value of constructor Primary, so it is always matched as Primary, never as Color. Warning number 11 - /.../fixtures/warning_11_untagged_literal_shadows_payload_kinds.res:15:5-10 + /.../fixtures/warning_11_untagged_literal_shadows_payload_kinds.res:17:5-10 - 13 │ let intAndFloat = x => - 14 │ switch x { - 15 │ | F(1.0) => 1 - 16 │ | F(_) | One => 2 - 17 │ } + 15 │ let intAndFloat = x => + 16 │ switch x { + 17 │ | F(1.0) => 1 + 18 │ | F(_) | One => 2 + 19 │ } this match case is unused. 1 is the runtime value of constructor One, so it is always matched as One, never as F. Warning number 11 - /.../fixtures/warning_11_untagged_literal_shadows_payload_kinds.res:24:5-8 + /.../fixtures/warning_11_untagged_literal_shadows_payload_kinds.res:27:5-8 - 22 │ let nestedConstant = x => - 23 │ switch x { - 24 │ | W(P) => 1 - 25 │ | W(Q(_)) | X => 2 - 26 │ } + 25 │ let nestedConstant = x => + 26 │ switch x { + 27 │ | W(P) => 1 + 28 │ | W(Q(_)) | X => 2 + 29 │ } this match case is unused. "x" is the runtime value of constructor X, so it is always matched as X, never as W. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warning_37_unused_constructor_pattern_only.res.expected b/tests/build_tests/super_errors/expected/warning_37_unused_constructor_pattern_only.res.expected index 373848f0435..f8dc9b146d3 100644 --- a/tests/build_tests/super_errors/expected/warning_37_unused_constructor_pattern_only.res.expected +++ b/tests/build_tests/super_errors/expected/warning_37_unused_constructor_pattern_only.res.expected @@ -5,8 +5,8 @@ 2 │ let v: int 3 │ } = { 4 │ type t = Foo | Bar - 5 │ let _describe = (x: t) => - 6 │ switch x { + 5 │ + 6 │ let _describe = (x: t) => constructor Foo is never used to build values. (However, this constructor appears in patterns.) @@ -18,8 +18,8 @@ 2 │ let v: int 3 │ } = { 4 │ type t = Foo | Bar - 5 │ let _describe = (x: t) => - 6 │ switch x { + 5 │ + 6 │ let _describe = (x: t) => constructor Bar is never used to build values. (However, this constructor appears in patterns.) \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warning_38_unused_extension_pattern_only.res.expected b/tests/build_tests/super_errors/expected/warning_38_unused_extension_pattern_only.res.expected index 5a129ed09c7..74f8741eedb 100644 --- a/tests/build_tests/super_errors/expected/warning_38_unused_extension_pattern_only.res.expected +++ b/tests/build_tests/super_errors/expected/warning_38_unused_extension_pattern_only.res.expected @@ -5,8 +5,8 @@ 3 │ } = { 4 │ type t = .. 5 │ type t += Foo - 6 │ let _describe = (x: t) => - 7 │ switch x { + 6 │ + 7 │ let _describe = (x: t) => extension constructor Foo is never used to build values. (However, this constructor appears in patterns.) \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warning_60_unused_module.res.expected b/tests/build_tests/super_errors/expected/warning_60_unused_module.res.expected index 71603e991a1..debfedd0dbb 100644 --- a/tests/build_tests/super_errors/expected/warning_60_unused_module.res.expected +++ b/tests/build_tests/super_errors/expected/warning_60_unused_module.res.expected @@ -6,7 +6,7 @@ 4 │ module Helper = { 5 │ let f = 1 6 │ } - 7 │ let v = 1 + 7 │ unused value f. @@ -19,7 +19,7 @@ 4 │ module Helper = { 5 │  let f = 1 6 │  } - 7 │ let v = 1 - 8 │ } + 7 │ + 8 │ let v = 1 unused module Helper. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warning_8_untagged_boolean_kind_payload.res.expected b/tests/build_tests/super_errors/expected/warning_8_untagged_boolean_kind_payload.res.expected index cced36fcc69..d2985ebdb90 100644 --- a/tests/build_tests/super_errors/expected/warning_8_untagged_boolean_kind_payload.res.expected +++ b/tests/build_tests/super_errors/expected/warning_8_untagged_boolean_kind_payload.res.expected @@ -1,14 +1,14 @@ Warning number 8 - /.../fixtures/warning_8_untagged_boolean_kind_payload.res:4:3-6:3 + /.../fixtures/warning_8_untagged_boolean_kind_payload.res:5:3-7:3 - 2 │ @unboxed type t = | @as(true) Yes | Value(jsBool) - 3 │ let f = (v: t) => - 4 │ switch v { - 5 │  | Yes => 1 - 6 │  } - 7 │ - 8 │ type alias = bool + 3 │ + 4 │ let f = (v: t) => + 5 │ switch v { + 6 │  | Yes => 1 + 7 │  } + 8 │ + 9 │ type alias = bool You forgot to handle a possible case here, for example: | Value(_) \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warnings1.res.expected b/tests/build_tests/super_errors/expected/warnings1.res.expected index 024ddebc3fb..2796fbdfd63 100644 --- a/tests/build_tests/super_errors/expected/warnings1.res.expected +++ b/tests/build_tests/super_errors/expected/warnings1.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/warnings1.res:3:3 + /.../fixtures/warnings1.res:4:3 - 1 │ let x = (a, b) => a + b - 2 │ let z = () => { - 3 │ x(10) - 4 │ 10 - 5 │ } + 2 │ + 3 │ let z = () => { + 4 │ x(10) + 5 │ 10 + 6 │ } This function call is incorrect. The function has type: diff --git a/tests/build_tests/super_errors/expected/wrong_name_component_prop.res.expected b/tests/build_tests/super_errors/expected/wrong_name_component_prop.res.expected index af78b823428..b341263362a 100644 --- a/tests/build_tests/super_errors/expected/wrong_name_component_prop.res.expected +++ b/tests/build_tests/super_errors/expected/wrong_name_component_prop.res.expected @@ -1,11 +1,11 @@ We've found a bug for you! - /.../fixtures/wrong_name_component_prop.res:32:28-38 + /.../fixtures/wrong_name_component_prop.res:33:28-38 - 30 │ } - 31 │ - 32 │ let dddd = Component.make({nonExistant: "hello"}) - 33 │ + 31 │ } + 32 │ + 33 │ let dddd = Component.make({nonExistant: "hello"}) + 34 │ The field nonExistant does not belong to type Component.props diff --git a/tests/build_tests/super_errors/expected/wrong_type_prop_punning.res.expected b/tests/build_tests/super_errors/expected/wrong_type_prop_punning.res.expected index e07a69fed79..4c59e97c785 100644 --- a/tests/build_tests/super_errors/expected/wrong_type_prop_punning.res.expected +++ b/tests/build_tests/super_errors/expected/wrong_type_prop_punning.res.expected @@ -1,12 +1,12 @@ We've found a bug for you! - /.../fixtures/wrong_type_prop_punning.res:21:13-20 + /.../fixtures/wrong_type_prop_punning.res:22:13-20 - 19 │ @react.component - 20 │ let make = (~someProp: array<int>) => { - 21 │ <Level2 someProp /> - 22 │ } - 23 │ } + 20 │ @react.component + 21 │ let make = (~someProp: array<int>) => { + 22 │ <Level2 someProp /> + 23 │ } + 24 │ } This has type: array<int> But the component prop someProp is expected to have type: float \ No newline at end of file diff --git a/tests/build_tests/super_errors/fixtures/UntaggedAtMostOneObject.res b/tests/build_tests/super_errors/fixtures/UntaggedAtMostOneObject.res index f771b6239e1..bb23ae64b94 100644 --- a/tests/build_tests/super_errors/fixtures/UntaggedAtMostOneObject.res +++ b/tests/build_tests/super_errors/fixtures/UntaggedAtMostOneObject.res @@ -1,4 +1,5 @@ type a = {x: int} type b = {y: int} + @unboxed type t = A(a) | B(b) diff --git a/tests/build_tests/super_errors/fixtures/access_record_field_on_array.res b/tests/build_tests/super_errors/fixtures/access_record_field_on_array.res index d49ac75ac95..b0b5addf20b 100644 --- a/tests/build_tests/super_errors/fixtures/access_record_field_on_array.res +++ b/tests/build_tests/super_errors/fixtures/access_record_field_on_array.res @@ -1,5 +1,6 @@ module X = { type y = {d: int} + type x = { a: int, b: int, diff --git a/tests/build_tests/super_errors/fixtures/access_record_field_on_option.res b/tests/build_tests/super_errors/fixtures/access_record_field_on_option.res index 9d71abf6d5e..ffb1fb1942c 100644 --- a/tests/build_tests/super_errors/fixtures/access_record_field_on_option.res +++ b/tests/build_tests/super_errors/fixtures/access_record_field_on_option.res @@ -1,5 +1,6 @@ module X = { type y = {d: int} + type x = { a: int, b: int, diff --git a/tests/build_tests/super_errors/fixtures/await.res b/tests/build_tests/super_errors/fixtures/await.res index 63e982c6e88..55f98e58cda 100644 --- a/tests/build_tests/super_errors/fixtures/await.res +++ b/tests/build_tests/super_errors/fixtures/await.res @@ -1,4 +1,5 @@ let a = async () => 3 + let foo = async () => { let _ = () () => await a() diff --git a/tests/build_tests/super_errors/fixtures/for_of_type_mismatch.res b/tests/build_tests/super_errors/fixtures/for_of_type_mismatch.res index 2b6833d8402..68688f38510 100644 --- a/tests/build_tests/super_errors/fixtures/for_of_type_mismatch.res +++ b/tests/build_tests/super_errors/fixtures/for_of_type_mismatch.res @@ -1,5 +1,6 @@ // Test for...of with incompatible array element type let numbers: array<int> = [1, 2, 3] + for x of numbers->Array.asIterable { let y: string = x Console.log(y) diff --git a/tests/build_tests/super_errors/fixtures/function_call_mismatch.res b/tests/build_tests/super_errors/fixtures/function_call_mismatch.res index 1d3bafce1af..261599c4cf8 100644 --- a/tests/build_tests/super_errors/fixtures/function_call_mismatch.res +++ b/tests/build_tests/super_errors/fixtures/function_call_mismatch.res @@ -1,5 +1,6 @@ @module("shelljs") external cd: string => string = "cd" + external exec: string => string = "exec" let cloneInTemp = (temp: string): string => { diff --git a/tests/build_tests/super_errors/fixtures/highlighting4.res b/tests/build_tests/super_errors/fixtures/highlighting4.res index e6d29d5c6b7..93a8954bad6 100644 --- a/tests/build_tests/super_errors/fixtures/highlighting4.res +++ b/tests/build_tests/super_errors/fixtures/highlighting4.res @@ -1,5 +1,7 @@ @@warnerror("A") + /* single char highlighted */ @deprecated type a = int + type b = a diff --git a/tests/build_tests/super_errors/fixtures/js_name_clash_module.res b/tests/build_tests/super_errors/fixtures/js_name_clash_module.res index 4d1e72a3518..d9d6adad62b 100644 --- a/tests/build_tests/super_errors/fixtures/js_name_clash_module.res +++ b/tests/build_tests/super_errors/fixtures/js_name_clash_module.res @@ -1,4 +1,5 @@ exception Foo + module Foo = { let x = 1 } diff --git a/tests/build_tests/super_errors/fixtures/jsx_component_prop_plain_function.res b/tests/build_tests/super_errors/fixtures/jsx_component_prop_plain_function.res index 39b4e47d5fb..39080988487 100644 --- a/tests/build_tests/super_errors/fixtures/jsx_component_prop_plain_function.res +++ b/tests/build_tests/super_errors/fixtures/jsx_component_prop_plain_function.res @@ -5,6 +5,7 @@ module React = { type component<'props> = Jsx.component<'props> external component: componentLike<'props, element> => component<'props> = "%component_identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/jsx_invalid_prop_ast0_conversion.res b/tests/build_tests/super_errors/fixtures/jsx_invalid_prop_ast0_conversion.res index 3876d99228d..ed1d6fc734c 100644 --- a/tests/build_tests/super_errors/fixtures/jsx_invalid_prop_ast0_conversion.res +++ b/tests/build_tests/super_errors/fixtures/jsx_invalid_prop_ast0_conversion.res @@ -6,6 +6,7 @@ module React = { type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> type component<'props> = Jsx.component<'props> external component: componentLike<'props, element> => component<'props> = "%component_identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/jsx_plain_function_component.res b/tests/build_tests/super_errors/fixtures/jsx_plain_function_component.res index 59424fd91cd..d54a2e08e88 100644 --- a/tests/build_tests/super_errors/fixtures/jsx_plain_function_component.res +++ b/tests/build_tests/super_errors/fixtures/jsx_plain_function_component.res @@ -5,6 +5,7 @@ module React = { external component: componentLike<'props, element> => component<'props> = "%component_identity" external string: string => element = "%identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" @@ -14,6 +15,7 @@ module React = { module ReactDOM = { external someElement: React.element => option<React.element> = "%identity" + @module("react/jsx-runtime") external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/jsx_unboxed_props.res b/tests/build_tests/super_errors/fixtures/jsx_unboxed_props.res index 5656154e3ea..f9258421f72 100644 --- a/tests/build_tests/super_errors/fixtures/jsx_unboxed_props.res +++ b/tests/build_tests/super_errors/fixtures/jsx_unboxed_props.res @@ -2,6 +2,7 @@ module React = { type element = Jsx.element type component<'props> = Jsx.component<'props> external string: string => element = "%identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/jsx_unboxed_props_spread.res b/tests/build_tests/super_errors/fixtures/jsx_unboxed_props_spread.res index f6e2996863c..15520dd4e7c 100644 --- a/tests/build_tests/super_errors/fixtures/jsx_unboxed_props_spread.res +++ b/tests/build_tests/super_errors/fixtures/jsx_unboxed_props_spread.res @@ -1,9 +1,12 @@ module React = { type element = Jsx.element type component<'props> = Jsx.component<'props> + external component: Jsx.componentLike<'props, element> => component<'props> = "%component_identity" + external string: string => element = "%identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/missing_required_prop.res b/tests/build_tests/super_errors/fixtures/missing_required_prop.res index c8311dd4c75..1780835b46d 100644 --- a/tests/build_tests/super_errors/fixtures/missing_required_prop.res +++ b/tests/build_tests/super_errors/fixtures/missing_required_prop.res @@ -4,12 +4,16 @@ module React = { type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> type component<'props> = Jsx.component<'props> external component: componentLike<'props, element> => component<'props> = "%component_identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" + external string: string => element = "%identity" } + module ReactDOM = { external someElement: React.element => option<React.element> = "%identity" + @module("react/jsx-runtime") external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/missing_required_prop_when_children.res b/tests/build_tests/super_errors/fixtures/missing_required_prop_when_children.res index 0c7b5a871f1..2cebe932cd9 100644 --- a/tests/build_tests/super_errors/fixtures/missing_required_prop_when_children.res +++ b/tests/build_tests/super_errors/fixtures/missing_required_prop_when_children.res @@ -4,15 +4,20 @@ module React = { type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> type component<'props> = Jsx.component<'props> external component: componentLike<'props, element> => component<'props> = "%component_identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" + @module("react/jsx-runtime") external jsxs: (component<'props>, 'props) => element = "jsxs" + external string: string => element = "%identity" external array: array<element> => element = "%identity" } + module ReactDOM = { external someElement: React.element => option<React.element> = "%identity" + @module("react/jsx-runtime") external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/missing_required_prop_when_single_child.res b/tests/build_tests/super_errors/fixtures/missing_required_prop_when_single_child.res index 6cfd82905d6..06698e1a479 100644 --- a/tests/build_tests/super_errors/fixtures/missing_required_prop_when_single_child.res +++ b/tests/build_tests/super_errors/fixtures/missing_required_prop_when_single_child.res @@ -4,12 +4,16 @@ module React = { type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> type component<'props> = Jsx.component<'props> external component: componentLike<'props, element> => component<'props> = "%component_identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" + external string: string => element = "%identity" } + module ReactDOM = { external someElement: React.element => option<React.element> = "%identity" + @module("react/jsx-runtime") external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" } diff --git a/tests/build_tests/super_errors/fixtures/module_alias_coercion_printed_once.res b/tests/build_tests/super_errors/fixtures/module_alias_coercion_printed_once.res index 31d529a3b61..19cd7a58e67 100644 --- a/tests/build_tests/super_errors/fixtures/module_alias_coercion_printed_once.res +++ b/tests/build_tests/super_errors/fixtures/module_alias_coercion_printed_once.res @@ -1,5 +1,6 @@ module Inner = { type t<'a> } + module A = Inner let m = (x: A.t<[#X]>) => (x :> A.t<[#X | #Y]>) diff --git a/tests/build_tests/super_errors/fixtures/moreArguments5.res b/tests/build_tests/super_errors/fixtures/moreArguments5.res index 1bd24141109..593323c8001 100644 --- a/tests/build_tests/super_errors/fixtures/moreArguments5.res +++ b/tests/build_tests/super_errors/fixtures/moreArguments5.res @@ -1,5 +1,6 @@ module Sub = { type a = {a: int} } + let x = (a, b, c, d) => {Sub.a: 2} let y = x(2).Sub.a diff --git a/tests/build_tests/super_errors/fixtures/newtype_group_warning_scope.res b/tests/build_tests/super_errors/fixtures/newtype_group_warning_scope.res index 8aaa40872ee..dd1dd73fbca 100644 --- a/tests/build_tests/super_errors/fixtures/newtype_group_warning_scope.res +++ b/tests/build_tests/super_errors/fixtures/newtype_group_warning_scope.res @@ -2,6 +2,7 @@ let suppressed = (@warning("-26") type a, x: a) => { let unused = 1 x } + let unsuppressed = (type a, x: a) => { let unused = 1 x diff --git a/tests/build_tests/super_errors/fixtures/not_allowed_in_functor_body.res b/tests/build_tests/super_errors/fixtures/not_allowed_in_functor_body.res index 4bc97701dd6..ea4171cb808 100644 --- a/tests/build_tests/super_errors/fixtures/not_allowed_in_functor_body.res +++ b/tests/build_tests/super_errors/fixtures/not_allowed_in_functor_body.res @@ -14,6 +14,7 @@ module F = ( let v = 1 } ) + module M = unpack(pack) let _ = M.v } diff --git a/tests/build_tests/super_errors/fixtures/object_private_row_write_through_signature.res b/tests/build_tests/super_errors/fixtures/object_private_row_write_through_signature.res index 6b1d6ecddd8..23392346241 100644 --- a/tests/build_tests/super_errors/fixtures/object_private_row_write_through_signature.res +++ b/tests/build_tests/super_errors/fixtures/object_private_row_write_through_signature.res @@ -5,4 +5,5 @@ module M: { } = { type t = private {.."x": int} } + let mutate = (o: M.t) => o["x"] = 1 diff --git a/tests/build_tests/super_errors/fixtures/object_value_signature_set_mismatch.res b/tests/build_tests/super_errors/fixtures/object_value_signature_set_mismatch.res index c710d6ca307..b6b1acab330 100644 --- a/tests/build_tests/super_errors/fixtures/object_value_signature_set_mismatch.res +++ b/tests/build_tests/super_errors/fixtures/object_value_signature_set_mismatch.res @@ -2,6 +2,7 @@ moregeneral requires equal field mutability, so an interface cannot silently drop @set from a value's object type. */ @val external impl: {@set "x": int} = "impl" + module M: { let v: {"x": int} } = { diff --git a/tests/build_tests/super_errors/fixtures/object_write_after_open_target_coercion.res b/tests/build_tests/super_errors/fixtures/object_write_after_open_target_coercion.res index 377db39dcc4..9da964f19a3 100644 --- a/tests/build_tests/super_errors/fixtures/object_write_after_open_target_coercion.res +++ b/tests/build_tests/super_errors/fixtures/object_write_after_open_target_coercion.res @@ -7,6 +7,7 @@ type wide = {"a": int, "b": int} type narrow = {"a": int} + let p = (v: {"x": wide}) => { let r = (v :> {.."x": narrow}) r["x"] = {"a": 1} diff --git a/tests/build_tests/super_errors/fixtures/object_write_poly_field_less_general.res b/tests/build_tests/super_errors/fixtures/object_write_poly_field_less_general.res index f2e575b9e1d..8efb9404106 100644 --- a/tests/build_tests/super_errors/fixtures/object_write_poly_field_less_general.res +++ b/tests/build_tests/super_errors/fixtures/object_write_poly_field_less_general.res @@ -2,6 +2,7 @@ scheme: a monomorphic function must not satisfy one instance while reads keep instantiating the unchanged scheme. */ type t = {@set "id": 'a. 'a => 'a} + let f = (o: t) => { o["id"] = _x => 1 o["id"]("hello") diff --git a/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_both.res b/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_both.res index 15852549675..ee3dcbf30de 100644 --- a/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_both.res +++ b/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_both.res @@ -2,6 +2,7 @@ type x = { @as("z") x: int, y: int, } + type y = { @as("w") x: int, y: int, diff --git a/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_left.res b/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_left.res index ca409bd863c..bef0f2fe0e0 100644 --- a/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_left.res +++ b/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_left.res @@ -2,6 +2,7 @@ type x = { @as("z") x: int, y: int, } + type y = { x: int, y: int, diff --git a/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_right.res b/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_right.res index 9642420c56d..b34c9148f90 100644 --- a/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_right.res +++ b/tests/build_tests/super_errors/fixtures/record_coercion_as_payload_mismatch_right.res @@ -2,6 +2,7 @@ type x = { x: int, y: int, } + type y = { @as("z") x: int, y: int, diff --git a/tests/build_tests/super_errors/fixtures/record_coercion_missing_field.res b/tests/build_tests/super_errors/fixtures/record_coercion_missing_field.res index 81adbfe82b2..38108303452 100644 --- a/tests/build_tests/super_errors/fixtures/record_coercion_missing_field.res +++ b/tests/build_tests/super_errors/fixtures/record_coercion_missing_field.res @@ -2,6 +2,7 @@ type x = { x: int, y: int, } + type y = { x: int, y: int, diff --git a/tests/build_tests/super_errors/fixtures/record_coercion_optional_mismatch.res b/tests/build_tests/super_errors/fixtures/record_coercion_optional_mismatch.res index 7b272ec7c76..43f993fb1f7 100644 --- a/tests/build_tests/super_errors/fixtures/record_coercion_optional_mismatch.res +++ b/tests/build_tests/super_errors/fixtures/record_coercion_optional_mismatch.res @@ -2,6 +2,7 @@ type x = { x?: int, y: int, } + type y = { x: int, y: int, diff --git a/tests/build_tests/super_errors/fixtures/record_type_spreads_deep_sub.res b/tests/build_tests/super_errors/fixtures/record_type_spreads_deep_sub.res index 82681095bcf..c8172affaa8 100644 --- a/tests/build_tests/super_errors/fixtures/record_type_spreads_deep_sub.res +++ b/tests/build_tests/super_errors/fixtures/record_type_spreads_deep_sub.res @@ -1,5 +1,6 @@ // Checks that deep subsitution works as intended type t<'a, 'b> = {x: result<'a, 'b>} + type d = { ...t<int, int>, } diff --git a/tests/build_tests/super_errors/fixtures/recursive_component_create_element_requires_component.res b/tests/build_tests/super_errors/fixtures/recursive_component_create_element_requires_component.res index 542db6fdb99..715e0d03650 100644 --- a/tests/build_tests/super_errors/fixtures/recursive_component_create_element_requires_component.res +++ b/tests/build_tests/super_errors/fixtures/recursive_component_create_element_requires_component.res @@ -5,6 +5,7 @@ module React = { type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> type component<'props> = Jsx.component<'props> external component: componentLike<'props, element> => component<'props> = "%component_identity" + @module("react") external createElement: (component<'props>, 'props) => element = "createElement" } diff --git a/tests/build_tests/super_errors/fixtures/recursive_type.res b/tests/build_tests/super_errors/fixtures/recursive_type.res index 0a14eca45f7..68f00aef843 100644 --- a/tests/build_tests/super_errors/fixtures/recursive_type.res +++ b/tests/build_tests/super_errors/fixtures/recursive_type.res @@ -4,6 +4,7 @@ type rec tt = [ | #List(list<tt>) ] + type sexp = tt /* {2 Serialization (encoding)} */ diff --git a/tests/build_tests/super_errors/fixtures/type2.res b/tests/build_tests/super_errors/fixtures/type2.res index 12f507ad57a..49b656a9201 100644 --- a/tests/build_tests/super_errors/fixtures/type2.res +++ b/tests/build_tests/super_errors/fixtures/type2.res @@ -1,6 +1,7 @@ @send external push: (array<'a>, 'a) => unit = "push" let a = [] + let () = { push(a, 3)->ignore push(a, "3")->ignore diff --git a/tests/build_tests/super_errors/fixtures/typemod_signature_expected.res b/tests/build_tests/super_errors/fixtures/typemod_signature_expected.res index 3f19e510ed5..bed2355712c 100644 --- a/tests/build_tests/super_errors/fixtures/typemod_signature_expected.res +++ b/tests/build_tests/super_errors/fixtures/typemod_signature_expected.res @@ -1,4 +1,5 @@ module type T = { module M: (X: {}) => {} } + module type T2 = T with type M.t = int diff --git a/tests/build_tests/super_errors/fixtures/uncurried_wrong_label.res b/tests/build_tests/super_errors/fixtures/uncurried_wrong_label.res index 944ba5528d9..407a28879e2 100644 --- a/tests/build_tests/super_errors/fixtures/uncurried_wrong_label.res +++ b/tests/build_tests/super_errors/fixtures/uncurried_wrong_label.res @@ -2,5 +2,6 @@ let foo = (~x) => { let _ = () (~y) => x + y } + // This looks too far into the return type let d = foo(~y=3) diff --git a/tests/build_tests/super_errors/fixtures/variant_coercion_mismatching_types.res b/tests/build_tests/super_errors/fixtures/variant_coercion_mismatching_types.res index cc6e9686724..b297cd9d0d0 100644 --- a/tests/build_tests/super_errors/fixtures/variant_coercion_mismatching_types.res +++ b/tests/build_tests/super_errors/fixtures/variant_coercion_mismatching_types.res @@ -1,4 +1,5 @@ type x = One(bool) | Two | Three | Four | Five + type y = { x: x, y: int, diff --git a/tests/build_tests/super_errors/fixtures/variant_payload_tag_mismatch.res b/tests/build_tests/super_errors/fixtures/variant_payload_tag_mismatch.res index fa7a6305b62..29dfe6ed118 100644 --- a/tests/build_tests/super_errors/fixtures/variant_payload_tag_mismatch.res +++ b/tests/build_tests/super_errors/fixtures/variant_payload_tag_mismatch.res @@ -6,6 +6,7 @@ module M: { type t = | @as("C") A({x: int}) | @as("A") C({x: int}) let a = A({x: 1}) } + Console.log( switch M.a { | M.A(_) => "A" diff --git a/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_bigint.res b/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_bigint.res index c96bb45b6de..013d1648083 100644 --- a/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_bigint.res +++ b/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_bigint.res @@ -1,4 +1,5 @@ @unboxed type t = | @as(2n) Two | BI(bigint) | S(string) + let f = (v: t) => switch v { | BI(02n) => "dead" diff --git a/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload.res b/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload.res index 435ca4cc117..04890020f6e 100644 --- a/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload.res +++ b/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload.res @@ -37,6 +37,7 @@ let fine = x => // Every alternative can never match. @unboxed type u = | @as("a") UA | @as("b") UB | US(string) + let allAlternatives = x => switch x { | US("a") | US("b") => 1 diff --git a/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload_kinds.res b/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload_kinds.res index 0f1aaa929f6..04c5f4909f0 100644 --- a/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload_kinds.res +++ b/tests/build_tests/super_errors/fixtures/warning_11_untagged_literal_shadows_payload_kinds.res @@ -2,6 +2,7 @@ // Without @as, a constructor is represented by its name. @unboxed type color = Primary | Color(string) + let byName = x => switch x { | Color("Primary") => 1 @@ -10,6 +11,7 @@ let byName = x => // @as(1) and 1.0 are the same JavaScript number. @unboxed type num = | @as(1) One | F(float) + let intAndFloat = x => switch x { | F(1.0) => 1 @@ -19,6 +21,7 @@ let intAndFloat = x => // A nested untagged constant has the value of its @as. @unboxed type inner = | @as("x") P | Q(int) @unboxed type outer = | @as("x") X | W(inner) + let nestedConstant = x => switch x { | W(P) => 1 diff --git a/tests/build_tests/super_errors/fixtures/warning_37_unused_constructor_pattern_only.res b/tests/build_tests/super_errors/fixtures/warning_37_unused_constructor_pattern_only.res index 12928f43009..d148cd90a02 100644 --- a/tests/build_tests/super_errors/fixtures/warning_37_unused_constructor_pattern_only.res +++ b/tests/build_tests/super_errors/fixtures/warning_37_unused_constructor_pattern_only.res @@ -2,10 +2,12 @@ module M: { let v: int } = { type t = Foo | Bar + let _describe = (x: t) => switch x { | Foo => "foo" | Bar => "bar" } + let v = 1 } diff --git a/tests/build_tests/super_errors/fixtures/warning_38_unused_extension_pattern_only.res b/tests/build_tests/super_errors/fixtures/warning_38_unused_extension_pattern_only.res index 8be8bbb6b8c..a1c169b32a3 100644 --- a/tests/build_tests/super_errors/fixtures/warning_38_unused_extension_pattern_only.res +++ b/tests/build_tests/super_errors/fixtures/warning_38_unused_extension_pattern_only.res @@ -3,10 +3,12 @@ module M: { } = { type t = .. type t += Foo + let _describe = (x: t) => switch x { | Foo => "foo" | _ => "other" } + let v = 1 } diff --git a/tests/build_tests/super_errors/fixtures/warning_60_unused_module.res b/tests/build_tests/super_errors/fixtures/warning_60_unused_module.res index 1e8e4ac6b48..768d8884090 100644 --- a/tests/build_tests/super_errors/fixtures/warning_60_unused_module.res +++ b/tests/build_tests/super_errors/fixtures/warning_60_unused_module.res @@ -4,5 +4,6 @@ module M: { module Helper = { let f = 1 } + let v = 1 } diff --git a/tests/build_tests/super_errors/fixtures/warning_8_untagged_boolean_kind_payload.res b/tests/build_tests/super_errors/fixtures/warning_8_untagged_boolean_kind_payload.res index d3b18fd2801..89e38c8119e 100644 --- a/tests/build_tests/super_errors/fixtures/warning_8_untagged_boolean_kind_payload.res +++ b/tests/build_tests/super_errors/fixtures/warning_8_untagged_boolean_kind_payload.res @@ -1,5 +1,6 @@ @typeOf("boolean") type jsBool @unboxed type t = | @as(true) Yes | Value(jsBool) + let f = (v: t) => switch v { | Yes => 1 @@ -7,6 +8,7 @@ let f = (v: t) => type alias = bool @unboxed type u = | @as(true) Yes2 | Value2(alias) + let g = (v: u) => switch v { | Yes2 => 1 diff --git a/tests/build_tests/super_errors/fixtures/warnings1.res b/tests/build_tests/super_errors/fixtures/warnings1.res index 7ba4a79e264..6765642014c 100644 --- a/tests/build_tests/super_errors/fixtures/warnings1.res +++ b/tests/build_tests/super_errors/fixtures/warnings1.res @@ -1,4 +1,5 @@ let x = (a, b) => a + b + let z = () => { x(10) 10 diff --git a/tests/build_tests/super_errors/fixtures/wrong_name_component_prop.res b/tests/build_tests/super_errors/fixtures/wrong_name_component_prop.res index 2028c2e6b21..3db0adf485a 100644 --- a/tests/build_tests/super_errors/fixtures/wrong_name_component_prop.res +++ b/tests/build_tests/super_errors/fixtures/wrong_name_component_prop.res @@ -16,6 +16,7 @@ module Component = { eight: 'eight, ninth: 'ninth, } + let make = props => { props.name ++ props.second ++ diff --git a/tests/build_tests/super_errors/fixtures/wrong_type_prop_punning.res b/tests/build_tests/super_errors/fixtures/wrong_type_prop_punning.res index d2f81ba7a34..94134ed3e1c 100644 --- a/tests/build_tests/super_errors/fixtures/wrong_type_prop_punning.res +++ b/tests/build_tests/super_errors/fixtures/wrong_type_prop_punning.res @@ -4,6 +4,7 @@ module React = { type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> type component<'props> = Jsx.component<'props> external component: componentLike<'props, element> => component<'props> = "%component_identity" + @module("react/jsx-runtime") external jsx: (component<'props>, 'props) => element = "jsx" } diff --git a/tests/dependencies/rescript-react/src/React.res b/tests/dependencies/rescript-react/src/React.res index ff2b1cd4d58..94e769d54e1 100644 --- a/tests/dependencies/rescript-react/src/React.res +++ b/tests/dependencies/rescript-react/src/React.res @@ -52,16 +52,22 @@ external createRef: unit => ref<nullable<'a>> = "createRef" module Children = { @module("react") @scope("Children") external map: (element, element => element) => element = "map" + @module("react") @scope("Children") external mapWithIndex: (element, (element, int) => element) => element = "map" + @module("react") @scope("Children") external forEach: (element, element => unit) => unit = "forEach" + @module("react") @scope("Children") external forEachWithIndex: (element, (element, int) => unit) => unit = "forEach" + @module("react") @scope("Children") external count: element => int = "count" + @module("react") @scope("Children") external only: element => element = "only" + @module("react") @scope("Children") external toArray: element => array<element> = "toArray" } @@ -147,48 +153,66 @@ external useReducerWithMapState: ( @module("react") external useEffectOnEveryRender: (unit => option<unit => unit>) => unit = "useEffect" + @module("react") external useEffect: (unit => option<unit => unit>, 'deps) => unit = "useEffect" + @module("react") external useEffect0: (unit => option<unit => unit>, @as(json`[]`) _) => unit = "useEffect" + @module("react") external useEffect1: (unit => option<unit => unit>, array<'a>) => unit = "useEffect" + @module("react") external useEffect2: (unit => option<unit => unit>, ('a, 'b)) => unit = "useEffect" + @module("react") external useEffect3: (unit => option<unit => unit>, ('a, 'b, 'c)) => unit = "useEffect" + @module("react") external useEffect4: (unit => option<unit => unit>, ('a, 'b, 'c, 'd)) => unit = "useEffect" + @module("react") external useEffect5: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect" + @module("react") external useEffect6: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect" + @module("react") external useEffect7: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = "useEffect" @module("react") external useLayoutEffectOnEveryRender: (unit => option<unit => unit>) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect: (unit => option<unit => unit>, 'deps) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect0: (unit => option<unit => unit>, @as(json`[]`) _) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect1: (unit => option<unit => unit>, array<'a>) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect2: (unit => option<unit => unit>, ('a, 'b)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect3: (unit => option<unit => unit>, ('a, 'b, 'c)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect4: (unit => option<unit => unit>, ('a, 'b, 'c, 'd)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect5: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect6: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useLayoutEffect" + @module("react") external useLayoutEffect7: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = "useLayoutEffect" @@ -313,29 +337,38 @@ external useDeferredValue: ('value, ~initialValue: 'value=?) => 'value = "useDef @module("react") external useInsertionEffectOnEveryRender: (unit => option<unit => unit>) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect: (unit => option<unit => unit>, 'deps) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect0: (unit => option<unit => unit>, @as(json`[]`) _) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect1: (unit => option<unit => unit>, array<'a>) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect2: (unit => option<unit => unit>, ('a, 'b)) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect3: (unit => option<unit => unit>, ('a, 'b, 'c)) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect4: (unit => option<unit => unit>, ('a, 'b, 'c, 'd)) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect5: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect6: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useInsertionEffect" + @module("react") external useInsertionEffect7: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit = "useInsertionEffect" @@ -413,12 +446,14 @@ type transitionStartFunctionAsync = transitionFunctionAsync => unit /** `startTransition` lets you render a part of the UI in the background. */ @module("react") external startTransition: transitionStartFunction = "startTransition" + @module("react") external startTransitionAsync: transitionStartFunctionAsync = "startTransition" /** `useTransition` is a React Hook that lets you render a part of the UI in the background. */ @module("react") external useTransition: unit => (bool, transitionStartFunction) = "useTransition" + @module("react") external useTransitionAsync: unit => (bool, transitionStartFunctionAsync) = "useTransition" diff --git a/tests/dependencies/rescript-react/src/ReactEvent.res b/tests/dependencies/rescript-react/src/ReactEvent.res index 54ac5910c25..ec7055360d7 100644 --- a/tests/dependencies/rescript-react/src/ReactEvent.res +++ b/tests/dependencies/rescript-react/src/ReactEvent.res @@ -7,18 +7,24 @@ module MakeEventWithType = ( ) => { @get external bubbles: Type.t => bool = "bubbles" @get external cancelable: Type.t => bool = "cancelable" + @get external currentTarget: Type.t => {..} = "currentTarget" /* Should return Dom.eventTarget */ + @get external defaultPrevented: Type.t => bool = "defaultPrevented" @get external eventPhase: Type.t => int = "eventPhase" @get external isTrusted: Type.t => bool = "isTrusted" @get external nativeEvent: Type.t => {..} = "nativeEvent" /* Should return Dom.event */ @send external preventDefault: Type.t => unit = "preventDefault" + @send external isDefaultPrevented: Type.t => bool = "isDefaultPrevented" + @send external stopPropagation: Type.t => unit = "stopPropagation" + @send external isPropagationStopped: Type.t => bool = "isPropagationStopped" + @get external target: Type.t => {..} = "target" /* Should return Dom.eventTarget */ @get external timeStamp: Type.t => float = "timeStamp" @get external type_: Type.t => string = "type" @@ -30,23 +36,32 @@ module Synthetic = { type t = synthetic<tag> @get external bubbles: synthetic<'a> => bool = "bubbles" @get external cancelable: synthetic<'a> => bool = "cancelable" + @get external currentTarget: synthetic<'a> => {..} = "currentTarget" /* Should return Dom.eventTarget */ + @get external defaultPrevented: synthetic<'a> => bool = "defaultPrevented" + @get external eventPhase: synthetic<'a> => int = "eventPhase" @get external isTrusted: synthetic<'a> => bool = "isTrusted" + @get external nativeEvent: synthetic<'a> => {..} = "nativeEvent" /* Should return Dom.event */ + @send external preventDefault: synthetic<'a> => unit = "preventDefault" + @send external isDefaultPrevented: synthetic<'a> => bool = "isDefaultPrevented" + @send external stopPropagation: synthetic<'a> => unit = "stopPropagation" + @send external isPropagationStopped: synthetic<'a> => bool = "isPropagationStopped" + @get external target: synthetic<'a> => {..} = "target" /* Should return Dom.eventTarget */ @get external timeStamp: synthetic<'a> => float = "timeStamp" @get external type_: synthetic<'a> => string = "type" @@ -78,8 +93,10 @@ module Keyboard = { @get external charCode: t => int = "charCode" @get external code: t => string = "code" @get external ctrlKey: t => bool = "ctrlKey" + @send external getModifierState: (t, string) => bool = "getModifierState" + @get external key: t => string = "key" @get external keyCode: t => int = "keyCode" @get external locale: t => string = "locale" @@ -94,6 +111,7 @@ module Focus = { type tag = JsxEvent.Focus.tag type t = synthetic<tag> include MakeEventWithType({type t = t}) + @get @return(nullable) external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ } @@ -114,15 +132,19 @@ module Mouse = { @get external clientX: t => int = "clientX" @get external clientY: t => int = "clientY" @get external ctrlKey: t => bool = "ctrlKey" + @send external getModifierState: (t, string) => bool = "getModifierState" + @get external metaKey: t => bool = "metaKey" @get external movementX: t => int = "movementX" @get external movementY: t => int = "movementY" @get external pageX: t => int = "pageX" @get external pageY: t => int = "pageY" + @get @return(nullable) external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ + @get external screenX: t => int = "screenX" @get external screenY: t => int = "screenY" @get external shiftKey: t => bool = "shiftKey" @@ -151,6 +173,7 @@ module Pointer = { @get external shiftKey: t => bool = "shiftKey" @get external altKey: t => bool = "altKey" @get external metaKey: t => bool = "metaKey" + @send external getModifierState: (t, string) => bool = "getModifierState" @@ -186,8 +209,10 @@ module Touch = { @get external altKey: t => bool = "altKey" @get external changedTouches: t => {..} = "changedTouches" /* Should return Dom.touchList */ @get external ctrlKey: t => bool = "ctrlKey" + @send external getModifierState: (t, string) => bool = "getModifierState" + @get external metaKey: t => bool = "metaKey" @get external shiftKey: t => bool = "shiftKey" @get external targetTouches: t => {..} = "targetTouches" /* Should return Dom.touchList */ diff --git a/tests/dependencies/rescript-react/src/ReactEvent.resi b/tests/dependencies/rescript-react/src/ReactEvent.resi index 61b5d4b5db6..689019d0159 100644 --- a/tests/dependencies/rescript-react/src/ReactEvent.resi +++ b/tests/dependencies/rescript-react/src/ReactEvent.resi @@ -43,22 +43,31 @@ module Synthetic: { type t = synthetic<tag> @get external bubbles: synthetic<'a> => bool = "bubbles" @get external cancelable: synthetic<'a> => bool = "cancelable" + @get external currentTarget: synthetic<'a> => {..} = "currentTarget" + @get external defaultPrevented: synthetic<'a> => bool = "defaultPrevented" + @get external eventPhase: synthetic<'a> => int = "eventPhase" @get external isTrusted: synthetic<'a> => bool = "isTrusted" + @get external nativeEvent: synthetic<'a> => {..} = "nativeEvent" + @send external preventDefault: synthetic<'a> => unit = "preventDefault" + @send external isDefaultPrevented: synthetic<'a> => bool = "isDefaultPrevented" + @send external stopPropagation: synthetic<'a> => unit = "stopPropagation" + @send external isPropagationStopped: synthetic<'a> => bool = "isPropagationStopped" + @get external target: synthetic<'a> => {..} = "target" @get external timeStamp: synthetic<'a> => float = "timeStamp" @get external type_: synthetic<'a> => string = "type" @@ -132,8 +141,10 @@ module Keyboard: { @get external charCode: t => int = "charCode" @get external code: t => string = "code" @get external ctrlKey: t => bool = "ctrlKey" + @send external getModifierState: (t, string) => bool = "getModifierState" + @get external key: t => string = "key" @get external keyCode: t => int = "keyCode" @get external locale: t => string = "locale" @@ -162,6 +173,7 @@ module Focus: { @get external timeStamp: t => float = "timeStamp" @get external type_: t => string = "type" @send external persist: t => unit = "persist" + @get @return(nullable) external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ } @@ -210,15 +222,19 @@ module Mouse: { @get external clientX: t => int = "clientX" @get external clientY: t => int = "clientY" @get external ctrlKey: t => bool = "ctrlKey" + @send external getModifierState: (t, string) => bool = "getModifierState" + @get external metaKey: t => bool = "metaKey" @get external movementX: t => int = "movementX" @get external movementY: t => int = "movementY" @get external pageX: t => int = "pageX" @get external pageY: t => int = "pageY" + @get @return(nullable) external relatedTarget: t => option<{..}> = "relatedTarget" /* Should return Dom.eventTarget */ + @get external screenX: t => int = "screenX" @get external screenY: t => int = "screenY" @get external shiftKey: t => bool = "shiftKey" @@ -268,6 +284,7 @@ module Pointer: { @get external shiftKey: t => bool = "shiftKey" @get external altKey: t => bool = "altKey" @get external metaKey: t => bool = "metaKey" + @send external getModifierState: (t, string) => bool = "getModifierState" @@ -331,8 +348,10 @@ module Touch: { @get external altKey: t => bool = "altKey" @get external changedTouches: t => {..} = "changedTouches" /* Should return Dom.touchList */ @get external ctrlKey: t => bool = "ctrlKey" + @send external getModifierState: (t, string) => bool = "getModifierState" + @get external metaKey: t => bool = "metaKey" @get external shiftKey: t => bool = "shiftKey" @get external targetTouches: t => {..} = "targetTouches" /* Should return Dom.touchList */ diff --git a/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.res b/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.res index cb00d25bc2c..0bb969305b3 100644 --- a/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.res +++ b/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.res @@ -3,6 +3,7 @@ * As soon as React provides a mechanism for error-catching using functional component, * this is likely to be deprecated and/or move to user space. */ + type info = {componentStack: string} type params<'error> = { diff --git a/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.resi b/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.resi index 0ebdbc8affb..86165bce6f5 100644 --- a/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.resi +++ b/tests/dependencies/rescript-react/src/RescriptReactErrorBoundary.resi @@ -3,6 +3,7 @@ * As soon as React provides a mechanism for error-catching using functional component, * this is likely to be deprecated and/or move to user space. */ + type info = {componentStack: string} type params<'error> = { diff --git a/tests/dependencies/rescript-react/src/RescriptReactRouter.res b/tests/dependencies/rescript-react/src/RescriptReactRouter.res index 747154149db..c96d890741b 100644 --- a/tests/dependencies/rescript-react/src/RescriptReactRouter.res +++ b/tests/dependencies/rescript-react/src/RescriptReactRouter.res @@ -34,6 +34,7 @@ type makeEventOptions = { cancelable?: bool, composed?: bool, } + @new external makeEvent: (string, ~options: makeEventOptions=?) => Dom.event = "Event" /* This is copied from array.ml. We want to cut dependencies for rescript-react so @@ -47,6 +48,7 @@ let arrayToList = a => { } tolist(a->Array.length - 1, list{}) } + /* if we ever roll our own parser in the future, make sure you test all url combinations e.g. foo.com/?#bar */ @@ -74,12 +76,14 @@ let pathParse = str => raw->String.split("/")->Array.filter(item => item->String.length != 0)->arrayToList } + let path = (~serverUrlString=?, ()) => switch (serverUrlString, window) { | (None, None) => list{} | (Some(serverUrlString), _) => pathParse(serverUrlString) | (_, Some(window: Dom.window)) => pathParse(window->location->pathname) } + let hash = () => switch window { | None => "" @@ -93,6 +97,7 @@ let hash = () => raw->String.slice(~start=1) } } + let searchParse = str => switch str { | "" diff --git a/tests/dependencies/rescript-react/src/RescriptReactRouter.resi b/tests/dependencies/rescript-react/src/RescriptReactRouter.resi index 25357f3267b..12cd071864f 100644 --- a/tests/dependencies/rescript-react/src/RescriptReactRouter.resi +++ b/tests/dependencies/rescript-react/src/RescriptReactRouter.resi @@ -3,7 +3,9 @@ let push: string => unit /** update the url with the string path. modifies the current history entry instead of creating a new one. Example: `replace(\"/book/1\")`, `replace(\"/books#title\")` */ let replace: string => unit + type watcherID + type url = { /* path takes window.location.path, like "/book/title/edit" and turns it into `["book", "title", "edit"]` */ path: list<string>, diff --git a/tests/docstring_tests/Node.res b/tests/docstring_tests/Node.res index 29783b629a0..3a30f01d15a 100644 --- a/tests/docstring_tests/Node.res +++ b/tests/docstring_tests/Node.res @@ -26,14 +26,18 @@ module ChildProcess = { type readable type spawnReturns = {stderr: readable, stdout: readable} type spawnOptions = {cwd?: string, env?: Dict.t<string>, timeout?: int} + @module("node:child_process") external spawn: (string, array<string>, ~options: spawnOptions=?) => spawnReturns = "spawn" @send external on: (readable, string, Buffer.t => unit) => unit = "on" + @send external once: (spawnReturns, string, (Null.t<float>, Null.t<string>) => unit) => unit = "once" + // execSync is used by scripts/res/GenApiDocs.res type execSyncOptions = {maxBuffer?: float} + @module("child_process") external execSync: (string, ~options: execSyncOptions=?) => Buffer.t = "execSync" } diff --git a/tests/docstring_tests/SpawnAsync.res b/tests/docstring_tests/SpawnAsync.res index be5f5812f5b..1483e17d83e 100644 --- a/tests/docstring_tests/SpawnAsync.res +++ b/tests/docstring_tests/SpawnAsync.res @@ -5,6 +5,7 @@ type t = { stderr: array<Buffer.t>, code: Null.t<float>, } + let run = async (~command, ~args, ~options=?) => { let spawn = ChildProcess.spawn(command, args, ~options?) let stdout = [] diff --git a/tests/gentype_tests/stdlib-no-shims/src/StdlibNoShims.res b/tests/gentype_tests/stdlib-no-shims/src/StdlibNoShims.res index 9d3c5300118..fdd43a4e931 100644 --- a/tests/gentype_tests/stdlib-no-shims/src/StdlibNoShims.res +++ b/tests/gentype_tests/stdlib-no-shims/src/StdlibNoShims.res @@ -68,6 +68,7 @@ let idRef = (x: ref<int>) => x @genType let returnsUnit = (): unit => () + @genType let idTuple = (x: (int, string, float)) => x diff --git a/tests/gentype_tests/typescript-react-example/src/Comments.res b/tests/gentype_tests/typescript-react-example/src/Comments.res index af278c6c1cf..f4e867f5bcf 100644 --- a/tests/gentype_tests/typescript-react-example/src/Comments.res +++ b/tests/gentype_tests/typescript-react-example/src/Comments.res @@ -5,8 +5,10 @@ module DecideSubject = { /** A hint to use as a guide when thinking of your poem.*/ hint: string, } + /** The input used to generate the prompt and system prompt.*/ type input + /** The output from evaluating the llm prompt*/ type output = { /** The text of the poem.*/ diff --git a/tests/gentype_tests/typescript-react-example/src/ErrorHandler.resi b/tests/gentype_tests/typescript-react-example/src/ErrorHandler.resi index d20c3654e24..19787bc869f 100644 --- a/tests/gentype_tests/typescript-react-example/src/ErrorHandler.resi +++ b/tests/gentype_tests/typescript-react-example/src/ErrorHandler.resi @@ -2,6 +2,7 @@ module type Error = { type t let notification: t => (string, string) } + module Make: (Error: Error) => { let notify: Error.t => (string, string) } diff --git a/tests/gentype_tests/typescript-react-example/src/EscapedNames.res b/tests/gentype_tests/typescript-react-example/src/EscapedNames.res index fea9823548e..c304f88948f 100644 --- a/tests/gentype_tests/typescript-react-example/src/EscapedNames.res +++ b/tests/gentype_tests/typescript-react-example/src/EscapedNames.res @@ -19,6 +19,7 @@ type record = { \"Illegal-field name": int, \"UPPERCASE": int, } + @genType let myRecord = { normalField: IllegalName, @@ -30,6 +31,7 @@ let myRecord = { /* https://github.com/rescript-lang/rescript/issues/8312 */ type props = {} let make = (_: props) => React.null + @genType let \"Icon_Add": props => React.element = make diff --git a/tests/gentype_tests/typescript-react-example/src/FirstClassModules.res b/tests/gentype_tests/typescript-react-example/src/FirstClassModules.res index 9f8b9834357..6b60378f373 100644 --- a/tests/gentype_tests/typescript-react-example/src/FirstClassModules.res +++ b/tests/gentype_tests/typescript-react-example/src/FirstClassModules.res @@ -2,34 +2,45 @@ module type MT = { let x: int type t = int @module("foo") external f: int => int = "f" + module type XXX = { type tt = string } + module EmptyInnerModule: { } + module InnerModule2: { let k: t } + module InnerModule3: { type inner = int let k3: inner => inner } + module type TT = { let u: (int, int) } + module Z: TT let y: string } + module M = { let y = "abc" + module type XXX = { type tt = string } + module EmptyInnerModule = {} + module InnerModule2 = { let k = 4242 } + module InnerModule3 = { type inner = int let k3 = x => x + 1 @@ -38,9 +49,11 @@ module M = { module type TT = { let u: (int, int) } + module Z = { let u = (0, 0) } + type t = int @module("foo") external f: int => int = "f" let x = 42 diff --git a/tests/gentype_tests/typescript-react-example/src/Hooks.res b/tests/gentype_tests/typescript-react-example/src/Hooks.res index 8a7d9922ebf..c7a6b962edf 100644 --- a/tests/gentype_tests/typescript-react-example/src/Hooks.res +++ b/tests/gentype_tests/typescript-react-example/src/Hooks.res @@ -46,13 +46,16 @@ module Another = { module Inner = { @genType @react.component let make = (~vehicle) => <div>{React.string("Another Hook " ++ vehicle.name)}</div> + module Another = { @genType @react.component let anotherComponent = (~vehicle) => <div>{React.string("Another Hook " ++ vehicle.name)}</div> } + module Inner2 = { @genType @react.component let make = (~vehicle) => <div>{React.string("Another Hook " ++ vehicle.name)}</div> + module Another = { @genType @react.component let anotherComponent = (~vehicle) => diff --git a/tests/gentype_tests/typescript-react-example/src/ImmutableArray.res b/tests/gentype_tests/typescript-react-example/src/ImmutableArray.res index 55d271d9609..ef88e441d09 100644 --- a/tests/gentype_tests/typescript-react-example/src/ImmutableArray.res +++ b/tests/gentype_tests/typescript-react-example/src/ImmutableArray.res @@ -1,4 +1,5 @@ type t<+'a> + module Array = { open Belt type array2<'a> = (array<'a>, array<'a>) diff --git a/tests/gentype_tests/typescript-react-example/src/InnerModuleSignature.res b/tests/gentype_tests/typescript-react-example/src/InnerModuleSignature.res index 391531868de..018e9330e72 100644 --- a/tests/gentype_tests/typescript-react-example/src/InnerModuleSignature.res +++ b/tests/gentype_tests/typescript-react-example/src/InnerModuleSignature.res @@ -1,5 +1,6 @@ module InnerModule: { type t = private string + @genType let make: t => string } = { diff --git a/tests/gentype_tests/typescript-react-example/src/ModuleAliases.res b/tests/gentype_tests/typescript-react-example/src/ModuleAliases.res index fb1a2ed514b..4983a05023b 100644 --- a/tests/gentype_tests/typescript-react-example/src/ModuleAliases.res +++ b/tests/gentype_tests/typescript-react-example/src/ModuleAliases.res @@ -6,10 +6,12 @@ module Outer = { module Outer2 = { module OuterInnerAlias = Outer.Inner + module Inner2 = { module InnerNested = { type t = {nested: int} } + module OuterInnerAlias2 = OuterInnerAlias } } diff --git a/tests/gentype_tests/typescript-react-example/src/NestedVariants.res b/tests/gentype_tests/typescript-react-example/src/NestedVariants.res index f91b15d3709..577580a1d82 100644 --- a/tests/gentype_tests/typescript-react-example/src/NestedVariants.res +++ b/tests/gentype_tests/typescript-react-example/src/NestedVariants.res @@ -7,9 +7,11 @@ let makeVariant = () => NonUnary(5, 3) type typeC = | C(string) | D(string) + type typeB = {c: typeC} type typeD = Int(int) type typeE = int + type typeA<'a> = | A('a, int) | B('a, int) @@ -17,9 +19,11 @@ type typeA<'a> = type typeF<'a> = | F('a) | G('a) + type typeH = | H(typeD, int) | I(typeD, int) + type typeJ = J(typeD, typeD) type typeK = K((typeD, typeD)) @@ -54,8 +58,10 @@ let makeK = (): typeK => K((Int(5), Int(3))) type boxedBinary = | BB(typeD, int) | Z(int) + @genType type unboxedBinary = UB(typeD, int) + @genType type inline = | I({i: int, j: int}) diff --git a/tests/gentype_tests/typescript-react-example/src/ReservedNames.res b/tests/gentype_tests/typescript-react-example/src/ReservedNames.res index 8961ce260c2..29406f06714 100644 --- a/tests/gentype_tests/typescript-react-example/src/ReservedNames.res +++ b/tests/gentype_tests/typescript-react-example/src/ReservedNames.res @@ -11,6 +11,7 @@ let window = 3 module Products = { @genType let createNew = "createNew" + @genType let delete = "delete" } diff --git a/tests/gentype_tests/typescript-react-example/src/Usage.res b/tests/gentype_tests/typescript-react-example/src/Usage.res index 12d383e2172..d8a39afc033 100644 --- a/tests/gentype_tests/typescript-react-example/src/Usage.res +++ b/tests/gentype_tests/typescript-react-example/src/Usage.res @@ -1,3 +1,4 @@ let a = 5 + @genType let b = Wrapper.MyModuleAlias.add(a, 3) diff --git a/tests/syntax_benchmarks/data/Napkinscript.res b/tests/syntax_benchmarks/data/Napkinscript.res index c8596e584ba..047c81619cd 100644 --- a/tests/syntax_benchmarks/data/Napkinscript.res +++ b/tests/syntax_benchmarks/data/Napkinscript.res @@ -103,6 +103,7 @@ module Doc = { | Group({shouldBreak: bool, doc: t}) | CustomLayout(list<t>) | BreakParent + /* | Cursor */ let nil = Nil @@ -2944,6 +2945,7 @@ module ParsetreeViewer: { let shouldIndentBinaryExpr: Parsetree.expression => bool let shouldInlineRhsBinaryExpr: Parsetree.expression => bool let filterPrinteableAttributes: Parsetree.attributes => Parsetree.attributes + let partitionPrinteableAttributes: Parsetree.attributes => ( Parsetree.attributes, Parsetree.attributes, @@ -2953,6 +2955,7 @@ module ParsetreeViewer: { Asttypes.arg_label, Parsetree.expression, )> => bool + let requiresSpecialCallbackPrintingFirstArg: list<( Asttypes.arg_label, Parsetree.expression, @@ -4255,6 +4258,7 @@ module CommentTable = { ->Doc.toString(~width=80) ->print_endline } + let attach = (tbl, loc, comments) => switch comments { | list{} => () @@ -12602,6 +12606,7 @@ module Parser = { } let beginRegion = p => p.regions = list{ref(Report), ...p.regions} + let endRegion = p => try p.regions = List.tl(p.regions) catch { | Failure(_) => () @@ -12759,6 +12764,7 @@ module NapkinScript = { let id = Location.mknoloc("napkinscript.patternhole") Ast_helper.Pat.extension((id, PStr(list{}))) } + /* Ast_helper.Pat.any () */ let defaultModuleExpr = () => Ast_helper.Mod.structure(list{}) diff --git a/tests/syntax_tests/data/ast-mapping/expected/Braces.res.txt b/tests/syntax_tests/data/ast-mapping/expected/Braces.res.txt index 94ec22a3e38..32986b560c3 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/Braces.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/Braces.res.txt @@ -1,9 +1,11 @@ let value = {42} + let branch = if true { 1 } else { 2 } + let case = switch value { | 42 => value | _ => 0 diff --git a/tests/syntax_tests/data/ast-mapping/expected/FunctionsAndArrows.res.txt b/tests/syntax_tests/data/ast-mapping/expected/FunctionsAndArrows.res.txt index 508c2860fb2..4763329d388 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/FunctionsAndArrows.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/FunctionsAndArrows.res.txt @@ -7,6 +7,7 @@ let id = x => x // labeled, optional, and default parameters let labeled = (~x, ~y) => x - y + let optional = (~x=?, ~y=1, z) => { switch x { | Some(x) => x + y + z diff --git a/tests/syntax_tests/data/ast-mapping/expected/JSXElements.res.txt b/tests/syntax_tests/data/ast-mapping/expected/JSXElements.res.txt index 835aab0f9f5..2cbfcb9c121 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/JSXElements.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/JSXElements.res.txt @@ -39,7 +39,9 @@ let elementWithConditionalChildren = ReactDOM.jsx( }), }, ) + let commentOnly = ReactDOM.jsx("div", {/* no child */}) + let commentsBetweenElements = ReactDOM.jsx( "div", { diff --git a/tests/syntax_tests/data/ast-mapping/expected/JSXFragments.res.txt b/tests/syntax_tests/data/ast-mapping/expected/JSXFragments.res.txt index b80a42ace16..e2c9e22a1e2 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/JSXFragments.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/JSXFragments.res.txt @@ -22,7 +22,9 @@ let nestedFragments = React.jsxs( ]), }, ) + let commentOnly = React.jsx(React.jsxFragment, {}) // no child + let commentsBetweenElements = React.jsxs( React.jsxFragment /* between */, {children: React.array([ReactDOM.jsx("span", {}), ReactDOM.jsx("span", {})])}, diff --git a/tests/syntax_tests/data/ast-mapping/expected/JsxComponents.res.txt b/tests/syntax_tests/data/ast-mapping/expected/JsxComponents.res.txt index b463e41a075..a2383bfba1e 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/JsxComponents.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/JsxComponents.res.txt @@ -3,7 +3,9 @@ module A = { type props<'x> = { x: 'x, } + let make = ({x, _}: props<_>): React.element => React.string(x) + let make = React.component({ let \"JsxComponents$A" = (props: props<_>) => make(props) \"JsxComponents$A" @@ -15,6 +17,7 @@ module B = { /** Doc */ @deprecated @genType let make = ({x, _}: props): React.element => React.string(x) + /** Doc */ @deprecated @genType let make = React.component({ @@ -26,6 +29,7 @@ module B = { module C = { let make = (props: props): React.element => React.string(props.x) + let make = React.component({ let \"JsxComponents$C" = (props: props): React.element => make(props) \"JsxComponents$C" @@ -34,6 +38,7 @@ module C = { module D = { let make = (props: props): React.element => React.string(props.x) + let make = React.component({ let \"JsxComponents$D" = (props: props): React.element => make(props) \"JsxComponents$D" @@ -57,6 +62,7 @@ module F: { } let make: React.component<props<string>> + @jsx.componentWithProps let other: props => React.element } = { @@ -66,6 +72,7 @@ module F: { } let make = ({x, _}: props<_>): React.element => React.string(x) + let make = React.component({ let \"JsxComponents$F" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ast-mapping/expected/RawExtensions.res.txt b/tests/syntax_tests/data/ast-mapping/expected/RawExtensions.res.txt index 3b21442b871..6e9b07042e1 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/RawExtensions.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/RawExtensions.res.txt @@ -1,7 +1,9 @@ let add = %raw("(a, b) => a + b") + let template = %raw(`function (a) { return "x" + a }`) + let escaped = %raw(`"a\`b\${c}"`) let fn = %ffi("(a) => a + 1") let applied = %ffi(`(a, b) => a * b`)(2, 3) diff --git a/tests/syntax_tests/data/ast-mapping/expected/TernaryExpressions.res.txt b/tests/syntax_tests/data/ast-mapping/expected/TernaryExpressions.res.txt index 3fb4f4dbcaf..2c2c02bb2a4 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/TernaryExpressions.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/TernaryExpressions.res.txt @@ -2,6 +2,7 @@ let choose = (condition, yes, no) => condition ? yes : no let nested = (first, second, a, b, c) => first ? a : second ? b : c let inCondition = (first, second, a, b, c) => (first ? second : false) ? a : b + c + let mixed = (condition, yes, no) => if condition { condition ? yes : no diff --git a/tests/syntax_tests/data/ast-mapping/expected/regexp.res.txt b/tests/syntax_tests/data/ast-mapping/expected/regexp.res.txt index 5818664601b..16806da9d3b 100644 --- a/tests/syntax_tests/data/ast-mapping/expected/regexp.res.txt +++ b/tests/syntax_tests/data/ast-mapping/expected/regexp.res.txt @@ -4,8 +4,10 @@ let characterClass = /[/\]]+/u let unicode = /世界+/g let dot = /./s let flags = /a/dgimsuy + @foo let attributed = /a/g + let comments = [/* before */ /a/g /* after */, /b/] let use = f(/a/i, /b/m) let expressionAttributes = @foo /a/g diff --git a/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt b/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt index 241cb963078..c7dc9e340d6 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt @@ -15,6 +15,7 @@ type state = { module Styles = { open Css + let terminal = style(list{ margin(10->px), backgroundColor("222"->hex), @@ -26,7 +27,9 @@ module Styles = { fontFamily(#custom(Theme.codeFontFamily)), unsafe("WebkitOverflowScrolling", "touch"), }) + let line = style(list{whiteSpace(#preWrap)}) + let input = style(list{ backgroundColor("222"->hex), fontFamily(#custom(Theme.codeFontFamily)), @@ -37,6 +40,7 @@ module Styles = { padding(zero), outlineStyle(none), }) + let title = style(list{ fontSize(48->px), fontWeight(extraBold), diff --git a/tests/syntax_tests/data/conversion/reason/expected/comments.res.txt b/tests/syntax_tests/data/conversion/reason/expected/comments.res.txt index 948e3ba49be..5065f0e7637 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/comments.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/comments.res.txt @@ -5,6 +5,7 @@ let /* a */ x /* b */ = /* c */ 1 /* comment 2 */ // comment 4 let x = 1 /* 5 */ + /* 6 */ let f = ( @@ -18,6 +19,7 @@ let f = ( // 7 y: 2, // 8 } + /* **** comment */ /* ** comment */ /* comment */ @@ -68,6 +70,7 @@ type variant = | X(int) /* End of line on X */ /* Comment above Y */ | Y(int) /* End of line on Y */ + /* Comment on entire type def for variant */ type rec x = { @@ -139,12 +142,14 @@ let store_attributes = arg => { Temp.logIt(proc_name, ()) } } + 3 // - 3 //- 3 //- 3 /* - */ + // **** comment /* ** comment */ @ocaml.doc(" docstring ") @@ -290,6 +295,7 @@ type t3 = (int, int) // End of line on (int, int) type variant = | X(int, int) // End of line on X | Y(int, int) // End of line on Y + // Comment on entire type def for variant // Before let @@ -421,6 +427,7 @@ let result = @ocaml.doc("") (2 + 3) // }; let a = () + for i in 0 to 10 { // bla a @@ -434,6 +441,7 @@ type color = | Red(int) // After red end of line | Black(int) // After black end of line | Green(int) // After green end of line + // On next line after color type def let blahCurriedX = (x, x) => @@ -445,6 +453,7 @@ let blahCurriedX = (x, x) => | Black(x) => 0 // After black | Green(x) => 0 } // After second green + // On next line after blahCurriedX def let name_equal = (x, y) => x == y @@ -631,6 +640,7 @@ while trueThing { // does work ) } + while trueThing { f( // a @@ -661,6 +671,7 @@ ignore((_xxx, _yyy) => { type tester<'a, 'b> = | TwoArgsConstructor('a, 'b) | OneTupleArgConstructor(('a, 'b)) + let callFunctionTwoArgs = (a, b) => () let callFunctionOneTuple = tuple => () diff --git a/tests/syntax_tests/data/conversion/reason/expected/modType.res.txt b/tests/syntax_tests/data/conversion/reason/expected/modType.res.txt index 260265ccf4d..a3454a224b9 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/modType.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/modType.res.txt @@ -1,12 +1,14 @@ module Same = (Na: N, Nb: N): ((S with type number1 = Na.number) with type number2 = Nb.number) => { type number1 = Na.number type number2 = Nb.number + let rec sim = ((n, m)) => if Na.is_zero(n) { Nb.is_zero(m) } else { sim((Na.pred(n), Nb.pred(m))) } + let similar = ((n, m)) => try sim((n, m)) catch { | Na.Too_small => false diff --git a/tests/syntax_tests/data/conversion/reason/expected/ppx.res.txt b/tests/syntax_tests/data/conversion/reason/expected/ppx.res.txt index 3f0dda10e0a..3800c8052d9 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/ppx.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/ppx.res.txt @@ -10,6 +10,7 @@ } } ` + {taggedTemplate: false} ) @@ -21,7 +22,9 @@ module Form = %form( @as("form-name") formName: string, } + type output = input + let validators = { name: { strategy: OnFirstBlur, diff --git a/tests/syntax_tests/data/ppx/react/expected/aliasProps.res.txt b/tests/syntax_tests/data/ppx/react/expected/aliasProps.res.txt index cf1e0bc6ad1..f85b0d3f5b3 100644 --- a/tests/syntax_tests/data/ppx/react/expected/aliasProps.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/aliasProps.res.txt @@ -15,6 +15,7 @@ module C0 = { let text = __text_value (React.string(text): React.element) } + let make = React.component({ let \"AliasProps$C0" = (props: props<_>) => make(props) @@ -37,6 +38,7 @@ module C1 = { let text = __text_value (React.string(p ++ text): React.element) } + let make = React.component({ let \"AliasProps$C1" = (props: props<_>) => make(props) @@ -58,6 +60,7 @@ module C2 = { let bar = __foo_value (React.string(bar): React.element) } + let make = React.component({ let \"AliasProps$C2" = (props: props<_>) => make(props) @@ -90,6 +93,7 @@ module C3 = { }: React.element ) } + let make = React.component({ let \"AliasProps$C3" = (props: props<_>) => make(props) @@ -112,6 +116,7 @@ module C4 = { let x = __x_value (ReactDOM.jsx("div", {children: ?ReactDOM.someElement(b)}): React.element) } + let make = React.component({ let \"AliasProps$C4" = (props: props<_>) => make(props) @@ -134,6 +139,7 @@ module C5 = { let z = __z_value (x + y + z: React.element) } + let make = React.component({ let \"AliasProps$C5" = (props: props<_>) => make(props) @@ -148,6 +154,7 @@ module C6 = { let make: React.component<props> } + @res.jsxComponentProps type props<'comp, 'x> = { comp: 'comp, @@ -156,6 +163,7 @@ module C6 = { let make = ({comp: module(Comp: Comp), x: (a, b), _}: props<_, _>): React.element => React.jsx(Comp.make, {}) + let make = React.component({ let \"AliasProps$C6" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/asyncAwait.res.txt b/tests/syntax_tests/data/ppx/react/expected/asyncAwait.res.txt index f0dce005e25..d9e7f3b5eb0 100644 --- a/tests/syntax_tests/data/ppx/react/expected/asyncAwait.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/asyncAwait.res.txt @@ -10,6 +10,7 @@ module C0 = { let a = await f(a) ReactDOM.jsx("div", {children: ?ReactDOM.someElement({React.int(a)})}) } + let make = React.component({ let \"AsyncAwait$C0" = (props: props<_>) => Jsx.promise(make(props)) @@ -29,6 +30,7 @@ module C1 = { | #off => React.string("off") } } + let make = React.component({ let \"AsyncAwait$C1" = (props: props<_>) => Jsx.promise(make(props)) @@ -46,6 +48,7 @@ module Braced = { let a = await f(a) ReactDOM.jsx("div", {children: ?ReactDOM.someElement({React.int(a)})}) } + let make = React.component({ let \"AsyncAwait$Braced" = (props: props<_>) => Jsx.promise(make(props)) diff --git a/tests/syntax_tests/data/ppx/react/expected/commentAtTop.res.txt b/tests/syntax_tests/data/ppx/react/expected/commentAtTop.res.txt index 033f9b418d6..c0a48e04662 100644 --- a/tests/syntax_tests/data/ppx/react/expected/commentAtTop.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/commentAtTop.res.txt @@ -6,6 +6,7 @@ type props<'msg> = { let make = ({msg, _}: props<_>): React.element => { ReactDOM.jsx("div", {children: ?ReactDOM.someElement({msg->React.string})}) } + let make = React.component({ let \"CommentAtTop" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/defaultPatternProp.res.txt b/tests/syntax_tests/data/ppx/react/expected/defaultPatternProp.res.txt index b1ea9117691..ddf93b36486 100644 --- a/tests/syntax_tests/data/ppx/react/expected/defaultPatternProp.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/defaultPatternProp.res.txt @@ -6,6 +6,7 @@ module C0 = { type props = {} let make = (_: props): React.element => React.null + let make = React.component({ let \"DefaultPatternProp$C0$M" = props => make(props) @@ -14,6 +15,7 @@ module C0 = { } module type S = module type of M + @res.jsxComponentProps type props<'component> = { component?: 'component, @@ -27,6 +29,7 @@ module C0 = { let module(C: S) = __component_value (React.jsx(C.make, {}): React.element) } + let make = React.component({ let \"DefaultPatternProp$C0" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/defaultValueProp.res.txt b/tests/syntax_tests/data/ppx/react/expected/defaultValueProp.res.txt index 5406c7724d4..ba31d682b2e 100644 --- a/tests/syntax_tests/data/ppx/react/expected/defaultValueProp.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/defaultValueProp.res.txt @@ -4,6 +4,7 @@ module C0 = { a?: 'a, b?: 'b, } + let make = ({a: ?__a, b: ?__b, _}: props<_, _>) => { let __a_value = switch __a { | Some(a) => a @@ -17,6 +18,7 @@ module C0 = { let b = __b_value (React.int(a + b): React.element) } + let make = React.component({ let \"DefaultValueProp$C0" = (props: props<_>) => make(props) \"DefaultValueProp$C0" @@ -38,6 +40,7 @@ module C1 = { let a = __a_value (React.int(a + b): React.element) } + let make = React.component({ let \"DefaultValueProp$C1" = (props: props<_>) => make(props) @@ -47,6 +50,7 @@ module C1 = { module C2 = { let a = "foo" + @res.jsxComponentProps type props<'a> = { a?: 'a, @@ -60,6 +64,7 @@ module C2 = { let a = __a_value (React.string(a): React.element) } + let make = React.component({ let \"DefaultValueProp$C2" = (props: props<_>) => make(props) @@ -85,6 +90,7 @@ module C3 = { }: React.element ) } + let make = React.component({ let \"DefaultValueProp$C3" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/fileLevelConfig.res.txt b/tests/syntax_tests/data/ppx/react/expected/fileLevelConfig.res.txt index 2cd52b3ac31..eeec4feefd4 100644 --- a/tests/syntax_tests/data/ppx/react/expected/fileLevelConfig.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/fileLevelConfig.res.txt @@ -9,6 +9,7 @@ module V4A = { let make = ({msg, _}: props<_>): Preact.element => { Preact.Elements.jsx("div", {children: ?Preact.Elements.someElement({msg->React.string})}) } + let make = Preact.component({ let \"FileLevelConfig$V4A" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt b/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt index feabbdaf5f4..1b0812a8c6c 100644 --- a/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt +++ b/tests/syntax_tests/data/ppx/react/expected/firstClassModules.resi.txt @@ -5,6 +5,7 @@ module Select: { type key type t } + @res.jsxComponentProps type props<'model, 'selected, 'onChange, 'items> = { model: 'model, diff --git a/tests/syntax_tests/data/ppx/react/expected/forwardRef.res.txt b/tests/syntax_tests/data/ppx/react/expected/forwardRef.res.txt index f23f859040f..34b6281e1c7 100644 --- a/tests/syntax_tests/data/ppx/react/expected/forwardRef.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/forwardRef.res.txt @@ -29,12 +29,14 @@ module V4A = { ]), }, ) + let make = React.forwardRef({ let \"ForwardRef$V4A$FancyInput" = (props: props<_>, ref) => make(props, ref) \"ForwardRef$V4A$FancyInput" }) } + @res.jsxComponentProps type props = {} @@ -50,6 +52,7 @@ module V4A = { }, ) } + let make = React.component({ let \"ForwardRef$V4A" = props => make(props) @@ -86,12 +89,14 @@ module V4AUncurried = { ]), }, ) + let make = React.forwardRef({ let \"ForwardRef$V4AUncurried$FancyInput" = (props: props<_>, ref) => make(props, ref) \"ForwardRef$V4AUncurried$FancyInput" }) } + @res.jsxComponentProps type props = {} @@ -107,6 +112,7 @@ module V4AUncurried = { }, ) } + let make = React.component({ let \"ForwardRef$V4AUncurried" = props => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/fragment.res.txt b/tests/syntax_tests/data/ppx/react/expected/fragment.res.txt index 80c3bb1d868..67f207d12a5 100644 --- a/tests/syntax_tests/data/ppx/react/expected/fragment.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/fragment.res.txt @@ -2,21 +2,26 @@ let _ = React.jsx(React.jsxFragment, {}) let _ = React.jsx(React.jsxFragment, {children: ReactDOM.jsx("div", {})}) + let _ = React.jsxs( React.jsxFragment, {children: React.array([ReactDOM.jsx("div", {}), ReactDOM.jsx("div", {})])}, ) + let _ = React.jsx(React.jsxFragment, {children: React.jsx(React.jsxFragment, {})}) let _ = React.jsx(Z.make, {}) let _ = React.jsx(Z.make, {children: ReactDOM.jsx("div", {})}) let _ = React.jsx(Z.make, {a: "a", children: ReactDOM.jsx("div", {})}) + let _ = React.jsxs( Z.make, {children: React.array([ReactDOM.jsx("div", {}), ReactDOM.jsx("div", {})])}, ) + let _ = ReactDOM.jsx("div", {}) let _ = ReactDOM.jsx("div", {children: ?ReactDOM.someElement(ReactDOM.jsx("div", {}))}) let _ = ReactDOM.jsx("div", {id: "id", children: ?ReactDOM.someElement(ReactDOM.jsx("div", {}))}) + let _ = ReactDOM.jsxs( "div", {children: React.array([ReactDOM.jsx("div", {}), ReactDOM.jsx("div", {})])}, diff --git a/tests/syntax_tests/data/ppx/react/expected/interface.res.txt b/tests/syntax_tests/data/ppx/react/expected/interface.res.txt index 77b6e77aec2..6f9981a815f 100644 --- a/tests/syntax_tests/data/ppx/react/expected/interface.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/interface.res.txt @@ -3,7 +3,9 @@ module A = { type props<'x> = { x: 'x, } + let make = ({x, _}: props<_>): React.element => React.string(x) + let make = React.component({ let \"Interface$A" = (props: props<_>) => make(props) \"Interface$A" @@ -15,6 +17,7 @@ module NoProps = { type props = {} let make = (_: props): React.element => ReactDOM.jsx("div", {}) + let make = React.component({ let \"Interface$NoProps" = props => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/interface.resi.txt b/tests/syntax_tests/data/ppx/react/expected/interface.resi.txt index d0cc914abf7..b819ab34647 100644 --- a/tests/syntax_tests/data/ppx/react/expected/interface.resi.txt +++ b/tests/syntax_tests/data/ppx/react/expected/interface.resi.txt @@ -3,6 +3,7 @@ module A: { type props<'x> = { x: 'x, } + let make: React.component<props<string>> } diff --git a/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.res.txt b/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.res.txt index 266f97d3281..f3580c98d26 100644 --- a/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.res.txt @@ -3,6 +3,7 @@ type props<'x, 'ref> = { x: 'x, ref?: 'ref, } + let make = ( {x, _}: props<string, ReactDOM.Ref.currentDomRef>, ref: nullable<ReactDOM.Ref.currentDomRef>, @@ -10,6 +11,7 @@ let make = ( let _ = ref->Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef) React.string(x) } + let make = React.forwardRef({ let \"InterfaceWithRef" = (props: props<_>, ref) => make(props, ref) \"InterfaceWithRef" diff --git a/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.resi.txt b/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.resi.txt index 462fa9d6404..cf547d26c66 100644 --- a/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.resi.txt +++ b/tests/syntax_tests/data/ppx/react/expected/interfaceWithRef.resi.txt @@ -3,4 +3,5 @@ type props<'x, 'ref> = { x: 'x, ref?: 'ref, } + let make: React.component<props<string, ReactDOM.Ref.currentDomRef>> diff --git a/tests/syntax_tests/data/ppx/react/expected/mangleKeyword.res.txt b/tests/syntax_tests/data/ppx/react/expected/mangleKeyword.res.txt index fd905c590ba..78eb9d2bdc8 100644 --- a/tests/syntax_tests/data/ppx/react/expected/mangleKeyword.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/mangleKeyword.res.txt @@ -9,12 +9,14 @@ module C4A0 = { let make = ({@as("open") _open, @as("type") _type, _}: props<_, string>): React.element => React.string(_open) + let make = React.component({ let \"MangleKeyword$C4A0" = (props: props<_>) => make(props) \"MangleKeyword$C4A0" }) } + module C4A1 = { @res.jsxComponentProps @live type props<'T_open, 'T_type> = { diff --git a/tests/syntax_tests/data/ppx/react/expected/nested.res.txt b/tests/syntax_tests/data/ppx/react/expected/nested.res.txt index 4931436a500..35f584aad73 100644 --- a/tests/syntax_tests/data/ppx/react/expected/nested.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/nested.res.txt @@ -1,12 +1,14 @@ module Outer = { @res.jsxComponentProps type props = {} + let make = (_: props): React.element => { module Inner = { @res.jsxComponentProps type props = {} let make = (_: props): React.element => ReactDOM.jsx("div", {}) + let make = React.component({ let \"Nested$Outer" = props => make(props) @@ -16,6 +18,7 @@ module Outer = { React.jsx(Inner.make, {}) } + let make = React.component({ let \"Nested$Outer" = props => make(props) \"Nested$Outer" diff --git a/tests/syntax_tests/data/ppx/react/expected/newtype.res.txt b/tests/syntax_tests/data/ppx/react/expected/newtype.res.txt index 5873c71b31e..92408363a66 100644 --- a/tests/syntax_tests/data/ppx/react/expected/newtype.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/newtype.res.txt @@ -10,6 +10,7 @@ module V4A = { let make = (type a, {a, b, c, _}: props<a, array<option<[#Foo(a)]>>, 'a>): React.element => ReactDOM.jsx("div", {}) + let make = React.component({ let \"Newtype$V4A" = (props: props<_>) => make(props) @@ -27,6 +28,7 @@ module V4A1 = { let make = (type x y, {a, b, c, _}: props<x, array<y>, 'a>): React.element => ReactDOM.jsx("div", {}) + let make = React.component({ let \"Newtype$V4A1" = (props: props<_>) => make(props) @@ -48,6 +50,7 @@ module V4A2 = { module T = unpack(foo) ReactDOM.jsx("div", {}) } + let make = React.component({ let \"Newtype$V4A2" = (props: props<_>) => make(props) @@ -65,12 +68,14 @@ module V4A3 = { module T = unpack(foo: T with type t = a) foo } + let make = React.component({ let \"Newtype$V4A3" = (props: props<_>) => make(props) \"Newtype$V4A3" }) } + @res.jsxComponentProps type props<'x, 'q> = { x: 'x, @@ -78,6 +83,7 @@ type props<'x, 'q> = { } let make = ({x, q, _}: props<('a, 'b), 'a>): React.element => [fst(x), q] + let make = React.component({ let \"Newtype" = (props: props<_>) => make(props) @@ -93,6 +99,7 @@ module Uncurried = { } let make = (type a, {?foo, _}: props<_>): React.element => React.null + let make = React.component({ let \"Newtype$Uncurried" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/noPropsWithKey.res.txt b/tests/syntax_tests/data/ppx/react/expected/noPropsWithKey.res.txt index 443bb57c62e..1a481fa6780 100644 --- a/tests/syntax_tests/data/ppx/react/expected/noPropsWithKey.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/noPropsWithKey.res.txt @@ -5,6 +5,7 @@ module V4CA = { type props = {} let make = (_: props): React.element => ReactDOM.jsx("div", {}) + let make = React.component({ let \"NoPropsWithKey$V4CA" = props => make(props) @@ -34,6 +35,7 @@ module V4C = { ]), }, ) + let make = React.component({ let \"NoPropsWithKey$V4C" = props => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/optimizeAutomaticMode.res.txt b/tests/syntax_tests/data/ppx/react/expected/optimizeAutomaticMode.res.txt index 7ccf95dfb35..6ce4b5e17e3 100644 --- a/tests/syntax_tests/data/ppx/react/expected/optimizeAutomaticMode.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/optimizeAutomaticMode.res.txt @@ -4,6 +4,7 @@ module User = { type t = {firstName: string, lastName: string} let format = user => "Dr." ++ user.lastName + @res.jsxComponentProps type props<'doctor> = { doctor: 'doctor, @@ -12,6 +13,7 @@ module User = { let make = ({doctor, _}: props<_>): React.element => { ReactDOM.jsx("h1", {id: "h1", children: ?ReactDOM.someElement({React.string(format(doctor))})}) } + let make = React.component({ let \"OptimizeAutomaticMode$User" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/optionalKeyType.res.txt b/tests/syntax_tests/data/ppx/react/expected/optionalKeyType.res.txt index 0420bce343e..16ee150124a 100644 --- a/tests/syntax_tests/data/ppx/react/expected/optionalKeyType.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/optionalKeyType.res.txt @@ -8,18 +8,21 @@ let _ = React.jsxKeyed(C.make, {}, ~key?, ()) let _ = ReactDOM.jsxKeyed("div", {}, ~key="k", ()) let _ = ReactDOM.jsxKeyed("div", {}, ~key=?Some("k"), ()) let _ = ReactDOM.jsxKeyed("div", {}, ~key?, ()) + let _ = ReactDOM.jsxsKeyed( "div", {children: React.array([ReactDOM.jsx("br", {}), ReactDOM.jsx("br", {})])}, ~key="k", (), ) + let _ = ReactDOM.jsxsKeyed( "div", {children: React.array([ReactDOM.jsx("br", {}), ReactDOM.jsx("br", {})])}, ~key=?Some("k"), (), ) + let _ = ReactDOM.jsxsKeyed( "div", {children: React.array([ReactDOM.jsx("br", {}), ReactDOM.jsx("br", {})])}, diff --git a/tests/syntax_tests/data/ppx/react/expected/returnConstraint.res.txt b/tests/syntax_tests/data/ppx/react/expected/returnConstraint.res.txt index 43e3ca14aef..ddd4b721102 100644 --- a/tests/syntax_tests/data/ppx/react/expected/returnConstraint.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/returnConstraint.res.txt @@ -5,6 +5,7 @@ module Standard = { type props = {} let make = (_: props): React.element => React.string("ok") + let make = React.component({ let \"ReturnConstraint$Standard" = props => make(props) @@ -17,6 +18,7 @@ module ForwardRef = { type props = {} let make = (_: props, _ref): React.element => ReactDOM.jsx("div", {}) + let make = React.forwardRef({ let \"ReturnConstraint$ForwardRef" = (props, ref) => make(props, ref) @@ -29,6 +31,7 @@ module WithProps = { let make = (props: props): React.element => ReactDOM.jsx("span", {children: ?ReactDOM.someElement({React.int(props.value)})}) + let make = React.component({ let \"ReturnConstraint$WithProps" = (props: props): React.element => make(props) \"ReturnConstraint$WithProps" @@ -41,6 +44,7 @@ module Async = { let make = async (_: props): React.element => ReactDOM.jsx("div", {children: ?ReactDOM.someElement({React.string("async")})}) + let make = React.component({ let \"ReturnConstraint$Async" = props => Jsx.promise(make(props)) diff --git a/tests/syntax_tests/data/ppx/react/expected/sharedProps.res.txt b/tests/syntax_tests/data/ppx/react/expected/sharedProps.res.txt index 34d29a757e4..202be4471b1 100644 --- a/tests/syntax_tests/data/ppx/react/expected/sharedProps.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/sharedProps.res.txt @@ -4,6 +4,7 @@ module V4A1 = { type props = sharedProps<string> let make = ({x, y, _}: props): React.element => React.string(x ++ y) + let make = React.component({ let \"SharedProps$V4A1" = props => make(props) @@ -15,6 +16,7 @@ module V4A2 = { type props<'a> = sharedProps<'a> let make = ({x, y, _}: props<_>): React.element => React.string(x ++ y) + let make = React.component({ let \"SharedProps$V4A2" = (props: props<_>) => make(props) @@ -26,6 +28,7 @@ module V4A3 = { type props<'a> = sharedProps<string, 'a> let make = ({x, y, _}: props<_>): React.element => React.string(x ++ y) + let make = React.component({ let \"SharedProps$V4A3" = (props: props<_>) => make(props) @@ -37,6 +40,7 @@ module V4A4 = { type props = sharedProps let make = ({x, y, _}: props): React.element => React.string(x ++ y) + let make = React.component({ let \"SharedProps$V4A4" = props => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/sharedPropsWithProps.res.txt b/tests/syntax_tests/data/ppx/react/expected/sharedPropsWithProps.res.txt index 91eea5058fc..094cc964ddf 100644 --- a/tests/syntax_tests/data/ppx/react/expected/sharedPropsWithProps.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/sharedPropsWithProps.res.txt @@ -18,6 +18,7 @@ let f = a => Promise.resolve(a + a) module V4A1 = { type props = sharedProps let make = (props): React.element => React.string(props.x ++ props.y) + let make = React.component({ let \"SharedPropsWithProps$V4A1" = (props): React.element => make(props) \"SharedPropsWithProps$V4A1" @@ -27,6 +28,7 @@ module V4A1 = { module V4A2 = { type props = sharedProps let make = (props: props): React.element => React.string(props.x ++ props.y) + let make = React.component({ let \"SharedPropsWithProps$V4A2" = (props: props): React.element => make(props) \"SharedPropsWithProps$V4A2" @@ -36,6 +38,7 @@ module V4A2 = { module V4A3 = { type props<'a> = sharedProps<'a> let make = ({x, y}: props<_>): React.element => React.string(x ++ y) + let make = React.component({ let \"SharedPropsWithProps$V4A3" = (props: props<_>): React.element => make(props) \"SharedPropsWithProps$V4A3" @@ -45,6 +48,7 @@ module V4A3 = { module V4A4 = { type props<'a> = sharedProps<string, 'a> let make = ({x, y}: props<_>): React.element => React.string(x ++ y) + let make = React.component({ let \"SharedPropsWithProps$V4A4" = (props: props<_>): React.element => make(props) \"SharedPropsWithProps$V4A4" @@ -53,10 +57,12 @@ module V4A4 = { module V4A5 = { type props<'a> = {a: 'a} + let make = async ({a}: props<_>): React.element => { let a = await f(a) ReactDOM.jsx("div", {children: ?ReactDOM.someElement({React.int(a)})}) } + let make = React.component({ let \"SharedPropsWithProps$V4A5" = (props: props<_>): React.element => Jsx.promise(make(props)) \"SharedPropsWithProps$V4A5" @@ -65,12 +71,14 @@ module V4A5 = { module V4A6 = { type props<'status> = {status: 'status} + let make = async ({status}: props<_>): React.element => { switch status { | #on => React.string("on") | #off => React.string("off") } } + let make = React.component({ let \"SharedPropsWithProps$V4A6" = (props: props<_>): React.element => Jsx.promise(make(props)) \"SharedPropsWithProps$V4A6" @@ -83,6 +91,7 @@ module V4A7 = { let make = (props): React.element => { React.int(props.count) } + let make = React.component({ let \"SharedPropsWithProps$V4A7" = @directive("'use memo'") (props): React.element => make(props) @@ -95,6 +104,7 @@ module V4A8 = { // The payload has no effect; it is accepted with a deprecation warning. let make = (props): React.element => React.string(props.x) + let make = React.component({ let \"SharedPropsWithProps$V4A8" = (props): React.element => make(props) \"SharedPropsWithProps$V4A8" diff --git a/tests/syntax_tests/data/ppx/react/expected/topLevel.res.txt b/tests/syntax_tests/data/ppx/react/expected/topLevel.res.txt index bc712ece06e..886d36bce63 100644 --- a/tests/syntax_tests/data/ppx/react/expected/topLevel.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/topLevel.res.txt @@ -11,6 +11,7 @@ module V4A = { Console.log("This function should be named 'TopLevel.react'") ReactDOM.jsx("div", {}) } + let make = React.component({ let \"TopLevel$V4A" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt b/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt index 491f5c7d191..8586b2d5d3a 100644 --- a/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/typeConstraint.res.txt @@ -8,6 +8,7 @@ module V4A = { } let make = (type a, {a, b, _}: props<_, _>): React.element => ReactDOM.jsx("div", {}) + let make = React.component({ let \"TypeConstraint$V4A" = (props: props<_>) => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/uncurriedProps.res.txt b/tests/syntax_tests/data/ppx/react/expected/uncurriedProps.res.txt index 9e635bafdd6..a7a1dff341a 100644 --- a/tests/syntax_tests/data/ppx/react/expected/uncurriedProps.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/uncurriedProps.res.txt @@ -1,4 +1,5 @@ @@jsxConfig({version: 4}) + @res.jsxComponentProps type props<'a> = { a?: 'a, @@ -12,6 +13,7 @@ let make = ({a: ?__a, _}: props<unit => unit>) => { let a: unit => unit = __a_value (React.null: React.element) } + let make = React.component({ let \"UncurriedProps" = (props: props<_>) => make(props) @@ -46,6 +48,7 @@ module Foo = { }: React.element ) } + let make = React.component({ let \"UncurriedProps$Foo" = (props: props<_>) => make(props) @@ -58,6 +61,7 @@ module Bar = { type props = {} let make = (_: props): React.element => React.jsx(Foo.make, {callback: {(_, _, _) => ()}}) + let make = React.component({ let \"UncurriedProps$Bar" = props => make(props) diff --git a/tests/syntax_tests/data/ppx/react/expected/v4.res.txt b/tests/syntax_tests/data/ppx/react/expected/v4.res.txt index a23517ad7dd..dbf4c5c06a6 100644 --- a/tests/syntax_tests/data/ppx/react/expected/v4.res.txt +++ b/tests/syntax_tests/data/ppx/react/expected/v4.res.txt @@ -3,7 +3,9 @@ type props<'x, 'y> = { x: 'x, // Component with type constraint y: 'y, } + let make = ({x, y, _}: props<string, string>): React.element => React.string(x ++ y) + let make = React.component({ let \"V4" = (props: props<_>) => make(props) \"V4" @@ -16,6 +18,7 @@ module Braced = { } let make = ({name, _}: props<_>): React.element => React.string(name) + let make = React.component({ let \"V4$Braced" = (props: props<_>) => make(props) @@ -31,6 +34,7 @@ module AnotherName = { } let anotherName = ({x, _}: props<_>): React.element => React.string(x) + let anotherName = React.component({ let \"V4$AnotherName$anotherName" = (props: props<_>) => anotherName(props) @@ -45,6 +49,7 @@ module Uncurried = { } let make = ({x, _}: props<_>): React.element => React.string(x) + let make = React.component({ let \"V4$Uncurried" = (props: props<_>) => make(props) @@ -86,6 +91,7 @@ module Rec = { let rec make = (_: props): React.element => { make(({}: props)) } + let make = React.component({ let \"V4$Rec" = props => make(props) @@ -100,6 +106,7 @@ module Rec1 = { let rec make = (_: props): React.element => { React.null } + let make = React.component({ let \"V4$Rec1" = props => make(props) @@ -116,6 +123,7 @@ module Rec2 = { } and mm = x => make(x) + let make = React.component({ let \"V4$Rec2" = props => make(props) diff --git a/tests/syntax_tests/data/printer/comments/expected/callbackTrailing.res.txt b/tests/syntax_tests/data/printer/comments/expected/callbackTrailing.res.txt index 852da869a7c..340e934d17a 100644 --- a/tests/syntax_tests/data/printer/comments/expected/callbackTrailing.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/callbackTrailing.res.txt @@ -50,13 +50,16 @@ let labeled = call(~fn=x => x /* keep labeled */) let optional = call(~fn=?x => x /* keep optional */) let labeledFirst = call(~fn=x => x /* keep first */, value) let optionalLast = call(value, ~fn=?x => x /* keep last */) + let labeledBelow = call( ~fn=x => x, /* keep below */ ) + let optionalLine = call( ~fn=?x => x, // keep line ) + let labeledNested = call(~fn=x => call(~fn=y => y /* keep nested */)) let leadingLabeled = call(/* keep leading label */ ~fn=x => x) @@ -71,11 +74,13 @@ outer(x => x => x, // keep nested line ) ) + outer(x => call( ~fn=x => x, // keep nested labeled line ) ) + outer(x => call( ~fn=?x => x, // keep nested optional line diff --git a/tests/syntax_tests/data/printer/comments/expected/docCommentParameters.res.txt b/tests/syntax_tests/data/printer/comments/expected/docCommentParameters.res.txt index 6be363ea313..755f5585056 100644 --- a/tests/syntax_tests/data/printer/comments/expected/docCommentParameters.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/docCommentParameters.res.txt @@ -2,10 +2,12 @@ let f = ( /**The runner*/ run: string, ) => run + let f = ( /** The runner */ run: string, ) => run + let f = ( /** Positional */ x, @@ -14,6 +16,7 @@ let f = ( /** Typed */ ~z: int, ) => x + y + z + let f = ( /** Optional */ ~a=?, @@ -22,6 +25,7 @@ let f = ( ~c as /** Aliased */ d, ) => d + let f = ( /** Locally abstract */ type a, diff --git a/tests/syntax_tests/data/printer/comments/expected/expr.res.txt b/tests/syntax_tests/data/printer/comments/expected/expr.res.txt index 848e546b303..e4a95afc3c4 100644 --- a/tests/syntax_tests/data/printer/comments/expected/expr.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/expr.res.txt @@ -71,6 +71,7 @@ let x = (/* c0 */ "string" /* c1 */: /* c2 */ string /* c3 */) // after let x = /* before */ true /* after */ let x = /* before */ Red /* after */ let x = /* before */ Red(/* c0 */ shade /* c1 */) /* after */ + let x = /* before */ Red /* after Red */( /* c0 */ r /* c1 */, /* c2 */ g /* c3 */, @@ -93,6 +94,7 @@ let x = /* c0 */ list{/* c1 */ a /* c2 */, /* c3 */ b /* c4 */, /* c5 */ c /* c6 // Pexp_array let x = [/* c0 */ a /* c1 */, /* c2 */ b /* c3 */, /* c4 */ c /* c5 */] let x = [/* a */] + let x = [ // test ] @@ -233,6 +235,7 @@ try { // Pexp_fun let f = (/* c0 */ a /* c1 */, /* c2 */ b /* c3 */): /* c4 */ int /* c5 */ => /* c6 */ 20 /* c7 */ + let multiply = (/* c0 */ m1 /* c1 */, /* c2 */ m2 /* c3 */) => { // here open Matrix4D @@ -256,6 +259,7 @@ let f = ( ) => () let multiply = (type /* c-2 */ t /* c-1 */, /* c0 */ m1 /* c1 */, /* c2 */ m2 /* c3 */) => () + let multiply = ( type /* c-4 */ t /* c-3 */ /* c-2 */ s /* c-1 */, /* c0 */ m1 /* c1 */, @@ -293,6 +297,7 @@ f(() => 1) f(_ => 1) // c2 f(a => 1) + // c3 f((~a) => // c4 @@ -331,6 +336,7 @@ Doc.concat( rows, /* a */ ) + Doc.concat(list{ privateFlag, rows, diff --git a/tests/syntax_tests/data/printer/comments/expected/modExpr.res.txt b/tests/syntax_tests/data/printer/comments/expected/modExpr.res.txt index d802464dec6..10142c27705 100644 --- a/tests/syntax_tests/data/printer/comments/expected/modExpr.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/modExpr.res.txt @@ -24,10 +24,12 @@ /* c6 */ Arg2 /* c7 */, /* c8 */ Arg3 /* c9 */, ) /* c10 */ + /* c0 */ module /* c1 */ X /* c2 */ = /* c3 */ F( /* c4 */ A /* c5 */: /* c6 */ SetLike /* c7 */, /* c7 */ B /* c8 */: /* c9 */ TreeLike /* c10 */, ) /* c11 */ + /* c0 */ module /* c1 */ S0 /* c2 */ = /* c3 */ Make /* c4 */(/* lbrace */ { type t = int /* c5 */ let eq /* c6 */ = (x, y) => x == y diff --git a/tests/syntax_tests/data/printer/comments/expected/modType.res.txt b/tests/syntax_tests/data/printer/comments/expected/modType.res.txt index 7f0ff61abc4..c319a2e029c 100644 --- a/tests/syntax_tests/data/printer/comments/expected/modType.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/modType.res.txt @@ -19,10 +19,12 @@ // Pmty_functor /* c0 */ module type /* c1 */ Functor /* c2 */ = /* c3 */ SetLike /* c4 */ => /* c5 */ Set /* c6 */ + module type Functor = /* before */ ( /* before S */ S /* after S */: /* before */ SetLike /* after */, /* before B */ B /* after B */: /* before */ BtreeLike /* after */, ) => /* before NeoTree */ NeoTree // after NeoTree + module type Functor = ( /* c0 */ /* c1 */ /* c2 */ SetLike /* c3 */, /* c4 */ /* c5 */ /* c6 */ BtreeLike /* c7 */, diff --git a/tests/syntax_tests/data/printer/comments/expected/namedArgs.res.txt b/tests/syntax_tests/data/printer/comments/expected/namedArgs.res.txt index c74b892f8a5..5f77a8b4789 100644 --- a/tests/syntax_tests/data/printer/comments/expected/namedArgs.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/namedArgs.res.txt @@ -80,6 +80,7 @@ let f = (~x /* a */ /* a2 */=? /* b */ /* b2 */, ~y) => x let f = (~x as y=? /* a */, ~z) => y let f = (~x=?, /* a */ ~y) => x let f = (~x=? /* a */, ~y) => x + let f = ( ~x: int /* a */=? /* b */, ~someLongParameterName, diff --git a/tests/syntax_tests/data/printer/comments/expected/pattern.res.txt b/tests/syntax_tests/data/printer/comments/expected/pattern.res.txt index 3b4a79fb8e0..2934955ae27 100644 --- a/tests/syntax_tests/data/printer/comments/expected/pattern.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/pattern.res.txt @@ -23,6 +23,7 @@ let /* here */ Black /* there */ = color let /* here */ Black(/* inside */) /* there */ = color let Black(/* inside */ /* inside2 */) = color let Black(/* inside */ /* inside2 */ /* inside 3 */) = color + let Black( // singleLineComment ) = color diff --git a/tests/syntax_tests/data/printer/comments/expected/structureItem.res.txt b/tests/syntax_tests/data/printer/comments/expected/structureItem.res.txt index 5dfc7e189e3..8ee240e95b4 100644 --- a/tests/syntax_tests/data/printer/comments/expected/structureItem.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/structureItem.res.txt @@ -6,6 +6,7 @@ // Pstr_include /* c0 */ include /* c1 */ Belt /* c2 */ + /* c0 */ include /* c1 */ { let a /* inside */ = 2 } /* c2 */ diff --git a/tests/syntax_tests/data/printer/comments/expected/typeDefinition.res.txt b/tests/syntax_tests/data/printer/comments/expected/typeDefinition.res.txt index 87ba674da8a..6e200d03ada 100644 --- a/tests/syntax_tests/data/printer/comments/expected/typeDefinition.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/typeDefinition.res.txt @@ -12,6 +12,7 @@ /* before */ type t = /* before manifest */ string /* after */ /* before */ type /* before name */ t /* after name */ = /* before manifest */ string /* after */ + /* before */ type /* before name */ t /* after name */< /* c0 */ 'err /* c1 */, /* c2 */ 'success /* c3 */, diff --git a/tests/syntax_tests/data/printer/comments/expected/typexpr.res.txt b/tests/syntax_tests/data/printer/comments/expected/typexpr.res.txt index c02f7ebe0b4..b428d5baa71 100644 --- a/tests/syntax_tests/data/printer/comments/expected/typexpr.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/typexpr.res.txt @@ -42,10 +42,12 @@ type add = /* before */ ( /* c0 */ int /* c1 */, /* c2 */ int /* c3 */, ) => /* before return */ int /* after */ + type add = /* before */ ( /* c0 */ ~a: int /* c1 */, /* c2 */ ~b: int /* c3 */, ) => /* before return */ int /* after */ + type multiply = /* before */ ( /* c0 */ ~fn: ( /* cinner0 */ int /* cinner1 */, @@ -53,6 +55,7 @@ type multiply = /* before */ ( ) => /* cx */ int /* c1 */, /* c2 */ ~b: int /* c3 */, ) => int /* after */ + type make = ( ~activity: ActivityFlow_Activity.t, ~showExpert: (string, string) => unit, @@ -95,6 +98,7 @@ external another_test: ( // comment 2 int, ) => unit = "test" + type optionalArg = (~x: int /* a */=?, unit) => int type lastOptionalArg = (~x: int /* a */=?) => int external optionalArgExternal: (~x: int /* a */=?, unit) => int = "f" @@ -103,6 +107,7 @@ type lastOptionalArgAfter = (~x: int=? /* a */) => int type optionalArgAround = (~x: int /* a */ /* a2 */=? /* b */, ~y: int) => int type optionalArgThenComma = (~x: int=?, /* a */ ~y: int) => int external optionalArgAfterExternal: (~x: int=? /* a */, unit) => int = "f" + type optionalArgAfterMultiline = ( ~x: int=? /* a */, ~someLongParameterName: int, diff --git a/tests/syntax_tests/data/printer/comments/expected/valueBindings.res.txt b/tests/syntax_tests/data/printer/comments/expected/valueBindings.res.txt index e5cac613d77..659594eab40 100644 --- a/tests/syntax_tests/data/printer/comments/expected/valueBindings.res.txt +++ b/tests/syntax_tests/data/printer/comments/expected/valueBindings.res.txt @@ -3,6 +3,7 @@ let x = 1 // leading snd value-binding and y = 2 + /* leading snd value-binding */ let walkList: 'node. unit = comments => { diff --git a/tests/syntax_tests/data/printer/expected/regexp.res.txt b/tests/syntax_tests/data/printer/expected/regexp.res.txt index b1d7791474b..44d55caca38 100644 --- a/tests/syntax_tests/data/printer/expected/regexp.res.txt +++ b/tests/syntax_tests/data/printer/expected/regexp.res.txt @@ -4,8 +4,10 @@ let characterClass = /[/\]]+/u let unicode = /世界+/g let dot = /./s let flags = /a/dgimsuy + @foo let attributed = /a/g + let comments = [/* before */ /a/g /* after */, /b/] let use = f(/a/i, /b/m) let expressionAttributes = @foo /a/g diff --git a/tests/syntax_tests/data/printer/expected/regexpStatements.res.txt b/tests/syntax_tests/data/printer/expected/regexpStatements.res.txt index a5193971eca..7ecd139add4 100644 --- a/tests/syntax_tests/data/printer/expected/regexpStatements.res.txt +++ b/tests/syntax_tests/data/printer/expected/regexpStatements.res.txt @@ -191,8 +191,10 @@ let afterOpenExpression = () => { } let beforeStatementAttribute = 0 + @foo /a/->ignore + /**Keep the documentation attribute.*/ /b/->ignore diff --git a/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt b/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt index 6f9b61a2bc1..2f24e1d0bc8 100644 --- a/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/DocComments.res.txt @@ -2,8 +2,10 @@ let doc1: ( /** ddd */ ~x: int, ) => int = (~x) => x + 1 + let doc2: /** ddd */ int => int = x => x + 1 let doc3: /** ddd */ int => int = x => x + 1 + let doc4: ( /** ddd */ ~x: int, diff --git a/tests/syntax_tests/data/printer/expr/expected/apply.res.txt b/tests/syntax_tests/data/printer/expr/expected/apply.res.txt index d8c08db77a6..d74444132ae 100644 --- a/tests/syntax_tests/data/printer/expr/expected/apply.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/apply.res.txt @@ -20,6 +20,7 @@ let cmp = rbt.compare2(Array.getUnsafe(old, oldIter.contents), longerNode.longVa let uncurriedUnit = apply() let coordinate = make2dCoordinate({x: 1, y: 2}) + let coordinate = make3dCoordinate({ ...base, field1: thisIsAPrettyLongNameHere, @@ -28,6 +29,7 @@ let coordinate = make3dCoordinate({ }) let coordinate = make2dCoordinateArray([x, y]) + let coordinate = make3dCoordinateArray([ thisIsAPrettyLongNameHere, thisIsAPrettyLongNameHere, @@ -35,6 +37,7 @@ let coordinate = make3dCoordinateArray([ ]) let coordinate = make2dCoordinateTuple((x, y)) + let coordinate = make3dCoordinateTuple(( thisIsAPrettyLongNameHere, thisIsAPrettyLongNameHere, @@ -42,6 +45,7 @@ let coordinate = make3dCoordinateTuple(( )) let coordinate = make2dCoordinateList(list{x, y}) + let coordinate = make3dCoordinateList(list{ thisIsAPrettyLongNameHere, thisIsAPrettyLongNameHere, @@ -50,6 +54,7 @@ let coordinate = make3dCoordinateList(list{ }) let coordinate = makeJsCoordinate({"x": 1, "y": 1}) + let user = makeJsUser({ "name": "steve", "age": 32, @@ -67,27 +72,35 @@ document.createElementWithOptions("div", elementProps(~onClick=_ => Console.log( f(1) f([1, 2, 3]) + f([ suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuperLong, suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuperLong, suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuperLong, ]) + f((1, 2, 3)) f({"a": 1}) f(list{1}) + f(` template string `) + f(`single line`) + f(" template string ") + f({ expr }) + f({expr}) + f({ exception Exit throw(Exit) diff --git a/tests/syntax_tests/data/printer/expr/expected/array.res.txt b/tests/syntax_tests/data/printer/expr/expected/array.res.txt index 8565e0dc359..9499ce14b15 100644 --- a/tests/syntax_tests/data/printer/expr/expected/array.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/array.res.txt @@ -1,5 +1,6 @@ let x = [] let x = [a, b, c] + let x = [ superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, @@ -29,6 +30,7 @@ let x = [...[1, 2], 3, ...[]] let x = [...[...xs, 1], ...ys] let x = @attr [1, ...xs] let x = [...(xs: array<int>), ...ys->Array.map(f)] + let x = [ ...superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, diff --git a/tests/syntax_tests/data/printer/expr/expected/assert.res.txt b/tests/syntax_tests/data/printer/expr/expected/assert.res.txt index 93d7d60d5ca..6e191225776 100644 --- a/tests/syntax_tests/data/printer/expr/expected/assert.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/assert.res.txt @@ -21,6 +21,7 @@ let x = assert(apply(arg1, arg2)) let x = assert(-1) let x = assert(!true) let x = assert(x => print(x)) + let x = assert(switch x { | Blue => () | Yello => () diff --git a/tests/syntax_tests/data/printer/expr/expected/assignment.res.txt b/tests/syntax_tests/data/printer/expr/expected/assignment.res.txt index 887afd4b4c9..37d08c38184 100644 --- a/tests/syntax_tests/data/printer/expr/expected/assignment.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/assignment.res.txt @@ -2,10 +2,12 @@ f := { first: one, second: two, } + f.contents = { first: one, second: two, } + obj["value"] = { first: one, second: two, @@ -17,12 +19,14 @@ f := [ thirdVeryLongArrayElement, fourthVeryLongArrayElement, ] + f.contents = [ firstVeryLongArrayElement, secondVeryLongArrayElement, thirdVeryLongArrayElement, fourthVeryLongArrayElement, ] + obj["value"] = [ firstVeryLongArrayElement, secondVeryLongArrayElement, @@ -34,10 +38,12 @@ f := () => { doA() doB() } + f.contents = () => { doA() doB() } + obj["value"] = () => { doA() doB() @@ -47,10 +53,12 @@ f := @attr () => { doA() doB() } + f.contents = @attr () => { doA() doB() } + obj["value"] = @attr () => { doA() doB() @@ -61,11 +69,13 @@ f := | Some(value) => value | None => fallback } + f.contents = switch value { | Some(value) => value | None => fallback } + obj["value"] = switch value { | Some(value) => value @@ -73,27 +83,33 @@ obj["value"] = } f := firstVeryLongOperand + secondVeryLongOperand + thirdVeryLongOperand + fourthVeryLongOperand + f.contents = firstVeryLongOperand + secondVeryLongOperand + thirdVeryLongOperand + fourthVeryLongOperand + obj["value"] = firstVeryLongOperand + secondVeryLongOperand + thirdVeryLongOperand + fourthVeryLongOperand f := {firstVeryLongOperand + secondVeryLongOperand + thirdVeryLongOperand + fourthVeryLongOperand} + f.contents = { firstVeryLongOperand + secondVeryLongOperand + thirdVeryLongOperand + fourthVeryLongOperand } + obj["value"] = { firstVeryLongOperand + secondVeryLongOperand + thirdVeryLongOperand + fourthVeryLongOperand } // Assignments used as operands retain their grouping. let nested = (f := {first: one, second: two})->ignore + let field = ( f.contents = { first: one, second: two, } )->ignore + let object = ( obj["value"] = { first: one, diff --git a/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt b/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt index c02694d1508..8b9df042023 100644 --- a/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt @@ -48,16 +48,19 @@ let _ = await %extension let _ = await "test" let _ = await ((a, b) => a + b) let _ = await (async (a, b) => a + b) + let _ = await ( switch x { | A => () | B => () } ) + let _ = await [1, 2, 3] let _ = await (1, 2, 3) let _ = await {name: "Steve", age: 32} let _ = await (user.name = "Steve") + let _ = await ( if 20 { true @@ -65,25 +68,30 @@ let _ = await ( false } ) + let _ = await (condition() ? true : false) let _ = await f(x) let _ = await f(x) let _ = await (f(x): Promise.t<unit>) + let _ = await ( while true { infiniteLoop() } ) + let _ = await ( try ok() catch { | _ => logError() } ) + let _ = await ( for i in 0 to 10 { sideEffect() } ) + let _ = await (assert(x)) let _ = await promises[0] let _ = await promises["resolved"] @@ -96,6 +104,7 @@ let _ = await Promise(status) // braces are being dropped, because the ast only has space to record braces surrounding the await let _ = await x + // here braces stay, because of precedence let _ = await { let x = 1 diff --git a/tests/syntax_tests/data/printer/expr/expected/binary.res.txt b/tests/syntax_tests/data/printer/expr/expected/binary.res.txt index 2185cc1955f..669b2e887e2 100644 --- a/tests/syntax_tests/data/printer/expr/expected/binary.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/binary.res.txt @@ -31,16 +31,19 @@ let x = foo ++ bar let x = 1 + 1 let x = (a => a + 1) + (b => b + 2) let x = -1 + -1 + let x = switch z { | Red => 1 }->switch y { | Blue => 2 } + let x = try z catch { | Exit => 1 }->try y catch { | Blue => 2 } + let x = if true { 1 @@ -51,6 +54,7 @@ let x = } else { 3 } + let x = for i in 0 to 10 { () }->for i in 0 to 10 { @@ -84,6 +88,7 @@ let rotateX = (range / rect.height * refY - range / 2) * getXMultiplication(rect let rotateY = (range / rect.width * refX - range / 2) * getYMultiplication(rect.width) let x = longIdentifier + longIdentifier + longIdentifier + let x = longIdentifier + longIdentifier + @@ -91,12 +96,14 @@ let x = longIdentifier - longIdentifier + longIdentifier + let x = longIdentifier + longIdentifier * longIdentifier + longIdentifier - longIdentifier + longIdentifier + let x = longIdentifier + longIdentifier * longIdentifier * longIdentifier / longIdentifier + @@ -109,6 +116,7 @@ let x = longIdentifier && longIdentifier && longIdentifier + let x = (longIdentifier && longIdentifier) || longIdentifier && longIdentifier || @@ -140,6 +148,7 @@ while continuePrefix.contents && aPrefixLen.contents <= aLen && bPrefixLen.conte let nextNonwhiteA = nextNonWhiteChar(aStr, 1, aPrefixLen.contents - 1) let nextNonwhiteB = nextNonWhiteChar(bStr, 1, bPrefixLen.contents - 1) } + let () = { let () = sideEffect() if ( @@ -205,12 +214,14 @@ let x = a && a.b let x = a && x.y && g.h let x = a && true let x = a && true && true + let x = a && { let a = true let b = true a || b } + let x = a && { @@ -244,6 +255,7 @@ let x = | Blue => "blue" | Red => "red" } + let x = a && switch color { @@ -292,6 +304,7 @@ let x = } else { false } + let x = a && if true { @@ -309,6 +322,7 @@ let x = sideEffect() do() } + let x = a && { @@ -323,6 +337,7 @@ let x = a && while true { do() } + let x = a && while true { @@ -335,6 +350,7 @@ let x = a && for i in 0 to 10 { true } + let x = a && for i in 0 to 10 { @@ -351,6 +367,7 @@ let x = module L = Log L.log() } + let x = a && { @@ -366,6 +383,7 @@ let x = exception Exit throw(Exit) } + let x = a && { @@ -384,6 +402,7 @@ let x = open React killPerform() } + let x = a && { @@ -462,6 +481,7 @@ x->(y->z) x->(y->(z->w)) let x = "z" ++ a->f ++ "x" + let toString = functionArgs => { functionArgs == [] ? "" : "<" ++ functionArgs->List.map(argToString)->String.concat(",") ++ ">" } @@ -521,5 +541,6 @@ let make = (~keycap) => <Kbd keycap="Ctrl" /> + <Kbd keycap="Shift" /> + <Kbd ke // rescript-lang/syntax/issues/499 (@doesNotRaise [])->Belt.Array.getExn(0) + @doesNotRaise []->Belt.Array.getExn(0) diff --git a/tests/syntax_tests/data/printer/expr/expected/block.res.txt b/tests/syntax_tests/data/printer/expr/expected/block.res.txt index f9331a10a51..3dff5c4b22e 100644 --- a/tests/syntax_tests/data/printer/expr/expected/block.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/block.res.txt @@ -18,6 +18,7 @@ let reifyStyle = (type a, x: 'a): (style<a>, a) => { type rec constructor @val external canvasGradient: constructor = "CanvasGradient" /* internal */ @val external canvasPattern: constructor = "CanvasPattern" /* internal */ + let instanceOf = ( %raw(`function(x,y) {return +(x instanceof y)}`): ('a, constructor) => bool ) /* internal */ diff --git a/tests/syntax_tests/data/printer/expr/expected/braced.res.txt b/tests/syntax_tests/data/printer/expr/expected/braced.res.txt index aa0af975709..4d402d37596 100644 --- a/tests/syntax_tests/data/printer/expr/expected/braced.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/braced.res.txt @@ -29,16 +29,19 @@ let _ = {a} let _ = {"constant"} let _ = {() => Console.log("test")} + let _ = { switch b { | true => () | false => () } } + let _ = switch {b} { | true => () | false => () } + let _ = {apply(a, b)} let _ = {apply}(a, b) @@ -47,6 +50,7 @@ let _ = { | Exit => () } } + let _ = try {danger()} catch { | Exit => () } @@ -56,6 +60,7 @@ let _ = {({a}, {b}, {x + y})} let _ = {Rgb(r, g, b)} let _ = Rgb({r}, {g}, {b}) + let _ = Rgb( { r @@ -70,6 +75,7 @@ let _ = Rgb( let _ = {{name: "steve", age: 30}} let _ = {name: {"steve"}, age: {30}} + let _ = { name: { "steve" @@ -86,6 +92,7 @@ let _ = {{user.name}.first} let _ = {[a, b, c]} let _ = [{a}, {b}, {c}] + let _ = [ { a @@ -100,6 +107,7 @@ let _ = [ let _ = {list{a, b, c}} let _ = {list{{a}, {b}, {c}}} + let _ = { list{ { @@ -126,6 +134,7 @@ let _ = { () } } + let _ = { if {true} { () @@ -161,12 +170,15 @@ let _ = { () } } + let _ = while {true} { () } + while {/* c0 */ true /* c1 */} { () } + while ( { true @@ -174,6 +186,7 @@ while ( ) { () } + while ( { /* c0 */ true // c1 @@ -187,6 +200,7 @@ let _ = { () } } + for _ in { 0 } to { @@ -204,6 +218,7 @@ let localToGlobalX = ( ): coordinate<globalCoordinates> => { x +. (Environment.width /. 2. -. centering.x) } + map((arr, i): coordinate<globalCoordinates> => { x +. (Environment.width /. 2. -. centering.x) }) @@ -216,12 +231,15 @@ let _ = {module(ME)} let _ = {module(ME: MyMod)} {myArray}[{0}] + { myArray }[{ 0 }] + {myArray}[{0}] = {20} + { myArray }[{ @@ -236,6 +254,7 @@ myArray[20] = { {jsObject}["foo"] {jsObject}["foo"] = {"bar"} + {jsObject}["foo"] = { a + b } @@ -243,9 +262,11 @@ myArray[20] = { { jsObject }["foo"] + {jsObject}["foo"] = {"bar"} apply({a}, {b}, {c}) + apply( { a @@ -259,6 +280,7 @@ apply( ) Thing.map(foo, (arg1, arg2) => {MyModuleBlah.toList(argument)}) + Thing.map({foo}, (arg1, arg2) => { MyModuleBlah.toList(argument) }) @@ -277,9 +299,11 @@ arr->Belt.Array.map(x => { }) apply(~a={a}) + apply({ a }) + apply({ a }) @@ -311,6 +335,7 @@ let x = { } {a} + {b} + { a } + diff --git a/tests/syntax_tests/data/printer/expr/expected/bsObj.res.txt b/tests/syntax_tests/data/printer/expr/expected/bsObj.res.txt index 083bb52267f..572217ddf3b 100644 --- a/tests/syntax_tests/data/printer/expr/expected/bsObj.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/bsObj.res.txt @@ -17,11 +17,13 @@ let person = { let user = {"name": (ceo.name: string)} // braces should be preserved on rhs let user = {"name": {ceo.name}} + let user = { "name": { ceo.name }, } + // braced + constrained expr let user = {"name": {(ceo.name: string)}} diff --git a/tests/syntax_tests/data/printer/expr/expected/callback.res.txt b/tests/syntax_tests/data/printer/expr/expected/callback.res.txt index 046a9f5d3fc..3e83b62f543 100644 --- a/tests/syntax_tests/data/printer/expr/expected/callback.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/callback.res.txt @@ -1,5 +1,6 @@ array->Array.forEach(((value, height)) => add(rbt, value, ~height)->ignore) someArray->Array.forEach(((value, height)) => add(rbt, value, ~height)->ignore) + someArraaaaaaayWithAVeryLooooooooooooooooooooooooooooooooooooooongName->Array.forEach((( value, height, @@ -14,9 +15,11 @@ let make = (arr, ~compare) => { Thing.map(foo, (arg1, arg2) => MyModuleBlah.toList(argument)) Thing.map(foo, bar, baz, (aaaaaaaaaaarg1, aaaaarg2) => MyModuleBlah.toList(argument)) Thing.map(fooooooooooooooooooo, bar, baz, (abc, z) => MyModuleBlah.toList(argument)) + Thing.map(fooooooooooooooooooo, baaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaaaaaz, (abc, z) => MyModuleBlah.toList(argument) ) + Fooooooooooooooooooo.baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(baaaz, quuuuux => something(here) ) @@ -119,6 +122,7 @@ Thing.map( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarg3, ~fn=(param1, parm2) => doStuff(param1, parm2), ) + Thing.map( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarg1, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarg2, @@ -135,6 +139,7 @@ Thing.map(~fn=?(arg1, arg2) => MyModuleBlah.toList(argument), foo) Thing.map(~fn=(arg1, arg2) => { MyModuleBlah.toList(argument) }, longArgument, veryLooooongArgument) + Thing.map(~fn=?(arg1, arg2) => { MyModuleBlah.toList(argument) }, longArgument, veryLooooongArgument) @@ -146,6 +151,7 @@ Thing.map( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarg3, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarg4, ) + Thing.map( ~fn=?(param1, parm2) => doStuff(param1, parm2), aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarg2, diff --git a/tests/syntax_tests/data/printer/expr/expected/coerce.res.txt b/tests/syntax_tests/data/printer/expr/expected/coerce.res.txt index 3c74ea4de5b..8e428ce567c 100644 --- a/tests/syntax_tests/data/printer/expr/expected/coerce.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/coerce.res.txt @@ -67,24 +67,29 @@ let arrayIndex = values[index :> int] values[index :> int] = (value :> b) let recordSpread = {...value :> b, field: value} let bracedOperand = ({value} :> b) + let blockSequence = { { foo() value } :> b } + let checked = assert(value :> bool) (value :> b) let ternaryCallback = condition ? (x => (x :> b)) : other let piped = (value :> b)->foo + let blockTail = { foo() (value :> b) } + let blockHead = { (value :> b) foo() } + let dictSpread = dict{...value :> dict<b>, "field": value} // A constrained operand needs parentheses when the coercion is a binding RHS. @@ -101,9 +106,11 @@ let beforeJsx = () => { // These grammar positions don't parse a bare trailing coercion. let locallyAbstract: type a. a = (value :> a) + let guarded = switch value { | _ if (flag :> bool) => value } + let jsxSpread = <Component {...(props :> propsType)} /> @attr(? value if (flag :> bool)) @@ -112,6 +119,7 @@ let attributeGuard = value // Attribute and extension payloads parse their contents as plain expressions. @attr((value :> b)) let attributePayload = value + let extensionPayload = %extension((value :> b)) // First-class module unpacking also parses a plain expression. diff --git a/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt b/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt index 929669fab0f..828d80590a4 100644 --- a/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/constructor.res.txt @@ -3,12 +3,15 @@ let y = false let r = Reducer() let r = Reducer(state, nexState, sideEffect) + let r = Reducer( superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, ) + let r = Reducer([state, nexState, sideEffect]) + let r = Reducer([ superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, @@ -45,6 +48,7 @@ let c = ConstructorWithASuuuuuuuuuuuuuuuperLoooooooooooooooooooooooooooooongIiii let c = ConstructorWithASuuuuuuuuuuuuuuuperLoooooooooooooooooooooooooooooongIiiiiiiiiideeeentifieeeeeeeeeeeeeeeeer(list{}) let coordinate = JsCoord({"x": 1, "y": 1}) + let user = JsUser({ "name": "steve", "age": 32, diff --git a/tests/syntax_tests/data/printer/expr/expected/extension.res.txt b/tests/syntax_tests/data/printer/expr/expected/extension.res.txt index c3536b19b4b..58c32ff73a4 100644 --- a/tests/syntax_tests/data/printer/expr/expected/extension.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/extension.res.txt @@ -4,10 +4,12 @@ let node = %raw(@attr ("0")) let node = %raw(@attrStructureLvl (@attrOnExpr "0")) let node = %raw(@attrStructureLvl @attrStructureLvl2 @attrStructureLvl3 (@attrOnExpr "0")) + let node = %raw( @attrStructureLvl @attrStructureLvl2 @attrStructureLvl3 (@attrOnExpr @attrOnExpr2 @attrOnExpr3 @attrOnExpr4 @attrOnExpr5 "unsafe raw js") ) + let f: (int, int) => int = %raw((a, b) => "{return a + b}") let f = (x, y) => { diff --git a/tests/syntax_tests/data/printer/expr/expected/field.res.txt b/tests/syntax_tests/data/printer/expr/expected/field.res.txt index f3e2fed8960..4d9b9271ecc 100644 --- a/tests/syntax_tests/data/printer/expr/expected/field.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/field.res.txt @@ -21,6 +21,7 @@ let x = apply(arg1, arg2).field let x = (-1).x let x = (!true).x let x = (x => print(x)).x + let x = ( switch x { | Blue => () @@ -49,6 +50,7 @@ let x = ( ).x let x = (assert(false)).x + let x = ( try sideEffect() catch { | Exit => () diff --git a/tests/syntax_tests/data/printer/expr/expected/firstClassModule.res.txt b/tests/syntax_tests/data/printer/expr/expected/firstClassModule.res.txt index d3fcbd534ed..12df0f06aa8 100644 --- a/tests/syntax_tests/data/printer/expr/expected/firstClassModule.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/firstClassModule.res.txt @@ -10,22 +10,27 @@ let x = @attr module(Foo: FirstClass) module(Teenager)[0] module(Teenager)->age->Console.log module(Teenager)[0]->Console.log + module(Teenager)->age->isAdult ? Console.log("has responsibilities") : Console.log("can play in the playground") + module(Streets)[0]->isExpensive ? Console.log("big money") : Console.log("affordable") let () = { module(Teenager)->age->Console.log } + let () = { module(Teenager)[0] } + let () = { module(Teenager)->age->isAdult ? Console.log("has responsibilities") : Console.log("can play in the playground") } + let () = { module(Streets)[0]->isExpensive ? Console.log("big money") : Console.log("affordable") } diff --git a/tests/syntax_tests/data/printer/expr/expected/fun.res.txt b/tests/syntax_tests/data/printer/expr/expected/fun.res.txt index d5f7e02218d..ef186493143 100644 --- a/tests/syntax_tests/data/printer/expr/expected/fun.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/fun.res.txt @@ -190,6 +190,7 @@ let make = (~onChange: option<({"testing": bool}, array<string>) => unit>=?, chi let add = (a, b): int => a + b let add = (a, b): {"field1": int, "field2": string, "field3": int, "field4": int} => a + b + let add = (superLongParameterName1, superLongParameterName2, superLongParameterName3): { "field1": int, "field2": string, @@ -206,12 +207,14 @@ let add = (superLongParameterName1, superLongParameterName2, superLongParameterN } => a + b let add = ((a, b)): (int, string, int, int) => a + b + let add = ((a, b)): ( intWithSuperLongName, stringWithSuperLongName, intWithSuperLongName, intWithSuperLongName, ) => a + b + let add = (( superLongParameterName, bsuperLongParameterName, @@ -226,6 +229,7 @@ let add = (list{a, b}): list< intWithSuperLongName, intWithSuperLongName, > => a + b + let add = (list{ superLongParameterName, bsuperLongParameterName, @@ -244,6 +248,7 @@ let add = ([a, b]): array< intWithSuperLongName, intWithSuperLongName, > => a + b + let add = ([ superLongParameterName, bsuperLongParameterName, @@ -258,8 +263,10 @@ let add = ([ let add = ({x: superLongParameterName, y: superLongParameterName, z: superLongParameterName}) => x + y + z + let add = ({x: superLongParameterName, y: superLongParameterName, z: superLongParameterName}) => x + y + z + let add = ({ x: x as superLongParameterName, y: y as superLongParameterName, @@ -268,6 +275,7 @@ let add = ({ let add = (Color(superLongParameterName, superLongParameterName, superLongParameterNameeeeeee)) => x + y + z + let add = (Color( superLongParameterName, superLongParameterName, diff --git a/tests/syntax_tests/data/printer/expr/expected/functionLayouts.res.txt b/tests/syntax_tests/data/printer/expr/expected/functionLayouts.res.txt index 96e60317212..e38bd37b75a 100644 --- a/tests/syntax_tests/data/printer/expr/expected/functionLayouts.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/functionLayouts.res.txt @@ -7,14 +7,17 @@ let fragment = value => <> <First value /> <Second value /> </> + consume(value => <> <First value /> <Second value /> </>) + consume(value => <> <First value /> <Second value /> </>, argument) + consume(argument, value => <> <First value /> <Second value /> @@ -25,10 +28,12 @@ let block = // Keep the body comment. await compute(first, second) } + consume(argument, @attr async (~first, ~second=defaultValue): result => { // Keep the callback comment. await compute(first, second) }) + consume(firstVeryLongArgument, secondVeryLongArgument, (firstParameter, secondParameter) => compute(firstParameter, secondParameter) ) diff --git a/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt b/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt index b93bb7e875d..c3c87d23e3b 100644 --- a/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/jsx.res.txt @@ -21,27 +21,33 @@ let x = </F> </B> </A> + let x = <A> {children} <B /> </A> + let x = <A> <B /> {children} </A> + let x = <A>{a}</A> + let x = <A> {a} {b} </A> + let x = <custom-tag className="container"> {a} <B /> </custom-tag> + let x = <Foo.custom-tag className="container"> {a} @@ -302,9 +308,11 @@ let x = <MyComponent sidebar={<div>{test}</div>} nav={<Navbar />} /> // https://github.com/rescript-lang/syntax/issues/113 <div>{Console.log(a <= 10)}</div> + <div> <div>{Console.log(a <= 10)}</div> </div> + <div> <div onClick={_ => Console.log(a <= 10)}> <div>{Console.log(a <= 10)}</div> diff --git a/tests/syntax_tests/data/printer/expr/expected/jsxChildren.res.txt b/tests/syntax_tests/data/printer/expr/expected/jsxChildren.res.txt index dd90f2bd1c3..d0cc4f90d5c 100644 --- a/tests/syntax_tests/data/printer/expr/expected/jsxChildren.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/jsxChildren.res.txt @@ -31,6 +31,7 @@ let x = {hello} {user.name} </span> + let x = <span> <> @@ -38,13 +39,16 @@ let x = <Icon /> </> </span> + let x = <>{hello}</> let x = <>{hello}</> + let x = <> {hello} {world} </> + let x = <></> let x = <span></span> @@ -52,6 +56,7 @@ let x = <span></span> let x = <span>{render(hello)}</span> let x = <span>{hello->render}</span> let x = <span>{condition ? hello : world}</span> + let x = <span> {switch value { @@ -59,6 +64,7 @@ let x = | None => fallback }} </span> + let x = <span> { @@ -66,6 +72,7 @@ let x = child } </span> + let x = <span> { @@ -73,6 +80,7 @@ let x = hello } </span> + let x = <span> { @@ -80,6 +88,7 @@ let x = child } </span> + let x = <span> { @@ -87,6 +96,7 @@ let x = Hello.child } </span> + let x = <span> { @@ -94,7 +104,9 @@ let x = hello } </span> + let x = <span>{@label hello}</span> + let x = <span> { @@ -105,13 +117,16 @@ let x = } } </span> + let x = <span>{<Icon />}</span> + let x = <span> {/* before braced JSX */} {<Icon />} {/* after braced JSX */} </span> + let x = <> {/* before braced fragment */} @@ -123,11 +138,13 @@ let x = let x = <span>{/* before bare */ hello /* after bare */}</span> let x = <span>{/* inside */ hello /* still inside */}</span> let x = <>{/* inside fragment */ hello /* still in fragment */}</> + let x = <span> {hello /* between children */} {world} </span> + let x = <span>{{/* record field */ name: hello}}</span> // Child comments and their line breaks stay inside expression braces. let x = <span>{hello /* bare child */}</span> @@ -135,12 +152,15 @@ let x = <>{hello /* bare fragment child */}</> let x = <span>{user.name /* field child */}</span> let x = <span>{"hello" /* string child */}</span> let x = <span>{{name: hello} /* record child */}</span> + let x = <span> {hello} {/* already braced child */} </span> + let x = <span>{hello /* block comment */ /* line comment */}</span> + let x = <span> { @@ -148,7 +168,9 @@ let x = hello // Contains */ and must remain a line comment. } </span> + let x = <>{/* before record */ {name: hello} /* after record */}</> + let x = <span> {/* before a block */} @@ -158,12 +180,14 @@ let x = } {/* after a block */} </span> + let x = <span> {/* before a call */} {render(hello)} {/* after a call */} </span> + let x = <span> { @@ -172,7 +196,9 @@ let x = } {/* after bare child */} </span> + let x = <span>{hello /* trailing inside braces */}</span> + let x = <> { @@ -180,6 +206,7 @@ let x = hello } </> + let x = <span> { @@ -187,20 +214,24 @@ let x = {name: hello} /* after record */ } </span> + let x = <LongComponentName attribute="long attribute value"> {aLongChildIdentifierThatWillNeedToWrapAtNarrowWidths} </LongComponentName> let emptyWithBlockComment = <span>{/* empty */}</span> + let emptyWithLineComment = <span> { // contains */ } </span> + let emptyFragmentWithInlineBlockComment = <>{/* inside */}</> let emptyFragmentWithInlineLineComment = <>{/* inside */}</> + let emptyFragmentWithMixedComments = <> { @@ -209,7 +240,9 @@ let emptyFragmentWithMixedComments = /* third */ } </> + let emptyFragmentWithOutsideComment = <>{/* inside */}</> // outside + let emptyFragmentWithComments = <> { @@ -217,6 +250,7 @@ let emptyFragmentWithComments = /* second */ } </> + let nestedStandaloneComments = <div> {/* before */} @@ -231,12 +265,14 @@ let nestedStandaloneComments = </> {/* last */} </div> + let nestedInlineComments = <div> {/* before */} <Icon /> {/* after */} </div> + let explicitCommentContainers = <> {/* before */} @@ -247,17 +283,20 @@ let explicitCommentContainers = <span /> {/* after */} </> + let adjacentCommentContainers = <span> {/* one */} {/* two */} </span> + let commentBeforeExpression = <span> {/* before */} {hello} {/* after */} </span> + let emptyRecordChild = <span>{{}}</span> let wrappedEmptyRecordChild = <span>{{/* record */}}</span> diff --git a/tests/syntax_tests/data/printer/expr/expected/jsxChildrenComments.res.txt b/tests/syntax_tests/data/printer/expr/expected/jsxChildrenComments.res.txt index 048e837ca7c..903ea3e1dfb 100644 --- a/tests/syntax_tests/data/printer/expr/expected/jsxChildrenComments.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/jsxChildrenComments.res.txt @@ -3,6 +3,7 @@ let a = {x} {/* a */} </div> + let b = <div> {x} @@ -10,6 +11,7 @@ let b = {/* c */} {y} </div> + let c = <div> <span /> @@ -17,6 +19,7 @@ let c = <b /> </div> + let d = <div> {/* a */} @@ -24,34 +27,40 @@ let d = {/* b */} <b /> </div> + let e = <div> {/* a */} {/* b */} </div> + let f = <div> {x} {/* c */} {y} </div> + let g = <div> <span /> {/* c */} {x} </div> + let h = <div> {/* a */ /* b */} <span /> </div> + let i = <div> {x} {/* a */} </div> + let j = <div> { @@ -59,6 +68,7 @@ let j = x } </div> + let k = <div> { @@ -66,11 +76,13 @@ let k = /* trailing */ } </div> + let l = <div> {x} {/* trailing */} </div> + let m = <div> { @@ -78,11 +90,13 @@ let m = x } </div> + let n = <div> {/* a */ /* b */} <span /> </div> + let o = <div> { @@ -98,6 +112,7 @@ let a = {x} {/* a */} </> + let b = <> {x} @@ -105,6 +120,7 @@ let b = {/* c */} {y} </> + let c = <> <span /> @@ -112,6 +128,7 @@ let c = <b /> </> + let d = <> {/* a */} @@ -119,34 +136,40 @@ let d = {/* b */} <b /> </> + let e = <> {/* a */} {/* b */} </> + let f = <> {x} {/* c */} {y} </> + let g = <> <span /> {/* c */} {x} </> + let h = <> {/* a */ /* b */} <span /> </> + let i = <> {x} {/* a */} </> + let j = <> { @@ -154,6 +177,7 @@ let j = x } </> + let k = <> { @@ -161,11 +185,13 @@ let k = /* trailing */ } </> + let l = <> {x} {/* trailing */} </> + let m = <> { @@ -173,11 +199,13 @@ let m = x } </> + let n = <> {/* a */ /* b */} <span /> </> + let o = <> { @@ -197,6 +225,7 @@ let spanningContainer = } {y} </div> + let spanningFragmentContainer = <> {x} @@ -215,6 +244,7 @@ let multilineExpressionComment = } {y} </div> + let leadingExpressionComment = <div> <A /> @@ -230,30 +260,35 @@ let mixedLeadingContainers = {/* b */} {y} </div> + let mixedTrailingContainers = <div> {x} {/* b */} {/* a */} </div> + let mixedLeadingFragmentContainers = <> {/* a */} {/* b */} {y} </> + let mixedTrailingFragmentContainers = <> {x} {/* b */} {/* a */} </> + let mixedBetweenContainers = <div> {x /* a */} {/* b */} {/* c */ y} </div> + let mixedBetweenFragmentContainers = <> {x /* a */} @@ -263,30 +298,35 @@ let mixedBetweenFragmentContainers = let safeLineComment = <span>{value /* note */}</span> let safeInnerLineComment = <span>{value /* note */}</span> + let unsafeOpeningDelimiter = <span> { // starts /* } </span> + let unsafeClosingDelimiter = <span> { // closes */ } </span> + let unsafeNestedBlock = <> { // /* nested */ } </> + let unsafeReversedDelimiters = <> { // */ before /* } </> + let emptyLineComment = <span>{/* */}</span> let starLineComment = <span>{/* * */}</span> let slashLineComment = <>{/* / */}</> diff --git a/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt b/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt index e8480471a65..f5a59bd175e 100644 --- a/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt @@ -6,6 +6,7 @@ let f = (type t u v, xs: list<(t, u, v)>) => () let f = @attr (type t u v, xs: list<(t, u, v)>) => () let f = (type t u v s w z, xs: list<(t, u, v)>, ys: list<(s, w, z)>) => () let f = @attr (type t u v, @attr2 type s w z, xs: list<(t, u, v)>, ys: list<(s, w, z)>) => () + let f = ( @attr type t, @attr type s, diff --git a/tests/syntax_tests/data/printer/expr/expected/polyvariant.res.txt b/tests/syntax_tests/data/printer/expr/expected/polyvariant.res.txt index f7c4fa0e296..b97d9d60410 100644 --- a/tests/syntax_tests/data/printer/expr/expected/polyvariant.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/polyvariant.res.txt @@ -1,11 +1,14 @@ let r = #Reducer() let r = #Reducer(state, nexState, sideEffect) + let r = #Reducer( superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, ) + let r = #Reducer([state, nexState, sideEffect]) + let r = #Reducer([ superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, @@ -42,6 +45,7 @@ let c = #ConstructorWithASuuuuuuuuuuuuuuuperLoooooooooooooooooooooooooooooongIii let c = #ConstructorWithASuuuuuuuuuuuuuuuperLoooooooooooooooooooooooooooooongIiiiiiiiiideeeentifieeeeeeeeeeeeeeeeer(list{}) let coordinate = #JsCoord({"x": 1, "y": 1}) + let user = #JsUser({ "name": "steve", "age": 32, diff --git a/tests/syntax_tests/data/printer/expr/expected/record.res.txt b/tests/syntax_tests/data/printer/expr/expected/record.res.txt index d33ef76db57..83d1b5a83ee 100644 --- a/tests/syntax_tests/data/printer/expr/expected/record.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/record.res.txt @@ -1,4 +1,5 @@ let coord = {x: 3.13, y: 3.14} + let record = { firstField: superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, secondField: superLongIdentiiiiiiiifffffffiiiiieeeeeeeer, @@ -11,6 +12,7 @@ let forceBreak = { } let withSpread = {...initialState, time: nextTime} + let withSpreadAndForceBreak = { ...initialState, time: nextTime, @@ -25,6 +27,7 @@ let withSpreadAndNaturalBreak = { let x = @attr {x: 1, y: 2} let x = @attr {...initialState, superLongName: 1, superLongName: 2, superLongName: 5} + let x = @attr {...initialState, superLongName: 1, superLongName: 2, superLongName: 5, superLongName: 20} @@ -32,11 +35,13 @@ let x = let user = {name: (ceo.name: string)} // braces should be preserved on rhs let user = {name: {ceo.name}} + let user = { name: { ceo.name }, } + // braced + constrained expr let user = {name: {(ceo.name: string)}} @@ -58,20 +63,24 @@ let r = { // b b, } + let r = { a, // a b, // b } + let r = { /* a */ a, /* b */ b, } + let r = { a /* a */, b /* b */, } + let r = {a /* a */, b /* b */} let r = {x: ?None, y: ?None, z: ?(None: tt)} @@ -122,13 +131,16 @@ let optParen = {x: 3, y: ?(() => 3)} let optParen = {x: 3, y: ?-3} let x = {a: 2} + let x = { a: 2, bbbbbbbbbbbbbbbbbbbbb: 22222222222, ccccccccccccccccccccc: 22222222222222222, ddddddddddddddddddddd: 2222222222222, } + let x = {a: 2} + let x = { a: 2, } diff --git a/tests/syntax_tests/data/printer/expr/expected/refFunction.res.txt b/tests/syntax_tests/data/printer/expr/expected/refFunction.res.txt index 9f94c7ef7d4..f3cbff74c92 100644 --- a/tests/syntax_tests/data/printer/expr/expected/refFunction.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/refFunction.res.txt @@ -4,6 +4,7 @@ f.contents = () => { doA() doB() } + f := () => { doA() doB() @@ -13,6 +14,7 @@ f.contents = @attr () => { doA() doB() } + f := @attr () => { doA() doB() @@ -20,11 +22,14 @@ f := @attr () => { f := () => doA() f := @first @second () => doA() + f := async () => { await doA() doB() } + f := (value: int): int => value + 1 + f := (firstArgument, secondArgument, thirdArgument, fourthArgument, fifthArgument) => { doA(firstArgument, secondArgument) doB(thirdArgument, fourthArgument, fifthArgument) @@ -36,10 +41,12 @@ f := /* function */ () => { doA() doB() } + f.contents = /* attribute */ @attr () => { doA() doB() } + f := @attr () => { doA() doB() @@ -52,6 +59,7 @@ f := { doB() } } + f := (() => doA(): unit => unit) // Other operators still need parentheses around functions. @@ -63,5 +71,6 @@ let equal = doB() } ) + let left = (() => doA()) == f.contents let nested = (f := () => doA())->ignore diff --git a/tests/syntax_tests/data/printer/expr/expected/setfield.res.txt b/tests/syntax_tests/data/printer/expr/expected/setfield.res.txt index 06f4bf90873..d1cb0f161b0 100644 --- a/tests/syntax_tests/data/printer/expr/expected/setfield.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/setfield.res.txt @@ -1,4 +1,5 @@ user.name = "steve" + config.shouldSkip = !filePath.includes(allMlSuffixesCategory) && !filePath.endsWith(allScriptDirectoriesCategory) diff --git a/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt b/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt index afbf99802b1..90591652bb1 100644 --- a/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/ternary.res.txt @@ -26,6 +26,7 @@ let paymentMessage = : "There was an issue with the payment. Please contact support." let record = truth ? {x: 1, y: 2} : {x: 3, y: 5} + let record = truth ? { thisIsASuperLongFieldHere: loooooooooooooongIdentifier, @@ -37,6 +38,7 @@ let record = truth } let arr = truth ? [1, 2, 3, 4] : [4, 5, 6, 7] + let arr = truth ? [ thisIsASuperLongIdentifieeeeeeeer, @@ -50,6 +52,7 @@ let arr = truth ] let lst = truth ? list{1, 2, 3, 4} : list{4, 5, 6, 7} + let lst = truth ? list{ thisIsASuperLongIdentifieeeeeeeer, @@ -63,6 +66,7 @@ let lst = truth } let construct = truth ? Constructor(1, 2, 3, 4) : Constructor(4, 5, 6, 7) + let construct = truth ? Constructor( thisIsASuperLongIdentifieeeeeeeer, @@ -86,6 +90,7 @@ let x = truth let b = 2 a + b } + let x = truth ? { let a = 1 @@ -99,6 +104,7 @@ let x = truth } let x = truth ? create(a, b) : create(b, c) + let x = truth ? create( thisIsASuperLongIdentifieeeeeeeer, @@ -110,7 +116,9 @@ let x = truth thisIsASuperLongIdentifieeeeeeeer2, thisIsASuperLongIdentifieeeeeeeer3, ) + let x = truth ? create(a, b) : create(b, c) + let x = truth ? create( thisIsASuperLongIdentifieeeeeeeer, @@ -150,6 +158,7 @@ let x = exceptionLike } let tuple = truth ? (1, 2, 3, 4) : (4, 5, 6, 7) + let tuple = truth ? ( thisIsASuperLongIdentifieeeeeeeer, @@ -163,11 +172,13 @@ let tuple = truth ) let x = condition1 ? node.left : node.right + let x = condition1 ? nodeWithVeryLooooooooooooooooongNameHere.left : nodeWithVeryLooooooooooooooooongNameHere.right let x = condition ? node.left = Some(newNode) : node.right = Some(newNode) + let x = condition1 ? nodeWithVeryLooooooooooooooooongNameHere.left = Some(newNode) : nodeWithVeryLooooooooooooooooongNameHere.right = Some(newNode) @@ -183,6 +194,7 @@ let x = condition1 } else { () } + let () = condition1 ? { sideEffect() @@ -200,6 +212,7 @@ let () = condition1 : while true { doOtherThing() } + let () = condition1 ? for i in 0 to 10 { () @@ -219,9 +232,11 @@ let () = condition exception Exit throw(Exit) } + let () = condition ? foo() : assert(false) let x = condition ? module(Foo) : module(Int: Number) + let x = condition ? module(ModuleWithVeryLooooooooooooooooongNameHere) : module(ModuleWithVeryLooooooooooooooooongNameHereInt: Number) @@ -235,10 +250,12 @@ let x = condition open React render() } + let x = condition ? %eval("console.log") : %eval("console.err") let x = condition ? %eval("consoooooooooooooooooooooole.log") : %eval("consoleeeeeeeeeeeeeee.err") let jsObj = condition ? {"x": 1, "y": 2} : {"x": 20, "y": 100} + let jsObj = truth ? { "thisIsASuperLongFieldHere": loooooooooooooongIdentifier, diff --git a/tests/syntax_tests/data/printer/expr/expected/try.res.txt b/tests/syntax_tests/data/printer/expr/expected/try.res.txt index 70659483b27..0b39596ae0f 100644 --- a/tests/syntax_tests/data/printer/expr/expected/try.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/try.res.txt @@ -89,6 +89,7 @@ try myDangerousFn() finally { } let finally = x => x + let afterTry = () => { try { () diff --git a/tests/syntax_tests/data/printer/expr/expected/unary.res.txt b/tests/syntax_tests/data/printer/expr/expected/unary.res.txt index e3c7fd69176..63bb3d5eac9 100644 --- a/tests/syntax_tests/data/printer/expr/expected/unary.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/unary.res.txt @@ -47,6 +47,7 @@ let x = -apply(arg) let x = -Foo(a, b, c) let x = -{x: 1, y: 2} let x = -list{1, 2, 3} + let x = -( if true { 1 @@ -54,27 +55,33 @@ let x = -( 2 } ) + let x = -( for i in 0 to 10 { () } ) + let x = -( switch x { | Foo => 1 } ) + let x = -( while i < 10 { i.contents = 20 } ) + let x = -(1, 2, 3) + let x = -{ let a = 1 let b = 2 a + b } + let x = -{ sideEffect() generateNumber() diff --git a/tests/syntax_tests/data/printer/modExpr/expected/attributes.res.txt b/tests/syntax_tests/data/printer/modExpr/expected/attributes.res.txt index 1179ae4849c..a7768c331d0 100644 --- a/tests/syntax_tests/data/printer/modExpr/expected/attributes.res.txt +++ b/tests/syntax_tests/data/printer/modExpr/expected/attributes.res.txt @@ -1,8 +1,10 @@ module A = @attr F module B = @attr {} + module C = @attr { let x = 1 } + module D = @a @b F // on a functor application, its functor, or an argument @@ -12,12 +14,15 @@ module H = @attr F(A, B) module I = (@attr F(A))(B) module J = F(@attr X) module Q = F(@attr {}) + include @attr F({ type t = int }) + include (@attr F)({ type t = int }) + include F(@attr { type t = int }) diff --git a/tests/syntax_tests/data/printer/modExpr/expected/functor.res.txt b/tests/syntax_tests/data/printer/modExpr/expected/functor.res.txt index 312c49ecd41..c2559191aba 100644 --- a/tests/syntax_tests/data/printer/modExpr/expected/functor.res.txt +++ b/tests/syntax_tests/data/printer/modExpr/expected/functor.res.txt @@ -11,17 +11,21 @@ include (@functorAttr2 @functorAttr X: Map, @attr3 Y: Set) => Zzzzzzzzzzzzzzzzzz module Make = (A: X, B: Y) => { let a = A.a + B.b } + // constraint on return type module Make = (A: X, B: Y): Set => { let a = A.a + B.b } + include (@functorAttr X: Map, Y: Set, Z: SuperLongModuleTypeName, Foo: Baaaaaaaaar): Set => { let a = A.a + B.b } + // with attributes module Make = (@functorAttr A: X, B: Y): Set => { let a = A.a + B.b } + module Make = (@functorAttr A: X, @functorAttr2 B: Y): Set => { let a = A.a + B.b } @@ -46,6 +50,7 @@ module Make = ( type key = t type coll = list<key> let empty = list{} + let add = (y: coll, e: key) => if List.exists(x => eq(x, e), y) { y @@ -57,6 +62,7 @@ module Make = ( module Make = (A: X, B: Y): ((Set, Set) => Set) => { let a = A.a + B.b } + module Make = (SuperLongNaaaaaaaame: X, SuperLongNaaaaaaaame: Y, SuperLongNaaaaaaaame: Z): ( ( Seeeeeeeeeeeeeeeeeeeeeeeeeeeeet, diff --git a/tests/syntax_tests/data/printer/modExpr/expected/include.res.txt b/tests/syntax_tests/data/printer/modExpr/expected/include.res.txt index a1fec610ccf..3e01e2720c2 100644 --- a/tests/syntax_tests/data/printer/modExpr/expected/include.res.txt +++ b/tests/syntax_tests/data/printer/modExpr/expected/include.res.txt @@ -2,9 +2,11 @@ type t include Sprite.Comp({type t = t}) include Color.Comp({type t = t}) + include Pos.Comp({ type t = superLooooooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnngggggTyyyyyyypeeeNaaaaaammeee }) + include Area.Comp({type t = t}) include Anchor.Comp({type t = t}) include Move.Comp({type t = t}) diff --git a/tests/syntax_tests/data/printer/modExpr/expected/parens.res.txt b/tests/syntax_tests/data/printer/modExpr/expected/parens.res.txt index 641f1508293..477e568e8df 100644 --- a/tests/syntax_tests/data/printer/modExpr/expected/parens.res.txt +++ b/tests/syntax_tests/data/printer/modExpr/expected/parens.res.txt @@ -9,6 +9,7 @@ let e2 = (module(await (@a X)): module(S)) let e3 = (module(await (X: S1)): module(S2)) let e4 = (module(await @a (await X)): module(S)) let e5 = module(await @a X: S) + let f = () => { module M: T = (X: S) () diff --git a/tests/syntax_tests/data/printer/modExpr/expected/structure.res.txt b/tests/syntax_tests/data/printer/modExpr/expected/structure.res.txt index 14e1ecd1f67..31cc4493f41 100644 --- a/tests/syntax_tests/data/printer/modExpr/expected/structure.res.txt +++ b/tests/syntax_tests/data/printer/modExpr/expected/structure.res.txt @@ -31,6 +31,7 @@ module M7: { module N: { let x: int } + module N' = N }) @@ -62,8 +63,10 @@ module M6 = { module D = { let y = 3 } + module N = { let x = 1 } + module N' = N } diff --git a/tests/syntax_tests/data/printer/modType/expected/moduleTypeOf.res.txt b/tests/syntax_tests/data/printer/modType/expected/moduleTypeOf.res.txt index 2c1f4c85161..ed1236c4ca0 100644 --- a/tests/syntax_tests/data/printer/modType/expected/moduleTypeOf.res.txt +++ b/tests/syntax_tests/data/printer/modType/expected/moduleTypeOf.res.txt @@ -1,3 +1,4 @@ module type LinkedList = module type of List + module type LinkedList = @attr module type of List diff --git a/tests/syntax_tests/data/printer/modType/expected/withConstraints.res.txt b/tests/syntax_tests/data/printer/modType/expected/withConstraints.res.txt index 45b429ef33e..42f7f950c60 100644 --- a/tests/syntax_tests/data/printer/modType/expected/withConstraints.res.txt +++ b/tests/syntax_tests/data/printer/modType/expected/withConstraints.res.txt @@ -4,6 +4,7 @@ module type A = Foo with type t<'a> = string module type A = Foo with type t<'a, 'b> = string module type A = Foo with type t = 'st constraint 'st = int module type A = Foo with type t = 'st constraint 'st = int constraint 'x = int + module type A = Foo with type t = 'st constraint 'st = int constraint 'x = int and type t = 'st constraint 'st = int constraint 'x = int @@ -13,6 +14,7 @@ module type A = Foo with type t := string module type A = Foo with type t<'a> := string module type A = Foo with type t<'a, 'b> := string module type A = Foo with type Bar.t<'a, 'b> := string + module type A = Foo with type Bar.t<'a, 'b> := string and type Bar.t<'a, 'b> := string @@ -21,6 +23,7 @@ module type A = Foo module type A = Foo with module Bar = Array module type A = Foo with module Bar = Belt.Array module type A = Foo with module X.Bar = Belt.Array + module type A = Foo with module X.Bar = Belt.Array and module X.Bar = Belt.Array @@ -28,6 +31,7 @@ module type A = Foo module type A = Foo with module Bar := Array module type A = Foo with module Bar := Belt.Array + module type A = Foo with module X.Bar := Belt.Array and module X.Bar := Belt.Array @@ -36,12 +40,14 @@ module type A = Foo module Same = (Na: N, Nb: N): ((S with type number1 = Na.number) with type number2 = Nb.number) => { type number1 = Na.number type number2 = Nb.number + let rec sim = ((n, m)) => if Na.is_zero(n) { Nb.is_zero(m) } else { sim((Na.pred(n), Nb.pred(m))) } + let similar = ((n, m)) => try sim((n, m)) catch { | Na.Too_small => false diff --git a/tests/syntax_tests/data/printer/other/expected/StaticReactTypes.res.txt b/tests/syntax_tests/data/printer/other/expected/StaticReactTypes.res.txt index dd479c4a0a4..d7b8a1bf936 100644 --- a/tests/syntax_tests/data/printer/other/expected/StaticReactTypes.res.txt +++ b/tests/syntax_tests/data/printer/other/expected/StaticReactTypes.res.txt @@ -1,4 +1,5 @@ type empty = Empty_ + /* * Also create another form for splicing in nodes into otherwise fixed length * sets. diff --git a/tests/syntax_tests/data/printer/other/expected/attributes.res.txt b/tests/syntax_tests/data/printer/other/expected/attributes.res.txt index b34daf6830c..5f5be3c028e 100644 --- a/tests/syntax_tests/data/printer/other/expected/attributes.res.txt +++ b/tests/syntax_tests/data/printer/other/expected/attributes.res.txt @@ -8,6 +8,7 @@ let x = 1 let x = 1 %ext(: let x: int) + %ext(: let x: int let y: float diff --git a/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt b/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt index 784733579ff..94515d673e1 100644 --- a/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt +++ b/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt @@ -6,6 +6,7 @@ module Range = { /* See https://github.com/reasonml/reason-react/blob/master/docs/clone-element.md */ /* We'll need to spread both the style inside the props, and the props object itself using ReasonReact.cloneElement. */ type rec propsThatNeedSpreading = {style: ReactDOMRe.Style.t} + type rec renderTrackParams = { props: propsThatNeedSpreading, children: React.element, diff --git a/tests/syntax_tests/data/printer/pattern/expected/alias.res.txt b/tests/syntax_tests/data/printer/pattern/expected/alias.res.txt index f55c7b27eac..0d4e0f811b7 100644 --- a/tests/syntax_tests/data/printer/pattern/expected/alias.res.txt +++ b/tests/syntax_tests/data/printer/pattern/expected/alias.res.txt @@ -13,5 +13,6 @@ let f = x => | Some(@a ()) => 5 | _ => 6 } + let g = (@a _) => 1 let h = (@a ()) => 1 diff --git a/tests/syntax_tests/data/printer/pattern/expected/firstClassModules.res.txt b/tests/syntax_tests/data/printer/pattern/expected/firstClassModules.res.txt index 6712935cbc9..060efb6a329 100644 --- a/tests/syntax_tests/data/printer/pattern/expected/firstClassModules.res.txt +++ b/tests/syntax_tests/data/printer/pattern/expected/firstClassModules.res.txt @@ -1,6 +1,7 @@ let module(Set) = z let module(Set: Set.S with type elt = s) = y let module(Set: Set.S with type elt = s and type elt2 = t) = x + let module(Set: Set.S with type elt = s and type elt2 = t diff --git a/tests/syntax_tests/data/printer/pattern/expected/list.res.txt b/tests/syntax_tests/data/printer/pattern/expected/list.res.txt index 66d3131e082..9131949d31f 100644 --- a/tests/syntax_tests/data/printer/pattern/expected/list.res.txt +++ b/tests/syntax_tests/data/printer/pattern/expected/list.res.txt @@ -5,6 +5,7 @@ let list{1, 2, 3} = 1 let list{1, 2, ...tail} = 1 let list{aaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbb, cccccccccccccccccccccccccc} = 1 + let list{ aaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbb, diff --git a/tests/syntax_tests/data/printer/pattern/expected/record.res.txt b/tests/syntax_tests/data/printer/pattern/expected/record.res.txt index b1861d258b0..41b86b0bb7d 100644 --- a/tests/syntax_tests/data/printer/pattern/expected/record.res.txt +++ b/tests/syntax_tests/data/printer/pattern/expected/record.res.txt @@ -23,6 +23,7 @@ let get_age3 = ({age: "100", name: _}) => age2 let get_age3 = ({age: 1 .. 2, name: _}) => age2 let get_age3 = ({age: 'a' .. 'z', name: _}) => age2 let get_age3 = ({age: (a, b, c, d), name: _}) => age2 + let get_age3 = ({ age: ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, @@ -32,9 +33,11 @@ let get_age3 = ({ ), name: _, }) => age2 + let get_age3 = ({age: Rgb(r, g, b), name: _}) => age2 let get_age3 = ({age: Rgb({r, g, b}), name: _}) => age2 let get_age3 = ({age: Rgb({r: red, g: green, b: black}), name: _}) => age2 + let get_age3 = ({ age: Rgb( rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, @@ -43,6 +46,7 @@ let get_age3 = ({ ), name: _, }) => age2 + let get_age3 = ({ age: Rgb({ r: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, @@ -55,6 +59,7 @@ let get_age3 = ({ let get_age3 = ({age: #red, name: _}) => age2 let get_age3 = ({age: #Blue, name: _}) => age2 let get_age3 = ({age: #Rgb(r, g, b), name: _}) => age2 + let get_age3 = ({ age: #Rgb( rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, @@ -63,6 +68,7 @@ let get_age3 = ({ ), name: _, }) => age2 + let get_age3 = ({ age: #Rgb({ r: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, @@ -71,7 +77,9 @@ let get_age3 = ({ }), name: _, }) => age2 + let get_age3 = ({age: {birthDay: day, birthMonth: month}, name: _}) => age2 + let get_age3 = ({ age: { birthDay: daaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay, @@ -82,6 +90,7 @@ let get_age3 = ({ let get_age3 = ({age: [], name: _}) => age2 let get_age3 = ({age: [a, b, c, d], name: _}) => age2 + let get_age3 = ({ age: [ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, @@ -94,6 +103,7 @@ let get_age3 = ({ let get_age3 = ({age: list{}, name: _}) => age2 let get_age3 = ({age: list{a, b, c, d}, name: _}) => age2 + let get_age3 = ({ age: list{ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, @@ -117,10 +127,12 @@ let get_age3 = ({age: %raw("__GC"), name: _}) => age2 let get_age3 = ({age, _}) => age let get_age3 = ({_}) => "" + let get_age3 = () => switch x { | {age, _} => age } + let get_age3 = () => switch x { | {_} => "" diff --git a/tests/syntax_tests/data/printer/signature/expected/exception.resi.txt b/tests/syntax_tests/data/printer/signature/expected/exception.resi.txt index a2d580c8a34..3583204bb43 100644 --- a/tests/syntax_tests/data/printer/signature/expected/exception.resi.txt +++ b/tests/syntax_tests/data/printer/signature/expected/exception.resi.txt @@ -8,5 +8,6 @@ exception Exit = Ns.Lib.Terminate /** doc comment */ exception ExitEarly({x: int}) + /** doc comment */ exception ExitEarly({x: int, y: string}) diff --git a/tests/syntax_tests/data/printer/signature/expected/externalObjectSpread.resi.txt b/tests/syntax_tests/data/printer/signature/expected/externalObjectSpread.resi.txt index 3e3e77034b8..0219e18d5b3 100644 --- a/tests/syntax_tests/data/printer/signature/expected/externalObjectSpread.resi.txt +++ b/tests/syntax_tests/data/printer/signature/expected/externalObjectSpread.resi.txt @@ -1,3 +1,4 @@ type user = {"name": string} + @val external steve: {...user, "age": int} = "steve" diff --git a/tests/syntax_tests/data/printer/signature/expected/multilineSpacing.resi.txt b/tests/syntax_tests/data/printer/signature/expected/multilineSpacing.resi.txt new file mode 100644 index 00000000000..28194c311d2 --- /dev/null +++ b/tests/syntax_tests/data/printer/signature/expected/multilineSpacing.resi.txt @@ -0,0 +1,19 @@ +type t +let a: int + +type r = { + x: int, +} + +let b: int +// a comment does not count +let c: int + +/** Documented */ +let d: int + +module M: { + let x: int +} + +let e: int diff --git a/tests/syntax_tests/data/printer/signature/multilineSpacing.resi b/tests/syntax_tests/data/printer/signature/multilineSpacing.resi new file mode 100644 index 00000000000..820ef4a6c11 --- /dev/null +++ b/tests/syntax_tests/data/printer/signature/multilineSpacing.resi @@ -0,0 +1,14 @@ +type t +let a: int +type r = { + x: int, +} +let b: int +// a comment does not count +let c: int +/** Documented */ +let d: int +module M: { + let x: int +} +let e: int diff --git a/tests/syntax_tests/data/printer/structure/expected/exception.res.txt b/tests/syntax_tests/data/printer/structure/expected/exception.res.txt index 03f26bf5c0e..8dd547aeb7a 100644 --- a/tests/syntax_tests/data/printer/structure/expected/exception.res.txt +++ b/tests/syntax_tests/data/printer/structure/expected/exception.res.txt @@ -8,10 +8,12 @@ exception ExitEarly({@attr "jsExit": int, @attr "code": int}) exception ExitEarly({"jsExit": int}) exception ExitEarly({"jsExit": int}, {"code": int}) exception ExitEarly({"jsExit": int}, int, {"code": int}) + exception ExitEarly( {@attr "jsExit": int, @attr "code": int}, {@attr "jsExit": int, @attr "code": int}, ) + exception ExitJsStyle({..}) exception ExitJsStyle({.."code": int}) exception ExitJsStyle({.."code": int}) @@ -33,8 +35,10 @@ exception GadtExit(int): exit<int> /** doc comment */ exception ExitEarly({x: int}) + /** doc comment */ exception ExitEarly({x: int, y: string}) + /** doc comment */ exception ExitEarlyWithManyFields({ firstFieldName: int, diff --git a/tests/syntax_tests/data/printer/structure/expected/externalObjectSpread.res.txt b/tests/syntax_tests/data/printer/structure/expected/externalObjectSpread.res.txt index 3e3e77034b8..0219e18d5b3 100644 --- a/tests/syntax_tests/data/printer/structure/expected/externalObjectSpread.res.txt +++ b/tests/syntax_tests/data/printer/structure/expected/externalObjectSpread.res.txt @@ -1,3 +1,4 @@ type user = {"name": string} + @val external steve: {...user, "age": int} = "steve" diff --git a/tests/syntax_tests/data/printer/structure/expected/include.res.txt b/tests/syntax_tests/data/printer/structure/expected/include.res.txt index 3e013044097..12c0144fe66 100644 --- a/tests/syntax_tests/data/printer/structure/expected/include.res.txt +++ b/tests/syntax_tests/data/printer/structure/expected/include.res.txt @@ -8,6 +8,7 @@ include ( { @val @module("react") external createElementInternalHack: 'a = "createElement" + @send external apply: ('theFunction, 'theContext, 'arguments) => 'returnTypeOfTheFunction = "apply" diff --git a/tests/syntax_tests/data/printer/structure/expected/multilineSpacing.res.txt b/tests/syntax_tests/data/printer/structure/expected/multilineSpacing.res.txt new file mode 100644 index 00000000000..083f6ae7239 --- /dev/null +++ b/tests/syntax_tests/data/printer/structure/expected/multilineSpacing.res.txt @@ -0,0 +1,71 @@ +module Details = { + @react.component + let make = (~input as {filePath}: input) => React.string(filePath) +} + +module Body = { + @react.component + let make = (~input as {filePath, oldString}: input) => <> + <ToolView.Field label="file" value=filePath /> + <ToolView.Text label="replace" text=oldString /> + </> +} + +module Output = Tool.TextResult.Output +let failed = Tool.TextResult.failed + +// one-line items stay together, a comment above one does not count +let a = 1 +// about b +let b = 2 + +/** a doc comment prints on its own line */ +let c = 3 + +let d = 4 // trailing + +// an item that only breaks because of the line width is multi-line +let long = someFunctionWithAVeryLongName( + argumentNumberOne, + argumentNumberTwo, + argumentNumber3, + argument4, +) + +let e = 5 + +type r = { + x: int, +} + +let f = 6 + +// an own-line trailing comment of the previous item goes below the blank line +f(a => 1) + +// relocated +let g = { + 1 +} + +// blocks are not affected +let h = () => { + let x = 1 + let y = { + 2 + } + x + y +} + +// a template literal with a line break is multi-line +let s = `multi +line` + +let t = 5 + +// a trailing comment stays on the last line of a multi-line item +let g = { + 1 +} // trailing + +let h = 6 diff --git a/tests/syntax_tests/data/printer/structure/expected/typeExtension.res.txt b/tests/syntax_tests/data/printer/structure/expected/typeExtension.res.txt index e2909556320..54908550526 100644 --- a/tests/syntax_tests/data/printer/structure/expected/typeExtension.res.txt +++ b/tests/syntax_tests/data/printer/structure/expected/typeExtension.res.txt @@ -26,37 +26,49 @@ type t += private Foo = Bar | Circle = Geo.Circle2 type t += Foo = Geo.Metry.Bar @attr type t += @attr1 Foo + @attr type t += @attr1 Foo + @attr type t += @attr1 Foo | @attr2 Bar + @attr type t += @attr1 Foo | @attr2 Bar @attr type t += private @attr1 Foo + @attr type t += private @attr1 Foo + @attr type t += private @attr1 Foo | @attr2 Bar + @attr type t += private @attr1 Foo | @attr2 Bar @attr type t += @attr1 Foo = Bar + @attr type t += @attr1 Foo = Bar + @attr type t += @attr1 Foo = Foo2 | @attr2 Bar = Bar2 + @attr type t += @attr1 Foo = Foo2 | @attr2 Bar = Bar2 @attr type t += private @attr1 Foo = Foo2 + @attr type t += private @attr1 Foo = Foo2 + @attr type t += private @attr1 Foo = Foo2 | @attr2 Bar = Bar2 + @attr type t += private @attr1 Foo = Foo2 | @attr2 Bar = Bar2 diff --git a/tests/syntax_tests/data/printer/structure/multilineSpacing.res b/tests/syntax_tests/data/printer/structure/multilineSpacing.res new file mode 100644 index 00000000000..7eb0267f80d --- /dev/null +++ b/tests/syntax_tests/data/printer/structure/multilineSpacing.res @@ -0,0 +1,57 @@ +module Details = { + @react.component + let make = (~input as {filePath}: input) => React.string(filePath) +} +module Body = { + @react.component + let make = (~input as {filePath, oldString}: input) => <> + <ToolView.Field label="file" value=filePath /> + <ToolView.Text label="replace" text=oldString /> + </> +} +module Output = Tool.TextResult.Output +let failed = Tool.TextResult.failed + +// one-line items stay together, a comment above one does not count +let a = 1 +// about b +let b = 2 +/** a doc comment prints on its own line */ +let c = 3 +let d = 4 // trailing + +// an item that only breaks because of the line width is multi-line +let long = someFunctionWithAVeryLongName(argumentNumberOne, argumentNumberTwo, argumentNumber3, argument4) +let e = 5 +type r = { + x: int, +} +let f = 6 + +// an own-line trailing comment of the previous item goes below the blank line +f(a + // relocated + => 1) +let g = { + 1 +} + +// blocks are not affected +let h = () => { + let x = 1 + let y = { + 2 + } + x + y +} + +// a template literal with a line break is multi-line +let s = `multi +line` +let t = 5 + +// a trailing comment stays on the last line of a multi-line item +let g = { + 1 +} // trailing +let h = 6 diff --git a/tests/syntax_tests/data/printer/typeDef/expected/abstract.res.txt b/tests/syntax_tests/data/printer/typeDef/expected/abstract.res.txt index 013424b094e..8fa11270b40 100644 --- a/tests/syntax_tests/data/printer/typeDef/expected/abstract.res.txt +++ b/tests/syntax_tests/data/printer/typeDef/expected/abstract.res.txt @@ -10,6 +10,7 @@ type t = Module.Long.With.Very.VeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeryLongName type t = private Module.Long.With.Very.VeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeryLongName.t type t<'superlongthing, 'superlongthing, 'superlongthing, 'superlongthing, 'superlongthing> = string + type t< 'superlongthing, 'superlongthing, diff --git a/tests/syntax_tests/data/printer/typeDef/expected/attributes.res.txt b/tests/syntax_tests/data/printer/typeDef/expected/attributes.res.txt index 600f0dd2429..be0e24d6e49 100644 --- a/tests/syntax_tests/data/printer/typeDef/expected/attributes.res.txt +++ b/tests/syntax_tests/data/printer/typeDef/expected/attributes.res.txt @@ -1,8 +1,10 @@ @attr type t = float + @attr type t = float @attr @attr @attr @attr @attr @attr @attr @attr @attr @attr @attr @attr type t = int + @attr @attr @attr @attr @attr @attr @attr @attr @attr @attr @attr @attr type t = int @@ -11,6 +13,7 @@ type t = int @attrWithSuperLongIdentifeirName @attrWithSuperLongIdentifeirName type t = string + @attrWithSuperLongIdentifeirName @attrWithSuperLongIdentifeirName @attrWithSuperLongIdentifeirName @@ -23,24 +26,33 @@ type t = { email: string, name: string, } + /** doc */ @attr type t = {x: int} + @attr type t = .. + /** doc */ type t = {x: int} + /** doc */ type t = .. + /** doc */ @attr type t = {x: int} + /** doc */ @attr @attr2 type t = .. + /** doc */ @outer type t = {/* c1 */ /* c2 */ x: int} // trail + type t = /** doc */ | A | B + type t = /** doc */ | A diff --git a/tests/syntax_tests/data/printer/typeDef/expected/inlineRecordMultiline.res.txt b/tests/syntax_tests/data/printer/typeDef/expected/inlineRecordMultiline.res.txt index b4418c5b800..d8344d91b05 100644 --- a/tests/syntax_tests/data/printer/typeDef/expected/inlineRecordMultiline.res.txt +++ b/tests/syntax_tests/data/printer/typeDef/expected/inlineRecordMultiline.res.txt @@ -39,6 +39,7 @@ type rec gadt<_> = }): gadt<int> type ext = .. + type ext += | C({ name: string, diff --git a/tests/syntax_tests/data/printer/typeDef/expected/record.res.txt b/tests/syntax_tests/data/printer/typeDef/expected/record.res.txt index a2fea60a25a..a91778ea651 100644 --- a/tests/syntax_tests/data/printer/typeDef/expected/record.res.txt +++ b/tests/syntax_tests/data/printer/typeDef/expected/record.res.txt @@ -1,11 +1,13 @@ type user = {name: string, age: int} type result<'success, 'failure> = {ok: 'success, fail: 'failure} + type result<'success1, 'failure1, 'success2, 'failure2, 'success3, 'failure3> = { ok: 'success1, fail: 'failure2, } type user = {name: string, age: int, a: string, lot: string, more: string, fields: string} + type user<'lotsOfTypeVars, 'lotsOfTypeVars2, 'lotsOfTypeVars3, 'lotsOfTypeVars4> = { name: string, age: int, @@ -30,6 +32,7 @@ type user = { } constraint 't = string type t = private {name: string, age: int} + type t = private { name: string, age: int, @@ -37,6 +40,7 @@ type t = private { type t = User.t = private {name: string, age: int} type t = @attr User.t = private {name: string, age: int} + type t = User.t = private { name: string, age: int, diff --git a/tests/syntax_tests/data/printer/typeDef/expected/variant.res.txt b/tests/syntax_tests/data/printer/typeDef/expected/variant.res.txt index 3ca25274ad0..17b36d1db8f 100644 --- a/tests/syntax_tests/data/printer/typeDef/expected/variant.res.txt +++ b/tests/syntax_tests/data/printer/typeDef/expected/variant.res.txt @@ -2,27 +2,32 @@ type color = Red | Blue type color = Red | Blue | SuperLongColooooooooooooooourName | AnotherSuuuuuuuuuuuuuuperLongName type color = private Red | Blue + type color = private | Red | Blue | Green + type color = private Red | Blue | SuperLongColooooooooooooooourName | AnotherSuuuuuuuuuuuuuperLongName type color = Colour.t = private Red | Blue + type color = Colour.t = private | Red | Blue | Green + type color = Colour.t = private Red | Blue | SuperLongColoooooooooooooourName | AnotherSuuuuuuuuuuuuuperLongName // gadt type color = Red: color | Blue: color + type color = | Red: color | Blue: color @@ -30,6 +35,7 @@ type color = | AnotherSuuuuuuuuuperLongName: color type color = Rgb(float, float, float) | Hex(int) + type color = | Rgb(superLongTypeName, superLongTypeName, superLongTypeName, superLongTypeName) | Hex(superLongTypeName, superLongTypeName, superLongTypeName, superLongTypeName) @@ -115,5 +121,6 @@ type color = module S = { type s = Five | Six } + type aa = One | Two type bb = | ...aa | Three | Four | ...S.s diff --git a/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt index 9708f5202fd..56b47f765a8 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt @@ -185,10 +185,12 @@ external debounce: (int, unit => unit, unit => unit) => unit => unit = "debounce external debounce: (int, unit => unit, unit => unit => unit) => unit => unit = "debounce" type returnTyp = (int, int) => @magic float + type returnTyp = ( intWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, intWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, ) => @magic float + type returnTyp = ( intWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, intWithSuperLongIdentifierNameLoooooooooooooooooooooooooooooooooooooooooooooong, diff --git a/tests/syntax_tests/data/printer/typexpr/expected/bsObject.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/bsObject.res.txt index f854d538574..afc1c8d8222 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/bsObject.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/bsObject.res.txt @@ -1,5 +1,6 @@ type user = {"age": int} type user = {"age": int, "name": string} + type user = { "age": int, "name": string, @@ -10,6 +11,7 @@ type user = { type magic = {..} type t = {.."age": int} + type magicallyLong = {.. "age": int, "name": string, @@ -53,6 +55,7 @@ type t = {.} type t = private {.} type t = constr<{.}, {.}, {.}> + type t = { hr: React.component<{.}>, } diff --git a/tests/syntax_tests/data/printer/typexpr/expected/firstClassModule.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/firstClassModule.res.txt index bf3ca0f4d23..3a42bc4e1e3 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/firstClassModule.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/firstClassModule.res.txt @@ -1,6 +1,7 @@ type t = module(S) type t = module(Hashmap with type key = string) type t = module(Hashmap with type key = string and type value = int) + type t = module(Hashmap with type key = string and type value = int diff --git a/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt index 3531336594e..71ae407c5ad 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt @@ -33,6 +33,7 @@ type taggedUser = | Ceo({...user, "age": int, "direction": bool}, {...salary, "taxFraud": bool}) type polyTaggedUser = [#User({...user, "age": int})] + type polyTaggedUser2 = [ | #User({...user, "age": int}) | #Ceo({...user, "age": int, "direction": bool}, {...salary, "taxFraud": bool}) @@ -41,6 +42,7 @@ type polyTaggedUser2 = [ // notice .. and ..., they should have a space type u<'a> = {.. ...hi} as 'a type u<'a> = {.. ...hi, "superLongFieldName": string, "superLongFieldName22222222222": int} as 'a + type u<'a> = {.. ...hi, "superLongFieldName": string, diff --git a/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt index c4ee5cb61b5..c3754eef9af 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt @@ -1,5 +1,6 @@ type t = Option.t<string> type t = Mod.Sub.t<a, b, c> + type t = Mod.Sub.t< soooooLoooooong, soooooLoooooong, @@ -19,6 +20,7 @@ type t = Mod.Sub.t< b, c, > + type t = Mod.Sub.t< Mod.Sub.t<soooooLoooooong, soooooLoooooong, soooooLoooooong, soooooLoooooong, soooooLoooooong>, Nested.Module.t<string, float>, @@ -45,6 +47,7 @@ let t: list< > = x type t = Option.t<(tupleTyp1, tupleTyp2, tupleTyp3)> + type t = Option.t<( tupleTyp1, tupleTyp2, @@ -57,6 +60,7 @@ type t = Option.t<( tupleTyp3, tupleTyp3, )> + let t: Option.t<( tupleTyp1, tupleTyp2, diff --git a/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt index b88b67251ea..fe13262e17e 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt @@ -11,6 +11,7 @@ let id = (x: [> #Red | #Green | #Blue]) => x let upper = (x: [< #Red | #Green]) => true type point = [#Point(float, float)] type \"type" = [#"Point🗿"(\"let", float)] + type shape = [ | #Rectangle(point, point) | #Circle(point, float) @@ -78,6 +79,7 @@ module type Conjunctive = { let f: [< #T([< u2]) & ([< u2]) & ([< u1])] => unit let g: [< #S & ([< u2]) & ([< u2]) & ([< u1])] => unit + let g: [< | #"Exotic-S+" & ([< #"Exotic-u2+"]) & ([< #"Exotic-u2-"]) & ([< #"Exotic-u1+++"]) ] => unit @@ -92,6 +94,7 @@ type currencyPoly = [ // should not break, user wrote it on one line type currencyPoly = [#USD | #CAD | #EUR] + // // should break, line length exceeded type currencyPoly = [ @@ -126,6 +129,7 @@ type foo = [ // doc comments on inherited polyvariant types type rgb = [#Red | #Green | #Blue] + type color = [ | /** Primary colors from RGB */ rgb /** A warm color */ diff --git a/tests/syntax_tests/res_test.ml b/tests/syntax_tests/res_test.ml index 8d32728467f..454ace84f97 100644 --- a/tests/syntax_tests/res_test.ml +++ b/tests/syntax_tests/res_test.ml @@ -31,7 +31,7 @@ let () = "/* a\n\ \ multi-line comment */\n\ let s = `line 1\n\ - line 2`\n\ + line 2`\n\n\ let r = %raw(`\n\ \ function () {\n\ \ return 1\n\ @@ -556,6 +556,165 @@ module Parser_api_test = struct windows_crlf () end +(* Res_doc.item_separator puts a blank line next to an item that prints on + several lines, measuring the documents on each side as to_string lays them + out. Res_doc.comment hides comments from the measurement. *) +module Multiline_item_spacing_test = struct + module Doc = Res_doc + + let check name ~expected actual = + if actual <> expected then + failwith + (Printf.sprintf "%s:\nexpected:\n%S\nactual:\n%S" name expected actual) + + (* Module items are printed inside a broken group, like print_structure. *) + let print ?(width = 80) doc = + Doc.to_string ~width (Doc.breakable_group ~force_break:true doc) + let items prev next = Doc.concat [prev; Doc.item_separator ~prev ~next; next] + let a = Doc.text "let a = 1" + let b = Doc.text "let b = 2" + + (* A function call that fits on one line at width 80 but not at width 10. *) + let call = + Doc.group + (Doc.concat + [ + Doc.text "f("; + Doc.indent + (Doc.concat + [ + Doc.soft_line; + Doc.text "x,"; + Doc.line; + Doc.text "y"; + Doc.trailing_comma; + ]); + Doc.soft_line; + Doc.text ")"; + ]) + + let measuring () = + check "one-line items stay together" ~expected:"let a = 1\nlet b = 2" + (print (items a b)); + check "a hard line spans lines" ~expected:"x\ny\n\nlet b = 2" + (print (items (Doc.concat [Doc.text "x"; Doc.hard_line; Doc.text "y"]) b)); + check "a literal line spans lines" ~expected:"`x\ny`\n\nlet b = 2" + (print + (items (Doc.concat [Doc.text "`x"; Doc.literal_line; Doc.text "y`"]) b)); + check "a newline inside text spans lines" ~expected:"`x\ny`\n\nlet b = 2" + (print (items (Doc.text "`x\ny`") b)); + check "an item list spans lines" + ~expected:"let a = 1\nlet b = 2\n\nlet c = 3" + (print (items (items a b) (Doc.text "let c = 3"))); + check "a group that fits is one line" ~expected:"f(x, y)\nlet b = 2" + (print (items call b)); + check "a group that breaks spans lines" + ~expected:"f(\n x,\n y,\n)\n\nlet b = 2" + (print ~width:5 (items call b)); + check "a chosen custom layout is measured" ~expected:"let a = 1\nlet b = 2" + (print (items (Doc.custom_layout [a]) b)); + check "break parents and line suffixes do not span lines" + ~expected:"let a = 1 // c\nlet b = 2" + (print + (items + (Doc.concat + [a; Doc.break_parent; Doc.line_suffix (Doc.text " // c")]) + b)); + check "a comment above an item does not count" + ~expected:"let a = 1\n// c\nlet b = 2" + (print + (items a + (Doc.concat + [Doc.comment (Doc.concat [Doc.text "// c"; Doc.hard_line]); b]))); + let forced_if_breaks = + Doc.if_breaks (Doc.text "a") (Doc.concat [Doc.text "b"; Doc.hard_line]) + in + check "an if-breaks broken by its flat branch takes the break branch" + ~expected:"xa\nlet b = 2" + (print (items (Doc.concat [Doc.text "x"; forced_if_breaks]) b)); + check "an if-breaks in a broken group takes the break branch" + ~expected:"{\n}\n\nlet b = 2" + (print + (items + (Doc.breakable_group ~force_break:true + (Doc.concat + [ + Doc.if_breaks (Doc.text "{") (Doc.text "("); + Doc.line; + Doc.text "}"; + ])) + b)) + + let trailing_comments () = + let block = + Doc.concat [Doc.text "let a = {"; Doc.hard_line; Doc.text "}"] + in + let after_block suffix = + items (Doc.concat [block; Doc.line_suffix suffix]) b + in + check "a same-line trailing comment stays on its line" + ~expected:"let a = {\n} // c\n\nlet b = 2" + (print (after_block (Doc.text " // c"))); + check "an own-line trailing comment moves below the blank line" + ~expected:"let a = {\n}\n\n// c\nlet b = 2" + (print (after_block (Doc.concat [Doc.hard_line; Doc.text "// c"]))); + check "an empty own-line trailing comment prints an empty line" + ~expected:"let a = {\n}\n\n\nlet b = 2" + (print (after_block Doc.hard_line)) + + let predicates () = + let separator = Doc.item_separator ~prev:a ~next:b in + assert (Doc.will_break separator); + assert (Doc.will_break Doc.break_parent); + assert (Doc.will_break (Doc.comment Doc.hard_line)); + assert (not (Doc.will_break (Doc.comment a))); + (* A separator breaks its group, which flushes a pending line suffix. *) + assert (Doc.has_pending_line_suffix (Doc.comment (Doc.line_suffix a))); + assert ( + not + (Doc.has_pending_line_suffix + (Doc.group (Doc.concat [Doc.line_suffix a; separator])))); + assert (Doc.is_nil Doc.nil); + [ + a; + Doc.line_suffix a; + Doc.concat [a; b]; + Doc.indent a; + Doc.trailing_comma; + Doc.line; + Doc.group a; + Doc.custom_layout [a]; + Doc.break_parent; + separator; + Doc.comment a; + ] + |> List.iter (fun doc -> assert (not (Doc.is_nil doc))); + check "an empty custom layout prints nothing" ~expected:"" + (print (Doc.custom_layout [])) + + (* debug prints to stdout; send it to the null device. *) + let debug () = + flush stdout; + let saved = Unix.dup Unix.stdout in + let null = Unix.openfile Filename.null [Unix.O_WRONLY] 0 in + Unix.dup2 null Unix.stdout; + Fun.protect + ~finally:(fun () -> + flush stdout; + Unix.dup2 saved Unix.stdout; + Unix.close saved; + Unix.close null) + (fun () -> Doc.debug (Doc.concat [items a b; Doc.comment a])) + + let run () = + measuring (); + trailing_comments (); + predicates (); + debug (); + print_endline "✅ multi-line item spacing" +end + let () = Outcome_printer_tests.run () let () = Parser_api_test.run () let () = Res_utf8_test.run () +let () = Multiline_item_spacing_test.run () diff --git a/tests/tests/src/ExternalArity.res b/tests/tests/src/ExternalArity.res index 7b4ffaf3d71..2a3eee4ffdd 100644 --- a/tests/tests/src/ExternalArity.res +++ b/tests/tests/src/ExternalArity.res @@ -38,5 +38,6 @@ module ReactTest = { @react.component @module("react-intl") external make: (~id: string, ~defaultMessage: string) => React.element = "FormattedMessage" } + let _ = <FormattedMessage id="test" defaultMessage="Test" /> } diff --git a/tests/tests/src/UncurriedExternals.res b/tests/tests/src/UncurriedExternals.res index af1e40ac679..c38d6f311ad 100644 --- a/tests/tests/src/UncurriedExternals.res +++ b/tests/tests/src/UncurriedExternals.res @@ -10,6 +10,7 @@ module StandardNotation = { } = { external sum: (float, float) => float = "sum" } + let hh = M.sum(1.0, 2.0) @get_index external get: (array<string>, int) => option<'a> = "" @@ -32,6 +33,7 @@ module StandardNotation = { @module("react") external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState" + let (get, set) = useState(() => 3) } diff --git a/tests/tests/src/UntaggedVariants.res b/tests/tests/src/UntaggedVariants.res index c39db062be9..826784e4ef8 100644 --- a/tests/tests/src/UntaggedVariants.res +++ b/tests/tests/src/UntaggedVariants.res @@ -1,5 +1,6 @@ @unboxed type t = A | I(int) | S(string) + @unboxed type t2 = S2(string) | I2(float) @@ -270,26 +271,32 @@ module OptionUnboxingHeuristic = { @unboxed type untaggedWithOptionPayload = A | B(option<string>) + let untaggedWithOptionPayload = (x: untaggedWithOptionPayload) => Some(x) @unboxed type untaggedWithIntPayload = A | B(int) + let untaggedWithIntPayload = (x: untaggedWithIntPayload) => Some(x) @unboxed type untaggedInlineNoOption = A | B({x: int}) + let untaggedInlineNoOptions = (x: untaggedInlineNoOption) => Some(x) @unboxed type untaggedInlineUnaryWihtExplicitOption = A | B({x: option<int>}) + let untaggedInlineUnaryWihtExplicitOption = (x: untaggedInlineUnaryWihtExplicitOption) => Some(x) @unboxed type untaggedInlineUnaryWihtImplicitOption = A | B({x?: int}) + let untaggedInlineUnaryWihtImplicitOption = (x: untaggedInlineUnaryWihtImplicitOption) => Some(x) @unboxed type untaggedInlineMultinaryOption = A | B({x: option<int>, y?: string}) + let untaggedInlineMultinaryOption = (x: untaggedInlineMultinaryOption) => Some(x) } diff --git a/tests/tests/src/VariantCoercion.res b/tests/tests/src/VariantCoercion.res index 69f9aca7d0b..af367ea272e 100644 --- a/tests/tests/src/VariantCoercion.res +++ b/tests/tests/src/VariantCoercion.res @@ -127,11 +127,13 @@ module CoerceVariantBinaryOp = { let x = 0->Int.bitwiseOr(B :> int) let v = B + let f1 = () => switch v { | A => "a" | B => "b" } + let f2 = () => switch (v :> int) { | 2 => "b" diff --git a/tests/tests/src/a.res b/tests/tests/src/a.res index 6a68ebedef1..f1998cbfca4 100644 --- a/tests/tests/src/a.res +++ b/tests/tests/src/a.res @@ -16,6 +16,7 @@ include ( ) => { let u = S.add(1, 2) } + module H = M({ let add = (x, y) => x + y }) diff --git a/tests/tests/src/acyc/x.res b/tests/tests/src/acyc/x.res index 389f650aef6..0215e5fd70e 100644 --- a/tests/tests/src/acyc/x.res +++ b/tests/tests/src/acyc/x.res @@ -1,17 +1,21 @@ module A0_a1 = { let v = 3 } + module A1_a2: { let v: int } = { let v = A0_a1.v } + module A2_a3 = { let v = A1_a2.v } + module A3_a4 = { include A2_a3 } + module A4_a5 = { include A3_a4 diff --git a/tests/tests/src/adt_optimize_test.mjs b/tests/tests/src/adt_optimize_test.mjs index d489fb71c51..af5c77a99e7 100644 --- a/tests/tests/src/adt_optimize_test.mjs +++ b/tests/tests/src/adt_optimize_test.mjs @@ -187,7 +187,7 @@ function f11(x) { RE_EXN_ID: "Assert_failure", _1: [ "adt_optimize_test.res", - 202, + 203, 9 ], Error: new Error() diff --git a/tests/tests/src/adt_optimize_test.res b/tests/tests/src/adt_optimize_test.res index 1d693e85030..e2ff7d127e9 100644 Binary files a/tests/tests/src/adt_optimize_test.res and b/tests/tests/src/adt_optimize_test.res differ diff --git a/tests/tests/src/alias_default_value_test.res b/tests/tests/src/alias_default_value_test.res index 3849a08a348..c63427f5b4e 100644 --- a/tests/tests/src/alias_default_value_test.res +++ b/tests/tests/src/alias_default_value_test.res @@ -36,6 +36,7 @@ module C4 = { module C6 = { module type Comp = { let xx: int + @react.component let make: unit => React.element } diff --git a/tests/tests/src/alias_test.res b/tests/tests/src/alias_test.res index 4dda168b12a..7f9334dc49f 100644 --- a/tests/tests/src/alias_test.res +++ b/tests/tests/src/alias_test.res @@ -39,11 +39,13 @@ let a18 = a17 let a19 = a18 let a20 = a19 ++ "not" + let v = if String.getUnsafe(a20, 0) == "h" { 1 } else { 2 } + let a21 = a20 ++ a20 let a22 = "test " ++ (a21 ++ "hello") diff --git a/tests/tests/src/ari_regress_test.mjs b/tests/tests/src/ari_regress_test.mjs index 3b339197ba7..a1b46fda4c5 100644 --- a/tests/tests/src/ari_regress_test.mjs +++ b/tests/tests/src/ari_regress_test.mjs @@ -18,10 +18,10 @@ function v(__x) { } Mocha.describe("Ari_regress_test", () => { - Mocha.test("curry", () => Test_utils.eq("File \"ari_regress_test.res\", line 25, characters 7-14", 7, 7)); - Mocha.test("curry2", () => Test_utils.eq("File \"ari_regress_test.res\", line 30, characters 6-13", 14, (v(1), v(1)))); - Mocha.test("curry3", () => Test_utils.eq("File \"ari_regress_test.res\", line 40, characters 7-14", x, 14)); - Mocha.test("ref count", () => Test_utils.eq("File \"ari_regress_test.res\", line 44, characters 7-14", h, 2)); + Mocha.test("curry", () => Test_utils.eq("File \"ari_regress_test.res\", line 26, characters 7-14", 7, 7)); + Mocha.test("curry2", () => Test_utils.eq("File \"ari_regress_test.res\", line 31, characters 6-13", 14, (v(1), v(1)))); + Mocha.test("curry3", () => Test_utils.eq("File \"ari_regress_test.res\", line 41, characters 7-14", x, 14)); + Mocha.test("ref count", () => Test_utils.eq("File \"ari_regress_test.res\", line 45, characters 7-14", h, 2)); }); /* Not a pure module */ diff --git a/tests/tests/src/ari_regress_test.res b/tests/tests/src/ari_regress_test.res index 0e152dea3b2..151926527a8 100644 --- a/tests/tests/src/ari_regress_test.res +++ b/tests/tests/src/ari_regress_test.res @@ -16,6 +16,7 @@ let g1 = (x, y) => { let () = h.contents = h.contents + 1 (xx, yy) => xx + yy + u } + let x = gg(3, 5)(6) let v = g1(3, 4)(6, _) diff --git a/tests/tests/src/arity.res b/tests/tests/src/arity.res index 5d83884039d..2eb8c8a862c 100644 --- a/tests/tests/src/arity.res +++ b/tests/tests/src/arity.res @@ -14,6 +14,7 @@ let u2 = (~f: t0, a, b) => { let f = (~x, y) => x + y let add = \"+" + // let u = f(3,~x=2,1); // This function has arity2 but was expected arity3 diff --git a/tests/tests/src/arity_deopt_test.mjs b/tests/tests/src/arity_deopt_test.mjs index ca0d033b470..c61407866ad 100644 --- a/tests/tests/src/arity_deopt_test.mjs +++ b/tests/tests/src/arity_deopt_test.mjs @@ -21,10 +21,10 @@ function f3(x) { Mocha.describe("Arity_deopt_test", () => { Mocha.test("arity_deopt_tests", () => { - Test_utils.eq("File \"arity_deopt_test.res\", line 43, characters 7-14", 6, 6); Test_utils.eq("File \"arity_deopt_test.res\", line 44, characters 7-14", 6, 6); Test_utils.eq("File \"arity_deopt_test.res\", line 45, characters 7-14", 6, 6); Test_utils.eq("File \"arity_deopt_test.res\", line 46, characters 7-14", 6, 6); + Test_utils.eq("File \"arity_deopt_test.res\", line 47, characters 7-14", 6, 6); }); }); diff --git a/tests/tests/src/arity_deopt_test.res b/tests/tests/src/arity_deopt_test.res index b46682c8c67..e101b2dcc4d 100644 --- a/tests/tests/src/arity_deopt_test.res +++ b/tests/tests/src/arity_deopt_test.res @@ -34,6 +34,7 @@ let f3 = x => { let a = x (y, z) => a + y + z } + /* be careful! When you start optimize functions of [@bs], its call site invariant (Ml_app) will not hold any more. So the best is never shrink functons which could change arity diff --git a/tests/tests/src/array_safe_get.res b/tests/tests/src/array_safe_get.res index a15b8582b4e..42bb5fd8d64 100644 --- a/tests/tests/src/array_safe_get.res +++ b/tests/tests/src/array_safe_get.res @@ -1,4 +1,5 @@ let x = [1, 2] + let y = try x->Array.getUnsafe(3) catch { | Invalid_argument(msg) => Console.log(msg) diff --git a/tests/tests/src/bal_set_mini.res b/tests/tests/src/bal_set_mini.res index fa4f4a313b5..2e40a9c84cd 100644 --- a/tests/tests/src/bal_set_mini.res +++ b/tests/tests/src/bal_set_mini.res @@ -1,6 +1,7 @@ type rec t<'a> = | Empty | Node(t<'a>, 'a, t<'a>, int) + let rec height = x => switch x { | Empty => 0 diff --git a/tests/tests/src/big_enum.res b/tests/tests/src/big_enum.res index 52d0686c27d..96d6eeeb257 100644 --- a/tests/tests/src/big_enum.res +++ b/tests/tests/src/big_enum.res @@ -299,6 +299,7 @@ type t = | A297 | A298 | A299 + let to_enum = x => switch x { | A0 => 0 @@ -602,6 +603,7 @@ let to_enum = x => | A298 => 298 | A299 => 299 } + let to_string = x => switch x { | A0 => "A0" diff --git a/tests/tests/src/block_alias_test.mjs b/tests/tests/src/block_alias_test.mjs index a386425ffcc..f3a43ecf2f3 100644 --- a/tests/tests/src/block_alias_test.mjs +++ b/tests/tests/src/block_alias_test.mjs @@ -38,13 +38,13 @@ let f = Primitive_object.equal; Mocha.describe("Block_alias_test", () => { Mocha.test("block_alias_tests", () => { - Test_utils.eq("File \"block_alias_test.res\", line 28, characters 7-14", Stdlib_List.length({hd: 1, tl: {hd: 2, tl: /* [] */0}}), 2); - Test_utils.ok("File \"block_alias_test.res\", line 29, characters 7-14", Primitive_object.equal(v0, { + Test_utils.eq("File \"block_alias_test.res\", line 30, characters 7-14", Stdlib_List.length({hd: 1, tl: {hd: 2, tl: /* [] */0}}), 2); + Test_utils.ok("File \"block_alias_test.res\", line 31, characters 7-14", Primitive_object.equal(v0, { TAG: "A", _0: 0, _1: 1 })); - Test_utils.eq("File \"block_alias_test.res\", line 30, characters 7-14", v0, v1); + Test_utils.eq("File \"block_alias_test.res\", line 32, characters 7-14", v0, v1); }); }); diff --git a/tests/tests/src/block_alias_test.res b/tests/tests/src/block_alias_test.res index 74885e253ca..2db5cf77fc8 100644 --- a/tests/tests/src/block_alias_test.res +++ b/tests/tests/src/block_alias_test.res @@ -2,6 +2,7 @@ open Mocha open Test_utils module Block = {} + type t = | A0(int) | A(int, int) @@ -18,6 +19,7 @@ module Caml_obj = {} module V = { module List = {} } + let f = (a, b) => a == b let h = List.length diff --git a/tests/tests/src/braced_pipe_and_inline.mjs b/tests/tests/src/braced_pipe_and_inline.mjs index dc713663da3..c9c965f93c4 100644 --- a/tests/tests/src/braced_pipe_and_inline.mjs +++ b/tests/tests/src/braced_pipe_and_inline.mjs @@ -22,7 +22,7 @@ if (shadowed !== 4) { RE_EXN_ID: "Assert_failure", _1: [ "braced_pipe_and_inline.res", - 20, + 24, 0 ], Error: new Error() @@ -36,7 +36,7 @@ if (generatedName !== 12) { RE_EXN_ID: "Assert_failure", _1: [ "braced_pipe_and_inline.res", - 28, + 34, 0 ], Error: new Error() @@ -55,7 +55,7 @@ if (fanoutFirst !== 9) { RE_EXN_ID: "Assert_failure", _1: [ "braced_pipe_and_inline.res", - 32, + 38, 0 ], Error: new Error() diff --git a/tests/tests/src/braced_pipe_and_inline.res b/tests/tests/src/braced_pipe_and_inline.res index 4513db4d233..4e2d991f003 100644 --- a/tests/tests/src/braced_pipe_and_inline.res +++ b/tests/tests/src/braced_pipe_and_inline.res @@ -3,28 +3,34 @@ module Ops = { } let direct = 2->{Ops.add(3)} + let opened = 2->{ open Ops add(3) } + let bound = 2->{ let y = 3 Ops.add(y) } let x = 1 + let shadowed = x->{ let x = 2 Ops.add(3) } + assert(shadowed == 4) let __tuple_internal_obj = 7 + let generatedName = (1 + 1) ->{ let __tuple_internal_obj = 10 Ops.add(__tuple_internal_obj) } + assert(generatedName == 12) let fanout = (1 + 1)->(x => x + __tuple_internal_obj, x => x) diff --git a/tests/tests/src/bs_auto_uncurry.res b/tests/tests/src/bs_auto_uncurry.res index 507e03087e6..967961f79d6 100644 --- a/tests/tests/src/bs_auto_uncurry.res +++ b/tests/tests/src/bs_auto_uncurry.res @@ -34,17 +34,20 @@ fun (_){ */ let f_0 = () => hi(() => ()) + let f_01 = () => hi((() as x) => if x == () { Console.log("x") } ) /* FIXME: not inlined */ + let f_02 = xs => hi((() as x) => { xs := x Console.log("x") }) + let f_03 = (xs, u) => hi(u) let h = (x, y, z) => map2(x, y, z) @@ -60,6 +63,7 @@ let h3 = x => ff(x, 2, add3(1)) let h4 = x => ff1(x, add3(1)) let h5 = x => ff2(x, add3(2)) + let add = (x, y) => { Console.log((x, y)) x + y @@ -68,6 +72,7 @@ let add = (x, y) => { let h6 = x => ff2(x, add) type elem + @val external optional_cb: ( (string, ~props: elem=?, array<int>) => elem /* This should emit a warning ? */, diff --git a/tests/tests/src/bs_ignore_effect_test.mjs b/tests/tests/src/bs_ignore_effect_test.mjs index fc56b964304..a9ca8204ead 100644 --- a/tests/tests/src/bs_ignore_effect_test.mjs +++ b/tests/tests/src/bs_ignore_effect_test.mjs @@ -20,8 +20,8 @@ let h = (v.contents = v.contents + 1 | 0, { let z = (v.contents = v.contents + 1 | 0, "Float", add(3.0, 2.0)); Mocha.describe("Bs_ignore_effect_test", () => { - Mocha.test("ignore effect 1", () => Test_utils.eq("File \"bs_ignore_effect_test.res\", line 29, characters 35-42", v.contents, 2)); - Mocha.test("ignore effect 2", () => Test_utils.eq("File \"bs_ignore_effect_test.res\", line 30, characters 35-42", z, 5.0)); + Mocha.test("ignore effect 1", () => Test_utils.eq("File \"bs_ignore_effect_test.res\", line 32, characters 35-42", v.contents, 2)); + Mocha.test("ignore effect 2", () => Test_utils.eq("File \"bs_ignore_effect_test.res\", line 33, characters 35-42", z, 5.0)); }); export { diff --git a/tests/tests/src/bs_ignore_effect_test.res b/tests/tests/src/bs_ignore_effect_test.res index d085bfa8469..c0e2e91f02b 100644 --- a/tests/tests/src/bs_ignore_effect_test.res +++ b/tests/tests/src/bs_ignore_effect_test.res @@ -6,9 +6,11 @@ function add(x,y){ return x + y } `) + type rec kind<_> = | Float: kind<float> | String: kind<string> + @val external add: (@ignore kind<'a>, 'a, 'a) => 'a = "add" let v = ref(0) @@ -16,6 +18,7 @@ let v = ref(0) @obj external config: (~hi: int, ~lo: int, unit) => _ = "" let h = config(~hi=2, ~lo=0, ignore(v.contents = v.contents + 1)) + let z = add( { v.contents = v.contents + 1 diff --git a/tests/tests/src/bs_ignore_test.res b/tests/tests/src/bs_ignore_test.res index 8afa7b64a7f..aff974ef514 100644 --- a/tests/tests/src/bs_ignore_test.res +++ b/tests/tests/src/bs_ignore_test.res @@ -3,9 +3,11 @@ function add(x,y){ return x + y } `) + type rec kind<_> = | Float: kind<float> | String: kind<string> + @val external add: (@ignore kind<'a>, 'a, 'a) => 'a = "add" let () = { diff --git a/tests/tests/src/bs_splice_partial.mjs b/tests/tests/src/bs_splice_partial.mjs index 8f703e597fa..af044b30327 100644 --- a/tests/tests/src/bs_splice_partial.mjs +++ b/tests/tests/src/bs_splice_partial.mjs @@ -2,7 +2,7 @@ function test(g) { - g.xx(10, 3, "xxx", 1, 2, 3); + g.xx(11, 3, "xxx", 1, 2, 3); } function test_hi(x) { diff --git a/tests/tests/src/bs_splice_partial.res b/tests/tests/src/bs_splice_partial.res index 21633ee1542..8b797871c17 100644 --- a/tests/tests/src/bs_splice_partial.res +++ b/tests/tests/src/bs_splice_partial.res @@ -4,6 +4,7 @@ */ type t + @send @variadic external on_exit_slice3: (t, int, ~h: @as(3) _, @as("xxx") _, array<int>) => unit = "xx" diff --git a/tests/tests/src/coercion_module_alias_test.res b/tests/tests/src/coercion_module_alias_test.res index ac2760d662c..fcd8e9c869e 100644 --- a/tests/tests/src/coercion_module_alias_test.res +++ b/tests/tests/src/coercion_module_alias_test.res @@ -12,6 +12,7 @@ l(C''.fromCharCode(66)) module C3 = { include String } + l(C3.fromCharCode(66)) let f = x => { @@ -20,6 +21,7 @@ let f = x => { } M.L.length(x) } + let g = x => { module L = List L.length(L.map(x, n => n + 1)) @@ -36,8 +38,10 @@ module M' = { module N = { let x = 1 } + module N' = N } + l(M'.N'.x) module M'': { @@ -45,10 +49,13 @@ module M'': { let x: int } } = (M') + l(M''.N'.x) + module M2 = { include M' } + module M3: { module N': { let x: int @@ -56,12 +63,15 @@ module M3: { } = { include M' } + l(M3.N'.x) + module M3': { module N': { let x: int } } = (M2) + l(M3'.N'.x) module M4: { @@ -72,21 +82,26 @@ module M4: { module N = { let x = 1 } + module N' = N } + l(M4.N'.x) module F0 = (X: {}) => { module N = { let x = 1 } + module N' = N } + module G0: (X: {}) => { module N': { let x: int } } = F0 + module M5 = G0() l(M5.N'.x) @@ -94,9 +109,11 @@ module M6 = { module D = { let y = 3 } + module N = { let x = 1 } + module N' = N } @@ -104,9 +121,12 @@ module M1: { module N: { let x: int } + module N' = N } = M6 + l(M1.N'.x) + module M7: { module N': { let x: int @@ -115,8 +135,10 @@ module M7: { module N: { let x: int } + module N' = N }) + l(M7.N'.x) open M6 @@ -126,13 +148,17 @@ module M8 = { module C = String module C' = C } + module M9: { module C: { let fromCharCode: int => string } + module C' = C } = M8 + l(M9.C'.fromCharCode(66)) + module M10: { module C': { let fromCharCode: int => string @@ -141,6 +167,8 @@ module M10: { module C: { let fromCharCode: int => string } + module C' = C }) + l(M10.C'.fromCharCode(66)) diff --git a/tests/tests/src/condition_compilation_test.mjs b/tests/tests/src/condition_compilation_test.mjs index f301681a448..4bf5c349c0c 100644 --- a/tests/tests/src/condition_compilation_test.mjs +++ b/tests/tests/src/condition_compilation_test.mjs @@ -12,8 +12,8 @@ v.contents = v.contents + 1 | 0; let a = v.contents; Mocha.describe("Condition_compilation_test", () => { - Mocha.test("condition compilation vv", () => Test_utils.eq("File \"condition_compilation_test.res\", line 52, characters 44-51", 3, 3)); - Mocha.test("condition compilation v", () => Test_utils.eq("File \"condition_compilation_test.res\", line 53, characters 43-50", v.contents, 2)); + Mocha.test("condition compilation vv", () => Test_utils.eq("File \"condition_compilation_test.res\", line 53, characters 44-51", 3, 3)); + Mocha.test("condition compilation v", () => Test_utils.eq("File \"condition_compilation_test.res\", line 54, characters 43-50", v.contents, 2)); }); let b = "u"; diff --git a/tests/tests/src/condition_compilation_test.res b/tests/tests/src/condition_compilation_test.res index 18f1c071b13..07d6269f9e5 100644 --- a/tests/tests/src/condition_compilation_test.res +++ b/tests/tests/src/condition_compilation_test.res @@ -46,6 +46,7 @@ let ocaml_veriosn = "unknown" #end */ open Mocha + open Test_utils describe(__MODULE__, () => { diff --git a/tests/tests/src/conditional/cond_a_B.res b/tests/tests/src/conditional/cond_a_B.res index e4d235f354f..c37e3f3f50c 100644 --- a/tests/tests/src/conditional/cond_a_B.res +++ b/tests/tests/src/conditional/cond_a_B.res @@ -1,6 +1,7 @@ module B = { let value = 3 } + module A = { let u = B.value } diff --git a/tests/tests/src/const_block_test.mjs b/tests/tests/src/const_block_test.mjs index 7c25d4aa969..2a1d5abe532 100644 --- a/tests/tests/src/const_block_test.mjs +++ b/tests/tests/src/const_block_test.mjs @@ -35,7 +35,7 @@ function h() { function g() { f(); - Test_utils.eq("File \"const_block_test.res\", line 25, characters 5-12", [ + Test_utils.eq("File \"const_block_test.res\", line 26, characters 5-12", [ a[0], b[0] ], [ @@ -49,7 +49,7 @@ Mocha.describe("Const_block_test", () => { Mocha.test("avoid_mutable_inline_test", () => { c[0] = 3; c[1] = 4; - Test_utils.eq("File \"const_block_test.res\", line 40, characters 7-14", [ + Test_utils.eq("File \"const_block_test.res\", line 41, characters 7-14", [ 3, 4, 2, diff --git a/tests/tests/src/const_block_test.res b/tests/tests/src/const_block_test.res index 4b80c76bf00..522e3263c03 100644 --- a/tests/tests/src/const_block_test.res +++ b/tests/tests/src/const_block_test.res @@ -5,6 +5,7 @@ let a = [0., 1., 2.] let b = [0, 1, 2] let c = [0, 1, 2, 3, 4, 5] let v = (0, 1, 2, 3, 4, 5) + let f = () => { a->Array.setUnsafe(0, 3.0) b->Array.setUnsafe(0, 3) diff --git a/tests/tests/src/const_test.res b/tests/tests/src/const_test.res index b3233364c9f..4298ffcbd0d 100644 --- a/tests/tests/src/const_test.res +++ b/tests/tests/src/const_test.res @@ -29,6 +29,7 @@ let h = x => | #B => 1 | #C => 2 } + let hh = () => switch "x" { | "y" => 1 diff --git a/tests/tests/src/defunctor_make_test.res b/tests/tests/src/defunctor_make_test.res index c68abb9c80c..7e0696f17a9 100644 --- a/tests/tests/src/defunctor_make_test.res +++ b/tests/tests/src/defunctor_make_test.res @@ -1,12 +1,15 @@ module Comparable: { type comparator<'a> let getcompare: comparator<'a> => ('a, 'a) => int + module type C = { type id type key let compare: comparator<key> } + type compare<'key, 'id> = module(C with type key = 'key and type id = 'id) + module Make: ( M: { type key @@ -16,11 +19,13 @@ module Comparable: { } = { type comparator<'a> = ('a, 'a) => int let getcompare: comparator<'a> => ('a, 'a) => int = x => x + module type C = { type id type key let compare: comparator<key> } + type compare<'key, 'id> = module(C with type key = 'key and type id = 'id) module Make = ( @@ -156,10 +161,12 @@ module V0 = Comparable.Make({ type key = int let compare = (x: key, y) => Pervasives.compare((x: key), y) }) + module V1 = Comparable.Make({ type key = int let compare = (x: key, y) => Pervasives.compare(x, y) }) + let v0 = empty(module(V0)) let v1 = empty(module(V1)) diff --git a/tests/tests/src/demo_page.res b/tests/tests/src/demo_page.res index bcdb0adc915..098ba6551af 100644 --- a/tests/tests/src/demo_page.res +++ b/tests/tests/src/demo_page.res @@ -28,16 +28,19 @@ let rec map = (f, x) => /** Test curry and uncurry calling convention */ let test_curry = (x, y) => x + y + let f = test_curry(32, ...) /** Create a typed binding for react */ type t + type element @val external document: t = "document" @send external getElementById: (t, string) => element = "getElementById" /** Phantom types */ type config + type component type attrs type component_class @@ -45,9 +48,11 @@ type component_class /** make a json object */ @obj external config: (~display_name: string=?, ~render: unit => component, unit) => config = "" + /** make a json object */ @obj external attrs: (~alt: string=?, ~autoPlay: bool=?, unit) => attrs = "" + external str: string => component = "%identity" type vdom diff --git a/tests/tests/src/demo_pipe.res b/tests/tests/src/demo_pipe.res index fb945c7b082..11c35f16211 100644 --- a/tests/tests/src/demo_pipe.res +++ b/tests/tests/src/demo_pipe.res @@ -1,4 +1,5 @@ type readline + @send external on: ( readline, @@ -8,4 +9,5 @@ external on: ( | #close(unit => unit) ], ) => readline = "on" + let register = rl => rl->on(#line(x => Console.log(x)))->on(#close(() => Console.log("finished"))) diff --git a/tests/tests/src/dollar_ident_js_test.res b/tests/tests/src/dollar_ident_js_test.res index 3b56557ed50..49030d8ee24 100644 --- a/tests/tests/src/dollar_ident_js_test.res +++ b/tests/tests/src/dollar_ident_js_test.res @@ -11,8 +11,10 @@ let update$ = {...record$, count$: 5} let fn$ = (~count$, ~inc$) => count$ + inc$ let $ = count$ + $count + let $$ = value$ => { Console.log(value$) value$ + $count } + let call$$ = $$($) diff --git a/tests/tests/src/earger_curry_test.mjs b/tests/tests/src/earger_curry_test.mjs index 4c43a780b4f..20922b59828 100644 --- a/tests/tests/src/earger_curry_test.mjs +++ b/tests/tests/src/earger_curry_test.mjs @@ -95,11 +95,11 @@ let c = g(0)(3, 4); let d = g(0)(3, 5); Mocha.describe("Earger_curry_test", () => { - Mocha.test("earger curry a", () => Test_utils.eq("File \"earger_curry_test.res\", line 137, characters 34-41", a, 10)); - Mocha.test("earger curry b", () => Test_utils.eq("File \"earger_curry_test.res\", line 138, characters 34-41", b, 11)); - Mocha.test("earger curry c", () => Test_utils.eq("File \"earger_curry_test.res\", line 139, characters 34-41", c, 10)); - Mocha.test("earger curry d", () => Test_utils.eq("File \"earger_curry_test.res\", line 140, characters 34-41", d, 11)); - Mocha.test("earger curry all_v", () => Test_utils.eq("File \"earger_curry_test.res\", line 141, characters 38-45", all_v.contents, {hd: 8, tl: {hd: 6, tl: {hd: 6, tl: {hd: 4, tl: {hd: 4, tl: {hd: 2, tl: /* [] */0}}}}}})); + Mocha.test("earger curry a", () => Test_utils.eq("File \"earger_curry_test.res\", line 139, characters 34-41", a, 10)); + Mocha.test("earger curry b", () => Test_utils.eq("File \"earger_curry_test.res\", line 140, characters 34-41", b, 11)); + Mocha.test("earger curry c", () => Test_utils.eq("File \"earger_curry_test.res\", line 141, characters 34-41", c, 10)); + Mocha.test("earger curry d", () => Test_utils.eq("File \"earger_curry_test.res\", line 142, characters 34-41", d, 11)); + Mocha.test("earger curry all_v", () => Test_utils.eq("File \"earger_curry_test.res\", line 143, characters 38-45", all_v.contents, {hd: 8, tl: {hd: 6, tl: {hd: 6, tl: {hd: 4, tl: {hd: 4, tl: {hd: 2, tl: /* [] */0}}}}}})); }); export { diff --git a/tests/tests/src/earger_curry_test.res b/tests/tests/src/earger_curry_test.res index b789099c07a..87320f62bbd 100644 --- a/tests/tests/src/earger_curry_test.res +++ b/tests/tests/src/earger_curry_test.res @@ -105,6 +105,7 @@ let f = x => }, ... ) /* in */ + /* all_v := !v :: !all_v ; u */ @@ -126,6 +127,7 @@ let g = x => { all_v := list{v.contents, ...all_v.contents} u } + let a = f(0)(3, 4) let b = f(0)(3, 5) diff --git a/tests/tests/src/equal_exception_test.mjs b/tests/tests/src/equal_exception_test.mjs index f7acf333bcd..5f4aec80a14 100644 --- a/tests/tests/src/equal_exception_test.mjs +++ b/tests/tests/src/equal_exception_test.mjs @@ -68,7 +68,7 @@ if (Primitive_object.equal(e, { RE_EXN_ID: "Assert_failure", _1: [ "equal_exception_test.res", - 38, + 40, 0 ], Error: new Error() @@ -80,7 +80,7 @@ if (Not_found === "Not_found" !== false) { RE_EXN_ID: "Assert_failure", _1: [ "equal_exception_test.res", - 39, + 41, 0 ], Error: new Error() diff --git a/tests/tests/src/equal_exception_test.res b/tests/tests/src/equal_exception_test.res index f930d06fd27..b200dba1e9e 100644 --- a/tests/tests/src/equal_exception_test.res +++ b/tests/tests/src/equal_exception_test.res @@ -29,11 +29,13 @@ describe(__MODULE__, () => { }) let e = Not_found + let eq = x => switch x { | Not_found => true | _ => false } + exception Not_found assert((e == Not_found) == false) assert(eq(Not_found) == false) diff --git a/tests/tests/src/exception_raise_test.mjs b/tests/tests/src/exception_raise_test.mjs index 0a321a3b5e1..5e89d19d925 100644 --- a/tests/tests/src/exception_raise_test.mjs +++ b/tests/tests/src/exception_raise_test.mjs @@ -97,7 +97,7 @@ try { RE_EXN_ID: "Assert_failure", _1: [ "exception_raise_test.res", - 46, + 47, 7 ], Error: new Error() @@ -146,7 +146,7 @@ function input_lines(ic, _acc) { } Mocha.describe("Exception_raise_test", () => { - Mocha.test("exception values", () => Test_utils.eq("File \"exception_raise_test.res\", line 72, characters 7-14", [ + Mocha.test("exception values", () => Test_utils.eq("File \"exception_raise_test.res\", line 75, characters 7-14", [ f, ff, fff, @@ -159,13 +159,13 @@ Mocha.describe("Exception_raise_test", () => { ])); Mocha.test("Exn.Error conversion", () => { if (a1.RE_EXN_ID === "JsExn") { - return Test_utils.eq("File \"exception_raise_test.res\", line 77, characters 21-28", a1._1, 2); + return Test_utils.eq("File \"exception_raise_test.res\", line 80, characters 21-28", a1._1, 2); } throw { RE_EXN_ID: "Assert_failure", _1: [ "exception_raise_test.res", - 78, + 81, 11 ], Error: new Error() @@ -179,9 +179,9 @@ Mocha.describe("Exception_raise_test", () => { let e = Primitive_exceptions.internalToException(raw_e); testValue = Stdlib_JsExn.fromException(e) !== undefined; } - Test_utils.eq("File \"exception_raise_test.res\", line 86, characters 7-14", testValue, true); + Test_utils.eq("File \"exception_raise_test.res\", line 89, characters 7-14", testValue, true); }); - Mocha.test("raw function call", () => Test_utils.eq("File \"exception_raise_test.res\", line 90, characters 7-14", ((a,b,c,_) => a + b + c)(1, 2, 3, 4), 6)); + Mocha.test("raw function call", () => Test_utils.eq("File \"exception_raise_test.res\", line 93, characters 7-14", ((a,b,c,_) => a + b + c)(1, 2, 3, 4), 6)); }); export { diff --git a/tests/tests/src/exception_raise_test.res b/tests/tests/src/exception_raise_test.res index 7e9a5be544c..c09ff676947 100644 --- a/tests/tests/src/exception_raise_test.res +++ b/tests/tests/src/exception_raise_test.res @@ -7,6 +7,7 @@ exception Local exception B(list<int>) exception C(int, int) exception D((int, int)) + let appf = (g, x) => { module U = { exception A(int) @@ -59,8 +60,10 @@ let fff0 = (x, g) => | exception _ => 1 | _ => g() } + type in_channel @val external input_line: in_channel => string = "input_line" + let rec input_lines = (ic, acc) => switch input_line(ic) { | exception _ => List.reverse(acc) diff --git a/tests/tests/src/exception_value_test.res b/tests/tests/src/exception_value_test.res index 4ee358dc406..7f90bfb7b65 100644 --- a/tests/tests/src/exception_value_test.res +++ b/tests/tests/src/exception_value_test.res @@ -9,12 +9,14 @@ let hh = () => { let v = throw(Not_found) v + 3 } + /* TODO: comment for line column number */ exception A(int) exception B exception C(int, int) let u = A(3) + /** note in ocaml, if such exception is not caught, it will be re-raised */ let test_not_found = (f, ()) => diff --git a/tests/tests/src/exponentiation_test.mjs b/tests/tests/src/exponentiation_test.mjs index 79dc7ff3e97..5bd1cb0fd0d 100644 --- a/tests/tests/src/exponentiation_test.mjs +++ b/tests/tests/src/exponentiation_test.mjs @@ -25,22 +25,22 @@ function bigintPowMul(base, left, right) { Mocha.describe("Exponentiation_test", () => { Mocha.test("exponentiation operations", () => { - Test_utils.eq("File \"exponentiation_test.res\", line 17, characters 7-14", 2 ** 3 ** 2, Math.pow(2, Math.pow(3, 2))); - Test_utils.eq("File \"exponentiation_test.res\", line 18, characters 7-14", 2 ** (-3) ** 2, Math.pow(2, Math.pow(-3, 2))); - Test_utils.eq("File \"exponentiation_test.res\", line 19, characters 7-14", (2 ** 3) ** 2, Math.pow(Math.pow(2, 3), 2)); - Test_utils.eq("File \"exponentiation_test.res\", line 20, characters 7-14", (-2) ** 2, Math.pow(-2, 2)); - Test_utils.eq("File \"exponentiation_test.res\", line 22, characters 7-14", 512, intPow(2, intPow(3, 2))); - Test_utils.eq("File \"exponentiation_test.res\", line 23, characters 7-14", 512, intPow(2, intPow(-3, 2))); - Test_utils.eq("File \"exponentiation_test.res\", line 24, characters 7-14", 64, intPow(intPow(2, 3), 2)); - Test_utils.eq("File \"exponentiation_test.res\", line 25, characters 7-14", -2147483648, intPow(-2, 31)); - Test_utils.eq("File \"exponentiation_test.res\", line 26, characters 7-14", 0, intPow(2, 32)); - Test_utils.eq("File \"exponentiation_test.res\", line 27, characters 7-14", 0, intPow(2147483647, 2)); - Test_utils.eq("File \"exponentiation_test.res\", line 28, characters 7-14", 0, intPow(-2147483648, 2)); - Test_utils.eq("File \"exponentiation_test.res\", line 30, characters 7-14", 256, four ** four | 0); - Test_utils.eq("File \"exponentiation_test.res\", line 32, characters 7-14", 2 ** (0 / 10000), 1); - Test_utils.eq("File \"exponentiation_test.res\", line 33, characters 7-14", 2 ** (3 * 4), 4096); - Test_utils.eq("File \"exponentiation_test.res\", line 34, characters 7-14", 2 ** (5 % 3), 4); - Test_utils.eq("File \"exponentiation_test.res\", line 35, characters 7-14", bigintPowMul(2n, 3n, 2n), 64n); + Test_utils.eq("File \"exponentiation_test.res\", line 18, characters 7-14", 2 ** 3 ** 2, Math.pow(2, Math.pow(3, 2))); + Test_utils.eq("File \"exponentiation_test.res\", line 19, characters 7-14", 2 ** (-3) ** 2, Math.pow(2, Math.pow(-3, 2))); + Test_utils.eq("File \"exponentiation_test.res\", line 20, characters 7-14", (2 ** 3) ** 2, Math.pow(Math.pow(2, 3), 2)); + Test_utils.eq("File \"exponentiation_test.res\", line 21, characters 7-14", (-2) ** 2, Math.pow(-2, 2)); + Test_utils.eq("File \"exponentiation_test.res\", line 23, characters 7-14", 512, intPow(2, intPow(3, 2))); + Test_utils.eq("File \"exponentiation_test.res\", line 24, characters 7-14", 512, intPow(2, intPow(-3, 2))); + Test_utils.eq("File \"exponentiation_test.res\", line 25, characters 7-14", 64, intPow(intPow(2, 3), 2)); + Test_utils.eq("File \"exponentiation_test.res\", line 26, characters 7-14", -2147483648, intPow(-2, 31)); + Test_utils.eq("File \"exponentiation_test.res\", line 27, characters 7-14", 0, intPow(2, 32)); + Test_utils.eq("File \"exponentiation_test.res\", line 28, characters 7-14", 0, intPow(2147483647, 2)); + Test_utils.eq("File \"exponentiation_test.res\", line 29, characters 7-14", 0, intPow(-2147483648, 2)); + Test_utils.eq("File \"exponentiation_test.res\", line 31, characters 7-14", 256, four ** four | 0); + Test_utils.eq("File \"exponentiation_test.res\", line 33, characters 7-14", 2 ** (0 / 10000), 1); + Test_utils.eq("File \"exponentiation_test.res\", line 34, characters 7-14", 2 ** (3 * 4), 4096); + Test_utils.eq("File \"exponentiation_test.res\", line 35, characters 7-14", 2 ** (5 % 3), 4); + Test_utils.eq("File \"exponentiation_test.res\", line 36, characters 7-14", bigintPowMul(2n, 3n, 2n), 64n); }); }); diff --git a/tests/tests/src/exponentiation_test.res b/tests/tests/src/exponentiation_test.res index 216de749954..37597624ab2 100644 --- a/tests/tests/src/exponentiation_test.res +++ b/tests/tests/src/exponentiation_test.res @@ -8,6 +8,7 @@ let four: int = %raw(`4`) let floatPowDiv = (base: float, numerator: float, denominator: float) => base ** (numerator /. denominator) + let floatPowMul = (base: float, left: float, right: float) => base ** (left *. right) let floatPowMod = (base: float, value: float, modulus: float) => base ** (value % modulus) let bigintPowMul = (base: bigint, left: bigint, right: bigint) => base ** (left * right) diff --git a/tests/tests/src/ext_array_test.res b/tests/tests/src/ext_array_test.res index 6173d828486..8303312cc14 100644 --- a/tests/tests/src/ext_array_test.res +++ b/tests/tests/src/ext_array_test.res @@ -175,6 +175,7 @@ let rfind_with_index = (arr, cmp, v) => { } type split<'a> = [#No_split | #Split(array<'a>, array<'a>)] + let rfind_and_split = (arr, cmp, v): split<_> => { let i = rfind_with_index(arr, cmp, v) if i < 0 { diff --git a/tests/tests/src/ffi_arity_test.mjs b/tests/tests/src/ffi_arity_test.mjs index 3dacab2b45b..1d83e26607f 100644 --- a/tests/tests/src/ffi_arity_test.mjs +++ b/tests/tests/src/ffi_arity_test.mjs @@ -58,17 +58,17 @@ let abc_u = abc; fff(); Mocha.describe("Ffi_arity_test", () => { - Mocha.test("mapi with function", () => Test_utils.eq("File \"ffi_arity_test.res\", line 52, characters 7-14", v, [ + Mocha.test("mapi with function", () => Test_utils.eq("File \"ffi_arity_test.res\", line 54, characters 7-14", v, [ 0, 1, 4 ])); - Mocha.test("mapi with addition", () => Test_utils.eq("File \"ffi_arity_test.res\", line 56, characters 7-14", vv, [ + Mocha.test("mapi with addition", () => Test_utils.eq("File \"ffi_arity_test.res\", line 58, characters 7-14", vv, [ 1, 3, 5 ])); - Mocha.test("map with parseInt", () => Test_utils.eq("File \"ffi_arity_test.res\", line 60, characters 7-14", hh, [ + Mocha.test("map with parseInt", () => Test_utils.eq("File \"ffi_arity_test.res\", line 62, characters 7-14", hh, [ 1, 2, 3 diff --git a/tests/tests/src/ffi_arity_test.res b/tests/tests/src/ffi_arity_test.res index be200c79d67..65559fcf254 100644 --- a/tests/tests/src/ffi_arity_test.res +++ b/tests/tests/src/ffi_arity_test.res @@ -23,6 +23,7 @@ let hh = map(["1", "2", "3"], x => parseInt(x)) let u = () => 3 let vvv = ref(0) + let fff = () => { /* No inline */ Console.log("x") @@ -31,6 +32,7 @@ let fff = () => { } let g = () => fff() + /* will be compiled into var g = function () { fff (0)} not {[ var g = fff ]} diff --git a/tests/tests/src/ffi_js_test.mjs b/tests/tests/src/ffi_js_test.mjs index 30e1c15e67d..9445c8dbb76 100644 --- a/tests/tests/src/ffi_js_test.mjs +++ b/tests/tests/src/ffi_js_test.mjs @@ -47,15 +47,15 @@ function create_prim() { } Mocha.describe("Ffi_js_test", () => { - Mocha.test("higher_order function", () => Test_utils.eq("File \"ffi_js_test.res\", line 58, characters 41-48", 6, $$higher_order(1)(2, 3))); + Mocha.test("higher_order function", () => Test_utils.eq("File \"ffi_js_test.res\", line 59, characters 41-48", 6, $$higher_order(1)(2, 3))); Mocha.test("config objects", () => { - Test_utils.eq("File \"ffi_js_test.res\", line 65, characters 7-14", Object.keys(int_config).length, 2); - Test_utils.eq("File \"ffi_js_test.res\", line 66, characters 7-14", Object.keys(string_config).length, 2); + Test_utils.eq("File \"ffi_js_test.res\", line 66, characters 7-14", Object.keys(int_config).length, 2); + Test_utils.eq("File \"ffi_js_test.res\", line 67, characters 7-14", Object.keys(string_config).length, 2); }); Mocha.test("side effect config", () => { let u = 3; u = u + 1 | 0; - Test_utils.eq("File \"ffi_js_test.res\", line 79, characters 7-14", u, 4); + Test_utils.eq("File \"ffi_js_test.res\", line 80, characters 7-14", u, 4); }); Mocha.test("GADT operations", () => {}); }); diff --git a/tests/tests/src/ffi_js_test.res b/tests/tests/src/ffi_js_test.res index 66f4f7f589d..a98374df1de 100644 --- a/tests/tests/src/ffi_js_test.res +++ b/tests/tests/src/ffi_js_test.res @@ -7,6 +7,7 @@ let keys: Obj.t => array<string> = %raw(" function (x){return Object.keys(x)}") } } `) + @val external higher_order: int => (int, int) => int = "$$higher_order" open Mocha diff --git a/tests/tests/src/ffi_test.res b/tests/tests/src/ffi_test.res index 77762f755b9..75053424790 100644 --- a/tests/tests/src/ffi_test.res +++ b/tests/tests/src/ffi_test.res @@ -31,6 +31,7 @@ let v = () => { Textarea.set_minHeight(u, 3) Textarea.get_minHeight(u) } + /* Textarea.set_minHeight_x */ let f = () => { diff --git a/tests/tests/src/flattern_order_test.res b/tests/tests/src/flattern_order_test.res index 3f986247979..4c0cabb0f2b 100644 --- a/tests/tests/src/flattern_order_test.res +++ b/tests/tests/src/flattern_order_test.res @@ -49,6 +49,7 @@ type t = { } let v = ref(0) + let rec obj = { get: _ => v.contents, set: i => v := i, diff --git a/tests/tests/src/flexible_array_test.mjs b/tests/tests/src/flexible_array_test.mjs index 7cff1f6fdb7..133e5ceedfc 100644 --- a/tests/tests/src/flexible_array_test.mjs +++ b/tests/tests/src/flexible_array_test.mjs @@ -313,7 +313,7 @@ if (!Primitive_object.equal(x, of_array([ RE_EXN_ID: "Assert_failure", _1: [ "flexible_array_test.res", - 184, + 185, 2 ], Error: new Error() @@ -331,7 +331,7 @@ if (!Primitive_object.equal(x$1, of_array(y))) { RE_EXN_ID: "Assert_failure", _1: [ "flexible_array_test.res", - 187, + 188, 2 ], Error: new Error() diff --git a/tests/tests/src/flexible_array_test.res b/tests/tests/src/flexible_array_test.res index e9ff8fb7856..f75f1560d4b 100644 --- a/tests/tests/src/flexible_array_test.res +++ b/tests/tests/src/flexible_array_test.res @@ -166,6 +166,7 @@ module Int_array: { append(smaller, push_front(larger, head)) } } + let of_array = arr => { let v = ref(empty) for i in 0 to Array.length(arr) - 1 { diff --git a/tests/tests/src/format_regression.mjs b/tests/tests/src/format_regression.mjs index f06f105f26f..bba8dd65a7b 100644 --- a/tests/tests/src/format_regression.mjs +++ b/tests/tests/src/format_regression.mjs @@ -6,7 +6,7 @@ function peek_queue(param) { RE_EXN_ID: "Assert_failure", _1: [ "format_regression.res", - 10, + 12, 22 ], Error: new Error() @@ -18,7 +18,7 @@ function int_of_size(param) { RE_EXN_ID: "Assert_failure", _1: [ "format_regression.res", - 11, + 13, 23 ], Error: new Error() @@ -30,7 +30,7 @@ function take_queue(param) { RE_EXN_ID: "Assert_failure", _1: [ "format_regression.res", - 12, + 14, 22 ], Error: new Error() @@ -42,7 +42,7 @@ function format_pp_token(param, param$1, param$2) { RE_EXN_ID: "Assert_failure", _1: [ "format_regression.res", - 13, + 15, 35 ], Error: new Error() diff --git a/tests/tests/src/format_regression.res b/tests/tests/src/format_regression.res index a8394503f43..86b1c683c6c 100644 --- a/tests/tests/src/format_regression.res +++ b/tests/tests/src/format_regression.res @@ -1,10 +1,12 @@ @@warning("-20-21") type tag type queue_elem<'a> + type queue<'a> = { mutable insert: queue_elem<'a>, mutable body: queue_elem<'a>, } + type size type pp_token let peek_queue = _ => assert(false) @@ -12,6 +14,7 @@ let int_of_size = _ => assert(false) let take_queue = _ => assert(false) let format_pp_token = (_, _, _) => assert(false) let pp_infinity = 1000000010 + type pp_queue_elem = { mutable elem_size: size, token: pp_token, @@ -24,6 +27,7 @@ type formatter = { mutable pp_right_total: int, mutable pp_queue: queue<pp_queue_elem>, } + let rec advance_loop = state => switch peek_queue(state.pp_queue) { | {elem_size: size, token: tok, length: len} => diff --git a/tests/tests/src/global_module_alias_test.mjs b/tests/tests/src/global_module_alias_test.mjs index cfccbd84894..a532c531eec 100644 --- a/tests/tests/src/global_module_alias_test.mjs +++ b/tests/tests/src/global_module_alias_test.mjs @@ -37,7 +37,7 @@ function xx() { } Mocha.describe("Global_module_alias_test", () => { - Mocha.test("module alias basic operations", () => Test_utils.eq("File \"global_module_alias_test.res\", line 71, characters 7-14", Stdlib_List.length({hd: 1, tl: {hd: 2, tl: /* [] */0}}), 2)); + Mocha.test("module alias basic operations", () => Test_utils.eq("File \"global_module_alias_test.res\", line 72, characters 7-14", Stdlib_List.length({hd: 1, tl: {hd: 2, tl: /* [] */0}}), 2)); Mocha.test("module alias with Make functor", () => { v.contents = v.contents + 1 | 0; v.contents = v.contents + 1 | 0; @@ -51,16 +51,16 @@ Mocha.describe("Global_module_alias_test", () => { v.contents = v.contents + 1 | 0; v.contents = v.contents + 1 | 0; v.contents = v.contents + 1 | 0; - Test_utils.eq("File \"global_module_alias_test.res\", line 76, characters 7-14", v.contents, 12); + Test_utils.eq("File \"global_module_alias_test.res\", line 77, characters 7-14", v.contents, 12); }); - Mocha.test("module alias unpacking", () => Test_utils.eq("File \"global_module_alias_test.res\", line 80, characters 7-14", g(), 4)); + Mocha.test("module alias unpacking", () => Test_utils.eq("File \"global_module_alias_test.res\", line 81, characters 7-14", g(), 4)); Mocha.test("module alias with functor applications", () => { let V = xx(); - Test_utils.eq("File \"global_module_alias_test.res\", line 85, characters 7-14", V.length({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}), 3); - Test_utils.eq("File \"global_module_alias_test.res\", line 86, characters 7-14", v.contents, 15); + Test_utils.eq("File \"global_module_alias_test.res\", line 86, characters 7-14", V.length({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}), 3); + Test_utils.eq("File \"global_module_alias_test.res\", line 87, characters 7-14", v.contents, 15); let H = f(); - Test_utils.eq("File \"global_module_alias_test.res\", line 88, characters 7-14", H.length({hd: 1, tl: {hd: 2, tl: /* [] */0}}), 2); - Test_utils.eq("File \"global_module_alias_test.res\", line 89, characters 7-14", v.contents, 21); + Test_utils.eq("File \"global_module_alias_test.res\", line 89, characters 7-14", H.length({hd: 1, tl: {hd: 2, tl: /* [] */0}}), 2); + Test_utils.eq("File \"global_module_alias_test.res\", line 90, characters 7-14", v.contents, 21); }); }); diff --git a/tests/tests/src/global_module_alias_test.res b/tests/tests/src/global_module_alias_test.res index 15f32151f55..78338de4d1d 100644 --- a/tests/tests/src/global_module_alias_test.res +++ b/tests/tests/src/global_module_alias_test.res @@ -26,6 +26,7 @@ module Make = (U: S) => { v.contents = v.contents + 1 v.contents = v.contents + 1 } + include U } diff --git a/tests/tests/src/gpr496_test.mjs b/tests/tests/src/gpr496_test.mjs index aa563d748f9..640140de5e0 100644 --- a/tests/tests/src/gpr496_test.mjs +++ b/tests/tests/src/gpr496_test.mjs @@ -42,9 +42,9 @@ function ff(x, y) { } Mocha.describe("Gpr496_test", () => { - Mocha.test("expected equals u", () => Test_utils.eq("File \"gpr496_test.res\", line 30, characters 37-44", expected, u)); - Mocha.test("expected equals expected2", () => Test_utils.eq("File \"gpr496_test.res\", line 31, characters 45-52", expected, expected2)); - Mocha.test("min function", () => Test_utils.eq("File \"gpr496_test.res\", line 32, characters 32-39", false, true < false)); + Mocha.test("expected equals u", () => Test_utils.eq("File \"gpr496_test.res\", line 31, characters 37-44", expected, u)); + Mocha.test("expected equals expected2", () => Test_utils.eq("File \"gpr496_test.res\", line 32, characters 45-52", expected, expected2)); + Mocha.test("min function", () => Test_utils.eq("File \"gpr496_test.res\", line 33, characters 32-39", false, true < false)); }); export { diff --git a/tests/tests/src/gpr496_test.res b/tests/tests/src/gpr496_test.res index 05a7d5c36c8..685bf239f78 100644 --- a/tests/tests/src/gpr496_test.res +++ b/tests/tests/src/gpr496_test.res @@ -13,6 +13,7 @@ let expected = ( ) let expected2 = (false, false, true, true, -1, 1, 0, 0) + let u = ( true == false, false == true, diff --git a/tests/tests/src/gpr_1072.mjs b/tests/tests/src/gpr_1072.mjs index b1578062cd6..99abac14822 100644 --- a/tests/tests/src/gpr_1072.mjs +++ b/tests/tests/src/gpr_1072.mjs @@ -120,23 +120,23 @@ let side_effect = { contents: 0 }; -again4(undefined, undefined, 149); - -again4(undefined, undefined, 150); - again4(undefined, undefined, 151); again4(undefined, undefined, 152); again4(undefined, undefined, 153); -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 160); +again4(undefined, undefined, 154); + +again4(undefined, undefined, 155); + +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 162); -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), (side_effect.contents = side_effect.contents - 1 | 0, undefined), 172); +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), (side_effect.contents = side_effect.contents - 1 | 0, undefined), 174); -again4(undefined, (side_effect.contents = side_effect.contents - 1 | 0, undefined), 180); +again4(undefined, (side_effect.contents = side_effect.contents - 1 | 0, undefined), 182); -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 183); +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 185); export { u, diff --git a/tests/tests/src/gpr_1072.res b/tests/tests/src/gpr_1072.res index 6ef2ca77f66..a865da9a02c 100644 --- a/tests/tests/src/gpr_1072.res +++ b/tests/tests/src/gpr_1072.res @@ -41,6 +41,7 @@ let v_ice_cream3: list<ice_cream3_expect> = list{ } type u + @obj external ice_cream4: (~flavor: @string [#vanilla | @as("x") #chocolate]=?, ~num: int, unit) => u = "" @@ -145,6 +146,7 @@ let () = { @val external again4: (~x: unit=?, ~y: unit, int, unit) => unit = "again4" let side_effect = ref(0) + let () = { again4(~y=(), __LINE__, ()) again4(~x=?None, ~y=(), __LINE__, ()) diff --git a/tests/tests/src/gpr_1698_test.mjs b/tests/tests/src/gpr_1698_test.mjs index 1f8098e5dee..c3f689a4329 100644 --- a/tests/tests/src/gpr_1698_test.mjs +++ b/tests/tests/src/gpr_1698_test.mjs @@ -47,7 +47,7 @@ function compare(context, state, _a, _b) { RE_EXN_ID: "Assert_failure", _1: [ "gpr_1698_test.res", - 41, + 45, 9 ], Error: new Error() @@ -72,7 +72,7 @@ function compare(context, state, _a, _b) { RE_EXN_ID: "Assert_failure", _1: [ "gpr_1698_test.res", - 41, + 45, 9 ], Error: new Error() diff --git a/tests/tests/src/gpr_1698_test.res b/tests/tests/src/gpr_1698_test.res index 68117389c7f..a5308a9e846 100644 --- a/tests/tests/src/gpr_1698_test.res +++ b/tests/tests/src/gpr_1698_test.res @@ -1,8 +1,11 @@ @@config({no_export: true}) + type value = | Natural(int) | Symbol(string) + type context = InSum + type rec t = | Val(value) | Neg(t) @@ -10,6 +13,7 @@ type rec t = | Pow(t, t) | Frac(t, t) | Gcd(t, t) + let rec is_number = (expr: t) => switch expr { | Val(Natural(_)) => true @@ -40,6 +44,7 @@ let rec compare = (context, state, a, b) => | (_, Gcd(_), _) => -1 | _ => assert(false) } + let a = Sum(list{sym("a"), Val(Natural(2))}) let b = sym("x") type st = {complex: bool} diff --git a/tests/tests/src/gpr_1728_test.mjs b/tests/tests/src/gpr_1728_test.mjs index 38fdb57dbc6..8f87897b694 100644 --- a/tests/tests/src/gpr_1728_test.mjs +++ b/tests/tests/src/gpr_1728_test.mjs @@ -29,16 +29,16 @@ Test_utils.eq("File \"gpr_1728_test.res\", line 19, characters 3-10", Number.par Test_utils.eq("File \"gpr_1728_test.res\", line 20, characters 3-10", Number.parseInt("0x32"), 50); Mocha.describe("Gpr_1728_test", () => { - Mocha.test("bad_inlining_test", () => Test_utils.eq("File \"gpr_1728_test.res\", line 23, characters 7-14", badInlining({ + Mocha.test("bad_inlining_test", () => Test_utils.eq("File \"gpr_1728_test.res\", line 24, characters 7-14", badInlining({ field: "3" }), undefined)); Mocha.test("parseInt_tests", () => { - Test_utils.eq("File \"gpr_1728_test.res\", line 27, characters 7-14", Number.parseInt("-13"), -13); - Test_utils.eq("File \"gpr_1728_test.res\", line 28, characters 7-14", Number.parseInt("+13"), 13); - Test_utils.eq("File \"gpr_1728_test.res\", line 29, characters 7-14", Number.parseInt("13"), 13); - Test_utils.eq("File \"gpr_1728_test.res\", line 30, characters 7-14", Number.parseInt("+0x32"), 50); - Test_utils.eq("File \"gpr_1728_test.res\", line 31, characters 7-14", Number.parseInt("-0x32"), -50); - Test_utils.eq("File \"gpr_1728_test.res\", line 32, characters 7-14", Number.parseInt("0x32"), 50); + Test_utils.eq("File \"gpr_1728_test.res\", line 28, characters 7-14", Number.parseInt("-13"), -13); + Test_utils.eq("File \"gpr_1728_test.res\", line 29, characters 7-14", Number.parseInt("+13"), 13); + Test_utils.eq("File \"gpr_1728_test.res\", line 30, characters 7-14", Number.parseInt("13"), 13); + Test_utils.eq("File \"gpr_1728_test.res\", line 31, characters 7-14", Number.parseInt("+0x32"), 50); + Test_utils.eq("File \"gpr_1728_test.res\", line 32, characters 7-14", Number.parseInt("-0x32"), -50); + Test_utils.eq("File \"gpr_1728_test.res\", line 33, characters 7-14", Number.parseInt("0x32"), 50); }); }); diff --git a/tests/tests/src/gpr_1728_test.res b/tests/tests/src/gpr_1728_test.res index f4fb4ba64f4..427f1f2b9a2 100644 --- a/tests/tests/src/gpr_1728_test.res +++ b/tests/tests/src/gpr_1728_test.res @@ -18,6 +18,7 @@ eq(__LOC__, parseInt("13"), 13) eq(__LOC__, parseInt("+0x32"), 50) eq(__LOC__, parseInt("-0x32"), -50) eq(__LOC__, parseInt("0x32"), 50) + describe(__MODULE__, () => { test("bad_inlining_test", () => { eq(__LOC__, badInlining({"field": "3"}), ()) diff --git a/tests/tests/src/gpr_1817_test.mjs b/tests/tests/src/gpr_1817_test.mjs index af4a3fdfd4c..b4825566f99 100644 --- a/tests/tests/src/gpr_1817_test.mjs +++ b/tests/tests/src/gpr_1817_test.mjs @@ -18,7 +18,7 @@ Mocha.describe("Gpr_1817_test", () => { Mocha.test("date comparison test", () => { let match = f(); console.log(match[0], match[1]); - Test_utils.eq("File \"gpr_1817_test.res\", line 16, characters 7-14", match[2], true); + Test_utils.eq("File \"gpr_1817_test.res\", line 17, characters 7-14", match[2], true); }); }); diff --git a/tests/tests/src/gpr_1817_test.res b/tests/tests/src/gpr_1817_test.res index 03f7674f956..27db81d78bd 100644 --- a/tests/tests/src/gpr_1817_test.res +++ b/tests/tests/src/gpr_1817_test.res @@ -9,6 +9,7 @@ let f = () => { let y = makeDate() (y > x, y < x, true) } + describe(__MODULE__, () => { test("date comparison test", () => { let (a0, a1, a2) = f() diff --git a/tests/tests/src/gpr_1943_test.mjs b/tests/tests/src/gpr_1943_test.mjs index 5e73d1f76a8..f9f12cd43db 100644 --- a/tests/tests/src/gpr_1943_test.mjs +++ b/tests/tests/src/gpr_1943_test.mjs @@ -26,7 +26,7 @@ Mocha.describe("Gpr_1943_test", () => { "_50x'": 5, "x'": 6 }); - Test_utils.eq("File \"gpr_1943_test.res\", line 19, characters 7-14", [ + Test_utils.eq("File \"gpr_1943_test.res\", line 20, characters 7-14", [ 0, 1, 2, diff --git a/tests/tests/src/gpr_1943_test.res b/tests/tests/src/gpr_1943_test.res index 80a2320ddb7..c2e0609a21d 100644 --- a/tests/tests/src/gpr_1943_test.res +++ b/tests/tests/src/gpr_1943_test.res @@ -2,6 +2,7 @@ open Mocha open Test_utils let f = x => (x["_003"], x["_50"], x["_50x"], x["__50"], x["__50x"], x["_50x'"], x["x'"]) + /* x##_ */ /* TODO: should have a syntax error */ describe(__MODULE__, () => { diff --git a/tests/tests/src/gpr_1946_test.mjs b/tests/tests/src/gpr_1946_test.mjs index aba433a9bc6..3311d41a6e0 100644 --- a/tests/tests/src/gpr_1946_test.mjs +++ b/tests/tests/src/gpr_1946_test.mjs @@ -24,11 +24,11 @@ function f(id) { return id; } -Test_utils.eq("File \"gpr_1946_test.res\", line 23, characters 3-10", ({ +Test_utils.eq("File \"gpr_1946_test.res\", line 24, characters 3-10", ({ _5: 3 })._5, 3); -Test_utils.eq("File \"gpr_1946_test.res\", line 24, characters 3-10", [ +Test_utils.eq("File \"gpr_1946_test.res\", line 25, characters 3-10", [ 2, 3 ], [ @@ -37,10 +37,10 @@ Test_utils.eq("File \"gpr_1946_test.res\", line 24, characters 3-10", [ ]); Mocha.describe("Gpr_1946_test", () => { - Mocha.test("test1", () => Test_utils.eq("File \"gpr_1946_test.res\", line 28, characters 7-14", ({ + Mocha.test("test1", () => Test_utils.eq("File \"gpr_1946_test.res\", line 29, characters 7-14", ({ _5: 3 })._5, 3)); - Mocha.test("test2", () => Test_utils.eq("File \"gpr_1946_test.res\", line 32, characters 7-14", [ + Mocha.test("test2", () => Test_utils.eq("File \"gpr_1946_test.res\", line 33, characters 7-14", [ 2, 3 ], [ diff --git a/tests/tests/src/gpr_1946_test.res b/tests/tests/src/gpr_1946_test.res index d7e05a3f882..35414281507 100644 --- a/tests/tests/src/gpr_1946_test.res +++ b/tests/tests/src/gpr_1946_test.res @@ -13,6 +13,7 @@ type t = { } let h = {a: 2, b: 3} + let f = id => { while false { () diff --git a/tests/tests/src/gpr_2608_test.mjs b/tests/tests/src/gpr_2608_test.mjs index d19fb173665..743bcbd2376 100644 --- a/tests/tests/src/gpr_2608_test.mjs +++ b/tests/tests/src/gpr_2608_test.mjs @@ -22,8 +22,8 @@ if (Stdlib_List.length(/* [] */0) < 0) { Mocha.describe("Gpr_2608_test", () => { Mocha.test("huntGroot conditions", () => { - Test_utils.eq("File \"gpr_2608_test.res\", line 21, characters 7-14", huntGrootCondition, false); - Test_utils.eq("File \"gpr_2608_test.res\", line 22, characters 7-14", huntGrootCondition2, true); + Test_utils.eq("File \"gpr_2608_test.res\", line 22, characters 7-14", huntGrootCondition, false); + Test_utils.eq("File \"gpr_2608_test.res\", line 23, characters 7-14", huntGrootCondition2, true); }); }); diff --git a/tests/tests/src/gpr_2608_test.res b/tests/tests/src/gpr_2608_test.res index 4502047c1df..508d02748b6 100644 --- a/tests/tests/src/gpr_2608_test.res +++ b/tests/tests/src/gpr_2608_test.res @@ -4,6 +4,7 @@ open Test_utils let nearestGroots = list{} let oppHeroes = list{0} + let huntGrootCondition = List.length(nearestGroots) > 0 && { let x = oppHeroes->List.filter(h => List.headOrThrow(nearestGroots) <= 1000) diff --git a/tests/tests/src/gpr_2682_test.mjs b/tests/tests/src/gpr_2682_test.mjs index bcdb0502313..b70df358219 100644 --- a/tests/tests/src/gpr_2682_test.mjs +++ b/tests/tests/src/gpr_2682_test.mjs @@ -49,7 +49,7 @@ if (!bbbb) { RE_EXN_ID: "Assert_failure", _1: [ "gpr_2682_test.res", - 52, + 53, 0 ], Error: new Error() diff --git a/tests/tests/src/gpr_2682_test.res b/tests/tests/src/gpr_2682_test.res index 4feee366db6..5e2e54d1f46 100644 --- a/tests/tests/src/gpr_2682_test.res +++ b/tests/tests/src/gpr_2682_test.res @@ -1,4 +1,5 @@ @@warning("-22") + /* [@@@config no_export] */ /* let for_each n = ([%raw{| diff --git a/tests/tests/src/gpr_3209_test.res b/tests/tests/src/gpr_3209_test.res index a0f469cbc83..009282f3598 100644 --- a/tests/tests/src/gpr_3209_test.res +++ b/tests/tests/src/gpr_3209_test.res @@ -1,5 +1,6 @@ /* [@@@warning "a-11-8-4-a"] */ @@warning("a+11+8-8") + type t6 = | T60 | T61 diff --git a/tests/tests/src/gpr_3536_test.mjs b/tests/tests/src/gpr_3536_test.mjs index 6e344eda2b7..53e35847fb3 100644 --- a/tests/tests/src/gpr_3536_test.mjs +++ b/tests/tests/src/gpr_3536_test.mjs @@ -10,8 +10,8 @@ function xx(obj, a0, a1, a2, a3, a4, a5) { } Mocha.describe("Gpr_3536_test", () => { - Mocha.test("method chaining with + operator", () => Test_utils.eq("File \"gpr_3536_test.res\", line 19, characters 7-14", 5, 5)); - Mocha.test("complex method chaining", () => Test_utils.eq("File \"gpr_3536_test.res\", line 23, characters 7-14", xx(3, (prim0, prim1) => prim0 - prim1 | 0, 2, (prim0, prim1) => prim0 + prim1 | 0, 4, (prim0, prim1) => prim0 * prim1 | 0, 3), 11)); + Mocha.test("method chaining with + operator", () => Test_utils.eq("File \"gpr_3536_test.res\", line 20, characters 7-14", 5, 5)); + Mocha.test("complex method chaining", () => Test_utils.eq("File \"gpr_3536_test.res\", line 24, characters 7-14", xx(3, (prim0, prim1) => prim0 - prim1 | 0, 2, (prim0, prim1) => prim0 + prim1 | 0, 4, (prim0, prim1) => prim0 * prim1 | 0, 3), 11)); }); let v = 5; diff --git a/tests/tests/src/gpr_3536_test.res b/tests/tests/src/gpr_3536_test.res index 2dc965b7026..3cb0f874718 100644 --- a/tests/tests/src/gpr_3536_test.res +++ b/tests/tests/src/gpr_3536_test.res @@ -10,6 +10,7 @@ module X = { let u = 3->X.Some let xx = (obj, a0, a1, a2, a3, a4, a5) => obj->a0(a1)->a2(a3)->a4(a5)->\"-"(1)->(3->\"-") + /* (a4 (a2 (a0 obj a1) a3) a5) */ diff --git a/tests/tests/src/gpr_3566_test.res b/tests/tests/src/gpr_3566_test.res index da177e5d4ec..b7a96ac118e 100644 --- a/tests/tests/src/gpr_3566_test.res +++ b/tests/tests/src/gpr_3566_test.res @@ -1,4 +1,5 @@ type t = A(int) | B(string) + let eq_A = (x: t, y) => switch x { | A(x) => @@ -36,6 +37,7 @@ module Test3 = () => { let f = (x, y) => x == y module Caml_obj = {} } + module Test4 = () => { module Caml_obj = {} let f = (x, y) => x == y diff --git a/tests/tests/src/gpr_3609_test.res b/tests/tests/src/gpr_3609_test.res index 58621c4be8c..eff32eee3aa 100644 --- a/tests/tests/src/gpr_3609_test.res +++ b/tests/tests/src/gpr_3609_test.res @@ -2,6 +2,7 @@ type state = | Empty | Int1(int) | Int2(int) + let func = (state: state): int => switch state { | Empty => 0 diff --git a/tests/tests/src/gpr_3875_test.mjs b/tests/tests/src/gpr_3875_test.mjs index 4bcf1c7959c..c21cca35748 100644 --- a/tests/tests/src/gpr_3875_test.mjs +++ b/tests/tests/src/gpr_3875_test.mjs @@ -34,7 +34,7 @@ function compilerBug(a, b, c, f) { Mocha.describe("Gpr_3875_test", () => { Mocha.test("compiler bug pattern matching", () => { compilerBug("x", undefined, true, () => true); - Test_utils.eq("File \"gpr_3875_test.res\", line 35, characters 7-14", result.contents, "Some x, f returns true"); + Test_utils.eq("File \"gpr_3875_test.res\", line 36, characters 7-14", result.contents, "Some x, f returns true"); }); }); diff --git a/tests/tests/src/gpr_3875_test.res b/tests/tests/src/gpr_3875_test.res index 79059daea46..8a4f26fbdcb 100644 --- a/tests/tests/src/gpr_3875_test.res +++ b/tests/tests/src/gpr_3875_test.res @@ -2,6 +2,7 @@ open Mocha open Test_utils let result = ref("") + /** TODO: pattern match over (Some \"xx\") could be simplified */ diff --git a/tests/tests/src/gpr_3980_test.mjs b/tests/tests/src/gpr_3980_test.mjs index 38c5b374828..b4af82cf677 100644 --- a/tests/tests/src/gpr_3980_test.mjs +++ b/tests/tests/src/gpr_3980_test.mjs @@ -7,7 +7,7 @@ if (1 !== 1) { RE_EXN_ID: "Assert_failure", _1: [ "gpr_3980_test.res", - 15, + 16, 7 ], Error: new Error() @@ -22,7 +22,7 @@ if (match !== 1) { RE_EXN_ID: "Assert_failure", _1: [ "gpr_3980_test.res", - 13, + 14, 9 ], Error: new Error() diff --git a/tests/tests/src/gpr_3980_test.res b/tests/tests/src/gpr_3980_test.res index 973e5ad93c2..d81dbcd7807 100644 --- a/tests/tests/src/gpr_3980_test.res +++ b/tests/tests/src/gpr_3980_test.res @@ -2,6 +2,7 @@ type student = { name: string, age: int, } + let _ = switch Some(1) { | Some(1) => switch %raw("1") { diff --git a/tests/tests/src/gpr_4274_test.res b/tests/tests/src/gpr_4274_test.res index 6370177087a..e26a86ed252 100644 --- a/tests/tests/src/gpr_4274_test.res +++ b/tests/tests/src/gpr_4274_test.res @@ -15,6 +15,7 @@ List.forEach(list{{N.x: 3}}, x => Console.log(x.x)) module Foo = { type record = {foo: string} } + let bar = [{Foo.foo: @reason.raw_literal("bar") "bar"}] let _ = Array.map(bar, b => b.foo) diff --git a/tests/tests/src/gpr_4280_test.mjs b/tests/tests/src/gpr_4280_test.mjs index 23fedb4de01..383d779f62e 100644 --- a/tests/tests/src/gpr_4280_test.mjs +++ b/tests/tests/src/gpr_4280_test.mjs @@ -61,16 +61,16 @@ function fn(authState, route) { } Mocha.describe("Gpr_4280_test", () => { - Mocha.test("fn with Unauthenticated and Invite", () => Test_utils.eq("File \"gpr_4280_test.res\", line 41, characters 54-61", fn("Unauthenticated", "Invite"), 1)); - Mocha.test("fn with Unauthenticated and Onboarding", () => Test_utils.eq("File \"gpr_4280_test.res\", line 43, characters 7-14", fn("Unauthenticated", { + Mocha.test("fn with Unauthenticated and Invite", () => Test_utils.eq("File \"gpr_4280_test.res\", line 42, characters 54-61", fn("Unauthenticated", "Invite"), 1)); + Mocha.test("fn with Unauthenticated and Onboarding", () => Test_utils.eq("File \"gpr_4280_test.res\", line 44, characters 7-14", fn("Unauthenticated", { NAME: "Onboarding", VAL: 0 }), 0)); - Mocha.test("fn with Unverified and Invite", () => Test_utils.eq("File \"gpr_4280_test.res\", line 45, characters 49-56", fn({ + Mocha.test("fn with Unverified and Invite", () => Test_utils.eq("File \"gpr_4280_test.res\", line 46, characters 49-56", fn({ NAME: "Unverified", VAL: 0 }, "Invite"), 2)); - Mocha.test("fn with Unauthenticated and unknown route", () => Test_utils.eq("File \"gpr_4280_test.res\", line 46, characters 61-68", fn("Unauthenticated", "xx"), 3)); + Mocha.test("fn with Unauthenticated and unknown route", () => Test_utils.eq("File \"gpr_4280_test.res\", line 47, characters 61-68", fn("Unauthenticated", "xx"), 3)); }); export { diff --git a/tests/tests/src/gpr_4280_test.res b/tests/tests/src/gpr_4280_test.res index e52766c6bb2..84a7970c791 100644 --- a/tests/tests/src/gpr_4280_test.res +++ b/tests/tests/src/gpr_4280_test.res @@ -2,6 +2,7 @@ open Mocha open Test_utils let u = ref(0) + let div = (~children, ()) => for i in 0 to 1 { u := 300 diff --git a/tests/tests/src/gpr_5169_test.res b/tests/tests/src/gpr_5169_test.res index 04b73414ba6..421db566421 100644 --- a/tests/tests/src/gpr_5169_test.res +++ b/tests/tests/src/gpr_5169_test.res @@ -4,10 +4,12 @@ module NotOption = { let a = NotOption.None /* undefined */ let b = NotOption.Some(1) /* 1 */ + let c = { open NotOption None } + let d = { open NotOption Some(1) @@ -19,10 +21,12 @@ module TotallyNotOption = { let e = TotallyNotOption.None /* undefined */ let f = TotallyNotOption.Some(1) /* 1 */ + let g = { open TotallyNotOption None } + let h = { open TotallyNotOption Some(1) @@ -34,10 +38,12 @@ module NotOption2 = { let i = NotOption2.None let j = NotOption2.Some(1) + let k = { open NotOption2 None } + let l = { open NotOption2 Some(1) diff --git a/tests/tests/src/gpr_5557.mjs b/tests/tests/src/gpr_5557.mjs index 9f2a08e9b2d..5a12c778bcd 100644 --- a/tests/tests/src/gpr_5557.mjs +++ b/tests/tests/src/gpr_5557.mjs @@ -9,7 +9,7 @@ function isA(c) { RE_EXN_ID: "Match_failure", _1: [ "gpr_5557.res", - 5, + 6, 2 ], Error: new Error() diff --git a/tests/tests/src/gpr_5557.res b/tests/tests/src/gpr_5557.res index 81d3274ed8a..b7f1e4de8b1 100644 --- a/tests/tests/src/gpr_5557.res +++ b/tests/tests/src/gpr_5557.res @@ -1,6 +1,7 @@ @@config({ flags: ["-w", "-8"], }) + let isA = c => switch c { | 'a' => true diff --git a/tests/tests/src/gpr_904_test.mjs b/tests/tests/src/gpr_904_test.mjs index 148db3f7b1d..1bf48484c58 100644 --- a/tests/tests/src/gpr_904_test.mjs +++ b/tests/tests/src/gpr_904_test.mjs @@ -24,11 +24,11 @@ function f(check) { } Mocha.describe("Gpr_904_test", () => { - Mocha.test("f function", () => Test_utils.eq("File \"gpr_904_test.res\", line 12, characters 30-37", false, f({ + Mocha.test("f function", () => Test_utils.eq("File \"gpr_904_test.res\", line 13, characters 30-37", false, f({ x: true, y: false }))); - Mocha.test("check_healty function", () => Test_utils.eq("File \"gpr_904_test.res\", line 14, characters 7-14", false, check_healty({ + Mocha.test("check_healty function", () => Test_utils.eq("File \"gpr_904_test.res\", line 15, characters 7-14", false, check_healty({ a: false, b: false, c: true diff --git a/tests/tests/src/gpr_904_test.res b/tests/tests/src/gpr_904_test.res index 8fff7e94730..3eceb70e891 100644 --- a/tests/tests/src/gpr_904_test.res +++ b/tests/tests/src/gpr_904_test.res @@ -6,6 +6,7 @@ let check_healty = check => !check["a"] && (!check["b"] && !check["c"]) let basic_not = x => !x let f = check => check["x"] && check["y"] + /* [x && y] in OCaml can be translated to [x && y] in JS */ describe(__MODULE__, () => { diff --git a/tests/tests/src/gpr_return_type_unused_attribute.res b/tests/tests/src/gpr_return_type_unused_attribute.res index c6a266be41c..f676f4e5435 100644 --- a/tests/tests/src/gpr_return_type_unused_attribute.res +++ b/tests/tests/src/gpr_return_type_unused_attribute.res @@ -2,6 +2,7 @@ @val external mk: int => [#a | #b] = "mk" + /* [@string] */ let v = mk(2) diff --git a/tests/tests/src/hello_res.res b/tests/tests/src/hello_res.res index 53ff9e29dae..b5034ec1142 100644 --- a/tests/tests/src/hello_res.res +++ b/tests/tests/src/hello_res.res @@ -32,6 +32,7 @@ module H = { let v = 3 } } + let u = { let {length: l, add} = module(List) list{}->add(l(list{1, 2, 3})) @@ -46,6 +47,7 @@ let bracedLocalModule = { let {v} = {module(H.H1)} v } + assert(bracedLocalModule == 3) let to = 3 diff --git a/tests/tests/src/inline_condition_with_pattern_matching.res b/tests/tests/src/inline_condition_with_pattern_matching.res index 215ea4f2960..e02c7b7b4bb 100644 --- a/tests/tests/src/inline_condition_with_pattern_matching.res +++ b/tests/tests/src/inline_condition_with_pattern_matching.res @@ -1,5 +1,6 @@ module Test1 = { type status = Vacations(int) | Sabbatical(int) | Sick + type person = | Teacher({age: int}) | Student({status: status}) @@ -15,6 +16,7 @@ module Test1 = { module Test2 = { type status = Vacations(int) | Sabbatical(int) | Sick | Present type reportCard = {passing: bool, gpa: float} + type person = | Teacher({name: string, age: int}) | Student({name: string, status: status, reportCard: reportCard}) diff --git a/tests/tests/src/inline_const.res b/tests/tests/src/inline_const.res index 2112455d4ab..ebbe2e15da2 100644 --- a/tests/tests/src/inline_const.res +++ b/tests/tests/src/inline_const.res @@ -7,6 +7,7 @@ @inline let f2 = `中文` @inline let escapedValue = `\x61\n\uD83D\uDE00` + /* Do we need fix let f2 : string = blabla */ @@ -22,6 +23,7 @@ module N1 = () => { @inline let xx = 3e-6 let xx0 = 3e-6 } + let h = f let hh = f ++ f diff --git a/tests/tests/src/inline_map2_test.mjs b/tests/tests/src/inline_map2_test.mjs index 8a034c64011..93894a4781e 100644 --- a/tests/tests/src/inline_map2_test.mjs +++ b/tests/tests/src/inline_map2_test.mjs @@ -1928,8 +1928,8 @@ let s = Stdlib_List.reduceReverse({hd: [ ], tl: /* [] */0}}}}, "Empty", (acc, param) => add$1(param[0], param[1], acc)); Mocha.describe("Inline_map2_test", () => { - Mocha.test("assertion1", () => Test_utils.eq("File \"inline_map2_test.res\", line 478, characters 30-37", find(10, m), /* 'a' */97)); - Mocha.test("assertion2", () => Test_utils.eq("File \"inline_map2_test.res\", line 479, characters 30-37", find$1("10", s), /* 'a' */97)); + Mocha.test("assertion1", () => Test_utils.eq("File \"inline_map2_test.res\", line 479, characters 30-37", find(10, m), /* 'a' */97)); + Mocha.test("assertion2", () => Test_utils.eq("File \"inline_map2_test.res\", line 480, characters 30-37", find$1("10", s), /* 'a' */97)); }); let eq = Test_utils.eq; diff --git a/tests/tests/src/inline_map2_test.res b/tests/tests/src/inline_map2_test.res index 86d9dcf1570..5eeb254800d 100644 --- a/tests/tests/src/inline_map2_test.res +++ b/tests/tests/src/inline_map2_test.res @@ -472,6 +472,7 @@ let s = List.reduceReverse(list{("10", 'a'), ("3", 'b'), ("7", 'c'), ("20", 'd') acc, (k, v), ) => SMap.add(k, v, acc)) + @val("console.log") external log: 'a => unit = "" describe(__MODULE__, () => { diff --git a/tests/tests/src/inline_map_test.mjs b/tests/tests/src/inline_map_test.mjs index cedd5223b4d..29256820474 100644 --- a/tests/tests/src/inline_map_test.mjs +++ b/tests/tests/src/inline_map_test.mjs @@ -154,7 +154,7 @@ let m = Stdlib_List.reduceReverse({hd: [ ], tl: /* [] */0}}}}, "Empty", (acc, param) => add(param[0], param[1], acc)); Mocha.describe("Inline_map_test", () => { - Mocha.test("inline map test", () => Test_utils.eq("File \"inline_map_test.res\", line 419, characters 7-14", find(10, m), /* 'a' */97)); + Mocha.test("inline map test", () => Test_utils.eq("File \"inline_map_test.res\", line 420, characters 7-14", find(10, m), /* 'a' */97)); }); /* m Not a pure module */ diff --git a/tests/tests/src/inline_map_test.res b/tests/tests/src/inline_map_test.res index 30e0bf30ea3..e14be70d7c4 100644 --- a/tests/tests/src/inline_map_test.res +++ b/tests/tests/src/inline_map_test.res @@ -4,6 +4,7 @@ open Test_utils module Ord = { type t = int } + let compare = (x: int, y: int) => compare(x, y) /* module Make(Ord: OrderedType) = struct */ diff --git a/tests/tests/src/inline_string_test.res b/tests/tests/src/inline_string_test.res index 0160c9ad92e..c0cb8d1c217 100644 --- a/tests/tests/src/inline_string_test.res +++ b/tests/tests/src/inline_string_test.res @@ -1,4 +1,5 @@ @@config({no_export: no_export}) + type t = | A_list | A_hashtable @@ -15,6 +16,7 @@ type t2 = | A_list | A_hashtable | A_bad + let string_of_associative_type = x => switch x { | A_list => "list" @@ -31,6 +33,7 @@ let f = x => | Some(_) => "Some" | None => "None" } + let u = v => f(Some(v)) Console.log((f(v), f(None), f(Some(3)))) diff --git a/tests/tests/src/int_poly_var_test.mjs b/tests/tests/src/int_poly_var_test.mjs index e8be67c412a..3acd8e1180d 100644 --- a/tests/tests/src/int_poly_var_test.mjs +++ b/tests/tests/src/int_poly_var_test.mjs @@ -145,8 +145,8 @@ function f(x) { Mocha.describe("Int_poly_var_test", () => { Mocha.test("int poly var test", () => { - Test_utils.eq("File \"int_poly_var_test.res\", line 102, characters 7-14", hihi, 3); - Test_utils.eq("File \"int_poly_var_test.res\", line 103, characters 7-14", tuple, [ + Test_utils.eq("File \"int_poly_var_test.res\", line 106, characters 7-14", hihi, 3); + Test_utils.eq("File \"int_poly_var_test.res\", line 107, characters 7-14", tuple, [ 0, 1, 2, diff --git a/tests/tests/src/int_poly_var_test.res b/tests/tests/src/int_poly_var_test.res index 17e9ed890d8..dc049e33a2e 100644 --- a/tests/tests/src/int_poly_var_test.res +++ b/tests/tests/src/int_poly_var_test.res @@ -8,6 +8,7 @@ type t = [ | #1 | #2 ] + type h = | A(t) | B(t, int) @@ -23,6 +24,7 @@ let nest = (x: h) => { | B(#0, _) => 6 } } + @inline let f = (x: t) => { switch x { @@ -53,6 +55,7 @@ let f3 = (x, b) => { | #333(_, h) => h } } + let h = x => x == #0 let g = f(#1) @@ -61,6 +64,7 @@ let hihi = f3(#3, 0) let hh9 = 3 == Obj.magic(#3) let hh10 = "3" == Obj.magic(#3) + let tuple = ( nest(A(#0)), nest(A(#1)), diff --git a/tests/tests/src/internal_unused_test.res b/tests/tests/src/internal_unused_test.res index d0e806b674b..14b4394c161 100644 --- a/tests/tests/src/internal_unused_test.res +++ b/tests/tests/src/internal_unused_test.res @@ -1,5 +1,6 @@ @@warning("A") @@warnerror("a") + @internal.local module P0 = { { @@ -8,6 +9,7 @@ module P0 = { (a + 2)->ignore } } + open! P0 @internal.local @@ -15,6 +17,7 @@ module P1 = { exception A let _a = 2 } + open! P1 let f = () => throw(A) diff --git a/tests/tests/src/jsx_optional_props_test.res b/tests/tests/src/jsx_optional_props_test.res index f4179cc36cd..45bb69f969b 100644 --- a/tests/tests/src/jsx_optional_props_test.res +++ b/tests/tests/src/jsx_optional_props_test.res @@ -13,12 +13,14 @@ let _element = <ComponentWithOptionalProps i=1 s="test" element={<div />} /> let _comment_only_host = <div>{/* no children prop */}</div> let _comment_only_fragment = <>{/* no children */}</> + let _comment_single_child = <div> {/* before */} <span /> {/* after */} </div> + let _comment_multiple_children = <div> <span /> diff --git a/tests/tests/src/jsx_preserve_cases.res b/tests/tests/src/jsx_preserve_cases.res index 2faca9cbc56..343a095acfb 100644 --- a/tests/tests/src/jsx_preserve_cases.res +++ b/tests/tests/src/jsx_preserve_cases.res @@ -15,9 +15,11 @@ module AsProp = { @as("foo bar") fooBar: string, @as("data-x") dataX: string, } + @react.componentWithProps let make = (_: props) => React.null } + let asProp = <AsProp fooBar="a" dataX="b" /> // A component bound to a lowercase global: <lowerComp /> would be an @@ -26,6 +28,7 @@ module Lower = { @react.component @val external make: (~x: int) => React.element = "lowerComp" } + let lowerExternal = <Lower x=1 /> // The call passes a lone spread itself, not a copy of it @@ -33,6 +36,7 @@ module LowerSpread = { type props = {x: int} @val external make: React.component<props> = "lowerComp" } + @val external lowerProps: unit => LowerSpread.props = "lowerProps" let lowerSpread = <LowerSpread {...lowerProps()} /> let lowerSpreadKeyed = <LowerSpread {...lowerProps()} key="k" /> @@ -49,6 +53,7 @@ let spreadCallKeyed = <div {...getProps()} key="k" /> // A sequence is not an AssignmentExpression, so it needs parentheses let count = ref(0) + let seqValue = <div title={ @@ -66,9 +71,11 @@ let fragmentChild = // A spread of a small record without optional fields copies its fields module Req = { type props = {a: string, b: string} + @react.componentWithProps let make = (props: props) => <div title={props.a ++ props.b} /> } + let copySpread = (p: Req.props) => <Req {...p} b="override" /> // A tag that is a field of a local module stays a member expression diff --git a/tests/tests/src/jsx_preserve_custom_runtime.res b/tests/tests/src/jsx_preserve_custom_runtime.res index 677030e1c0f..20b9630d1a9 100644 --- a/tests/tests/src/jsx_preserve_custom_runtime.res +++ b/tests/tests/src/jsx_preserve_custom_runtime.res @@ -1,36 +1,47 @@ @@config({ flags: ["-bs-jsx", "4", "-bs-jsx-preserve"], }) + @@jsxConfig({version: 4, module_: "MyJsx"}) // A JSX module whose runtime functions don't have React's JS names module MyJsx = { type element = Jsx.element type component<'props> = Jsx.component<'props> + external component: Jsx.componentLike<'props, element> => component<'props> = "%component_identity" @module("some-runtime") external jsx: (component<'props>, 'props) => element = "j" + @module("some-runtime") external jsxs: (component<'props>, 'props) => element = "js" + @module("some-runtime") external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "j" + @module("some-runtime") external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "js" + external array: array<element> => element = "%identity" type fragmentProps = {children?: element} @module("some-runtime") external jsxFragment: component<fragmentProps> = "Frag" type domProps = {children?: element, title?: string} + module Elements = { external someElement: element => option<element> = "%identity" + @module("some-runtime") external jsx: (string, domProps) => element = "j" + @module("some-runtime") external jsxs: (string, domProps) => element = "js" + @module("some-runtime") external jsxKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "j" + @module("some-runtime") external jsxsKeyed: (string, domProps, ~key: string=?, @ignore unit) => element = "js" } @@ -45,9 +56,11 @@ module Comp = { // The tag stays a member expression; <memoComp /> would be an intrinsic element let memoComp = memo(Comp.make) + module TopMemo = { let make = memoComp } + let topMemo = <TopMemo title="tm" /> // Several children, a fragment and a key @@ -56,6 +69,7 @@ let fragment = <span /> <b /> </> + let keyed = <div key="k"> <span /> diff --git a/tests/tests/src/jsx_preserve_test.res b/tests/tests/src/jsx_preserve_test.res index e66ff649029..3d5255ca747 100644 --- a/tests/tests/src/jsx_preserve_test.res +++ b/tests/tests/src/jsx_preserve_test.res @@ -47,14 +47,17 @@ let _unary_element_with_spread_props = <input {...baseProps} type_="text" /> let otherProps: JsxDOM.domProps = { id: "bar", } + let _unary_element_with_props_of_two_spreads = <input {...dict{...baseProps->Obj.magic, ...otherProps->Obj.magic}->Obj.magic} /> // including keys that aren't JSX attribute names let _unary_element_with_spread_and_spaced_key = <input {...dict{...baseProps->Obj.magic, "foo bar": "x"}->Obj.magic} /> + let _unary_element_with_spread_and_proto_key = <input {...dict{...baseProps->Obj.magic, "__proto__": "x"}->Obj.magic} /> + let _unary_element_with_spread_and_hyphenated_key = <input {...dict{...baseProps->Obj.magic, "aria-label": "x"}->Obj.magic} /> @@ -67,8 +70,10 @@ let _container_with_spread_and_repeated_children = "children": React.string("second"), }->Obj.magic} /> + let _unary_element_with_spread_and_repeated_key = <input {...dict{...baseProps->Obj.magic, "title": "x", "title": "y"}->Obj.magic} /> + // and a "key" property next to the key attribute let _unary_element_with_spread_and_key_prop_keyed = <input {...dict{...baseProps->Obj.magic, "key": "inner"}->Obj.magic} key="outer" /> @@ -172,6 +177,7 @@ let _youtube_iframe = module X = { type props = {} + @react.componentWithProps let make = (_props: props) => React.null } @@ -202,12 +208,14 @@ let make = (~children) => { let _comment_only_host = <div>{/* no children prop */}</div> let _comment_only_fragment = <>{/* no children */}</> + let _comment_single_child = <div> {/* before */} <span /> {/* after */} </div> + let _comment_multiple_children = <div> <span /> diff --git a/tests/tests/src/key_word_property2.res b/tests/tests/src/key_word_property2.res index 642822a8bd9..a364ac7f250 100644 --- a/tests/tests/src/key_word_property2.res +++ b/tests/tests/src/key_word_property2.res @@ -5,6 +5,7 @@ let test2 = v => } let test = p => (p["catch"], p["_then"]) + let (case, window, \"switch") = ( Export_keyword.case, Export_keyword.window, diff --git a/tests/tests/src/lazy_test.mjs b/tests/tests/src/lazy_test.mjs index 1bb5b6c1063..6e2092f57d3 100644 --- a/tests/tests/src/lazy_test.mjs +++ b/tests/tests/src/lazy_test.mjs @@ -76,27 +76,27 @@ let a7 = Stdlib_Lazy.get(a5); let a8 = Stdlib_Lazy.get(a6); Mocha.describe("Lazy_test", () => { - Mocha.test("simple", () => Test_utils.eq("File \"lazy_test.res\", line 72, characters 26-33", lazy_test(), [ + Mocha.test("simple", () => Test_utils.eq("File \"lazy_test.res\", line 74, characters 26-33", lazy_test(), [ 3, 32 ])); - Mocha.test("lazy_force", () => Test_utils.eq("File \"lazy_test.res\", line 74, characters 30-37", u_v.contents, 2)); - Mocha.test("lazy_from_fun", () => Test_utils.eq("File \"lazy_test.res\", line 75, characters 33-40", Stdlib_Lazy.get(l_from_fun), 3)); - Mocha.test("lazy_from_val", () => Test_utils.eq("File \"lazy_test.res\", line 76, characters 33-40", Stdlib_Lazy.get(Stdlib_Lazy.make(() => 3)), 3)); - Mocha.test("lazy_from_val2", () => Test_utils.eq("File \"lazy_test.res\", line 78, characters 7-14", Stdlib_Lazy.get(Stdlib_Lazy.get(Stdlib_Lazy.make(() => Stdlib_Lazy.make(() => 3)))), 3)); + Mocha.test("lazy_force", () => Test_utils.eq("File \"lazy_test.res\", line 76, characters 30-37", u_v.contents, 2)); + Mocha.test("lazy_from_fun", () => Test_utils.eq("File \"lazy_test.res\", line 77, characters 33-40", Stdlib_Lazy.get(l_from_fun), 3)); + Mocha.test("lazy_from_val", () => Test_utils.eq("File \"lazy_test.res\", line 78, characters 33-40", Stdlib_Lazy.get(Stdlib_Lazy.make(() => 3)), 3)); + Mocha.test("lazy_from_val2", () => Test_utils.eq("File \"lazy_test.res\", line 80, characters 7-14", Stdlib_Lazy.get(Stdlib_Lazy.get(Stdlib_Lazy.make(() => Stdlib_Lazy.make(() => 3)))), 3)); Mocha.test("lazy_from_val3", () => { debugger; - Test_utils.eq("File \"lazy_test.res\", line 82, characters 6-13", Stdlib_Lazy.get(Stdlib_Lazy.get(Stdlib_Lazy.make(() => forward_test))), 4); + Test_utils.eq("File \"lazy_test.res\", line 84, characters 6-13", Stdlib_Lazy.get(Stdlib_Lazy.get(Stdlib_Lazy.make(() => forward_test))), 4); }); - Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 90, characters 26-33", Stdlib_Lazy.get(a3), Stdlib_Lazy.get(a4))); - Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 91, characters 26-33", a7, undefined)); - Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 92, characters 26-33", a8, undefined)); - Mocha.test("File \"lazy_test.res\", line 93, characters 7-14", () => { + Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 92, characters 26-33", Stdlib_Lazy.get(a3), Stdlib_Lazy.get(a4))); + Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 93, characters 26-33", a7, undefined)); + Mocha.test("lazy_test.res", () => Test_utils.eq("File \"lazy_test.res\", line 94, characters 26-33", a8, undefined)); + Mocha.test("File \"lazy_test.res\", line 95, characters 7-14", () => { let evaluated = Stdlib_Lazy.make(() => 3); Stdlib_Lazy.get(evaluated); - Test_utils.ok("File \"lazy_test.res\", line 96, characters 7-14", Stdlib_Lazy.isEvaluated(evaluated)); + Test_utils.ok("File \"lazy_test.res\", line 98, characters 7-14", Stdlib_Lazy.isEvaluated(evaluated)); }); - Mocha.test("File \"lazy_test.res\", line 98, characters 7-14", () => Test_utils.ok("File \"lazy_test.res\", line 98, characters 25-32", !Stdlib_Lazy.isEvaluated(Stdlib_Lazy.make(() => { + Mocha.test("File \"lazy_test.res\", line 100, characters 7-14", () => Test_utils.ok("File \"lazy_test.res\", line 100, characters 25-32", !Stdlib_Lazy.isEvaluated(Stdlib_Lazy.make(() => { throw { RE_EXN_ID: "Not_found", Error: new Error() diff --git a/tests/tests/src/lazy_test.res b/tests/tests/src/lazy_test.res index e6d7d447751..07e957f7a39 100644 --- a/tests/tests/src/lazy_test.res +++ b/tests/tests/src/lazy_test.res @@ -39,6 +39,7 @@ let exotic = x => /* let l_from_val = Lazy.from_val 3 */ let l_from_fun = Lazy.make(_ => 3) + let forward_test = Lazy.make(() => { let u = ref(3) u.contents = u.contents + 1 @@ -53,6 +54,7 @@ let f006: Lazy.t<unit => int> = Lazy.make(() => { }) let f007 = Lazy.make(() => throw(Not_found)) + let f008 = Lazy.make(() => { Console.log("hi") throw(Not_found) diff --git a/tests/tests/src/lib_js_test.mjs b/tests/tests/src/lib_js_test.mjs index 9b01f120038..12dc97ae199 100644 --- a/tests/tests/src/lib_js_test.mjs +++ b/tests/tests/src/lib_js_test.mjs @@ -8,7 +8,7 @@ console.log(JSON.stringify({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}})); console.log("hey"); Mocha.describe("Lib_js_test", () => { - Mocha.test("anything_to_string", () => Test_utils.eq("File \"lib_js_test.res\", line 13, characters 38-45", "3", String(3))); + Mocha.test("anything_to_string", () => Test_utils.eq("File \"lib_js_test.res\", line 14, characters 38-45", "3", String(3))); }); /* Not a pure module */ diff --git a/tests/tests/src/lib_js_test.res b/tests/tests/src/lib_js_test.res index 2e43b55abb1..da9b374b583 100644 --- a/tests/tests/src/lib_js_test.res +++ b/tests/tests/src/lib_js_test.res @@ -7,6 +7,7 @@ let () = { Console.log(to_json_string(list{1, 2, 3})) Console.log("hey") } + @val external of_any: 'a => string = "String" describe(__MODULE__, () => { diff --git a/tests/tests/src/mario_game.res b/tests/tests/src/mario_game.res index 382a2ac60d5..590374c1b72 100644 --- a/tests/tests/src/mario_game.res +++ b/tests/tests/src/mario_game.res @@ -151,6 +151,7 @@ module Actors: { | SItem(item_typ) | SBlock(block_typ) } + module Dom_html = { type imageElement type canvasRenderingContext2D @@ -162,11 +163,14 @@ module Dom_html = { /* external createImg: (_ [@as "img"]) -> document -> imageElement = "createElement" [@@send] */ @send external createImg: (Dom.document, @as("img") _) => imageElement = "createElement" @val external requestAnimationFrame: (float => unit) => unit = "requestAnimationFrame" + @return(null_to_opt) @send external getElementById: (Dom.document, string) => option<Dom.element> = "getElementById" + @send external addEventListener: (Dom.document, string, Dom.event_like<'a> => bool, bool) => unit = "addEventListener" + @send external addEventListenerImg: (imageElement, string, Dom.event_like<'a> => bool, bool) => unit = "addEventListener" @@ -179,6 +183,7 @@ module Dom_html = { external elementToCanvasElement: Dom.element => canvasElement = "%identity" external windowToJsObj: Dom.window => {..} = "%identity" } + module Sprite: { open Actors @@ -635,6 +640,7 @@ module Sprite: { } } } + module Particle: { open Actors open Sprite @@ -784,6 +790,7 @@ module Particle: { update_pos(part) } } + module Object: { open Sprite open Actors @@ -801,6 +808,7 @@ module Object: { has_gravity: bool, speed: float, } + type obj = { params: obj_params, pos: xy, @@ -1378,6 +1386,7 @@ module Object: { | _ => list{} } } + module Draw: { let render: (Sprite.sprite, (float, float)) => unit @@ -1503,6 +1512,7 @@ module Draw: { let draw_background_color = canvas => throw(Failure("todo")) } + module Viewport: { open Actors @@ -1585,6 +1595,7 @@ module Viewport: { {...vpt, pos} } } + module Director: { let update_loop: ( Dom_html.canvasElement, @@ -2138,6 +2149,7 @@ module Director: { true } } + module Procedural_generator: { open Object open Actors @@ -2574,6 +2586,7 @@ module Procedural_generator: { /* Makes sure level map is uniquely generated at each call. */ let init = () => Random.self_init() } + module Main = { open Actors open Sprite diff --git a/tests/tests/src/method_name_test.mjs b/tests/tests/src/method_name_test.mjs index 6e9b82ce3d9..ab3dc16c209 100644 --- a/tests/tests/src/method_name_test.mjs +++ b/tests/tests/src/method_name_test.mjs @@ -32,7 +32,7 @@ function hg(x) { } Mocha.describe("Method_name_test", () => { - Mocha.test("method name test", () => Test_utils.eq("File \"method_name_test.res\", line 36, characters 7-14", 35, hg(h))); + Mocha.test("method name test", () => Test_utils.eq("File \"method_name_test.res\", line 37, characters 7-14", 35, hg(h))); }); export { diff --git a/tests/tests/src/method_name_test.res b/tests/tests/src/method_name_test.res index 16c34a208b6..56a3c98121b 100644 --- a/tests/tests/src/method_name_test.res +++ b/tests/tests/src/method_name_test.res @@ -17,6 +17,7 @@ let ff = (x, i, v) => { x["case__unsafe"](i) x["_open__"](3) } + /* x##__open 32; */ /* x##case_setUnsafe (i,v) */ /* do we need polymorphism over [case#=] diff --git a/tests/tests/src/module_alias_test.mjs b/tests/tests/src/module_alias_test.mjs index b474693bd0b..15ef5803772 100644 --- a/tests/tests/src/module_alias_test.mjs +++ b/tests/tests/src/module_alias_test.mjs @@ -17,7 +17,7 @@ let a = h.length({hd: 1, tl: {hd: 2, tl: {hd: 3, tl: /* [] */0}}}); Test_utils.eq("File \"module_alias_test.res\", line 25, characters 3-10", a, 3); Mocha.describe("Module_alias_test", () => { - Mocha.test("module_alias_test", () => Test_utils.eq("File \"module_alias_test.res\", line 28, characters 7-14", a, 3)); + Mocha.test("module_alias_test", () => Test_utils.eq("File \"module_alias_test.res\", line 29, characters 7-14", a, 3)); }); let N; diff --git a/tests/tests/src/module_alias_test.res b/tests/tests/src/module_alias_test.res index 8c3b3401cdb..f7f4748022e 100644 --- a/tests/tests/src/module_alias_test.res +++ b/tests/tests/src/module_alias_test.res @@ -23,6 +23,7 @@ let a = { } eq(__LOC__, a, 3) + describe(__MODULE__, () => { test("module_alias_test", () => { eq(__LOC__, a, 3) diff --git a/tests/tests/src/module_await_noop.res b/tests/tests/src/module_await_noop.res index dea1e0519b2..0de5220d693 100644 --- a/tests/tests/src/module_await_noop.res +++ b/tests/tests/src/module_await_noop.res @@ -10,6 +10,7 @@ module M: { // `module type of` doesn't strengthen the module's types module type T = module type of await M + module N: T = { type t = string let x = "" @@ -19,5 +20,6 @@ module N: T = { module G = () => { let y = 1 } + module A = G(await {}) let y = A.y diff --git a/tests/tests/src/module_missing_conversion.res b/tests/tests/src/module_missing_conversion.res index 8c80eb177cf..a906c45cb45 100644 --- a/tests/tests/src/module_missing_conversion.res +++ b/tests/tests/src/module_missing_conversion.res @@ -4,6 +4,7 @@ module XX = { include Array let f = x => x } + let u = [module(String: S)] let hh = { diff --git a/tests/tests/src/more_poly_variant_test.res b/tests/tests/src/more_poly_variant_test.res index e4c54eaf90c..16f10598788 100644 --- a/tests/tests/src/more_poly_variant_test.res +++ b/tests/tests/src/more_poly_variant_test.res @@ -43,6 +43,7 @@ let f1 = x => type myvariant2 = [#Tag3(int) | #Tag4 | myvariant] type x = [#a | #b | #c] + let f2 = x => switch x { | #...myvariant2 as x => diff --git a/tests/tests/src/name_mangle_test.mjs b/tests/tests/src/name_mangle_test.mjs index 35eb1259b52..13b5df5996d 100644 --- a/tests/tests/src/name_mangle_test.mjs +++ b/tests/tests/src/name_mangle_test.mjs @@ -83,19 +83,19 @@ function f12(x) { Mocha.describe("Name_mangle_test", () => { Mocha.test("name mangling test", () => { - Test_utils.eq("File \"name_mangle_test.res\", line 90, characters 7-14", f0({_open:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 91, characters 7-14", f1({_in:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 92, characters 7-14", f2({_MAX_LENGTH:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 93, characters 7-14", f3({_Capital:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 94, characters 7-14", f4({_open__:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 95, characters 7-14", f5({open__:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 96, characters 7-14", f6({ "_'x" :0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 97, characters 7-14", f7({_Capital__:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 98, characters 7-14", f8({_MAX__:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 99, characters 7-14", f9({__:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 100, characters 7-14", f10({__x:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 101, characters 7-14", f11({___:0}), 1); - Test_utils.eq("File \"name_mangle_test.res\", line 102, characters 7-14", f12({____:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 91, characters 7-14", f0({_open:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 92, characters 7-14", f1({_in:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 93, characters 7-14", f2({_MAX_LENGTH:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 94, characters 7-14", f3({_Capital:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 95, characters 7-14", f4({_open__:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 96, characters 7-14", f5({open__:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 97, characters 7-14", f6({ "_'x" :0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 98, characters 7-14", f7({_Capital__:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 99, characters 7-14", f8({_MAX__:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 100, characters 7-14", f9({__:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 101, characters 7-14", f10({__x:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 102, characters 7-14", f11({___:0}), 1); + Test_utils.eq("File \"name_mangle_test.res\", line 103, characters 7-14", f12({____:0}), 1); }); }); diff --git a/tests/tests/src/name_mangle_test.res b/tests/tests/src/name_mangle_test.res index f468ec600b8..5538d3bd0a0 100644 --- a/tests/tests/src/name_mangle_test.res +++ b/tests/tests/src/name_mangle_test.res @@ -78,6 +78,7 @@ let f11 = (x: {@set "___": int}) => { x["___"] = old + 1 x["___"] } + /* quad _ */ let f12 = (x: {@set "____": int}) => { let old = x["____"] diff --git a/tests/tests/src/nested_include.res b/tests/tests/src/nested_include.res index 8b1b457e120..93118b853a9 100644 --- a/tests/tests/src/nested_include.res +++ b/tests/tests/src/nested_include.res @@ -1,5 +1,6 @@ include { type t + include ( { let f = x => x diff --git a/tests/tests/src/nested_pattern_match_test.res b/tests/tests/src/nested_pattern_match_test.res index 73e1dae20cc..cd45e97334b 100644 --- a/tests/tests/src/nested_pattern_match_test.res +++ b/tests/tests/src/nested_pattern_match_test.res @@ -52,6 +52,7 @@ type t = { hi: int, lo: list<option<int>>, } + let f_opion = x => switch x { | {hi: 3, lo: list{None, None, Some(2), Some(1), Some(_), ..._}} => 2 diff --git a/tests/tests/src/node_assert.res b/tests/tests/src/node_assert.res index 517fb802898..019314f4011 100644 --- a/tests/tests/src/node_assert.res +++ b/tests/tests/src/node_assert.res @@ -2,5 +2,6 @@ @module("node:assert") external equal: ('a, 'a, ~message: string=?) => unit = "strictEqual" @module("node:assert") external deepEqual: ('a, 'a, ~message: string=?) => unit = "deepStrictEqual" @module("node:assert") external fail: (~message: string=?) => unit = "fail" + @module("node:assert") external throws: (unit => 'a, ~error: 'b=?, ~message: string=?) => unit = "throws" diff --git a/tests/tests/src/not_undefined_abbreviation_test.mjs b/tests/tests/src/not_undefined_abbreviation_test.mjs index 56fb3dbe1ce..2866e2f7ece 100644 --- a/tests/tests/src/not_undefined_abbreviation_test.mjs +++ b/tests/tests/src/not_undefined_abbreviation_test.mjs @@ -27,13 +27,13 @@ let refinedValue = {}; Mocha.describe("Not_undefined_abbreviation_test", () => { Mocha.test("a refined abstract type is not boxed in an option", () => { - Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 32, characters 7-14", refinedValue === refinedValue, true); - Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 33, characters 7-14", unwrap(refinedValue), "some"); - Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 34, characters 7-14", "none", "none"); + Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 33, characters 7-14", refinedValue === refinedValue, true); + Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 34, characters 7-14", unwrap(refinedValue), "some"); + Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 35, characters 7-14", "none", "none"); }); Mocha.test("a restated builtin keeps its payload kind", () => { - Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 38, characters 7-14", "count", "count"); - Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 39, characters 7-14", "name", "name"); + Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 39, characters 7-14", "count", "count"); + Test_utils.eq("File \"not_undefined_abbreviation_test.res\", line 40, characters 7-14", "name", "name"); }); }); diff --git a/tests/tests/src/not_undefined_abbreviation_test.res b/tests/tests/src/not_undefined_abbreviation_test.res index d9f978f1535..24fdd45bf72 100644 --- a/tests/tests/src/not_undefined_abbreviation_test.res +++ b/tests/tests/src/not_undefined_abbreviation_test.res @@ -19,6 +19,7 @@ let kind = value => } let wrap = (x: refined) => Some(x) + let unwrap = (x: option<refined>) => switch x { | Some(_) => "some" diff --git a/tests/tests/src/option_known_some_test.mjs b/tests/tests/src/option_known_some_test.mjs index c02790d3e4a..43236558430 100644 --- a/tests/tests/src/option_known_some_test.mjs +++ b/tests/tests/src/option_known_some_test.mjs @@ -39,20 +39,20 @@ function effectful() { Mocha.describe("Option_known_some_test", () => { Mocha.test("nested payload", () => { - Test_utils.eq("File \"option_known_some_test.res\", line 35, characters 7-14", 0, 0); - Test_utils.eq("File \"option_known_some_test.res\", line 36, characters 7-14", 3, 3); + Test_utils.eq("File \"option_known_some_test.res\", line 36, characters 7-14", 0, 0); + Test_utils.eq("File \"option_known_some_test.res\", line 37, characters 7-14", 3, 3); }); Mocha.test("polymorphic payload", () => { - Test_utils.eq("File \"option_known_some_test.res\", line 39, characters 7-14", [undefined], [undefined]); + Test_utils.eq("File \"option_known_some_test.res\", line 40, characters 7-14", [undefined], [undefined]); let v = Primitive_option.some(Primitive_option.some(undefined)); - Test_utils.eq("File \"option_known_some_test.res\", line 40, characters 7-14", [Primitive_option.some(undefined)], [Primitive_option.valFromOption(v)]); - Test_utils.eq("File \"option_known_some_test.res\", line 41, characters 7-14", [1], [1]); + Test_utils.eq("File \"option_known_some_test.res\", line 41, characters 7-14", [Primitive_option.some(undefined)], [Primitive_option.valFromOption(v)]); + Test_utils.eq("File \"option_known_some_test.res\", line 42, characters 7-14", [1], [1]); }); Mocha.test("payload with side effects", () => { - Test_utils.eq("File \"option_known_some_test.res\", line 44, characters 7-14", 0, effectful()); - Test_utils.eq("File \"option_known_some_test.res\", line 45, characters 7-14", 1, calls.contents); - Test_utils.eq("File \"option_known_some_test.res\", line 46, characters 7-14", 2, effectful()); - Test_utils.eq("File \"option_known_some_test.res\", line 47, characters 7-14", 2, calls.contents); + Test_utils.eq("File \"option_known_some_test.res\", line 45, characters 7-14", 0, effectful()); + Test_utils.eq("File \"option_known_some_test.res\", line 46, characters 7-14", 1, calls.contents); + Test_utils.eq("File \"option_known_some_test.res\", line 47, characters 7-14", 2, effectful()); + Test_utils.eq("File \"option_known_some_test.res\", line 48, characters 7-14", 2, calls.contents); }); }); diff --git a/tests/tests/src/option_known_some_test.res b/tests/tests/src/option_known_some_test.res index cad269d677e..f840ff90bdf 100644 --- a/tests/tests/src/option_known_some_test.res +++ b/tests/tests/src/option_known_some_test.res @@ -18,6 +18,7 @@ let poly = (y: 'a) => // A payload with side effects is evaluated once. let calls = ref(0) + let next = () => { calls := calls.contents + 1 calls.contents > 1 ? Some(calls.contents) : None diff --git a/tests/tests/src/option_repr_test.mjs b/tests/tests/src/option_repr_test.mjs index e7507c096f5..396f39955eb 100644 --- a/tests/tests/src/option_repr_test.mjs +++ b/tests/tests/src/option_repr_test.mjs @@ -136,20 +136,20 @@ function all_true(xs) { Mocha.describe("Option_repr_test", () => { Mocha.test("option comparison operations", () => { - Test_utils.ok("File \"option_repr_test.res\", line 117, characters 7-14", Primitive_object.lessthan(undefined, null)); - Test_utils.ok("File \"option_repr_test.res\", line 118, characters 7-14", !Primitive_object.greaterthan(undefined, null)); - Test_utils.ok("File \"option_repr_test.res\", line 119, characters 7-14", Primitive_object.greaterthan(null, undefined)); - Test_utils.ok("File \"option_repr_test.res\", line 120, characters 7-14", Primitive_object.lessthan(undefined, Primitive_option.some(undefined))); - Test_utils.ok("File \"option_repr_test.res\", line 121, characters 7-14", Primitive_object.greaterthan(Primitive_option.some(undefined), undefined)); + Test_utils.ok("File \"option_repr_test.res\", line 120, characters 7-14", Primitive_object.lessthan(undefined, null)); + Test_utils.ok("File \"option_repr_test.res\", line 121, characters 7-14", !Primitive_object.greaterthan(undefined, null)); + Test_utils.ok("File \"option_repr_test.res\", line 122, characters 7-14", Primitive_object.greaterthan(null, undefined)); + Test_utils.ok("File \"option_repr_test.res\", line 123, characters 7-14", Primitive_object.lessthan(undefined, Primitive_option.some(undefined))); + Test_utils.ok("File \"option_repr_test.res\", line 124, characters 7-14", Primitive_object.greaterthan(Primitive_option.some(undefined), undefined)); }); - Mocha.test("option greater than operations", () => Test_utils.ok("File \"option_repr_test.res\", line 125, characters 7-14", Stdlib_List.every({hd: Primitive_object.greaterthan(null, Primitive_option.some(undefined)) && Primitive_object.lessthan(Primitive_option.some(undefined), null), tl: /* [] */0}, x => x))); + Mocha.test("option greater than operations", () => Test_utils.ok("File \"option_repr_test.res\", line 128, characters 7-14", Stdlib_List.every({hd: Primitive_object.greaterthan(null, Primitive_option.some(undefined)) && Primitive_object.lessthan(Primitive_option.some(undefined), null), tl: /* [] */0}, x => x))); Mocha.test("option less than operations", () => { let xs_0 = Primitive_object.lessthan(Primitive_option.some(undefined), 3) && Primitive_object.greaterthan(3, Primitive_option.some(undefined)); let xs_1 = {hd: Primitive_object.lessthan(Primitive_option.some(undefined), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.greaterthan(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(undefined)), tl: {hd: Primitive_object.lessthan(Primitive_option.some(undefined), "3") && Primitive_object.greaterthan("3", Primitive_option.some(undefined)), tl: {hd: Primitive_object.lessthan(Primitive_option.some(undefined), true) && Primitive_object.greaterthan(true, Primitive_option.some(undefined)), tl: {hd: Primitive_object.lessthan(Primitive_option.some(undefined), false) && Primitive_object.greaterthan(false, Primitive_option.some(undefined)), tl: {hd: Primitive_object.lessthan(false, true) && Primitive_object.greaterthan(true, false), tl: {hd: Primitive_object.lessthan(false, true) && Primitive_object.greaterthan(true, false), tl: {hd: Primitive_object.lessthan(undefined, Primitive_option.some(undefined)) && Primitive_object.greaterthan(Primitive_option.some(undefined), undefined), tl: {hd: Primitive_object.lessthan(undefined, null) && Primitive_object.greaterthan(null, undefined), tl: {hd: ltx(undefined, x => x), tl: {hd: Primitive_object.lessthan(null, 3) && Primitive_object.greaterthan(3, null), tl: /* [] */0}}}}}}}}}}; let xs = {hd: xs_0, tl: xs_1}; - Test_utils.ok("File \"option_repr_test.res\", line 130, characters 6-13", Stdlib_List.every(xs, x => x)); + Test_utils.ok("File \"option_repr_test.res\", line 133, characters 6-13", Stdlib_List.every(xs, x => x)); }); - Mocha.test("option equality operations", () => Test_utils.ok("File \"option_repr_test.res\", line 149, characters 6-13", Stdlib_List.every({hd: true, tl: {hd: undefined !== null && null !== undefined, tl: {hd: Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)) && Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)), tl: {hd: Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))), tl: {hd: Primitive_object.notequal(Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined))), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.notequal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined)))), tl: /* [] */0}}}}}, x => x))); + Mocha.test("option equality operations", () => Test_utils.ok("File \"option_repr_test.res\", line 152, characters 6-13", Stdlib_List.every({hd: true, tl: {hd: undefined !== null && null !== undefined, tl: {hd: Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)) && Primitive_object.equal(Primitive_option.some(undefined), Primitive_option.some(undefined)), tl: {hd: Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.equal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(undefined))), tl: {hd: Primitive_object.notequal(Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined))), Primitive_option.some(Primitive_option.some(undefined))) && Primitive_object.notequal(Primitive_option.some(Primitive_option.some(undefined)), Primitive_option.some(Primitive_option.some(Primitive_option.some(undefined)))), tl: /* [] */0}}}}}, x => x))); }); let f7; diff --git a/tests/tests/src/option_repr_test.res b/tests/tests/src/option_repr_test.res index 9d3cb9eb298..60040932d8a 100644 --- a/tests/tests/src/option_repr_test.res +++ b/tests/tests/src/option_repr_test.res @@ -15,6 +15,7 @@ let f0 = x => type x = A(int, int) | None type x0 = Some(int) | None + let f1 = u => switch u { | A(_) => 0 @@ -44,6 +45,7 @@ let f4 = x => type t<'a> = | None | Some('a) + let f5 = a => Some(a) == None let f6 = a => Some(a) != None @@ -85,6 +87,7 @@ let length_10_id: list<int> = N.fromInitializer(~length=10, x => x) type xx<'a> = option<'a> = | None | Some('a) + let f13 = () => N.take(length_10_id, 8) == (Some(list{1, 2, 3}): option<_>) @val diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index 1b22efa6564..1718805e25c 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -26,6 +26,7 @@ let x29 = Some(JsError.make("")) let x30 = Some(ArrayBuffer.make(0)) let x31 = Some(ArrayBuffer.make(0)->DataView.fromBuffer) let x32 = Some((Map.make(): Map.t<string, string>)->Map.values) + let x33 = Some( ( AsyncIterator.make(_ => AsyncIterator.value(true)->Promise.resolve): AsyncIterator.t< diff --git a/tests/tests/src/optional_ffi_test.mjs b/tests/tests/src/optional_ffi_test.mjs index c29f82af0d6..fa5c7d26ba5 100644 --- a/tests/tests/src/optional_ffi_test.mjs +++ b/tests/tests/src/optional_ffi_test.mjs @@ -46,7 +46,7 @@ Mocha.describe("Optional_ffi_test", () => { Mocha.test("optional ffi test", () => { let u = hey(undefined, 3); let z = hey(5, 3); - Test_utils.eq("File \"optional_ffi_test.res\", line 41, characters 7-14", [ + Test_utils.eq("File \"optional_ffi_test.res\", line 44, characters 7-14", [ u, z ], [ @@ -79,7 +79,7 @@ Mocha.describe("Optional_ffi_test", () => { pair2_0, pair2_1 ]; - Test_utils.eq("File \"optional_ffi_test.res\", line 48, characters 7-14", pair, [ + Test_utils.eq("File \"optional_ffi_test.res\", line 51, characters 7-14", pair, [ [ 4, 1 @@ -89,7 +89,7 @@ Mocha.describe("Optional_ffi_test", () => { 1 ] ]); - Test_utils.eq("File \"optional_ffi_test.res\", line 49, characters 7-14", pair2, [ + Test_utils.eq("File \"optional_ffi_test.res\", line 52, characters 7-14", pair2, [ [ 4, 1 @@ -104,7 +104,7 @@ Mocha.describe("Optional_ffi_test", () => { "name4", pair_1$1 ]; - Test_utils.eq("File \"optional_ffi_test.res\", line 53, characters 7-14", pair$1, [ + Test_utils.eq("File \"optional_ffi_test.res\", line 56, characters 7-14", pair$1, [ "name4", "name4" ]); diff --git a/tests/tests/src/optional_ffi_test.res b/tests/tests/src/optional_ffi_test.res index 6a22bb1a680..cc1d5776bcc 100644 --- a/tests/tests/src/optional_ffi_test.res +++ b/tests/tests/src/optional_ffi_test.res @@ -7,9 +7,11 @@ function hey(x, y) { return x + y; } `) + @val external xx: (~x: int=?, ~y: int, unit) => int = "hey" let counter = ref(0) + let side_effect = x => { x.contents = x.contents + 1 x.contents @@ -20,6 +22,7 @@ let bug_to_fix = (f, x) => xx(~x=f(x), ~y=3, ()) /* : [f x] is done once */ let bug_to_fix2 = (f, x) => xx(~x=?f(x), ~y=3, ()) /* : [f x] is done once */ let counter2 = ref(0) + let side_effect2 = x => { x.contents = x.contents + 1 Some(x.contents) diff --git a/tests/tests/src/partial_application_eval_test.mjs b/tests/tests/src/partial_application_eval_test.mjs index 7c865f70985..f7b49025154 100644 --- a/tests/tests/src/partial_application_eval_test.mjs +++ b/tests/tests/src/partial_application_eval_test.mjs @@ -51,10 +51,10 @@ Mocha.describe("Partial_application_eval_test", () => { return calls; }; let arg = next(); - Test_utils.eq("File \"partial_application_eval_test.res\", line 35, characters 7-14", 1, calls); - Test_utils.eq("File \"partial_application_eval_test.res\", line 36, characters 7-14", 4, add(arg, 1, 2)); + Test_utils.eq("File \"partial_application_eval_test.res\", line 36, characters 7-14", 1, calls); Test_utils.eq("File \"partial_application_eval_test.res\", line 37, characters 7-14", 4, add(arg, 1, 2)); - Test_utils.eq("File \"partial_application_eval_test.res\", line 38, characters 7-14", 1, calls); + Test_utils.eq("File \"partial_application_eval_test.res\", line 38, characters 7-14", 4, add(arg, 1, 2)); + Test_utils.eq("File \"partial_application_eval_test.res\", line 39, characters 7-14", 1, calls); }); Mocha.test("the callee is evaluated once", () => { let calls = 0; @@ -65,36 +65,36 @@ Mocha.describe("Partial_application_eval_test", () => { let func = getAdd(); func(1, 2, 3); func(1, 2, 3); - Test_utils.eq("File \"partial_application_eval_test.res\", line 50, characters 7-14", 1, calls); + Test_utils.eq("File \"partial_application_eval_test.res\", line 51, characters 7-14", 1, calls); }); Mocha.test("a closure argument is created once", () => { let arg = x => x + 1 | 0; - Test_utils.ok("File \"partial_application_eval_test.res\", line 55, characters 7-14", arg === arg); + Test_utils.ok("File \"partial_application_eval_test.res\", line 56, characters 7-14", arg === arg); }); Mocha.test("a constant tuple argument is created once", () => { let arg = [ 1, 2 ]; - Test_utils.ok("File \"partial_application_eval_test.res\", line 60, characters 7-14", arg === arg); + Test_utils.ok("File \"partial_application_eval_test.res\", line 61, characters 7-14", arg === arg); }); Mocha.test("a nested None argument is created once", () => { let arg = Primitive_option.some(undefined); - Test_utils.ok("File \"partial_application_eval_test.res\", line 65, characters 7-14", arg === arg); + Test_utils.ok("File \"partial_application_eval_test.res\", line 66, characters 7-14", arg === arg); let arg$1 = Primitive_option.some(Primitive_option.some(undefined)); - Test_utils.ok("File \"partial_application_eval_test.res\", line 67, characters 7-14", arg$1 === arg$1); + Test_utils.ok("File \"partial_application_eval_test.res\", line 68, characters 7-14", arg$1 === arg$1); }); Mocha.test("a top-level partial application creates its arguments once", () => { - Test_utils.ok("File \"partial_application_eval_test.res\", line 71, characters 7-14", topLevelTuple(0) === topLevelTuple(0)); - Test_utils.ok("File \"partial_application_eval_test.res\", line 72, characters 7-14", topLevelNone(0) === topLevelNone(0)); - Test_utils.ok("File \"partial_application_eval_test.res\", line 73, characters 7-14", topLevelNestedNone(0) === topLevelNestedNone(0)); + Test_utils.ok("File \"partial_application_eval_test.res\", line 72, characters 7-14", topLevelTuple(0) === topLevelTuple(0)); + Test_utils.ok("File \"partial_application_eval_test.res\", line 73, characters 7-14", topLevelNone(0) === topLevelNone(0)); + Test_utils.ok("File \"partial_application_eval_test.res\", line 74, characters 7-14", topLevelNestedNone(0) === topLevelNestedNone(0)); }); Mocha.test("an external value is read once", () => { let arg = partialApplicationValue; - Test_utils.eq("File \"partial_application_eval_test.res\", line 78, characters 7-14", 3, add(arg, 1, 1)); Test_utils.eq("File \"partial_application_eval_test.res\", line 79, characters 7-14", 3, add(arg, 1, 1)); + Test_utils.eq("File \"partial_application_eval_test.res\", line 80, characters 7-14", 3, add(arg, 1, 1)); }); - Mocha.test("a partial application of values stays polymorphic", () => Test_utils.eq("File \"partial_application_eval_test.res\", line 84, characters 7-14", 2, 2)); + Mocha.test("a partial application of values stays polymorphic", () => Test_utils.eq("File \"partial_application_eval_test.res\", line 85, characters 7-14", 2, 2)); Mocha.test("callee and arguments are evaluated left to right", () => { let log = []; let getAdd = () => { @@ -108,17 +108,17 @@ Mocha.describe("Partial_application_eval_test", () => { let func = getAdd(); let arg$1 = arg("a", 1); let arg$2 = arg("b", 2); - Test_utils.eq("File \"partial_application_eval_test.res\", line 98, characters 7-14", [ + Test_utils.eq("File \"partial_application_eval_test.res\", line 99, characters 7-14", [ "callee", "a", "b" ], log); - Test_utils.eq("File \"partial_application_eval_test.res\", line 99, characters 7-14", 6, func(arg$1, arg$2, 3)); + Test_utils.eq("File \"partial_application_eval_test.res\", line 100, characters 7-14", 6, func(arg$1, arg$2, 3)); }); Mocha.test("an awaited argument stays in the async function", async () => { let arg = await Promise.resolve(1); - Test_utils.eq("File \"partial_application_eval_test.res\", line 104, characters 7-14", 4, add(arg, 1, 2)); - return Test_utils.eq("File \"partial_application_eval_test.res\", line 105, characters 7-14", 6, add(arg, 2, 3)); + Test_utils.eq("File \"partial_application_eval_test.res\", line 105, characters 7-14", 4, add(arg, 1, 2)); + return Test_utils.eq("File \"partial_application_eval_test.res\", line 106, characters 7-14", 6, add(arg, 2, 3)); }); }); diff --git a/tests/tests/src/partial_application_eval_test.res b/tests/tests/src/partial_application_eval_test.res index d9ac14f65a9..50a7b9c2c53 100644 --- a/tests/tests/src/partial_application_eval_test.res +++ b/tests/tests/src/partial_application_eval_test.res @@ -17,6 +17,7 @@ Object.defineProperty(globalThis, "partialApplicationValue", { configurable: true, }) `) + @val external partialApplicationValue: int = "partialApplicationValue" // At the top level, the bound argument is captured by the function only. diff --git a/tests/tests/src/pipe_send_readline.res b/tests/tests/src/pipe_send_readline.res index f58e460005b..45f7bd78b85 100644 --- a/tests/tests/src/pipe_send_readline.res +++ b/tests/tests/src/pipe_send_readline.res @@ -1,4 +1,5 @@ type readline + @send external on: ( readline as 'self, @@ -8,6 +9,7 @@ external on: ( | #close(unit => unit) ], ) => 'self = "on" + let u = rl => rl->on(#line(x => Console.log(x)))->on(#close(() => Console.log("finished"))) @send external send: ({"hi": int} as 'self, string) => 'self = "send" diff --git a/tests/tests/src/pm_opt_fields_mixed_test.mjs b/tests/tests/src/pm_opt_fields_mixed_test.mjs index 7635a10af32..e1f108cefb5 100644 --- a/tests/tests/src/pm_opt_fields_mixed_test.mjs +++ b/tests/tests/src/pm_opt_fields_mixed_test.mjs @@ -210,145 +210,145 @@ function optionString(o) { Mocha.describe("Pm_opt_fields_mixed_test", () => { Mocha.test("value pattern, then ?None on the same field", () => { - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 138, characters 7-14", valueThenNone({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 139, characters 7-14", valueThenNone({ x: 1 }), "x is 1"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 139, characters 7-14", valueThenNone({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 140, characters 7-14", valueThenNone({ y: 2 }), "y is 2"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 140, characters 7-14", valueThenNone({}), "no x"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 141, characters 7-14", valueThenNone({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 141, characters 7-14", valueThenNone({}), "no x"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 142, characters 7-14", valueThenNone({ x: 3 }), "other"); }); Mocha.test("?None, then a value pattern on the same field", () => { - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 144, characters 7-14", noneThenValue({}), "no x"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 145, characters 7-14", noneThenValue({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 145, characters 7-14", noneThenValue({}), "no x"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 146, characters 7-14", noneThenValue({ x: 1 }), "x is 1"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 146, characters 7-14", noneThenValue({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 147, characters 7-14", noneThenValue({ x: 2 }), "some x"); }); Mocha.test("?Some(v), then a value pattern on the same field", () => { - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 149, characters 7-14", someThenValue({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 150, characters 7-14", someThenValue({ x: 7, y: 1 }), 7); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 150, characters 7-14", someThenValue({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 151, characters 7-14", someThenValue({ x: 5 }), 100); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 151, characters 7-14", someThenValue({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 152, characters 7-14", someThenValue({ x: 5, y: 2 }), 100); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 152, characters 7-14", someThenValue({}), 0); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 153, characters 7-14", someThenValue({}), 0); }); Mocha.test("dict patterns", () => { - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 155, characters 7-14", dictValueThenNone({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 156, characters 7-14", dictValueThenNone({ x: 1 }), "x is 1"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 156, characters 7-14", dictValueThenNone({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 157, characters 7-14", dictValueThenNone({ y: 2 }), "y is 2"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 157, characters 7-14", dictValueThenNone({}), "no x"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 158, characters 7-14", dictValueThenNone({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 158, characters 7-14", dictValueThenNone({}), "no x"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 159, characters 7-14", dictValueThenNone({ x: 3 }), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 159, characters 7-14", dictSomeThenValue({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 160, characters 7-14", dictSomeThenValue({ x: 7, y: 1 }), 7); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 160, characters 7-14", dictSomeThenValue({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 161, characters 7-14", dictSomeThenValue({ x: 5 }), 100); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 161, characters 7-14", dictSomeThenValue({}), 0); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 162, characters 7-14", dictSomeThenValue({}), 0); }); Mocha.test("untagged variant cases", () => { - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 164, characters 7-14", allPayloadCases({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 165, characters 7-14", allPayloadCases({ p: "a" }), "string"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 165, characters 7-14", allPayloadCases({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 166, characters 7-14", allPayloadCases({ p: 1 }), "number"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 166, characters 7-14", allPayloadCases({}), "absent"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 167, characters 7-14", allPayloadCasesWithConstant({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 167, characters 7-14", allPayloadCases({}), "absent"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 168, characters 7-14", allPayloadCasesWithConstant({ c: "a" }), "string"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 168, characters 7-14", allPayloadCasesWithConstant({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 169, characters 7-14", allPayloadCasesWithConstant({ c: 1 }), "number"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 169, characters 7-14", allPayloadCasesWithConstant({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 170, characters 7-14", allPayloadCasesWithConstant({ c: "A" }), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 170, characters 7-14", allPayloadCasesWithConstant({}), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 171, characters 7-14", sharedCaseName([ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 171, characters 7-14", allPayloadCasesWithConstant({}), "other"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 172, characters 7-14", sharedCaseName([ { x: "a" }, {} ]), "first"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 172, characters 7-14", sharedCaseName([ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 173, characters 7-14", sharedCaseName([ {}, { x: "a" } ]), "second"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 173, characters 7-14", sharedCaseName([ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 174, characters 7-14", sharedCaseName([ {}, { x: 1 } ]), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 174, characters 7-14", sharedCaseName([ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 175, characters 7-14", sharedCaseName([ {}, {} ]), "other"); }); Mocha.test("a field whose type has an undefined case", () => { - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 177, characters 7-14", stringOrOther({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 178, characters 7-14", stringOrOther({ u: "a" }), "a"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 178, characters 7-14", stringOrOther({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 179, characters 7-14", stringOrOther({ u: null }), "null"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 179, characters 7-14", stringOrOther({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 180, characters 7-14", stringOrOther({ u: Primitive_option.some(undefinedCase.contents) }), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 180, characters 7-14", stringOrOther({}), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 181, characters 7-14", objectOrOther({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 181, characters 7-14", stringOrOther({}), "other"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 182, characters 7-14", objectOrOther({ u: {} }), "object"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 182, characters 7-14", objectOrOther({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 183, characters 7-14", objectOrOther({ u: Primitive_option.some(undefinedCase.contents) }), "undefined"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 183, characters 7-14", objectOrOther({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 184, characters 7-14", objectOrOther({ u: "a" }), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 184, characters 7-14", objectOrOther({}), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 185, characters 7-14", objectOnly({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 185, characters 7-14", objectOrOther({}), "other"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 186, characters 7-14", objectOnly({ u: {} }), "object"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 186, characters 7-14", objectOnly({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 187, characters 7-14", objectOnly({ u: Primitive_option.some(undefinedCase.contents) }), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 187, characters 7-14", objectOnly({}), "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 188, characters 7-14", boundPayload({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 188, characters 7-14", objectOnly({}), "other"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 189, characters 7-14", boundPayload({ u: Primitive_option.some(undefinedCase.contents) }), "undefined"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 189, characters 7-14", boundPayload({ + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 190, characters 7-14", boundPayload({ u: "a" }), "other value"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 190, characters 7-14", boundPayload({}), "absent"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 191, characters 7-14", boundPayload({}), "absent"); }); Mocha.test("options matched against constants", () => { - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 193, characters 7-14", 1 !== 1 ? "other" : "one", "one"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 194, characters 7-14", 2 !== 1 ? "other" : "one", "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 195, characters 7-14", undefined !== 1 ? "other" : "one", "other"); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 196, characters 7-14", optionString("x"), 1); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 197, characters 7-14", optionString("y"), 2); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 198, characters 7-14", optionString("z"), 3); - Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 199, characters 7-14", optionString(undefined), 3); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 194, characters 7-14", 1 !== 1 ? "other" : "one", "one"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 195, characters 7-14", 2 !== 1 ? "other" : "one", "other"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 196, characters 7-14", undefined !== 1 ? "other" : "one", "other"); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 197, characters 7-14", optionString("x"), 1); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 198, characters 7-14", optionString("y"), 2); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 199, characters 7-14", optionString("z"), 3); + Test_utils.eq("File \"pm_opt_fields_mixed_test.res\", line 200, characters 7-14", optionString(undefined), 3); }); }); diff --git a/tests/tests/src/pm_opt_fields_mixed_test.res b/tests/tests/src/pm_opt_fields_mixed_test.res index 9696695e10c..2fa9292d5d5 100644 --- a/tests/tests/src/pm_opt_fields_mixed_test.res +++ b/tests/tests/src/pm_opt_fields_mixed_test.res @@ -84,6 +84,7 @@ type withUndefined = | @as(null) Null | String(string) | Object(dict<string>) + type withUndefinedField = {u?: withUndefined} // Through a ref, so that `Some(Undefined)` is built at runtime diff --git a/tests/tests/src/poly_variant_test.mjs b/tests/tests/src/poly_variant_test.mjs index 18a6f648931..9a36f1e1d54 100644 --- a/tests/tests/src/poly_variant_test.mjs +++ b/tests/tests/src/poly_variant_test.mjs @@ -52,32 +52,32 @@ let u = { Mocha.describe("Poly_variant_test", () => { Mocha.test("poly variant string marshalling", () => { - Test_utils.eq("File \"poly_variant_test.res\", line 70, characters 7-14", vv, [ + Test_utils.eq("File \"poly_variant_test.res\", line 73, characters 7-14", vv, [ 3, 0, 4 ]); - Test_utils.eq("File \"poly_variant_test.res\", line 71, characters 7-14", [ + Test_utils.eq("File \"poly_variant_test.res\", line 74, characters 7-14", [ hey_int(5), hey_int(6) ], [ 5, 6 ]); - Test_utils.eq("File \"poly_variant_test.res\", line 72, characters 7-14", uu, [ + Test_utils.eq("File \"poly_variant_test.res\", line 75, characters 7-14", uu, [ "on_open", "on_closed", "in" ]); }); - Mocha.test("poly variant function application", () => Test_utils.eq("File \"poly_variant_test.res\", line 76, characters 7-14", v, "on_closed")); + Mocha.test("poly variant function application", () => Test_utils.eq("File \"poly_variant_test.res\", line 79, characters 7-14", v, "on_closed")); Mocha.test("poly variant pattern matching", () => { - Test_utils.eq("File \"poly_variant_test.res\", line 80, characters 7-14", 2, 2); - Test_utils.eq("File \"poly_variant_test.res\", line 81, characters 7-14", 3, p_is_int_test(u)); + Test_utils.eq("File \"poly_variant_test.res\", line 83, characters 7-14", 2, 2); + Test_utils.eq("File \"poly_variant_test.res\", line 84, characters 7-14", 3, p_is_int_test(u)); }); Mocha.test("emoji poly variant conversion", () => { - Test_utils.eq("File \"poly_variant_test.res\", line 85, characters 7-14", "🚀", "🚀"); - Test_utils.eq("File \"poly_variant_test.res\", line 86, characters 7-14", "🔥", "🔥"); + Test_utils.eq("File \"poly_variant_test.res\", line 88, characters 7-14", "🚀", "🚀"); + Test_utils.eq("File \"poly_variant_test.res\", line 89, characters 7-14", "🔥", "🔥"); }); }); diff --git a/tests/tests/src/poly_variant_test.res b/tests/tests/src/poly_variant_test.res index 9367f10eb26..2d33f66ccca 100644 --- a/tests/tests/src/poly_variant_test.res +++ b/tests/tests/src/poly_variant_test.res @@ -28,6 +28,7 @@ type u = [ | #on_open | #in_ ] + /* [@as "in"] TODO: warning test */ /* indeed we have a warning here */ /* TODO: add warning test @@ -57,11 +58,13 @@ let uu = [ let vv = [test_int_type(#on_open), test_int_type(#on_closed), test_int_type(#in_)] let option = #on_closed let v = test_string_type(~flag=option) + let p_is_int_test = x => switch x { | #a => 2 | #b(_) => 3 } + let u = #b(2) type t = [#"🚀" | #"🔥"] diff --git a/tests/tests/src/polyvar_test.res b/tests/tests/src/polyvar_test.res index 35391c91745..8d4e4c9abc1 100644 --- a/tests/tests/src/polyvar_test.res +++ b/tests/tests/src/polyvar_test.res @@ -19,4 +19,5 @@ let ff = { "A" } } + let () = Console.log((f(#A), ff, f1(#A))) diff --git a/tests/tests/src/ppx_apply_test.mjs b/tests/tests/src/ppx_apply_test.mjs index 197070a3efc..bf331accc4b 100644 --- a/tests/tests/src/ppx_apply_test.mjs +++ b/tests/tests/src/ppx_apply_test.mjs @@ -11,15 +11,15 @@ function unary(a) { return a + 3 | 0; } -Mocha.test("ppx_apply_test_unary", () => Test_utils.eq("File \"ppx_apply_test.res\", line 12, characters 5-12", 3, 3)); +Mocha.test("ppx_apply_test_unary", () => Test_utils.eq("File \"ppx_apply_test.res\", line 13, characters 5-12", 3, 3)); function h(a) { return globalThis.xx(a); } Mocha.describe("Ppx_apply_test", () => { - Mocha.test("function_application_test", () => Test_utils.eq("File \"ppx_apply_test.res\", line 25, characters 7-14", 3, 3)); - Mocha.test("external_function_test", () => Test_utils.ok("File \"ppx_apply_test.res\", line 30, characters 7-14", true)); + Mocha.test("function_application_test", () => Test_utils.eq("File \"ppx_apply_test.res\", line 26, characters 7-14", 3, 3)); + Mocha.test("external_function_test", () => Test_utils.ok("File \"ppx_apply_test.res\", line 31, characters 7-14", true)); }); let u = 3; diff --git a/tests/tests/src/ppx_apply_test.res b/tests/tests/src/ppx_apply_test.res index c35e66ac76a..0e4c52a9250 100644 --- a/tests/tests/src/ppx_apply_test.res +++ b/tests/tests/src/ppx_apply_test.res @@ -8,6 +8,7 @@ let nullary = () => 3 let unary = a => a + 3 let xx = unary(3) + test("ppx_apply_test_unary", () => { eq(__LOC__, u, 3) }) diff --git a/tests/tests/src/pq_test.res b/tests/tests/src/pq_test.res index 4e1e0eec286..397a7836cd7 100644 --- a/tests/tests/src/pq_test.res +++ b/tests/tests/src/pq_test.res @@ -2,6 +2,7 @@ module PrioQueue = { type priority = int type rec queue<'a> = Empty | Node(priority, 'a, queue<'a>, queue<'a>) let empty = Empty + let rec insert = (queue, prio, elt) => switch queue { | Empty => Node(prio, elt, Empty, Empty) @@ -12,7 +13,9 @@ module PrioQueue = { Node(p, e, insert(right, prio, elt), left) } } + exception Queue_is_empty + let rec remove_top = x => switch x { | Empty => throw(Queue_is_empty) @@ -25,6 +28,7 @@ module PrioQueue = { Node(rprio, relt, left, remove_top(right)) } } + let extract = x => switch x { | Empty => throw(Queue_is_empty) diff --git a/tests/tests/src/pr6726.res b/tests/tests/src/pr6726.res index 56d2658e804..e9e69c58d63 100644 --- a/tests/tests/src/pr6726.res +++ b/tests/tests/src/pr6726.res @@ -12,6 +12,7 @@ module ExtUnixAll = { external unused: unit => unit = "%identity" + module BigEndian = { let get_uint8 = (str, off) => 33 } @@ -23,9 +24,11 @@ module ExtUnix = { module Test = { open ExtUnix.All + let test_endian_string = x => { module B = BigEndian B.get_uint8(x, 0) } + let v = test_endian_string(1) } diff --git a/tests/tests/src/raw_pure_test.res b/tests/tests/src/raw_pure_test.res index 4dca38755be..9fae568ab8a 100644 --- a/tests/tests/src/raw_pure_test.res +++ b/tests/tests/src/raw_pure_test.res @@ -23,6 +23,7 @@ let x3 = %raw(`/ghoghos/`) let f = %raw("/*hello*/ 0 ") let hh = List.length + let f = x => { ignore( %raw("//eslint-disable diff --git a/tests/tests/src/rbset.mjs b/tests/tests/src/rbset.mjs index b68d1686331..912a31fc024 100644 --- a/tests/tests/src/rbset.mjs +++ b/tests/tests/src/rbset.mjs @@ -259,7 +259,7 @@ function unbalanced_left(x) { RE_EXN_ID: "Assert_failure", _1: [ "rbset.res", - 64, + 65, 9 ], Error: new Error() @@ -325,7 +325,7 @@ function unbalanced_right(x) { RE_EXN_ID: "Assert_failure", _1: [ "rbset.res", - 75, + 76, 9 ], Error: new Error() @@ -547,7 +547,7 @@ function remove_min(x) { RE_EXN_ID: "Assert_failure", _1: [ "rbset.res", - 138, + 140, 4 ], Error: new Error() @@ -583,7 +583,7 @@ function remove_min(x) { RE_EXN_ID: "Assert_failure", _1: [ "rbset.res", - 138, + 140, 4 ], Error: new Error() diff --git a/tests/tests/src/rbset.res b/tests/tests/src/rbset.res index e4311d1386c..b1e14034e15 100644 --- a/tests/tests/src/rbset.res +++ b/tests/tests/src/rbset.res @@ -1,5 +1,6 @@ type elt = int type color = Black | Red + type rec t = | Node(color, t, elt, t) | Empty @@ -94,6 +95,7 @@ let lbalance = (x1, x2, x3) => } | _ => Node(Black, x1, x2, x3) } + let rbalance = (x1, x2, x3) => switch (x1, x2, x3) { | (a, x, Node(Red, Node(Red, b, y, c), z, d)) => diff --git a/tests/tests/src/rec_fun_test.mjs b/tests/tests/src/rec_fun_test.mjs index 4cfb106a307..44effd39f1c 100644 --- a/tests/tests/src/rec_fun_test.mjs +++ b/tests/tests/src/rec_fun_test.mjs @@ -34,7 +34,7 @@ Primitive_object.updateDummy(x, {hd: 1, tl: y}); Primitive_object.updateDummy(y, {hd: 2, tl: x}); Mocha.describe("Rec_fun_test", () => { - Mocha.test("called contents", () => Test_utils.eq("File \"rec_fun_test.res\", line 25, characters 35-42", 2, called.contents)); + Mocha.test("called contents", () => Test_utils.eq("File \"rec_fun_test.res\", line 26, characters 35-42", 2, called.contents)); }); export { diff --git a/tests/tests/src/rec_fun_test.res b/tests/tests/src/rec_fun_test.res index 4ddb5dd04fa..ee8293d16bd 100644 --- a/tests/tests/src/rec_fun_test.res +++ b/tests/tests/src/rec_fun_test.res @@ -2,6 +2,7 @@ open Mocha open Test_utils let called = ref(0) + /* function hoisting prevent the toplevel bug */ let g = () => { let rec v = ref(next) diff --git a/tests/tests/src/rec_module_test.mjs b/tests/tests/src/rec_module_test.mjs index 56ce1edb560..292162be152 100644 --- a/tests/tests/src/rec_module_test.mjs +++ b/tests/tests/src/rec_module_test.mjs @@ -74,7 +74,7 @@ let Even = {}; let Odd = {}; Mocha.describe("Rec_module_test", () => { - Mocha.test("test1", () => Test_utils.eq("File \"rec_module_test.res\", line 71, characters 7-14", [ + Mocha.test("test1", () => Test_utils.eq("File \"rec_module_test.res\", line 73, characters 7-14", [ true, true, false, @@ -85,11 +85,11 @@ Mocha.describe("Rec_module_test", () => { B.odd(2), odd$1(4) ])); - Mocha.test("test2", () => Test_utils.eq("File \"rec_module_test.res\", line 75, characters 7-14", y(), 32)); - Mocha.test("test3", () => Test_utils.eq("File \"rec_module_test.res\", line 79, characters 7-14", x(), 35)); - Mocha.test("test4 - A.even", () => Test_utils.eq("File \"rec_module_test.res\", line 83, characters 7-14", true, A.even(2))); - Mocha.test("test4 - AA.even", () => Test_utils.eq("File \"rec_module_test.res\", line 87, characters 7-14", true, even$1(4))); - Mocha.test("test5", () => Test_utils.eq("File \"rec_module_test.res\", line 91, characters 7-14", false, B.odd(2))); + Mocha.test("test2", () => Test_utils.eq("File \"rec_module_test.res\", line 77, characters 7-14", y(), 32)); + Mocha.test("test3", () => Test_utils.eq("File \"rec_module_test.res\", line 81, characters 7-14", x(), 35)); + Mocha.test("test4 - A.even", () => Test_utils.eq("File \"rec_module_test.res\", line 85, characters 7-14", true, A.even(2))); + Mocha.test("test4 - AA.even", () => Test_utils.eq("File \"rec_module_test.res\", line 89, characters 7-14", true, even$1(4))); + Mocha.test("test5", () => Test_utils.eq("File \"rec_module_test.res\", line 93, characters 7-14", false, B.odd(2))); }); let effects = { diff --git a/tests/tests/src/rec_module_test.res b/tests/tests/src/rec_module_test.res index 4480d06444a..0e1412cfcd3 100644 --- a/tests/tests/src/rec_module_test.res +++ b/tests/tests/src/rec_module_test.res @@ -38,6 +38,7 @@ module rec AA: { } else { BB.odd(n - 1) } + let x = () => BB.y() + 3 } and BB: { @@ -52,6 +53,7 @@ and BB: { } else { AA.even(n - 1) } + let y = () => 32 } diff --git a/tests/tests/src/record_extension_test.mjs b/tests/tests/src/record_extension_test.mjs index 16b6161f820..82b979fc626 100644 --- a/tests/tests/src/record_extension_test.mjs +++ b/tests/tests/src/record_extension_test.mjs @@ -106,9 +106,9 @@ function u(f) { } } -Mocha.describe("File \"record_extension_test.res\", line 71, characters 9-16", () => { +Mocha.describe("File \"record_extension_test.res\", line 72, characters 9-16", () => { Mocha.test("record extension with exceptions", () => { - Test_utils.eq("File \"record_extension_test.res\", line 73, characters 7-14", u(() => { + Test_utils.eq("File \"record_extension_test.res\", line 74, characters 7-14", u(() => { throw { RE_EXN_ID: A, name: 1, @@ -116,7 +116,7 @@ Mocha.describe("File \"record_extension_test.res\", line 71, characters 9-16", ( Error: new Error() }; }), 2); - Test_utils.eq("File \"record_extension_test.res\", line 74, characters 7-14", u(() => { + Test_utils.eq("File \"record_extension_test.res\", line 75, characters 7-14", u(() => { throw { RE_EXN_ID: B, _1: 1, @@ -124,14 +124,14 @@ Mocha.describe("File \"record_extension_test.res\", line 71, characters 9-16", ( Error: new Error() }; }), 3); - Test_utils.eq("File \"record_extension_test.res\", line 75, characters 7-14", u(() => { + Test_utils.eq("File \"record_extension_test.res\", line 76, characters 7-14", u(() => { throw { RE_EXN_ID: C, name: 4, Error: new Error() }; }), 4); - Test_utils.eq("File \"record_extension_test.res\", line 76, characters 7-14", u(() => { + Test_utils.eq("File \"record_extension_test.res\", line 77, characters 7-14", u(() => { throw { RE_EXN_ID: D, code: 1, @@ -139,7 +139,7 @@ Mocha.describe("File \"record_extension_test.res\", line 71, characters 9-16", ( Error: new Error() }; }), 2); - Test_utils.eq("File \"record_extension_test.res\", line 77, characters 7-14", u(() => { + Test_utils.eq("File \"record_extension_test.res\", line 78, characters 7-14", u(() => { throw { RE_EXN_ID: D, code: 3, diff --git a/tests/tests/src/record_extension_test.res b/tests/tests/src/record_extension_test.res index ef4688c25db..bc4e92dda89 100644 --- a/tests/tests/src/record_extension_test.res +++ b/tests/tests/src/record_extension_test.res @@ -38,6 +38,7 @@ type t2 = | B | C({x: int, y: string}) | D({w: int}) + let f2 = x => switch x { | D(_) diff --git a/tests/tests/src/record_name_test.res b/tests/tests/src/record_name_test.res index 4d5b6bd9251..4fd6c534ad4 100644 --- a/tests/tests/src/record_name_test.res +++ b/tests/tests/src/record_name_test.res @@ -62,10 +62,12 @@ type t6 = { @as("x") x: int, @as("y") y: int, } + /* allow this case */ @obj external ff: (~x: int, ~h: @as(3) _) => _ = "" @obj external ff2: (~x: int, ~h: @as(3) _) => {"x": int} = "" + let u = () => { ignore(ff(~x=3)) ff2(~x=22) diff --git a/tests/tests/src/record_regression.res b/tests/tests/src/record_regression.res index 31f33454631..c90fb28c1e5 100644 --- a/tests/tests/src/record_regression.res +++ b/tests/tests/src/record_regression.res @@ -97,11 +97,13 @@ let pm0 = switch ir0 { | V0({x0, x3}) => (x0, x3) | V1({y0, y1}) => (y0, y1) } + let pm1 = switch ir1 { | V0({x0, x1, x3}) => (x0, x1, x3) | V0({x0, x1: ?None, x3}) => (x0, "n/a", x3) | V1({y0, y1}) => (y0, "n/a", y1) } + let pm2 = switch ir2 { | V0({x0, x1, x2, x3}) => (x0, x1, x2, x3) | V0({x0, x1: ?None, x2, x3}) => (x0, "n/a", x2, x3) @@ -109,6 +111,7 @@ let pm2 = switch ir2 { | V0({x0, x1: ?None, x2: ?None, x3}) => (x0, "n/a", 0, x3) | V1({y0, y1}) => (y0, "n/a", 0, y1) } + let inlinedRecord = ir => switch ir { | V0({x0, x1: ?Some("x1"), x2, x3}) => (x0, "x1", x2, x3) @@ -119,6 +122,7 @@ let inlinedRecord = ir => | V0({x0, x1: ?None, x2: ?None, x3}) => (x0, "n/a", 0, x3) | V1({y0, y1}) => (y0, "n/a", 0, y1) } + let pm3 = inlinedRecord(ir2) let pm4 = inlinedRecord(ir3) diff --git a/tests/tests/src/record_rest_test.mjs b/tests/tests/src/record_rest_test.mjs index 4b2e393e7dc..c31fc4a87d4 100644 --- a/tests/tests/src/record_rest_test.mjs +++ b/tests/tests/src/record_rest_test.mjs @@ -126,13 +126,13 @@ Mocha.describe("Record_rest_test", () => { version: "1.0", debug: true }; - Test_utils.eq("File \"record_rest_test.res\", line 151, characters 7-14", "test", "test"); - Test_utils.eq("File \"record_rest_test.res\", line 152, characters 7-14", rest, { + Test_utils.eq("File \"record_rest_test.res\", line 152, characters 7-14", "test", "test"); + Test_utils.eq("File \"record_rest_test.res\", line 153, characters 7-14", rest, { version: "1.0", debug: true }); }); - Mocha.test("match arm returns the named field and the rest record", () => Test_utils.eq("File \"record_rest_test.res\", line 157, characters 6-13", describeConfig({ + Mocha.test("match arm returns the named field and the rest record", () => Test_utils.eq("File \"record_rest_test.res\", line 158, characters 6-13", describeConfig({ name: "match", version: "2.0", debug: false @@ -143,12 +143,12 @@ Mocha.describe("Record_rest_test", () => { debug: false } ])); - Mocha.test("function parameter destructuring keeps the named field", () => Test_utils.eq("File \"record_rest_test.res\", line 164, characters 7-14", getName({ + Mocha.test("function parameter destructuring keeps the named field", () => Test_utils.eq("File \"record_rest_test.res\", line 165, characters 7-14", getName({ name: "param", version: "3.0", debug: true }), "param")); - Mocha.test("record rest accepts type aliases to record shapes", () => Test_utils.eq("File \"record_rest_test.res\", line 169, characters 6-13", getAliasedRest({ + Mocha.test("record rest accepts type aliases to record shapes", () => Test_utils.eq("File \"record_rest_test.res\", line 170, characters 6-13", getAliasedRest({ name: "aliased", version: "3.1", debug: false @@ -157,7 +157,7 @@ Mocha.describe("Record_rest_test", () => { debug: false })); Mocha.test("record rest accepts namespaced record types", () => { - Test_utils.eq("File \"record_rest_test.res\", line 177, characters 6-13", getNamespacedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 178, characters 6-13", getNamespacedRest({ name: "namespaced", version: "3.15", debug: true @@ -170,12 +170,12 @@ Mocha.describe("Record_rest_test", () => { version: "3.16", debug: false }; - Test_utils.eq("File \"record_rest_test.res\", line 189, characters 7-14", rest, { + Test_utils.eq("File \"record_rest_test.res\", line 190, characters 7-14", rest, { version: "3.16", debug: false }); }); - Mocha.test("record rest excludes fields renamed with @as", () => Test_utils.eq("File \"record_rest_test.res\", line 194, characters 6-13", getRenamedRest({ + Mocha.test("record rest excludes fields renamed with @as", () => Test_utils.eq("File \"record_rest_test.res\", line 195, characters 6-13", getRenamedRest({ "user-name": "renamed", version: "3.2", debug: true @@ -183,7 +183,7 @@ Mocha.describe("Record_rest_test", () => { version: "3.2", debug: true })); - Mocha.test("record rest can return a field renamed with @as alongside the rest", () => Test_utils.eq("File \"record_rest_test.res\", line 202, characters 6-13", getRenamedNameAndRest({ + Mocha.test("record rest can return a field renamed with @as alongside the rest", () => Test_utils.eq("File \"record_rest_test.res\", line 203, characters 6-13", getRenamedNameAndRest({ "user-name": "renamed", version: "3.25", debug: false @@ -194,7 +194,7 @@ Mocha.describe("Record_rest_test", () => { debug: false } ])); - Mocha.test("empty-field rest pattern still binds the whole record", () => Test_utils.eq("File \"record_rest_test.res\", line 210, characters 6-13", (({...__rest}) => __rest)({ + Mocha.test("empty-field rest pattern still binds the whole record", () => Test_utils.eq("File \"record_rest_test.res\", line 211, characters 6-13", (({...__rest}) => __rest)({ name: "whole", version: "3.5", debug: false @@ -210,12 +210,12 @@ Mocha.describe("Record_rest_test", () => { debug: true }; let {...rest} = whole; - Test_utils.eq("File \"record_rest_test.res\", line 218, characters 7-14", whole, { + Test_utils.eq("File \"record_rest_test.res\", line 219, characters 7-14", whole, { name: "wholeAlias", version: "3.6", debug: true }); - Test_utils.eq("File \"record_rest_test.res\", line 219, characters 7-14", rest, { + Test_utils.eq("File \"record_rest_test.res\", line 220, characters 7-14", rest, { name: "wholeAlias", version: "3.6", debug: true @@ -228,7 +228,7 @@ Mocha.describe("Record_rest_test", () => { style: "bold", onClick: onClick }); - Test_utils.eq("File \"record_rest_test.res\", line 225, characters 7-14", rest, { + Test_utils.eq("File \"record_rest_test.res\", line 226, characters 7-14", rest, { style: "bold", onClick: onClick }); @@ -238,18 +238,18 @@ Mocha.describe("Record_rest_test", () => { id: "1", value: 42 }; - Test_utils.eq("File \"record_rest_test.res\", line 230, characters 7-14", "1", "1"); - Test_utils.eq("File \"record_rest_test.res\", line 231, characters 7-14", intRest, { + Test_utils.eq("File \"record_rest_test.res\", line 231, characters 7-14", "1", "1"); + Test_utils.eq("File \"record_rest_test.res\", line 232, characters 7-14", intRest, { value: 42 }); - Test_utils.eq("File \"record_rest_test.res\", line 232, characters 7-14", (({id: __unused0, ...__rest}) => __rest)({ + Test_utils.eq("File \"record_rest_test.res\", line 233, characters 7-14", (({id: __unused0, ...__rest}) => __rest)({ id: "2", value: "hello" }), { value: "hello" }); }); - Mocha.test("tuple nested record rest is initialized", () => Test_utils.eq("File \"record_rest_test.res\", line 237, characters 6-13", getTupleRest([ + Mocha.test("tuple nested record rest is initialized", () => Test_utils.eq("File \"record_rest_test.res\", line 238, characters 6-13", getTupleRest([ { name: "tuple", version: "4.0", @@ -260,11 +260,11 @@ Mocha.describe("Record_rest_test", () => { version: "4.0", debug: false })); - Mocha.test("record rest works when the source is not a bare identifier", () => Test_utils.eq("File \"record_rest_test.res\", line 244, characters 7-14", getCallResultRest(), { + Mocha.test("record rest works when the source is not a bare identifier", () => Test_utils.eq("File \"record_rest_test.res\", line 245, characters 7-14", getCallResultRest(), { version: "4.5", debug: true })); - Mocha.test("record rest keeps the original parameter alias usable", () => Test_utils.eq("File \"record_rest_test.res\", line 249, characters 6-13", getNameRestAndOriginalVersion({ + Mocha.test("record rest keeps the original parameter alias usable", () => Test_utils.eq("File \"record_rest_test.res\", line 250, characters 6-13", getNameRestAndOriginalVersion({ name: "original", version: "4.75", debug: false @@ -277,7 +277,7 @@ Mocha.describe("Record_rest_test", () => { "4.75" ])); Mocha.test("variant payload rest works through the or-pattern path", () => { - Test_utils.eq("File \"record_rest_test.res\", line 257, characters 6-13", getWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 258, characters 6-13", getWrappedRest({ TAG: "Wrap", _0: { name: "wrapped", @@ -288,7 +288,7 @@ Mocha.describe("Record_rest_test", () => { version: "5.0", debug: true }); - Test_utils.eq("File \"record_rest_test.res\", line 262, characters 6-13", getWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 263, characters 6-13", getWrappedRest({ TAG: "Mirror", _0: { name: "mirror", @@ -301,7 +301,7 @@ Mocha.describe("Record_rest_test", () => { }); }); Mocha.test("inline record variant rest removes the runtime tag field", () => { - Test_utils.eq("File \"record_rest_test.res\", line 270, characters 6-13", getInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 271, characters 6-13", getInlineWrappedRest({ TAG: "InlineWrap", name: "inline", version: "7.0", @@ -310,7 +310,7 @@ Mocha.describe("Record_rest_test", () => { version: "7.0", debug: true }); - Test_utils.eq("File \"record_rest_test.res\", line 275, characters 6-13", getInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 276, characters 6-13", getInlineWrappedRest({ TAG: "InlineMirror", name: "inlineMirror", version: "8.0", @@ -321,7 +321,7 @@ Mocha.describe("Record_rest_test", () => { }); }); Mocha.test("inline record variant rest excludes fields renamed with @as", () => { - Test_utils.eq("File \"record_rest_test.res\", line 283, characters 6-13", getRenamedInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 284, characters 6-13", getRenamedInlineWrappedRest({ TAG: "RenamedInlineWrap", "user-name": "inlineRenamed", version: "8.5", @@ -330,7 +330,7 @@ Mocha.describe("Record_rest_test", () => { version: "8.5", debug: true }); - Test_utils.eq("File \"record_rest_test.res\", line 290, characters 6-13", getRenamedInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 291, characters 6-13", getRenamedInlineWrappedRest({ TAG: "RenamedInlineMirror", "user-name": "inlineRenamed2", version: "8.6", @@ -341,7 +341,7 @@ Mocha.describe("Record_rest_test", () => { }); }); Mocha.test("inline record variant rest removes a custom runtime tag field", () => { - Test_utils.eq("File \"record_rest_test.res\", line 300, characters 6-13", getCustomTaggedInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 301, characters 6-13", getCustomTaggedInlineWrappedRest({ kind: "CustomInlineWrap", name: "customInline", version: "9.0", @@ -350,7 +350,7 @@ Mocha.describe("Record_rest_test", () => { version: "9.0", debug: true }); - Test_utils.eq("File \"record_rest_test.res\", line 307, characters 6-13", getCustomTaggedInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 308, characters 6-13", getCustomTaggedInlineWrappedRest({ kind: "CustomInlineMirror", name: "customInlineMirror", version: "10.0", @@ -361,7 +361,7 @@ Mocha.describe("Record_rest_test", () => { }); }); Mocha.test("inline record rest works with a non-identifier custom tag name", () => { - Test_utils.eq("File \"record_rest_test.res\", line 317, characters 6-13", getDashedTaggedInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 318, characters 6-13", getDashedTaggedInlineWrappedRest({ "custom-tag": "DashedInlineWrap", name: "dashedInline", version: "11.0", @@ -370,7 +370,7 @@ Mocha.describe("Record_rest_test", () => { version: "11.0", debug: true }); - Test_utils.eq("File \"record_rest_test.res\", line 324, characters 6-13", getDashedTaggedInlineWrappedRest({ + Test_utils.eq("File \"record_rest_test.res\", line 325, characters 6-13", getDashedTaggedInlineWrappedRest({ "custom-tag": "DashedInlineMirror", name: "dashedInlineMirror", version: "12.0", @@ -386,7 +386,7 @@ Mocha.describe("Record_rest_test", () => { let {name: __unused0, ...rest} = param; return rest; }; - Test_utils.eq("File \"record_rest_test.res\", line 337, characters 6-13", strictDirectiveRest({ + Test_utils.eq("File \"record_rest_test.res\", line 338, characters 6-13", strictDirectiveRest({ name: "strict", version: "13.0", debug: false diff --git a/tests/tests/src/record_rest_test.res b/tests/tests/src/record_rest_test.res index 79cd4553241..6c240d522ac 100644 --- a/tests/tests/src/record_rest_test.res +++ b/tests/tests/src/record_rest_test.res @@ -44,6 +44,7 @@ let getRenamedNameAndRest = ({name, ...restConfig as rest}: renamedConfig) => (n let getName = ({name, ...restConfig as _rest}: config) => name let getWholeConfig = ({...config as rest}: config) => rest let makeConfig = (): config => {name: "call", version: "4.5", debug: true} + let getCallResultRest = () => { let {name: _, ...restConfig as rest} = makeConfig() rest diff --git a/tests/tests/src/record_type_spread.res b/tests/tests/src/record_type_spread.res index 50c963bbb8f..c6264ca5c8a 100644 --- a/tests/tests/src/record_type_spread.res +++ b/tests/tests/src/record_type_spread.res @@ -51,9 +51,11 @@ module DeepSub = { x: result<'a, 'b>, z: [#One | #Two('a) | #Three('b)], } + type d = { ...t<int, int>, } + let d: d = { x: Ok(1), z: #Two(1), diff --git a/tests/tests/src/record_with_test.mjs b/tests/tests/src/record_with_test.mjs index 1d456f7d04e..249b89bea8e 100644 --- a/tests/tests/src/record_with_test.mjs +++ b/tests/tests/src/record_with_test.mjs @@ -37,7 +37,7 @@ function f(g, h) { } Mocha.describe("Record_with_test", () => { - Mocha.test("eq_with", () => Test_utils.eq("File \"record_with_test.res\", line 39, characters 7-14", v, u_v)); + Mocha.test("eq_with", () => Test_utils.eq("File \"record_with_test.res\", line 40, characters 7-14", v, u_v)); }); let uv = { diff --git a/tests/tests/src/record_with_test.res b/tests/tests/src/record_with_test.res index 39b34e7f155..da24864e0c0 100644 --- a/tests/tests/src/record_with_test.res +++ b/tests/tests/src/record_with_test.res @@ -30,6 +30,7 @@ let uv = { enums: 0, extends: 0, } + let u_v = {...v, imports: 0} let f = (g, h) => {...g(h), imports: 0} diff --git a/tests/tests/src/recursive_module_test.mjs b/tests/tests/src/recursive_module_test.mjs index b112d87e989..0d76d367f7a 100644 --- a/tests/tests/src/recursive_module_test.mjs +++ b/tests/tests/src/recursive_module_test.mjs @@ -44,8 +44,8 @@ let Fact = { }; Mocha.describe("Recursive_module_test", () => { - Mocha.test("recursive module factorial", () => Test_utils.eq("File \"recursive_module_test.res\", line 25, characters 7-14", 120, fact$1(5))); - Mocha.test("recursive module exception", () => Test_utils.throws("File \"recursive_module_test.res\", line 29, characters 11-18", () => { + Mocha.test("recursive module factorial", () => Test_utils.eq("File \"recursive_module_test.res\", line 27, characters 7-14", 120, fact$1(5))); + Mocha.test("recursive module exception", () => Test_utils.throws("File \"recursive_module_test.res\", line 31, characters 11-18", () => { Int3.u(3); })); }); diff --git a/tests/tests/src/recursive_module_test.res b/tests/tests/src/recursive_module_test.res index d2a6d72033e..4c34335e1ce 100644 --- a/tests/tests/src/recursive_module_test.res +++ b/tests/tests/src/recursive_module_test.res @@ -9,6 +9,7 @@ module Fact = { module type S = { let fact: int => int } + module rec M: S = { let fact = n => if n <= 1 { @@ -17,6 +18,7 @@ module Fact = { n * M.fact(n - 1) } } + include M } diff --git a/tests/tests/src/recursive_records_test.mjs b/tests/tests/src/recursive_records_test.mjs index d947b60b1ea..758ab04f20b 100644 --- a/tests/tests/src/recursive_records_test.mjs +++ b/tests/tests/src/recursive_records_test.mjs @@ -56,7 +56,7 @@ function tl_exn(x) { RE_EXN_ID: "Assert_failure", _1: [ "recursive_records_test.res", - 43, + 44, 11 ], Error: new Error() @@ -77,18 +77,18 @@ function f3(x) { Mocha.describe("Recursive_records_test", () => { Mocha.test("recursive record operations", () => { - Test_utils.eq("File \"recursive_records_test.res\", line 56, characters 7-14", a0(rec_cell), 9); - Test_utils.eq("File \"recursive_records_test.res\", line 57, characters 7-14", a0(f0(3)), 9); + Test_utils.eq("File \"recursive_records_test.res\", line 57, characters 7-14", a0(rec_cell), 9); + Test_utils.eq("File \"recursive_records_test.res\", line 58, characters 7-14", a0(f0(3)), 9); }); Mocha.test("recursive inline record operations", () => { - Test_utils.eq("File \"recursive_records_test.res\", line 61, characters 7-14", (hd(rec_cell2) + hd(tl_exn(rec_cell2)) | 0) + hd(tl_exn(tl_exn(rec_cell2))) | 0, 9); + Test_utils.eq("File \"recursive_records_test.res\", line 62, characters 7-14", (hd(rec_cell2) + hd(tl_exn(rec_cell2)) | 0) + hd(tl_exn(tl_exn(rec_cell2))) | 0, 9); let rec_cell2$1 = f2(3); - Test_utils.eq("File \"recursive_records_test.res\", line 63, characters 7-14", (hd(rec_cell2$1) + hd(tl_exn(rec_cell2$1)) | 0) + hd(tl_exn(tl_exn(rec_cell2$1))) | 0, 9); + Test_utils.eq("File \"recursive_records_test.res\", line 64, characters 7-14", (hd(rec_cell2$1) + hd(tl_exn(rec_cell2$1)) | 0) + hd(tl_exn(tl_exn(rec_cell2$1))) | 0, 9); }); Mocha.test("recursive variant list operations", () => { - Test_utils.eq("File \"recursive_records_test.res\", line 69, characters 7-14", (Stdlib_List.headOrThrow(rec_cell3) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(rec_cell3)) | 0) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(Stdlib_List.tailOrThrow(rec_cell3))) | 0, 9); + Test_utils.eq("File \"recursive_records_test.res\", line 70, characters 7-14", (Stdlib_List.headOrThrow(rec_cell3) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(rec_cell3)) | 0) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(Stdlib_List.tailOrThrow(rec_cell3))) | 0, 9); let rec_cell3$1 = f3(3); - Test_utils.eq("File \"recursive_records_test.res\", line 71, characters 7-14", (Stdlib_List.headOrThrow(rec_cell3$1) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(rec_cell3$1)) | 0) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(Stdlib_List.tailOrThrow(rec_cell3$1))) | 0, 9); + Test_utils.eq("File \"recursive_records_test.res\", line 72, characters 7-14", (Stdlib_List.headOrThrow(rec_cell3$1) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(rec_cell3$1)) | 0) + Stdlib_List.headOrThrow(Stdlib_List.tailOrThrow(Stdlib_List.tailOrThrow(rec_cell3$1))) | 0, 9); }); }); diff --git a/tests/tests/src/recursive_records_test.res b/tests/tests/src/recursive_records_test.res index 02f6557c587..0a3b8cea249 100644 --- a/tests/tests/src/recursive_records_test.res +++ b/tests/tests/src/recursive_records_test.res @@ -26,6 +26,7 @@ type rec cell2 = | Cons({content: int, mutable next: cell2}) let rec rec_cell2 = Cons({content: 3, next: rec_cell2}) + /* over inline records */ let f2 = x => { let rec rec_cell2 = Cons({content: x * x - 6, next: rec_cell2}) diff --git a/tests/tests/src/res_debug.res b/tests/tests/src/res_debug.res index 1cd4a0f6d04..1487cad6ec2 100644 --- a/tests/tests/src/res_debug.res +++ b/tests/tests/src/res_debug.res @@ -8,6 +8,7 @@ /* "-dsource"; */ ], }) + type t = {x: int, y: int} // let f = (x,y) => { @@ -49,6 +50,7 @@ let testMatch = v => let h = '😊' let hey = "hello, 世界" + // failed to type check let optionMap = (x, f) => diff --git a/tests/tests/src/return_check.mjs b/tests/tests/src/return_check.mjs index e8a1fc418c0..67f934d21a3 100644 --- a/tests/tests/src/return_check.mjs +++ b/tests/tests/src/return_check.mjs @@ -20,7 +20,7 @@ function f_undefined(xs, i) { RE_EXN_ID: "Assert_failure", _1: [ "return_check.res", - 23, + 24, 12 ], Error: new Error() @@ -61,7 +61,7 @@ function f_null(xs, i) { RE_EXN_ID: "Assert_failure", _1: [ "return_check.res", - 51, + 52, 12 ], Error: new Error() @@ -77,7 +77,7 @@ function f_null_undefined(xs, i) { RE_EXN_ID: "Assert_failure", _1: [ "return_check.res", - 59, + 60, 12 ], Error: new Error() diff --git a/tests/tests/src/return_check.res b/tests/tests/src/return_check.res index feb5773b5e0..aac64fad70c 100644 --- a/tests/tests/src/return_check.res +++ b/tests/tests/src/return_check.res @@ -1,5 +1,6 @@ type element type dom + @send @return({null_to_opt: null_to_opt}) external getElementById: (dom, string) => option<element> = "getElementById" diff --git a/tests/tests/src/set_gen.mjs b/tests/tests/src/set_gen.mjs index 7d85fbd180a..ac6a4ef0e60 100644 --- a/tests/tests/src/set_gen.mjs +++ b/tests/tests/src/set_gen.mjs @@ -241,7 +241,7 @@ function internal_bal(l, v, r) { RE_EXN_ID: "Assert_failure", _1: [ "set_gen.res", - 278, + 280, 15 ], Error: new Error() @@ -260,7 +260,7 @@ function internal_bal(l, v, r) { RE_EXN_ID: "Assert_failure", _1: [ "set_gen.res", - 288, + 290, 19 ], Error: new Error() @@ -280,7 +280,7 @@ function internal_bal(l, v, r) { RE_EXN_ID: "Assert_failure", _1: [ "set_gen.res", - 300, + 302, 15 ], Error: new Error() @@ -299,7 +299,7 @@ function internal_bal(l, v, r) { RE_EXN_ID: "Assert_failure", _1: [ "set_gen.res", - 306, + 308, 19 ], Error: new Error() @@ -521,7 +521,7 @@ function of_sorted_list(l) { RE_EXN_ID: "Assert_failure", _1: [ "set_gen.res", - 447, + 449, 18 ], Error: new Error() diff --git a/tests/tests/src/set_gen.res b/tests/tests/src/set_gen.res index da5db1d356e..01360abf1f9 100644 --- a/tests/tests/src/set_gen.res +++ b/tests/tests/src/set_gen.res @@ -114,6 +114,7 @@ let max_int3 = (a: int, b, c) => } else { c } + let max_int_2 = (a: int, b) => if a >= b { a @@ -143,6 +144,7 @@ let rec check_height_and_diff = x => } let check = tree => ignore(check_height_and_diff(tree)) + /* Invariants: 1. {[ l < v < r]} diff --git a/tests/tests/src/shadow_dollar_test.mjs b/tests/tests/src/shadow_dollar_test.mjs index 88254be853a..014ac7a02e4 100644 --- a/tests/tests/src/shadow_dollar_test.mjs +++ b/tests/tests/src/shadow_dollar_test.mjs @@ -80,20 +80,20 @@ function fnShadow(w) { Mocha.describe("Shadow_dollar_test", () => { Mocha.test("shadowed names do not collide with $ identifiers", () => { - Test_utils.eq("File \"shadow_dollar_test.res\", line 65, characters 7-14", paramCollision(1, v => v * 10 | 0), 30); - Test_utils.eq("File \"shadow_dollar_test.res\", line 66, characters 7-14", laterBinding(1), [ + Test_utils.eq("File \"shadow_dollar_test.res\", line 67, characters 7-14", paramCollision(1, v => v * 10 | 0), 30); + Test_utils.eq("File \"shadow_dollar_test.res\", line 68, characters 7-14", laterBinding(1), [ 2, 20, 2, 20 ]); - Test_utils.eq("File \"shadow_dollar_test.res\", line 67, characters 7-14", earlierBinding(1), [ + Test_utils.eq("File \"shadow_dollar_test.res\", line 69, characters 7-14", earlierBinding(1), [ 2, 10, 2, 10 ]); - Test_utils.eq("File \"shadow_dollar_test.res\", line 68, characters 7-14", nested(1), [ + Test_utils.eq("File \"shadow_dollar_test.res\", line 70, characters 7-14", nested(1), [ 3, [ 2, @@ -105,9 +105,9 @@ Mocha.describe("Shadow_dollar_test", () => { ]); }); Mocha.test("shadowed names do not capture raw JS names", () => { - Test_utils.eq("File \"shadow_dollar_test.res\", line 72, characters 7-14", topShadow, 204); - Test_utils.eq("File \"shadow_dollar_test.res\", line 73, characters 7-14", topSibling, 404); - Test_utils.eq("File \"shadow_dollar_test.res\", line 74, characters 7-14", fnShadow(1), 602); + Test_utils.eq("File \"shadow_dollar_test.res\", line 74, characters 7-14", topShadow, 204); + Test_utils.eq("File \"shadow_dollar_test.res\", line 75, characters 7-14", topSibling, 404); + Test_utils.eq("File \"shadow_dollar_test.res\", line 76, characters 7-14", fnShadow(1), 602); }); }); diff --git a/tests/tests/src/shadow_dollar_test.res b/tests/tests/src/shadow_dollar_test.res index 48ffb5ddcaf..ec684ff1a87 100644 --- a/tests/tests/src/shadow_dollar_test.res +++ b/tests/tests/src/shadow_dollar_test.res @@ -41,12 +41,14 @@ let nested = x => { let base: int = %raw("1") let y = base * 2 + let topShadow = { let y = y + y1 y + y } let z = base * 2 + let topSibling = if z < 0 { let z$1 = z * 10 z$1 + z$1 diff --git a/tests/tests/src/shake_liveness_test.mjs b/tests/tests/src/shake_liveness_test.mjs index c2e9d8365c4..dd1c2533110 100644 --- a/tests/tests/src/shake_liveness_test.mjs +++ b/tests/tests/src/shake_liveness_test.mjs @@ -40,10 +40,10 @@ function statementHelper(x) { counter.contents = counter.contents + statementHelper(2) | 0; -Mocha.describe("File \"shake_liveness_test.res\", line 36, characters 9-16", () => { +Mocha.describe("File \"shake_liveness_test.res\", line 38, characters 9-16", () => { Mocha.test("kept bindings work", () => { - Test_utils.eq("File \"shake_liveness_test.res\", line 39, characters 7-14", counter.contents, 59); - Test_utils.eq("File \"shake_liveness_test.res\", line 40, characters 7-14", chainEnd(1), 338); + Test_utils.eq("File \"shake_liveness_test.res\", line 41, characters 7-14", counter.contents, 59); + Test_utils.eq("File \"shake_liveness_test.res\", line 42, characters 7-14", chainEnd(1), 338); }); }); diff --git a/tests/tests/src/shake_liveness_test.res b/tests/tests/src/shake_liveness_test.res index b7cc81cdc2a..0895cc66131 100644 --- a/tests/tests/src/shake_liveness_test.res +++ b/tests/tests/src/shake_liveness_test.res @@ -16,12 +16,14 @@ let chainEnd = (x: int) => chain2(x) + chain2(x + 1) // Unused, but its initializer has a side effect: it compiles to the statement // `bump(1)`, which keeps `bump` and, through it, `effectHelper`. %%private(let effectHelper = (x: int) => x * x * 7 + x * 3 + 5) + %%private( let bump = (x: int) => { counter := counter.contents + effectHelper(x) counter.contents } ) + %%private(let effectful = bump(1)) // Only used by a toplevel statement with a side effect. diff --git a/tests/tests/src/spread_literal_test.mjs b/tests/tests/src/spread_literal_test.mjs index bbf288c2bc9..25a4ed530d2 100644 --- a/tests/tests/src/spread_literal_test.mjs +++ b/tests/tests/src/spread_literal_test.mjs @@ -22,7 +22,7 @@ Mocha.describe("Spread_literal_test", () => { 2 ]; let b = [5]; - Test_utils.eq("File \"spread_literal_test.res\", line 14, characters 7-14", Primitive_array.spread([ + Test_utils.eq("File \"spread_literal_test.res\", line 15, characters 7-14", Primitive_array.spread([ a, [ 3, @@ -38,7 +38,7 @@ Mocha.describe("Spread_literal_test", () => { 5, 6 ]); - Test_utils.eq("File \"spread_literal_test.res\", line 15, characters 7-14", Primitive_array.spread([ + Test_utils.eq("File \"spread_literal_test.res\", line 16, characters 7-14", Primitive_array.spread([ [0], a, [], @@ -53,17 +53,17 @@ Mocha.describe("Spread_literal_test", () => { Mocha.test("list spreads keep items and spreads in order", () => { let xs = {hd: 1, tl: {hd: 2, tl: /* [] */0}}; let ys = {hd: 5, tl: /* [] */0}; - Test_utils.eq("File \"spread_literal_test.res\", line 21, characters 7-14", Primitive_list.spread([ + Test_utils.eq("File \"spread_literal_test.res\", line 22, characters 7-14", Primitive_list.spread([ xs, {hd: 3, tl: ys}, {hd: 6, tl: /* [] */0} ]), {hd: 1, tl: {hd: 2, tl: {hd: 3, tl: {hd: 5, tl: {hd: 6, tl: /* [] */0}}}}}); - Test_utils.eq("File \"spread_literal_test.res\", line 22, characters 7-14", Primitive_list.spread([ + Test_utils.eq("File \"spread_literal_test.res\", line 23, characters 7-14", Primitive_list.spread([ {hd: 0, tl: xs}, /* [] */0, {hd: 4, tl: ys} ]), {hd: 0, tl: {hd: 1, tl: {hd: 2, tl: {hd: 4, tl: {hd: 5, tl: /* [] */0}}}}}); - Test_utils.eq("File \"spread_literal_test.res\", line 23, characters 7-14", {hd: 0, tl: xs}, {hd: 0, tl: {hd: 1, tl: {hd: 2, tl: /* [] */0}}}); + Test_utils.eq("File \"spread_literal_test.res\", line 24, characters 7-14", {hd: 0, tl: xs}, {hd: 0, tl: {hd: 1, tl: {hd: 2, tl: /* [] */0}}}); }); Mocha.test("items and spreads are evaluated left to right", () => { log.contents = /* [] */0; @@ -76,7 +76,7 @@ Mocha.describe("Spread_literal_test", () => { {hd: note("d", 4), tl: note("e", {hd: 5, tl: /* [] */0})}, {hd: note("f", 6), tl: /* [] */0} ]); - Test_utils.eq("File \"spread_literal_test.res\", line 30, characters 7-14", [ + Test_utils.eq("File \"spread_literal_test.res\", line 31, characters 7-14", [ arr, lst ], [ @@ -87,7 +87,7 @@ Mocha.describe("Spread_literal_test", () => { ], {hd: 4, tl: {hd: 5, tl: {hd: 6, tl: /* [] */0}}} ]); - Test_utils.eq("File \"spread_literal_test.res\", line 31, characters 7-14", Stdlib_List.reverse(log.contents), {hd: "a", tl: {hd: "b", tl: {hd: "c", tl: {hd: "d", tl: {hd: "e", tl: {hd: "f", tl: /* [] */0}}}}}}); + Test_utils.eq("File \"spread_literal_test.res\", line 32, characters 7-14", Stdlib_List.reverse(log.contents), {hd: "a", tl: {hd: "b", tl: {hd: "c", tl: {hd: "d", tl: {hd: "e", tl: {hd: "f", tl: /* [] */0}}}}}}); }); }); diff --git a/tests/tests/src/spread_literal_test.res b/tests/tests/src/spread_literal_test.res index 660491eacb8..940b7b1c3ac 100644 --- a/tests/tests/src/spread_literal_test.res +++ b/tests/tests/src/spread_literal_test.res @@ -2,6 +2,7 @@ open Mocha open Test_utils let log = ref(list{}) + let note = (s, v) => { log := list{s, ...log.contents} v diff --git a/tests/tests/src/stdlib/Stdlib_ArrayTests.mjs b/tests/tests/src/stdlib/Stdlib_ArrayTests.mjs index b3f66b28e51..a4a78cd358d 100644 --- a/tests/tests/src/stdlib/Stdlib_ArrayTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_ArrayTests.mjs @@ -107,7 +107,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 25, + 26, 13, 38 ], @@ -117,7 +117,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 32, + 33, 13, 26 ], @@ -131,7 +131,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 37, + 39, 20, 41 ], @@ -141,7 +141,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 40, + 42, 13, 35 ], @@ -155,7 +155,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 46, + 49, 13, 38 ], @@ -165,7 +165,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 52, + 55, 20, 41 ], @@ -185,7 +185,7 @@ let arr = [ Test.run([ [ "Stdlib_ArrayTests.res", - 55, + 58, 13, 31 ], @@ -195,7 +195,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 66, + 69, 13, 24 ], @@ -220,7 +220,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 71, + 75, 20, 42 ], @@ -237,7 +237,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 73, + 78, 13, 32 ], @@ -251,7 +251,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 79, + 84, 20, 30 ], @@ -268,7 +268,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 81, + 87, 13, 34 ], @@ -286,7 +286,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 86, + 93, 20, 41 ], @@ -300,7 +300,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 87, + 94, 20, 38 ], @@ -310,7 +310,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 90, + 97, 13, 22 ], @@ -331,7 +331,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 95, + 103, 20, 40 ], @@ -348,7 +348,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 97, + 106, 13, 30 ], @@ -362,7 +362,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 104, + 113, 13, 27 ], @@ -384,7 +384,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 111, + 120, 13, 27 ], @@ -412,7 +412,7 @@ let result = Stdlib_Array.concatAll(arrays); Test.run([ [ "Stdlib_ArrayTests.res", - 121, + 130, 22, 53 ], @@ -428,7 +428,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 123, + 132, 15, 57 ], @@ -448,7 +448,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 130, + 139, 20, 39 ], @@ -458,7 +458,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 133, + 142, 13, 31 ], @@ -477,7 +477,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 140, + 149, 13, 31 ], @@ -491,7 +491,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 147, + 156, 13, 29 ], @@ -519,7 +519,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 154, + 163, 13, 29 ], @@ -536,7 +536,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 160, + 169, 20, 39 ], @@ -550,7 +550,7 @@ Test.run([ Test.run([ [ "Stdlib_ArrayTests.res", - 161, + 170, 20, 34 ], @@ -564,7 +564,7 @@ array.splice(1, 0, "foo"); Test.run([ [ "Stdlib_ArrayTests.res", - 166, + 175, 22, 49 ], @@ -579,7 +579,7 @@ let array$1 = [ Test.run([ [ "Stdlib_ArrayTests.res", - 172, + 181, 15, 43 ], diff --git a/tests/tests/src/stdlib/Stdlib_ArrayTests.res b/tests/tests/src/stdlib/Stdlib_ArrayTests.res index 6d85c3229d0..60cb29bb7ad 100644 --- a/tests/tests/src/stdlib/Stdlib_ArrayTests.res +++ b/tests/tests/src/stdlib/Stdlib_ArrayTests.res @@ -21,6 +21,7 @@ Test.run( eq, list{5, 3, 1}, ) + Test.run( __POS_OF__("reduceWithIndex - empty"), Array.reduceWithIndex([], list{}, (acc, v, i) => list{v + i, ...acc}), @@ -34,6 +35,7 @@ Test.run( eq, list{1, 2, 3}, ) + Test.run(__POS_OF__("reduceRight - empty"), Array.reduceRight([], list{}, List.add), eq, list{}) Test.run( @@ -42,6 +44,7 @@ Test.run( eq, list{1, 3, 5}, ) + Test.run( __POS_OF__("reduceWithIndex - empty"), Array.reduceRightWithIndex([], list{}, (acc, v, i) => list{v + i, ...acc}), @@ -68,7 +71,9 @@ Test.run( eq, [4, 16, 36], ) + Test.run(__POS_OF__("filterMap - no match"), Array.filterMap([1, 2, 3, 4, 5, 6], _ => None), eq, []) + Test.run( __POS_OF__("filterMap - empty"), Array.filterMap([], n => mod(n, 2) == 0 ? Some(n * n) : None), @@ -77,12 +82,14 @@ Test.run( ) Test.run(__POS_OF__("keepSome"), Array.keepSome([Some(1), None, Some(3)]), eq, [1, 3]) + Test.run( __POS_OF__("keepSome - all Some"), Array.keepSome([Some(1), Some(2), Some(3)]), eq, [1, 2, 3], ) + Test.run(__POS_OF__("keepSome - all None"), Array.keepSome([None, None, None]), eq, []) Test.run(__POS_OF__("keepSome - empty"), Array.keepSome([]), eq, []) @@ -92,7 +99,9 @@ Test.run( eq, Some(-6), ) + Test.run(__POS_OF__("findMap - no match"), Array.findMap([1, 2, 3, 4, 5, 6], _ => None), eq, None) + Test.run( __POS_OF__("findMap - empty"), Array.findMap([], n => mod(n, 2) == 0 ? Some(n * n) : None), diff --git a/tests/tests/src/stdlib/Stdlib_DictTests.mjs b/tests/tests/src/stdlib/Stdlib_DictTests.mjs index 2c40b598222..9a40d55b6f7 100644 --- a/tests/tests/src/stdlib/Stdlib_DictTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_DictTests.mjs @@ -508,7 +508,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 292, + 293, 13, 34 ], @@ -523,7 +523,7 @@ let dict = { Test.run([ [ "Stdlib_DictTests.res", - 304, + 305, 22, 38 ], @@ -533,7 +533,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 305, + 306, 22, 43 ], @@ -543,7 +543,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 306, + 307, 22, 37 ], @@ -553,7 +553,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 307, + 308, 22, 39 ], @@ -563,7 +563,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 309, + 311, 15, 51 ], @@ -594,7 +594,7 @@ function classify(d) { Test.run([ [ "Stdlib_DictTests.res", - 326, + 328, 22, 49 ], @@ -606,7 +606,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 327, + 329, 22, 47 ], @@ -619,7 +619,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 328, + 330, 22, 50 ], @@ -631,7 +631,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 329, + 331, 22, 49 ], @@ -643,7 +643,7 @@ Test.run([ Test.run([ [ "Stdlib_DictTests.res", - 330, + 332, 22, 47 ], diff --git a/tests/tests/src/stdlib/Stdlib_DictTests.res b/tests/tests/src/stdlib/Stdlib_DictTests.res index dcc99011a09..9b76666a247 100644 --- a/tests/tests/src/stdlib/Stdlib_DictTests.res +++ b/tests/tests/src/stdlib/Stdlib_DictTests.res @@ -288,6 +288,7 @@ Test.run( eq, "bar", ) + Test.run( __POS_OF__("getUnsafe - missing"), Dict.make()->Dict.getUnsafe("foo"), @@ -305,6 +306,7 @@ module Has = { Test.run(__POS_OF__("has - existing None"), dict->Dict.has("key2"), eq, true) Test.run(__POS_OF__("has - missing"), dict->Dict.has("key3"), eq, false) Test.run(__POS_OF__("has - prototype"), dict->Dict.has("toString"), eq, true) + Test.run( __POS_OF__("has - parantesis in generated code"), typeof(dict->Dict.has("key1")), diff --git a/tests/tests/src/stdlib/Stdlib_FloatTests.mjs b/tests/tests/src/stdlib/Stdlib_FloatTests.mjs index 1f8eb067e69..684fc412366 100644 --- a/tests/tests/src/stdlib/Stdlib_FloatTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_FloatTests.mjs @@ -205,7 +205,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 26, + 27, 13, 49 ], @@ -215,7 +215,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 32, + 34, 13, 50 ], @@ -225,7 +225,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 38, + 41, 13, 50 ], @@ -235,7 +235,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 44, + 48, 13, 51 ], @@ -245,7 +245,7 @@ Test.run([ Test.run([ [ "Stdlib_FloatTests.res", - 50, + 54, 20, 46 ], diff --git a/tests/tests/src/stdlib/Stdlib_FloatTests.res b/tests/tests/src/stdlib/Stdlib_FloatTests.res index 45b390e23c7..75f520c0b8a 100644 --- a/tests/tests/src/stdlib/Stdlib_FloatTests.res +++ b/tests/tests/src/stdlib/Stdlib_FloatTests.res @@ -22,24 +22,28 @@ Test.run(__POS_OF__("clamp - min infinity"), Float.clamp(~min=infinity, 4.2), eq Test.run(__POS_OF__("clamp - max infinity"), Float.clamp(~max=infinity, 4.2), eq, 4.2) Test.run(__POS_OF__("clamp - min -infinity"), Float.clamp(~min=neg_infinity, 4.2), eq, 4.2) Test.run(__POS_OF__("clamp - max -infinity"), Float.clamp(~max=neg_infinity, 4.2), eq, neg_infinity) + Test.run( __POS_OF__("clamp - min infinity, max infinity"), Float.clamp(~min=infinity, ~max=infinity, 4.2), eq, infinity, ) + Test.run( __POS_OF__("clamp - min -infinity, max infinity"), Float.clamp(~min=neg_infinity, ~max=infinity, 4.2), eq, 4.2, ) + Test.run( __POS_OF__("clamp - min infinity, max -infinity"), Float.clamp(~min=infinity, ~max=neg_infinity, 4.2), eq, infinity, // min wins ) + Test.run( __POS_OF__("clamp - min -infinity, max -infinity"), Float.clamp(~min=neg_infinity, ~max=neg_infinity, 4.2), diff --git a/tests/tests/src/stdlib/Stdlib_IntTests.mjs b/tests/tests/src/stdlib/Stdlib_IntTests.mjs index b7c549e6814..fc7e639e2b4 100644 --- a/tests/tests/src/stdlib/Stdlib_IntTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_IntTests.mjs @@ -119,7 +119,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 25, + 26, 13, 51 ], @@ -134,7 +134,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 31, + 33, 13, 51 ], @@ -150,7 +150,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 37, + 40, 13, 51 ], @@ -165,7 +165,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 43, + 47, 13, 51 ], @@ -177,7 +177,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 48, + 53, 20, 50 ], @@ -189,7 +189,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 50, + 56, 13, 52 ], @@ -201,7 +201,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 56, + 63, 13, 51 ], @@ -213,7 +213,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 62, + 70, 13, 52 ], @@ -228,7 +228,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 68, + 77, 13, 52 ], @@ -243,7 +243,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 74, + 84, 13, 52 ], @@ -259,7 +259,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 80, + 91, 13, 52 ], @@ -274,7 +274,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 86, + 98, 13, 62 ], @@ -290,7 +290,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 92, + 105, 13, 62 ], @@ -307,7 +307,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 98, + 112, 13, 62 ], @@ -324,7 +324,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 104, + 119, 13, 62 ], @@ -340,7 +340,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 110, + 126, 13, 62 ], @@ -353,7 +353,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 116, + 133, 13, 54 ], @@ -366,7 +366,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 122, + 140, 13, 63 ], @@ -379,7 +379,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 128, + 147, 13, 62 ], @@ -392,7 +392,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 134, + 154, 13, 63 ], @@ -408,7 +408,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 140, + 161, 13, 63 ], @@ -425,7 +425,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 146, + 168, 13, 63 ], @@ -442,7 +442,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 152, + 175, 13, 63 ], @@ -458,7 +458,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 158, + 181, 20, 27 ], @@ -468,7 +468,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 159, + 182, 20, 35 ], @@ -478,7 +478,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 160, + 183, 20, 35 ], @@ -488,7 +488,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 161, + 184, 20, 35 ], @@ -498,7 +498,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 162, + 185, 20, 35 ], @@ -508,7 +508,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 163, + 186, 20, 42 ], @@ -518,7 +518,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 164, + 187, 20, 42 ], @@ -528,7 +528,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 165, + 188, 20, 42 ], @@ -538,7 +538,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 166, + 189, 20, 42 ], @@ -548,7 +548,7 @@ Test.run([ Test.run([ [ "Stdlib_IntTests.res", - 168, + 191, 20, 44 ], diff --git a/tests/tests/src/stdlib/Stdlib_IntTests.res b/tests/tests/src/stdlib/Stdlib_IntTests.res index 60e2fbfce93..ad062269e20 100644 --- a/tests/tests/src/stdlib/Stdlib_IntTests.res +++ b/tests/tests/src/stdlib/Stdlib_IntTests.res @@ -21,133 +21,156 @@ Test.run( eq, [3, 5], ) + Test.run( __POS_OF__("range + positive, increasing, step 2"), Int.range(3, 7, ~options={step: 2}), eq, [3, 5], ) + Test.run( __POS_OF__("range + positive, increasing, step 2"), Int.range(3, 8, ~options={step: 2}), eq, [3, 5, 7], ) + Test.run( __POS_OF__("range - negative, increasing, step 2"), Int.range(-6, -3, ~options={step: 2}), eq, [-6, -4], ) + Test.run( __POS_OF__("range - positive, increasing, step 0"), catch(() => Int.range(3, 6, ~options={step: 0})), eq, JsError.RangeError.make("Incorrect range arguments")->JsError.toJsExn, ) + Test.run(__POS_OF__("range - start == end, step 0"), Int.range(3, 3, ~options={step: 0}), eq, []) + Test.run( __POS_OF__("range + positive, increasing, step -1"), Int.range(3, 6, ~options={step: -1}), eq, [], ) + Test.run( __POS_OF__("range + positive, decreasing, step 1"), Int.range(6, 3, ~options={step: 1}), eq, [], ) + Test.run( __POS_OF__("range + positive, decreasing, step -2"), Int.range(6, 3, ~options={step: -2}), eq, [6, 4], ) + Test.run( __POS_OF__("range + positive, increasing, step -2"), Int.range(6, 2, ~options={step: -2}), eq, [6, 4], ) + Test.run( __POS_OF__("range + positive, increasing, step -2"), Int.range(6, 1, ~options={step: -2}), eq, [6, 4, 2], ) + Test.run( __POS_OF__("range + negative, decreasing, step -2"), Int.range(-3, -6, ~options={step: -2}), eq, [-3, -5], ) + Test.run( __POS_OF__("range - positive, increasing, step 2, inclusive"), Int.range(3, 6, ~options={step: 2, inclusive: true}), eq, [3, 5], ) + Test.run( __POS_OF__("range + positive, increasing, step 2, inclusive"), Int.range(3, 7, ~options={step: 2, inclusive: true}), eq, [3, 5, 7], ) + Test.run( __POS_OF__("range + positive, increasing, step 2, inclusive"), Int.range(3, 8, ~options={step: 2, inclusive: true}), eq, [3, 5, 7], ) + Test.run( __POS_OF__("range - negative, increasing, step 2, inclusive"), Int.range(-6, -3, ~options={step: 2, inclusive: true}), eq, [-6, -4], ) + Test.run( __POS_OF__("range - positive, increasing, step 0, inclusive"), catch(() => Int.range(3, 6, ~options={step: 0, inclusive: true})), eq, JsError.RangeError.make("Incorrect range arguments")->JsError.toJsExn, ) + Test.run( __POS_OF__("range - start == end, step 0, inclusive"), Int.range(3, 3, ~options={step: 0, inclusive: true}), eq, [3], ) + Test.run( __POS_OF__("range + positive, increasing, step -1, inclusive"), Int.range(3, 6, ~options={step: -1, inclusive: true}), eq, [], ) + Test.run( __POS_OF__("range + positive, decreasing, step 1, inclusive"), Int.range(6, 3, ~options={step: 1, inclusive: true}), eq, [], ) + Test.run( __POS_OF__("range + positive, decreasing, step -2, inclusive"), Int.range(6, 3, ~options={step: -2, inclusive: true}), eq, [6, 4], ) + Test.run( __POS_OF__("range + positive, increasing, step -2, inclusive"), Int.range(6, 2, ~options={step: -2, inclusive: true}), eq, [6, 4, 2], ) + Test.run( __POS_OF__("range + positive, increasing, step -2, inclusive"), Int.range(6, 1, ~options={step: -2, inclusive: true}), eq, [6, 4, 2], ) + Test.run( __POS_OF__("range + negative, decreasing, step -2, inclusive"), Int.range(-3, -6, ~options={step: -2, inclusive: true}), diff --git a/tests/tests/src/stdlib/Stdlib_IteratorTests.mjs b/tests/tests/src/stdlib/Stdlib_IteratorTests.mjs index d2e2201a9e8..b12da983301 100644 --- a/tests/tests/src/stdlib/Stdlib_IteratorTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_IteratorTests.mjs @@ -436,7 +436,7 @@ if (match$8.done !== false && match$8.value === "stopped") { Test.run([ [ "Stdlib_IteratorTests.res", - 321, + 322, 13, 36 ], @@ -467,7 +467,7 @@ if (match$9.done !== false) { Test.run([ [ "Stdlib_IteratorTests.res", - 348, + 350, 13, 35 ], @@ -495,7 +495,7 @@ await Stdlib_AsyncIterableIterator.forEach(asyncIterableIterator, param => { Test.run([ [ "Stdlib_IteratorTests.res", - 374, + 376, 20, 35 ], @@ -530,7 +530,7 @@ await Stdlib_AsyncIterator.forEach(asyncIterator, value => { Test.run([ [ "Stdlib_IteratorTests.res", - 400, + 402, 20, 54 ], @@ -562,7 +562,7 @@ await Stdlib_AsyncIterator.forEach(asyncOmittedDoneIterator, value => { Test.run([ [ "Stdlib_IteratorTests.res", - 419, + 422, 13, 54 ], @@ -589,7 +589,7 @@ if (match$10.done !== false && match$10.value === "5") { Test.run([ [ "Stdlib_IteratorTests.res", - 449, + 452, 13, 39 ], @@ -615,7 +615,7 @@ await Stdlib_AsyncIterableIterator.forEach(asyncGeneratorIterable, value => { Test.run([ [ "Stdlib_IteratorTests.res", - 468, + 472, 13, 53 ], @@ -645,7 +645,7 @@ for await (let value of asyncIterableForAwait) { Test.run([ [ "Stdlib_IteratorTests.res", - 485, + 490, 20, 36 ], @@ -688,7 +688,7 @@ loop_0: for await (let value$1 of asyncIterableForAwaitLoopControl) { Test.run([ [ "Stdlib_IteratorTests.res", - 508, + 514, 13, 44 ], @@ -721,7 +721,7 @@ let startupLogs = ((async function* () { Test.run([ [ "Stdlib_IteratorTests.res", - 542, + 548, 13, 54 ], @@ -755,7 +755,7 @@ if (match$11.done !== false && match$11.value === "stopped") { Test.run([ [ "Stdlib_IteratorTests.res", - 571, + 578, 13, 41 ], @@ -786,7 +786,7 @@ if (match$12.done !== false) { Test.run([ [ "Stdlib_IteratorTests.res", - 600, + 608, 13, 40 ], @@ -813,7 +813,7 @@ await Stdlib_AsyncIterableIterator.forEach(createdAsyncIterableIterator, value = Test.run([ [ "Stdlib_IteratorTests.res", - 624, + 632, 13, 56 ], diff --git a/tests/tests/src/stdlib/Stdlib_IteratorTests.res b/tests/tests/src/stdlib/Stdlib_IteratorTests.res index cedbf409e0b..2e6032195ef 100644 --- a/tests/tests/src/stdlib/Stdlib_IteratorTests.res +++ b/tests/tests/src/stdlib/Stdlib_IteratorTests.res @@ -302,6 +302,7 @@ Test.run( ) let generatorReturnValueResult = ref(None) + let generatorReturnValue: Generator.t<int, string, unit> = %raw(`(function* () { yield 1 return "done" @@ -325,6 +326,7 @@ Test.run( ) let generatorThrowErrorResult = ref(None) + let generatorThrowError: Generator.t<int, string, unit> = %raw(`(function* () { try { yield 1 @@ -400,6 +402,7 @@ await asyncIterator->AsyncIterator.forEach(value => { Test.run(__POS_OF__("Creating your own async iterator"), asyncResult.contents, eq, Some("done")) let asyncOmittedDoneValues = ref([]) + let asyncOmittedDoneIterator: AsyncIterator.t<int, string, unit> = %raw(`({ step: 0, next() { @@ -453,6 +456,7 @@ Test.run( ) let asyncGeneratorIterableValues = ref([]) + let asyncGeneratorIterable: AsyncGenerator.t<int, unit, unit> = %raw(`(async function* () { yield 2 yield 3 @@ -472,6 +476,7 @@ Test.run( ) let asyncIterableForAwaitValues = ref([]) + let asyncIterableForAwait: AsyncIterable.t<int> = %raw(`(async function* () { yield 1 yield 2 @@ -485,6 +490,7 @@ for await value of asyncIterableForAwait { Test.run(__POS_OF__("for await...of"), asyncIterableForAwaitValues.contents, eq, [1, 2, 3]) let asyncIterableForAwaitLoopControlValues = ref([]) + let asyncIterableForAwaitLoopControl: AsyncIterable.t<int> = %raw(`(async function* () { yield 1 yield 2 @@ -552,6 +558,7 @@ let _asyncIterableView: AsyncIterable.t<int> = ( )->AsyncGenerator.asAsyncIterable let asyncGeneratorReturnValueResult = ref(None) + let asyncGeneratorReturnValue: AsyncGenerator.t<int, string, unit> = %raw(`(async function* () { yield 1 return "done" @@ -575,6 +582,7 @@ Test.run( ) let asyncGeneratorThrowErrorResult = ref(None) + let asyncGeneratorThrowError: AsyncGenerator.t<int, string, unit> = %raw(`(async function* () { try { yield 1 diff --git a/tests/tests/src/stdlib/Stdlib_ObjectTests.mjs b/tests/tests/src/stdlib/Stdlib_ObjectTests.mjs index 42845195c22..eee989fd219 100644 --- a/tests/tests/src/stdlib/Stdlib_ObjectTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_ObjectTests.mjs @@ -172,7 +172,7 @@ let d = new Date(2000, 1); Test.run([ [ "Stdlib_ObjectTests.res", - 31, + 32, 13, 23 ], @@ -182,7 +182,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 36, + 38, 20, 30 ], @@ -196,7 +196,7 @@ let x = { Test.run([ [ "Stdlib_ObjectTests.res", - 39, + 41, 20, 33 ], @@ -206,7 +206,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 40, + 42, 20, 33 ], @@ -220,7 +220,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 41, + 43, 20, 33 ], @@ -230,7 +230,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 42, + 44, 20, 45 ], @@ -240,7 +240,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 43, + 45, 20, 45 ], @@ -250,7 +250,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 44, + 46, 20, 45 ], @@ -264,7 +264,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 46, + 48, 20, 31 ], @@ -274,7 +274,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 47, + 49, 20, 31 ], @@ -284,7 +284,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 48, + 50, 20, 31 ], @@ -296,7 +296,7 @@ let mkBig = Stdlib_BigInt.fromString; Test.run([ [ "Stdlib_ObjectTests.res", - 51, + 53, 20, 32 ], @@ -306,7 +306,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 52, + 54, 20, 32 ], @@ -316,7 +316,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 53, + 55, 20, 32 ], @@ -326,7 +326,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 54, + 56, 20, 32 ], @@ -336,7 +336,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 55, + 57, 20, 32 ], @@ -346,7 +346,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 60, + 62, 13, 50 ], @@ -370,7 +370,7 @@ function assignOverwritesTarget(title, source) { Test.run([ [ "Stdlib_ObjectTests.res", - 68, + 70, 22, 39 ], @@ -381,7 +381,7 @@ function assignOverwritesTarget(title, source) { Test.run([ [ "Stdlib_ObjectTests.res", - 69, + 71, 22, 39 ], @@ -392,7 +392,7 @@ function assignOverwritesTarget(title, source) { Test.run([ [ "Stdlib_ObjectTests.res", - 70, + 72, 22, 39 ], @@ -414,7 +414,7 @@ function runGetTest(i) { Test.run([ [ "Stdlib_ObjectTests.res", - 88, + 90, 22, 46 ], @@ -497,7 +497,7 @@ function getSymbolTestWhenExists() { Test.run([ [ "Stdlib_ObjectTests.res", - 148, + 150, 15, 63 ], @@ -510,7 +510,7 @@ getSymbolTestWhenExists(); Test.run([ [ "Stdlib_ObjectTests.res", - 157, + 160, 13, 65 ], @@ -520,7 +520,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 166, + 169, 13, 46 ], @@ -532,7 +532,7 @@ Test.run([ Test.run([ [ "Stdlib_ObjectTests.res", - 173, + 176, 13, 46 ], diff --git a/tests/tests/src/stdlib/Stdlib_ObjectTests.res b/tests/tests/src/stdlib/Stdlib_ObjectTests.res index ee139d805ec..ba4644f1992 100644 --- a/tests/tests/src/stdlib/Stdlib_ObjectTests.res +++ b/tests/tests/src/stdlib/Stdlib_ObjectTests.res @@ -27,12 +27,14 @@ Test.run(__POS_OF__("is: list"), list{1, 2, 3} == list{1, 2, 3}, eq, true) Test.run(__POS_OF__("is: list"), list{1, 2, 3} === list{1, 2, 3}, eq, false) let d = Date.makeWithYM(~year=2000, ~month=1) + Test.run( __POS_OF__("is: date"), Object.is(Date.makeWithYM(~year=2000, ~month=1), Date.makeWithYM(~year=2000, ~month=1)), eq, false, ) + Test.run(__POS_OF__("is: date"), Object.is(d, d), eq, true) let x = {"a": 1} @@ -151,6 +153,7 @@ let getSymbolTestWhenExists = () => { Some("banana"), ) } + getSymbolTestWhenExists() Test.run( diff --git a/tests/tests/src/stdlib/Stdlib_ResultTests.mjs b/tests/tests/src/stdlib/Stdlib_ResultTests.mjs index 1ee75a2ebc7..91f858d2e12 100644 --- a/tests/tests/src/stdlib/Stdlib_ResultTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_ResultTests.mjs @@ -38,7 +38,7 @@ function forEachIfErrorDoNotCallFunction() { Test.run([ [ "Stdlib_ResultTests.res", - 17, + 18, 22, 63 ], @@ -51,7 +51,7 @@ forEachIfErrorDoNotCallFunction(); Test.run([ [ "Stdlib_ResultTests.res", - 25, + 27, 20, 48 ], @@ -67,7 +67,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 28, + 30, 13, 42 ], @@ -83,7 +83,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 34, + 36, 20, 25 ], @@ -96,7 +96,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 35, + 37, 20, 25 ], @@ -126,7 +126,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 36, + 38, 20, 25 ], @@ -148,7 +148,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 37, + 39, 20, 25 ], @@ -173,7 +173,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 38, + 40, 20, 25 ], @@ -195,7 +195,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 39, + 41, 20, 25 ], @@ -225,7 +225,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 40, + 42, 20, 25 ], @@ -251,7 +251,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 41, + 43, 20, 25 ], @@ -286,7 +286,7 @@ Test.run([ Test.run([ [ "Stdlib_ResultTests.res", - 42, + 44, 20, 25 ], diff --git a/tests/tests/src/stdlib/Stdlib_ResultTests.res b/tests/tests/src/stdlib/Stdlib_ResultTests.res index d76c1a3b36a..34a0b77023c 100644 --- a/tests/tests/src/stdlib/Stdlib_ResultTests.res +++ b/tests/tests/src/stdlib/Stdlib_ResultTests.res @@ -9,6 +9,7 @@ let forEachIfOkCallFunction = () => { Ok(3)->Result.forEach(i => called.contents->Array.push(i)) Test.run(__POS_OF__("forEach: if ok, call function with ok value once"), called.contents, eq, [3]) } + forEachIfOkCallFunction() let forEachIfErrorDoNotCallFunction = () => { @@ -16,6 +17,7 @@ let forEachIfErrorDoNotCallFunction = () => { Error(3)->Result.forEach(i => called.contents->Array.push(i)) Test.run(__POS_OF__("forEach: if error, do not call function"), called.contents, eq, []) } + forEachIfErrorDoNotCallFunction() // ======== diff --git a/tests/tests/src/stdlib/Stdlib_StringTests.mjs b/tests/tests/src/stdlib/Stdlib_StringTests.mjs index cd25d7f306a..4bb85cca220 100644 --- a/tests/tests/src/stdlib/Stdlib_StringTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_StringTests.mjs @@ -18,7 +18,7 @@ Test.run([ Test.run([ [ "Stdlib_StringTests.res", - 5, + 6, 13, 32 ], diff --git a/tests/tests/src/stdlib/Stdlib_StringTests.res b/tests/tests/src/stdlib/Stdlib_StringTests.res index f8ca0df1ac3..e9d60be5bd0 100644 --- a/tests/tests/src/stdlib/Stdlib_StringTests.res +++ b/tests/tests/src/stdlib/Stdlib_StringTests.res @@ -1,6 +1,7 @@ let eq = (a, b) => a == b Test.run(__POS_OF__("String.equal optimization"), String.equal("one", "three"), eq, false) + Test.run( __POS_OF__("String.asIterable"), "abc"->String.asIterable->Array.fromIterable, diff --git a/tests/tests/src/stdlib/Stdlib_TempTests.res b/tests/tests/src/stdlib/Stdlib_TempTests.res index 23ef80ee04f..52f4f0ecf33 100644 --- a/tests/tests/src/stdlib/Stdlib_TempTests.res +++ b/tests/tests/src/stdlib/Stdlib_TempTests.res @@ -25,6 +25,7 @@ Console.log2(dict, dict2) Console.info("") Console.info("Error") Console.info("---") + let f = () => { let error = JsError.make("hello") let typeError = JsError.TypeError.make("error") @@ -45,6 +46,7 @@ Console.info("") Console.info("JSON") Console.info("---") let json = JSON.parseOrThrow(`{"foo": "bar"}`) + Console.log( switch json { | Object(json) => @@ -83,6 +85,7 @@ Console.log({ Console.info("") Console.info("Object") Console.info("---") + let myObject = { "foo": "bar", } @@ -98,6 +101,7 @@ let withNewProp = Object.assign(copy, {"bar": "baz"}) Console.info("") Console.info("Promise") Console.info("---") + let promise: promise<int> = Promise.make((resolve, _reject) => { let _ = setTimeout(() => { resolve(1) @@ -140,6 +144,7 @@ Console.info("") Console.info("String") Console.info("---") let regexp = RegExp.fromString("(hello )(world)") + Console.log( " Hello world " ->String.toLowerCase diff --git a/tests/tests/src/stdlib/Stdlib_TestTests.mjs b/tests/tests/src/stdlib/Stdlib_TestTests.mjs index 3f5ed23ec51..bca6b692aad 100644 --- a/tests/tests/src/stdlib/Stdlib_TestTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_TestTests.mjs @@ -164,7 +164,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 23, + 24, 13, 27 ], @@ -174,7 +174,7 @@ Test.run([ Test.run([ [ "Stdlib_TestTests.res", - 28, + 30, 20, 31 ], diff --git a/tests/tests/src/stdlib/Stdlib_TestTests.res b/tests/tests/src/stdlib/Stdlib_TestTests.res index 977583ccf8e..f52ae09d21c 100644 --- a/tests/tests/src/stdlib/Stdlib_TestTests.res +++ b/tests/tests/src/stdlib/Stdlib_TestTests.res @@ -19,10 +19,12 @@ Test.run(__POS_OF__("print array"), Test.print([1, 2, 3]), eq, "[ 1, 2, 3 ]") Test.run(__POS_OF__("print symbol"), Test.print(Symbol.make("foo")), eq, "Symbol(foo)") Test.run(__POS_OF__("print function"), Test.print(() => 42), eq, "() => 42") Test.run(__POS_OF__("print es6 function"), Test.print(%raw("() => 42")), eq, "() => 42") + Test.run( __POS_OF__("print bigint"), Test.print(bign), eq, "359538626972463141629054847463408713596141135051689993197834953606314521560057077521179117265533756343080917907028764928468642653778928365536935093407075033972099821153102564152490980180778657888151737016910267884609166473806445896331617118664246696549595652408289446337476354361838599762500808052368249716736n", ) + Test.run(__POS_OF__("print set"), Test.print(Set.fromArray([1, 2, 2, 3])), eq, "Set(3) { 1, 2, 3 }") diff --git a/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res b/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res index 3c0eff53879..f0eee609828 100644 --- a/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res +++ b/tests/tests/src/stdlib/Stdlib_TypedArrayTests.res @@ -76,4 +76,5 @@ assertTrue("a typed array is a TypedArray.t through a coercion", () => { let x = BigInt64Array.fromLength(2) TypedArray.length(x :> TypedArray.t<bigint>) == 2 }) + let o = (x, map) => BigInt64Array.fromArrayLikeOrIterable(x, ~map) diff --git a/tests/tests/src/stdlib/Test.res b/tests/tests/src/stdlib/Test.res index 29d153132e4..5b8c5eba278 100644 --- a/tests/tests/src/stdlib/Test.res +++ b/tests/tests/src/stdlib/Test.res @@ -3,14 +3,17 @@ type process = {mutable exitCode: int} @val external process: process = "process" @scope("Error") @val external captureStackTrace: {..} => unit = "captureStackTrace" + @module("@babel/code-frame") @val external codeFrameColumns: (string, {..}, {..}) => string = "codeFrameColumns" + @module("fs") @val external readFileSync: (string, {..}) => string = "readFileSync" @module("path") @val external join: (string, string) => string = "join" let dirname = %raw("new URL('.', import.meta.url).pathname") @val @module("util") external inspect: _ => string = "inspect" + let print = value => switch Type.typeof(value) { | #string => JSON.stringifyAny(value)->Option.getOrThrow // uses " instead of ' diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_CollatorTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_CollatorTest.res index 1983bdc416f..3928bfc1771 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_CollatorTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_CollatorTest.res @@ -4,10 +4,12 @@ Console.log("Intl.Collator") let _collator = Intl.Collator.make() let _collator = Intl.Collator.make(~locales=["en-US"]) let _collator = Intl.Collator.make(~locales=["en-US", "en-GB"]) + let collator = Intl.Collator.make( ~locales=["en-US"], ~options={caseFirst: #upper, sensitivity: #base, ignorePunctuation: true, numeric: true}, ) + Intl.Collator.supportedLocalesOf(["en-US", "en-GB"])->ignore Intl.Collator.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_DateTimeFormatTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_DateTimeFormatTest.res index 8daee82d93a..b8af5bc8c47 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_DateTimeFormatTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_DateTimeFormatTest.res @@ -2,6 +2,7 @@ Console.log("---") Console.log("Intl.DateTimeFormat") Intl.DateTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore + Intl.DateTimeFormat.supportedLocalesOf( ["en-US", "en-GB"], ~options={localeMatcher: #lookup}, @@ -33,6 +34,7 @@ let options: Intl.DateTimeFormat.options = { fractionalSecondDigits: #3, timeZoneName: #longGeneric, } + let formatter = Intl.DateTimeFormat.make(~options) Console.log(formatter->Intl.DateTimeFormat.format(Date.fromTime(Date.now()))) diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_ListFormatTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_ListFormatTest.res index d925c00ccd3..8acfd5f0457 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_ListFormatTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_ListFormatTest.res @@ -3,10 +3,12 @@ Console.log("Intl.ListFormat") let _formatter = Intl.ListFormat.make() let _formatter = Intl.ListFormat.make(~locales=["en-US", "en-GB"]) + let _formatter = Intl.ListFormat.make( ~locales=["en-US", "en-GB"], ~options={style: #long, \"type": #conjunction}, ) + Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore Intl.ListFormat.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: #lookup})->ignore diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_LocaleTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_LocaleTest.res index fe9b0537b30..e9d6a866cc6 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_LocaleTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_LocaleTest.res @@ -2,6 +2,7 @@ Console.log("---") Console.log("Intl.Locale") let _locale = Intl.Locale.make("en-US") + let locale = Intl.Locale.make( "en-US", ~options={ diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_NumberFormatTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_NumberFormatTest.res index 1d7faf679be..fb18ba18582 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_NumberFormatTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_NumberFormatTest.res @@ -22,6 +22,7 @@ let groupingFormatter1 = Intl.NumberFormat.make( useGrouping: Intl.NumberFormat.Grouping.fromBool(true), }, ) + let groupingFormatter2 = Intl.NumberFormat.make( ~options={ useGrouping: Intl.NumberFormat.Grouping.fromString(#auto), diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_PluralRulesTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_PluralRulesTest.res index 3262ee5b61c..fe03421107d 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_PluralRulesTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_PluralRulesTest.res @@ -3,6 +3,7 @@ Console.log("Intl.PluralRules") let _formatter = Intl.PluralRules.make() let _formatter = Intl.PluralRules.make(~locales=["en-US", "en-GB"]) + let _formatter = Intl.PluralRules.make( ~options={ \"type": #ordinal, @@ -10,6 +11,7 @@ let _formatter = Intl.PluralRules.make( minimumSignificantDigits: #3, }, ) + let formatter = Intl.PluralRules.make( ~locales=["en-US"], ~options={ diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_RelativeTimeFormatTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_RelativeTimeFormatTest.res index e246525df95..261be2ccd38 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_RelativeTimeFormatTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_RelativeTimeFormatTest.res @@ -2,6 +2,7 @@ Console.log("---") Console.log("Intl.RelativeTimeFormat") Intl.RelativeTimeFormat.supportedLocalesOf(["en-US", "en-GB"])->ignore + Intl.RelativeTimeFormat.supportedLocalesOf( ["en-US", "en-GB"], ~options={localeMatcher: #lookup}, @@ -9,12 +10,14 @@ Intl.RelativeTimeFormat.supportedLocalesOf( let _formatter = Intl.RelativeTimeFormat.make() let _formatter = Intl.RelativeTimeFormat.make(~locales=["en-US", "en-GB"]) + let _formatter = Intl.RelativeTimeFormat.make( ~options={ numeric: #always, style: #narrow, }, ) + let formatter = Intl.RelativeTimeFormat.make( ~locales=["en-US"], ~options={ diff --git a/tests/tests/src/stdlib/intl/Stdlib_Intl_SegmenterTest.res b/tests/tests/src/stdlib/intl/Stdlib_Intl_SegmenterTest.res index a95819a6496..64d3509b0d6 100644 --- a/tests/tests/src/stdlib/intl/Stdlib_Intl_SegmenterTest.res +++ b/tests/tests/src/stdlib/intl/Stdlib_Intl_SegmenterTest.res @@ -6,11 +6,13 @@ Intl.Segmenter.supportedLocalesOf(["en-US", "en-GB"], ~options={localeMatcher: # let _formatter = Intl.Segmenter.make() let _formatter = Intl.Segmenter.make(~locales=["en-US", "en-GB"]) + let _formatter = Intl.Segmenter.make( ~options={ granularity: #word, }, ) + let formatter = Intl.Segmenter.make( ~locales=["en-US"], ~options={ diff --git a/tests/tests/src/stdlib_variance_test.mjs b/tests/tests/src/stdlib_variance_test.mjs index a9fb19cb68c..518c653431d 100644 --- a/tests/tests/src/stdlib_variance_test.mjs +++ b/tests/tests/src/stdlib_variance_test.mjs @@ -76,9 +76,9 @@ Mocha.describe("Stdlib_variance_test", () => { for (let x of widened) { seen.push(x); } - Test_utils.eq("File \"stdlib_variance_test.res\", line 64, characters 7-14", ["A"], seen); + Test_utils.eq("File \"stdlib_variance_test.res\", line 73, characters 7-14", ["A"], seen); }); - Mocha.test("a tag accepting more parameters is used where fewer are expected", () => Test_utils.eq("File \"stdlib_variance_test.res\", line 69, characters 7-14", "a|b:x", joinTag`a${"x"}b`)); + Mocha.test("a tag accepting more parameters is used where fewer are expected", () => Test_utils.eq("File \"stdlib_variance_test.res\", line 78, characters 7-14", "a|b:x", joinTag`a${"x"}b`)); }); let useWithB = failing; diff --git a/tests/tests/src/stdlib_variance_test.res b/tests/tests/src/stdlib_variance_test.res index e93b8ef51ca..dfe0f647367 100644 --- a/tests/tests/src/stdlib_variance_test.res +++ b/tests/tests/src/stdlib_variance_test.res @@ -5,22 +5,31 @@ open Test_utils // contravariant in their resume type, so these coercions type-check. let widenIterator = (i: Iterator.t<[#A], [#R], [#X | #Y]>) => (i :> Iterator.t<[#A | #B], [#R | #S], [#X]>) + let widenAsyncIterator = (i: AsyncIterator.t<[#A], [#R], [#X | #Y]>) => (i :> AsyncIterator.t<[#A | #B], [#R | #S], [#X]>) + let widenRawResult = (r: Iterator.rawResult<[#A], [#R]>) => (r :> Iterator.rawResult<[#A | #B], [#R | #S]>) + let widenAsyncRawResult = (r: AsyncIterator.rawResult<[#A], [#R]>) => (r :> AsyncIterator.rawResult<[#A | #B], [#R | #S]>) + let widenGenerator = (g: Generator.t<[#A], [#R], [#X | #Y]>) => (g :> Generator.t<[#A | #B], [#R | #S], [#X]>) + let widenAsyncGenerator = (g: AsyncGenerator.t<[#A], [#R], [#X | #Y]>) => (g :> AsyncGenerator.t<[#A | #B], [#R | #S], [#X]>) + let widenIterableIterator = (i: IterableIterator.t<[#A], [#R], [#X | #Y]>) => (i :> IterableIterator.t<[#A | #B], [#R | #S], [#X]>) + let widenAsyncIterableIterator = (i: AsyncIterableIterator.t<[#A], [#R], [#X | #Y]>) => (i :> AsyncIterableIterator.t<[#A | #B], [#R | #S], [#X]>) + let widenIteratorObject = (i: IteratorObject.t<[#A], [#R], [#X | #Y]>) => (i :> IteratorObject.t<[#A | #B], [#R | #S], [#X]>) + let widenArrayLike = (a: Array.arrayLike<[#A]>) => (a :> Array.arrayLike<[#A | #B]>) // A tag is contravariant in its parameters and covariant in its output. diff --git a/tests/tests/src/string_literal_normalization_test.mjs b/tests/tests/src/string_literal_normalization_test.mjs index 6ae30a14b68..d05fe5c2d23 100644 --- a/tests/tests/src/string_literal_normalization_test.mjs +++ b/tests/tests/src/string_literal_normalization_test.mjs @@ -45,31 +45,31 @@ let rawBridgeFunction = (() => '\\n'); let rawBridgeRegex = /\\n/; Mocha.describe("String_literal_normalization_test", () => { - Mocha.test("attribute payloads use semantic strings", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 44, characters 59-66", Math.max(1, 2), 2)); + Mocha.test("attribute payloads use semantic strings", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 46, characters 59-66", Math.max(1, 2), 2)); Mocha.test("scope and module payloads use semantic strings", () => { - Test_utils.eq("File \"string_literal_normalization_test.res\", line 47, characters 7-14", Math.max(1, 2), 2); - Test_utils.eq("File \"string_literal_normalization_test.res\", line 48, characters 7-14", Nodepath.basename("/a/b"), "b"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 49, characters 7-14", Math.max(1, 2), 2); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 50, characters 7-14", Nodepath.basename("/a/b"), "b"); }); - Mocha.test("ordinary escapes have one semantic representation", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 51, characters 69-76", escaped, "abc")); + Mocha.test("ordinary escapes have one semantic representation", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 53, characters 69-76", escaped, "abc")); Mocha.test("named escapes and line continuations have JavaScript semantics", () => { - Test_utils.eq("File \"string_literal_normalization_test.res\", line 54, characters 7-14", namedEscapes, "\b\f\n\r\t\x0b\0"); - Test_utils.eq("File \"string_literal_normalization_test.res\", line 55, characters 7-14", continued, "ab"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 56, characters 7-14", namedEscapes, "\b\f\n\r\t\x0b\0"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 57, characters 7-14", continued, "ab"); }); - Mocha.test("surrogate-pair escapes have one semantic representation", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 59, characters 7-14", surrogatePair, "😀")); + Mocha.test("surrogate-pair escapes have one semantic representation", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 61, characters 7-14", surrogatePair, "😀")); Mocha.test("ordinary literals participate in constant folding", () => { - Test_utils.eq("File \"string_literal_normalization_test.res\", line 63, characters 7-14", concatenated, "ab"); - Test_utils.eq("File \"string_literal_normalization_test.res\", line 64, characters 7-14", 1, 1); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 65, characters 7-14", concatenated, "ab"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 66, characters 7-14", 1, 1); }); - Mocha.test("template segments survive the ast0 bridge", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 67, characters 61-68", interpolated, "abc")); + Mocha.test("template segments survive the ast0 bridge", () => Test_utils.eq("File \"string_literal_normalization_test.res\", line 69, characters 61-68", interpolated, "abc")); Mocha.test("constant templates preserve value generalization", () => { - Test_utils.eq("File \"string_literal_normalization_test.res\", line 70, characters 7-14", polymorphicTemplateInt, 1); - Test_utils.eq("File \"string_literal_normalization_test.res\", line 71, characters 7-14", polymorphicTemplateString, "value"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 72, characters 7-14", polymorphicTemplateInt, 1); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 73, characters 7-14", polymorphicTemplateString, "value"); }); Mocha.test("raw extension payloads preserve source spelling through ast0", () => { - Test_utils.eq("File \"string_literal_normalization_test.res\", line 75, characters 7-14", rawBridgeExpression, "\\n"); - Test_utils.eq("File \"string_literal_normalization_test.res\", line 76, characters 7-14", rawBridgeFunction(), "\\n"); - Test_utils.eq("File \"string_literal_normalization_test.res\", line 77, characters 7-14", rawBridgeProgramValue, "\\n"); - Test_utils.eq("File \"string_literal_normalization_test.res\", line 78, characters 7-14", rawBridgeRegex.test("\\n"), true); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 77, characters 7-14", rawBridgeExpression, "\\n"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 78, characters 7-14", rawBridgeFunction(), "\\n"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 79, characters 7-14", rawBridgeProgramValue, "\\n"); + Test_utils.eq("File \"string_literal_normalization_test.res\", line 80, characters 7-14", rawBridgeRegex.test("\\n"), true); }); }); diff --git a/tests/tests/src/string_literal_normalization_test.res b/tests/tests/src/string_literal_normalization_test.res index 4760e723c68..1c3ae246bbb 100644 --- a/tests/tests/src/string_literal_normalization_test.res +++ b/tests/tests/src/string_literal_normalization_test.res @@ -14,8 +14,10 @@ external escapedModuleName: string => string = "basename" let escaped = "\x61\u0062\u{63}" let namedEscapes = "\b\f\n\r\t\v\0" + let continued = "a\ b" + let surrogatePair = "\uD83D\uDE00" let concatenated = "\x61" ++ "\u0062" let interpolated = `\x61${"b"}\u0063` diff --git a/tests/tests/src/string_set.res b/tests/tests/src/string_set.res index 43e592a7edc..9f90c7efe52 100644 --- a/tests/tests/src/string_set.res +++ b/tests/tests/src/string_set.res @@ -60,6 +60,7 @@ let rec split = (x, tree: Set_gen.t<_>): (Set_gen.t<_>, bool, Set_gen.t<_>) => (Set_gen.internal_join(l, v, lr), pres, rr) } } + let rec add = (x, tree: Set_gen.t<_>): Set_gen.t<_> => switch tree { | Empty => Node(Empty, x, Empty, 1) diff --git a/tests/tests/src/submodule.mjs b/tests/tests/src/submodule.mjs index 5e4c70a5fab..2a7a4cdfe6e 100644 --- a/tests/tests/src/submodule.mjs +++ b/tests/tests/src/submodule.mjs @@ -7,25 +7,25 @@ function a0(x, y) { return (x + y | 0) + 1 | 0; } -console.log(5); +console.log(6); function a1(x, y) { return a0(x, y) + 1 | 0; } -console.log(8); +console.log(10); function a2(x, y) { return a1(x, y) + 1 | 0; } -console.log(11); +console.log(14); function a3(x, y) { return a2(x, y) + 1 | 0; } -console.log(14); +console.log(18); function a4(x, y) { return a3(x, y) + 1 | 0; diff --git a/tests/tests/src/submodule.res b/tests/tests/src/submodule.res index a7f00290db0..fb417841a04 100644 --- a/tests/tests/src/submodule.res +++ b/tests/tests/src/submodule.res @@ -1,15 +1,19 @@ module A0 = { let () = Console.log(__LINE__) let a0 = (x, y) => x + y + 1 + module A1 = { let () = Console.log(__LINE__) let a1 = (x, y) => a0(x, y) + 1 + module A2 = { let () = Console.log(__LINE__) let a2 = (x, y) => a1(x, y) + 1 + module A3 = { let () = Console.log(__LINE__) let a3 = (x, y) => a2(x, y) + 1 + module A4 = { let () = Console.log(__LINE__) let a4 = (x, y) => a3(x, y) + 1 diff --git a/tests/tests/src/tagged_template_test.mjs b/tests/tests/src/tagged_template_test.mjs index efb0d26eba9..5a13618987d 100644 --- a/tests/tests/src/tagged_template_test.mjs +++ b/tests/tests/src/tagged_template_test.mjs @@ -71,34 +71,34 @@ let rawTag = Tagged_template_libJs.rawTag; let rawResult = rawTag`a ${1} b ${2} c`; Mocha.describe("tagged templates", () => { - Mocha.test("with externals, it should return a string with the correct interpolations", () => Test_utils.eq("File \"tagged_template_test.res\", line 99, characters 6-13", query, ` + Mocha.test("with externals, it should return a string with the correct interpolations", () => Test_utils.eq("File \"tagged_template_test.res\", line 100, characters 6-13", query, ` " SELECT * FROM 'users' WHERE id = '5'`)); - Mocha.test("with module scoped externals, it should also return a string with the correct interpolations", () => Test_utils.eq("File \"tagged_template_test.res\", line 108, characters 13-20", queryWithModule, "SELECT * FROM 'users' WHERE id = '5'")); - Mocha.test("a tag named json remains an ordinary tagged template", () => Test_utils.eq("File \"tagged_template_test.res\", line 112, characters 7-14", jsonTaggedQuery, "SELECT * FROM 'users'")); - Mocha.test("with externals, it should return the result of the function", () => Test_utils.eq("File \"tagged_template_test.res\", line 115, characters 79-86", length$1, 52)); - Mocha.test("with a runtime-constructed tag (factory), it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 118, characters 7-14", factoryQuery, "PREFIX SELECT * FROM 'users'")); - Mocha.test("with a tag from a bare package import, it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 124, characters 7-14", bareImportQuery, "PG: SELECT * FROM 'users'")); - Mocha.test("with a tag passed as a function argument, it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 128, characters 7-14", paramQuery, "SELECT id = '5'")); - Mocha.test("with a tag imported from another module, it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 132, characters 7-14", crossModuleQuery, "X: SELECT * FROM 'users'")); + Mocha.test("with module scoped externals, it should also return a string with the correct interpolations", () => Test_utils.eq("File \"tagged_template_test.res\", line 109, characters 13-20", queryWithModule, "SELECT * FROM 'users' WHERE id = '5'")); + Mocha.test("a tag named json remains an ordinary tagged template", () => Test_utils.eq("File \"tagged_template_test.res\", line 113, characters 7-14", jsonTaggedQuery, "SELECT * FROM 'users'")); + Mocha.test("with externals, it should return the result of the function", () => Test_utils.eq("File \"tagged_template_test.res\", line 116, characters 79-86", length$1, 52)); + Mocha.test("with a runtime-constructed tag (factory), it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 119, characters 7-14", factoryQuery, "PREFIX SELECT * FROM 'users'")); + Mocha.test("with a tag from a bare package import, it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 125, characters 7-14", bareImportQuery, "PG: SELECT * FROM 'users'")); + Mocha.test("with a tag passed as a function argument, it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 129, characters 7-14", paramQuery, "SELECT id = '5'")); + Mocha.test("with a tag imported from another module, it should emit tagged-template syntax", () => Test_utils.eq("File \"tagged_template_test.res\", line 133, characters 7-14", crossModuleQuery, "X: SELECT * FROM 'users'")); Mocha.test("it should call the tag as a real tagged template (TemplateStringsArray with .raw)", () => { - Test_utils.eq("File \"tagged_template_test.res\", line 136, characters 7-14", rawResult.hasRaw, true); - Test_utils.eq("File \"tagged_template_test.res\", line 137, characters 7-14", rawResult.cooked, [ + Test_utils.eq("File \"tagged_template_test.res\", line 137, characters 7-14", rawResult.hasRaw, true); + Test_utils.eq("File \"tagged_template_test.res\", line 138, characters 7-14", rawResult.cooked, [ "a ", " b ", " c" ]); - Test_utils.eq("File \"tagged_template_test.res\", line 138, characters 7-14", rawResult.raw, [ + Test_utils.eq("File \"tagged_template_test.res\", line 139, characters 7-14", rawResult.raw, [ "a ", " b ", " c" ]); - Test_utils.eq("File \"tagged_template_test.res\", line 139, characters 7-14", rawResult.values, [ + Test_utils.eq("File \"tagged_template_test.res\", line 140, characters 7-14", rawResult.values, [ 1, 2 ]); }); - Mocha.test("with a ReScript tag lifted via TaggedTemplate.make, it should return the correct interpolation", () => Test_utils.eq("File \"tagged_template_test.res\", line 144, characters 13-20", greeting, "hello Ada you're 36 years old!")); - Mocha.test("a regular string interpolation should continue working", () => Test_utils.eq("File \"tagged_template_test.res\", line 148, characters 7-14", `some random string interpolation`, "some random string interpolation")); + Mocha.test("with a ReScript tag lifted via TaggedTemplate.make, it should return the correct interpolation", () => Test_utils.eq("File \"tagged_template_test.res\", line 145, characters 13-20", greeting, "hello Ada you're 36 years old!")); + Mocha.test("a regular string interpolation should continue working", () => Test_utils.eq("File \"tagged_template_test.res\", line 149, characters 7-14", `some random string interpolation`, "some random string interpolation")); Mocha.test("ordinary interpolation evaluates values once from left to right", () => { let calls = []; let record = value => { @@ -106,15 +106,15 @@ Mocha.describe("tagged templates", () => { return value; }; let result = `start ${record("first")} middle ${record("second")} end`; - Test_utils.eq("File \"tagged_template_test.res\", line 158, characters 7-14", result, "start first middle second end"); - Test_utils.eq("File \"tagged_template_test.res\", line 159, characters 7-14", calls, [ + Test_utils.eq("File \"tagged_template_test.res\", line 159, characters 7-14", result, "start first middle second end"); + Test_utils.eq("File \"tagged_template_test.res\", line 160, characters 7-14", calls, [ "first", "second" ]); }); Mocha.test("invalid escapes remain valid in tagged-template segments", () => { let result = rawTag`\unicode`; - Test_utils.eq("File \"tagged_template_test.res\", line 164, characters 7-14", result.raw, ["\\unicode"]); + Test_utils.eq("File \"tagged_template_test.res\", line 165, characters 7-14", result.raw, ["\\unicode"]); }); }); diff --git a/tests/tests/src/tagged_template_test.res b/tests/tests/src/tagged_template_test.res index afa20e9e5c9..61779514cb6 100644 --- a/tests/tests/src/tagged_template_test.res +++ b/tests/tests/src/tagged_template_test.res @@ -23,6 +23,7 @@ let jsonTaggedQuery = json`SELECT * FROM ${table}` // The tag still emits backticks when used through `open` (i.e. once it has // crossed the module boundary as a value of the `taggedTemplate` type). open Pg + let query = sql` " SELECT * FROM ${table} WHERE id = ${id}` diff --git a/tests/tests/src/test_bool_equal.res b/tests/tests/src/test_bool_equal.res index 5264d2073f7..6b617921f2b 100644 --- a/tests/tests/src/test_bool_equal.res +++ b/tests/tests/src/test_bool_equal.res @@ -29,6 +29,7 @@ let f0 = x => } else { 2 } + let f1 = x => if !(x == true) { 1 @@ -42,6 +43,7 @@ let f2 = x => } else { 2 } + let f3 = x => if x == false { 1 diff --git a/tests/tests/src/test_demo.res b/tests/tests/src/test_demo.res index 5da073c69a8..9ae2842e366 100644 --- a/tests/tests/src/test_demo.res +++ b/tests/tests/src/test_demo.res @@ -1,4 +1,5 @@ let f = x => x + 1 + let rec fib = x => switch x { | 1 | 2 => 1 @@ -95,6 +96,7 @@ let f = (h, g, x) => ) let f = (x, y, z) => x + y + z + let g = (x, y) => { let u = x + y z => u + z @@ -104,6 +106,7 @@ let g1 = (x, y) => { let u = x + y (xx, yy) => xx + yy + u } + let x = g(3, 5)(6) let v = g1(3, 4)(6, ...) diff --git a/tests/tests/src/test_exception_escape.res b/tests/tests/src/test_exception_escape.res index 852059b38c0..5608006ddc0 100644 --- a/tests/tests/src/test_exception_escape.res +++ b/tests/tests/src/test_exception_escape.res @@ -2,6 +2,7 @@ module N: { let f: int } = { exception A(int) + let f = try throw(A(3)) catch { | _ => 3 } diff --git a/tests/tests/src/test_ffi.res b/tests/tests/src/test_ffi.res index ededddffbc5..3d22f76ae3c 100644 --- a/tests/tests/src/test_ffi.res +++ b/tests/tests/src/test_ffi.res @@ -7,6 +7,7 @@ external log: 'a => unit = "?ignore" @scope("console") external log2: 'a => unit = "log" external log3: 'a => unit = "log" + let v = u => { log3(u) log2(u) diff --git a/tests/tests/src/test_incomplete.mjs b/tests/tests/src/test_incomplete.mjs index 27415a8be71..98af0eb55a0 100644 --- a/tests/tests/src/test_incomplete.mjs +++ b/tests/tests/src/test_incomplete.mjs @@ -9,7 +9,7 @@ function f(x) { RE_EXN_ID: "Match_failure", _1: [ "test_incomplete.res", - 3, + 4, 2 ], Error: new Error() diff --git a/tests/tests/src/test_incomplete.res b/tests/tests/src/test_incomplete.res index f8c4a7d72a6..f1882980b24 100644 --- a/tests/tests/src/test_incomplete.res +++ b/tests/tests/src/test_incomplete.res @@ -1,4 +1,5 @@ @@warning("-a") + let f = x => switch x { | 1 diff --git a/tests/tests/src/test_let.res b/tests/tests/src/test_let.res index 8d8a8f074a5..c9fbd5dcc6c 100644 --- a/tests/tests/src/test_let.res +++ b/tests/tests/src/test_let.res @@ -2,4 +2,5 @@ let a = 3 Console.log(a) } + let b = 3 diff --git a/tests/tests/src/test_list.mjs b/tests/tests/src/test_list.mjs index aa0e07c15e6..60ea1ef3fe3 100644 --- a/tests/tests/src/test_list.mjs +++ b/tests/tests/src/test_list.mjs @@ -656,7 +656,7 @@ function chop(_k, _l) { RE_EXN_ID: "Assert_failure", _1: [ "test_list.res", - 343, + 344, 11 ], Error: new Error() diff --git a/tests/tests/src/test_list.res b/tests/tests/src/test_list.res index 73dd1e3079e..2cb92e67412 100644 --- a/tests/tests/src/test_list.res +++ b/tests/tests/src/test_list.res @@ -14,6 +14,7 @@ /* List operations */ let u = List.length + let rec length_aux = (len, x) => switch x { | list{} => len diff --git a/tests/tests/src/test_literals.res b/tests/tests/src/test_literals.res index 2a52f7dcdd8..ae8e435d435 100644 --- a/tests/tests/src/test_literals.res +++ b/tests/tests/src/test_literals.res @@ -1,3 +1,4 @@ /** nodejs */ let node_modules = "node_modules" + let node_modules_length = String.length("node_modules") diff --git a/tests/tests/src/test_nested_print.res b/tests/tests/src/test_nested_print.res index e6cebc6a459..640cccbe757 100644 --- a/tests/tests/src/test_nested_print.res +++ b/tests/tests/src/test_nested_print.res @@ -1,4 +1,5 @@ let u = (x, x) => x + x + let f = (g, x) => { let u = g(x) u + u diff --git a/tests/tests/src/test_per.res b/tests/tests/src/test_per.res index a33c4dfc06e..6522cf206a4 100644 --- a/tests/tests/src/test_per.res +++ b/tests/tests/src/test_per.res @@ -35,6 +35,7 @@ let min = (x, y) => } else { y } + let max = (x, y) => if x >= y { x @@ -127,6 +128,7 @@ type fpclass = | FP_zero | FP_infinite | FP_nan + external classify_float: float => fpclass = "?classify_float" external string_length: string => int = "%string_length" @@ -135,6 +137,7 @@ external string_length: string => int = "%string_length" external int_of_char: char => int = "%identity" external unsafe_char_of_int: int => char = "%identity" + let char_of_int = n => if n < 0 || n > 255 { invalid_arg("char_of_int") diff --git a/tests/tests/src/test_pervasives3.res b/tests/tests/src/test_pervasives3.res index fc83cc54fc8..4cbc3b89182 100644 --- a/tests/tests/src/test_pervasives3.res +++ b/tests/tests/src/test_pervasives3.res @@ -2,4 +2,5 @@ module Pervasives = { include Pervasives include List } + let v = List.concat diff --git a/tests/tests/src/test_primitive.res b/tests/tests/src/test_primitive.res index 8c2d8dc3a6a..03105322e7a 100644 --- a/tests/tests/src/test_primitive.res +++ b/tests/tests/src/test_primitive.res @@ -35,6 +35,7 @@ let test_abs = Math.abs(3.0) let v = [1.0, 2.0] let xxx = "a" let a = String.get(xxx, 0) + let u = b => { let a = if b { Console.log(1) @@ -44,6 +45,7 @@ let u = b => { } a } + let f = (h, b, ()) => h( if b { @@ -53,6 +55,7 @@ let f = (h, b, ()) => 3 + 4 }, ) + let f2 = (h, b, ()) => h( if b { @@ -61,7 +64,9 @@ let f2 = (h, b, ()) => 3 + 4 }, ) + @@warning("-26") + let f2 = (h, b, ()) => h( if b { @@ -71,12 +76,14 @@ let f2 = (h, b, ()) => 3 + 4 }, ) + let () = v[1] = 3.0 type u = { mutable u: float, v: float, } + let xx = (0., 0.) let unboxed_x = {u: 0., v: 0.} let f = ({u}) => u diff --git a/tests/tests/src/test_react_case.res b/tests/tests/src/test_react_case.res index 70b7a1e0d9b..677bbb2ecad 100644 --- a/tests/tests/src/test_react_case.res +++ b/tests/tests/src/test_react_case.res @@ -10,11 +10,15 @@ var CommentBox = React.createClass({ }); */ type obj_spec + type react_dom_element + @val external react_create_class: obj_spec => react_dom_element /* "createClass" "React" */ = "react_create_class" + type react_dom_component + @obj external mk_obj_spec: ( ~display_name: string=?, diff --git a/tests/tests/src/test_seq.res b/tests/tests/src/test_seq.res index 23d1f459735..8a6b3cecd4f 100644 --- a/tests/tests/src/test_seq.res +++ b/tests/tests/src/test_seq.res @@ -69,12 +69,14 @@ let rec assoc3 = (x, l) => /* ;; */ let help_action = () => throw(Stop(Unknown("-help"))) + let v = speclist => { ignore(assoc3("-help", speclist)) list{} } let f = (g, speclist) => g(assoc3("-help", speclist)) + let add_help = speclist => { let add1 = try { ignore(assoc3("-help", speclist)) diff --git a/tests/tests/src/test_set.res b/tests/tests/src/test_set.res index 78ed5e19994..be0fbe883ff 100644 --- a/tests/tests/src/test_set.res +++ b/tests/tests/src/test_set.res @@ -515,6 +515,7 @@ module Make = (Ord: OrderedType) => { | _ => of_sorted_list(l->List.sort((a, b) => Ord.compare(a, b)->Int.toFloat)) } } + module N = { let a = 3 } diff --git a/tests/tests/src/test_side_effect_functor.res b/tests/tests/src/test_side_effect_functor.res index b277cdd7e4f..a0897bc0e73 100644 --- a/tests/tests/src/test_side_effect_functor.res +++ b/tests/tests/src/test_side_effect_functor.res @@ -2,10 +2,12 @@ include ( { module M = () => { let v = ref(0) + { v.contents = v.contents + 1 v.contents->Int.toString->Console.log } + let u = 3 let use_v = () => v.contents let unuse_v = () => u + 32 diff --git a/tests/tests/src/test_simple_ref.res b/tests/tests/src/test_simple_ref.res index 44fcd26c1bc..9c48d67855a 100644 --- a/tests/tests/src/test_simple_ref.res +++ b/tests/tests/src/test_simple_ref.res @@ -6,6 +6,7 @@ include ( v.contents = v.contents + 1 v.contents } + let h = ref(0) let a = ref(0) @@ -16,6 +17,7 @@ include ( let b = a b.contents } + let real_escape = (f, v) => { let b = c f(b) diff --git a/tests/tests/src/test_simple_tailcall.res b/tests/tests/src/test_simple_tailcall.res index 6a2d8f4985e..5fe4b4dfe87 100644 --- a/tests/tests/src/test_simple_tailcall.res +++ b/tests/tests/src/test_simple_tailcall.res @@ -3,6 +3,7 @@ let rec length = (acc, x) => | list{} => acc | list{_, ...tl} => length(acc + 1, tl) } + let rec tailcall = x => tailcall(x) let rec non_length = x => diff --git a/tests/tests/src/test_trywith.mjs b/tests/tests/src/test_trywith.mjs index f9383e45265..1a964fb2587 100644 --- a/tests/tests/src/test_trywith.mjs +++ b/tests/tests/src/test_trywith.mjs @@ -112,7 +112,7 @@ function f(x) { RE_EXN_ID: "Assert_failure", _1: [ "test_trywith.res", - 59, + 61, 9 ], Error: new Error() diff --git a/tests/tests/src/test_trywith.res b/tests/tests/src/test_trywith.res index 3bc6206f3b5..55d33cc88c7 100644 --- a/tests/tests/src/test_trywith.res +++ b/tests/tests/src/test_trywith.res @@ -2,6 +2,7 @@ exception Out_of_memory exception Sys_error(string) exception Stack_overflow exception Sys_blocked_io + let ff = (g, x) => { try g(x) catch { | Not_found => () @@ -43,6 +44,7 @@ let u = () => { let f = 3 + 3 f + f } + let u1 = "bad character decimal encoding \\" let v = "bad character decimal encoding \\%c%c%c" diff --git a/tests/tests/src/test_tuple_destructring.res b/tests/tests/src/test_tuple_destructring.res index bfafa715cdc..4e98239083b 100644 --- a/tests/tests/src/test_tuple_destructring.res +++ b/tests/tests/src/test_tuple_destructring.res @@ -8,4 +8,5 @@ let v = N.b (3,4) belongs to ImmutableBlock */ let (u, h) = (3, 4) + let (g, gg) = (u, h) diff --git a/tests/tests/src/test_while_closure.mjs b/tests/tests/src/test_while_closure.mjs index 7f248c947eb..e651fa0cb9b 100644 --- a/tests/tests/src/test_while_closure.mjs +++ b/tests/tests/src/test_while_closure.mjs @@ -30,7 +30,7 @@ if (v.contents !== 45) { RE_EXN_ID: "Assert_failure", _1: [ "test_while_closure.res", - 55, + 56, 2 ], Error: new Error() diff --git a/tests/tests/src/test_while_closure.res b/tests/tests/src/test_while_closure.res index 71841134f9c..2231f0b3fee 100644 --- a/tests/tests/src/test_while_closure.res +++ b/tests/tests/src/test_while_closure.res @@ -39,6 +39,7 @@ This means inline is tricky in javascript, here we try to inline [_loop]? let v = ref(0) let count = 10 let arr = Array.make(~length=count, _ => ()) + let f = () => { let n = ref(0) while n.contents < count { diff --git a/tests/tests/src/test_while_side_effect.res b/tests/tests/src/test_while_side_effect.res index feb1d470b57..7233cd1ac6b 100644 --- a/tests/tests/src/test_while_side_effect.res +++ b/tests/tests/src/test_while_side_effect.res @@ -7,6 +7,7 @@ while { } { ignore() } + let rec fib = x => switch x { | 0 | 1 => 1 diff --git a/tests/tests/src/topsort_test.mjs b/tests/tests/src/topsort_test.mjs index 53aa6315b52..d2d57b2760d 100644 --- a/tests/tests/src/topsort_test.mjs +++ b/tests/tests/src/topsort_test.mjs @@ -255,7 +255,7 @@ if (!Primitive_object.equal(pathsort(grwork), {hd: "wake", tl: {hd: "shower", tl RE_EXN_ID: "Assert_failure", _1: [ "topsort_test.res", - 141, + 142, 9 ], Error: new Error() @@ -271,7 +271,7 @@ try { RE_EXN_ID: "Assert_failure", _1: [ "topsort_test.res", - 145, + 146, 2 ], Error: new Error() @@ -307,7 +307,7 @@ try { RE_EXN_ID: "Assert_failure", _1: [ "topsort_test.res", - 148, + 149, 7 ], Error: new Error() diff --git a/tests/tests/src/topsort_test.res b/tests/tests/src/topsort_test.res index 2b1e9b12924..16fe3cb6e08 100644 --- a/tests/tests/src/topsort_test.res +++ b/tests/tests/src/topsort_test.res @@ -113,6 +113,7 @@ let unsafe_topsort = graph => { let () = assert(unsafe_topsort(grwork) == list{"wake", "shower", "dress", "eat", "washup", "go"}) exception Cycle(list<string>) + let pathsort = graph => { let visited = ref(list{}) let empty_path = list{} diff --git a/tests/tests/src/tramp_fib_test.mjs b/tests/tests/src/tramp_fib_test.mjs index 164c3b86454..107e7cc6e65 100644 --- a/tests/tests/src/tramp_fib_test.mjs +++ b/tests/tests/src/tramp_fib_test.mjs @@ -70,8 +70,8 @@ function isOdd(n) { } Mocha.describe("Tramp_fib_test", () => { - Mocha.test("fibonacci trampoline", () => Test_utils.eq("File \"tramp_fib_test.res\", line 54, characters 7-14", iter(u), 89)); - Mocha.test("even/odd trampoline", () => Test_utils.eq("File \"tramp_fib_test.res\", line 58, characters 7-14", iter(isEven(20000)), true)); + Mocha.test("fibonacci trampoline", () => Test_utils.eq("File \"tramp_fib_test.res\", line 56, characters 7-14", iter(u), 89)); + Mocha.test("even/odd trampoline", () => Test_utils.eq("File \"tramp_fib_test.res\", line 60, characters 7-14", iter(isEven(20000)), true)); }); export { diff --git a/tests/tests/src/tramp_fib_test.res b/tests/tests/src/tramp_fib_test.res index f3a6d06ec39..8dd38238b3b 100644 --- a/tests/tests/src/tramp_fib_test.res +++ b/tests/tests/src/tramp_fib_test.res @@ -4,6 +4,7 @@ open Mocha open Test_utils type rec bounce<'a> = Continue('a) | Suspend(unit => bounce<'a>) + /* https://eli.thegreenplace.net/2017/on-recursion-continuations-and-trampolines/ */ /* http://gallium.inria.fr/seminaires/transparents/20141027.Frederic.Bour.pdf */ /* http://www.usrsb.in/blog/blog/2012/08/12/bouncing-pythons-generators-with-a-trampoline/ */ @@ -47,6 +48,7 @@ and isOdd = n => | 1 => Continue(true) | _ => isEven(n - 1) } + /* Suspend (fun [@bs] () -> isEven (n - 1)) */ describe(__MODULE__, () => { diff --git a/tests/tests/src/unboxed_variant_fold_test.mjs b/tests/tests/src/unboxed_variant_fold_test.mjs index 6a4fa8d2e3f..43992ebb475 100644 --- a/tests/tests/src/unboxed_variant_fold_test.mjs +++ b/tests/tests/src/unboxed_variant_fold_test.mjs @@ -185,98 +185,98 @@ function makeRecord(value) { Mocha.describe("Unboxed_variant_fold_test", () => { Mocha.test("constructors preserve dynamic payloads and effects", () => { - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 190, characters 7-14", colorName(makeColor("primary")), "not Color"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 191, characters 7-14", colorName(makeColor("blue")), "blue"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 192, characters 7-14", recName(makeRecord(1)), "rec"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 209, characters 7-14", colorName(makeColor("primary")), "not Color"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 210, characters 7-14", colorName(makeColor("blue")), "blue"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 211, characters 7-14", recName(makeRecord(1)), "rec"); let calls = 0; calls = calls + 1 | 0; - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 198, characters 7-14", colorName("primary"), "not Color"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 199, characters 7-14", calls, 1); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 217, characters 7-14", colorName("primary"), "not Color"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 218, characters 7-14", calls, 1); }); Mocha.test("folding agrees with runtime dispatch", () => { - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 202, characters 7-14", "not Color", colorName(id("primary"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 203, characters 7-14", "not Color", colorName(id("secondary"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 204, characters 7-14", "blue", colorName(id("blue"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 205, characters 7-14", "not Color", colorName(id("primary"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 206, characters 7-14", "one", numberName(id(1))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 207, characters 7-14", "number", numberName(id(2))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 208, characters 7-14", "one", numberName(id(1))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 209, characters 7-14", "int", pureName(id(1))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 210, characters 7-14", "string", pureName(id("x"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 211, characters 7-14", "obj", optName(id({ + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 221, characters 7-14", "not Color", colorName(id("primary"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 222, characters 7-14", "not Color", colorName(id("secondary"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 223, characters 7-14", "blue", colorName(id("blue"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 224, characters 7-14", "not Color", colorName(id("primary"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 225, characters 7-14", "one", numberName(id(1))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 226, characters 7-14", "number", numberName(id(2))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 227, characters 7-14", "one", numberName(id(1))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 228, characters 7-14", "int", pureName(id(1))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 229, characters 7-14", "string", pureName(id("x"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 230, characters 7-14", "obj", optName(id({ x: 1 }))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 212, characters 7-14", "null", optName(id(null))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 213, characters 7-14", "undef", optName(id(undefined))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 214, characters 7-14", "str", flagName(id("true"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 215, characters 7-14", "yes", flagName(id(true))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 216, characters 7-14", "yes", answerName(id(true))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 217, characters 7-14", "answer false", answerName(id(false))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 218, characters 7-14", "yes", answerName(id(true))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 219, characters 7-14", "toggle true", mixedName(id(true))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 220, characters 7-14", "off", mixedName(id(false))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 221, characters 7-14", "off", mixedName(id(false))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 222, characters 7-14", "unset", mixedName(id(null))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 223, characters 7-14", "false", mixedName(id("false"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 224, characters 7-14", "one", numName(id(1.0))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 225, characters 7-14", "float", numName(id(2.5))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 226, characters 7-14", "one", numName(id(1))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 227, characters 7-14", "rec", recName(id({ + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 231, characters 7-14", "null", optName(id(null))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 232, characters 7-14", "undef", optName(id(undefined))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 233, characters 7-14", "str", flagName(id("true"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 234, characters 7-14", "yes", flagName(id(true))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 235, characters 7-14", "yes", answerName(id(true))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 236, characters 7-14", "answer false", answerName(id(false))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 237, characters 7-14", "yes", answerName(id(true))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 238, characters 7-14", "toggle true", mixedName(id(true))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 239, characters 7-14", "off", mixedName(id(false))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 240, characters 7-14", "off", mixedName(id(false))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 241, characters 7-14", "unset", mixedName(id(null))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 242, characters 7-14", "false", mixedName(id("false"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 243, characters 7-14", "one", numName(id(1.0))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 244, characters 7-14", "float", numName(id(2.5))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 245, characters 7-14", "one", numName(id(1))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 246, characters 7-14", "rec", recName(id({ y: 1 }))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 228, characters 7-14", "empty", recName(id("empty"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 229, characters 7-14", "lit", pick(id("a"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 230, characters 7-14", "z", pick(id("z"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 231, characters 7-14", "lit", pick(id("a"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 232, characters 7-14", "w", outerName(id("primary"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 233, characters 7-14", "x", outerName(id("x"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 234, characters 7-14", "x", outerName(id("x"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 235, characters 7-14", "primary", boxedName(id({ + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 247, characters 7-14", "empty", recName(id("empty"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 248, characters 7-14", "lit", pick(id("a"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 249, characters 7-14", "z", pick(id("z"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 250, characters 7-14", "lit", pick(id("a"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 251, characters 7-14", "w", outerName(id("primary"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 252, characters 7-14", "x", outerName(id("x"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 253, characters 7-14", "x", outerName(id("x"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 254, characters 7-14", "primary", boxedName(id({ TAG: "BoxedColor", _0: "primary" }))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 236, characters 7-14", "not Color", boxedName(id("primary"))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 237, characters 7-14", "tuple", objectName(id([ + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 255, characters 7-14", "not Color", boxedName(id("primary"))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 256, characters 7-14", "tuple", objectName(id([ 1, 2 ]))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 238, characters 7-14", "record", objectName(id({ + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 257, characters 7-14", "record", objectName(id({ x: 1 }))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 239, characters 7-14", "zero", listName(id(/* [] */0))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 240, characters 7-14", "list", listName(id({hd: 1, tl: /* [] */0}))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 241, characters 7-14", "one", bigintName(id(10n))); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 242, characters 7-14", "one", wideName(id(1))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 258, characters 7-14", "zero", listName(id(/* [] */0))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 259, characters 7-14", "list", listName(id({hd: 1, tl: /* [] */0}))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 260, characters 7-14", "one", bigintName(id(10n))); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 261, characters 7-14", "one", wideName(id(1))); }); Mocha.test("the folded answers themselves are correct", () => { - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 246, characters 7-14", "not Color", "not Color"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 247, characters 7-14", "blue", "blue"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 248, characters 7-14", "one", "one"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 249, characters 7-14", "number", "number"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 250, characters 7-14", "int", "int"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 251, characters 7-14", "yes", "yes"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 252, characters 7-14", "answer false", "answer false"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 253, characters 7-14", answerName2(id(true)), "yes"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 254, characters 7-14", answerName2(id(false)), "answer false"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 255, characters 7-14", "off", "off"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 256, characters 7-14", "toggle true", "toggle true"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 257, characters 7-14", "false", "false"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 258, characters 7-14", "one", "one"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 259, characters 7-14", "lit", "lit"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 260, characters 7-14", "x", "x"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 261, characters 7-14", "primary", "primary"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 262, characters 7-14", "tuple", "tuple"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 263, characters 7-14", "zero", "zero"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 264, characters 7-14", "one", "one"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 265, characters 7-14", "one", "one"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 266, characters 7-14", "bigint", "bigint"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 267, characters 7-14", "two", "two"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 268, characters 7-14", "two", "two"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 265, characters 7-14", "not Color", "not Color"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 266, characters 7-14", "blue", "blue"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 267, characters 7-14", "one", "one"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 268, characters 7-14", "number", "number"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 269, characters 7-14", "int", "int"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 270, characters 7-14", "yes", "yes"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 271, characters 7-14", "answer false", "answer false"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 272, characters 7-14", answerName2(id(true)), "yes"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 273, characters 7-14", answerName2(id(false)), "answer false"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 274, characters 7-14", "off", "off"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 275, characters 7-14", "toggle true", "toggle true"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 276, characters 7-14", "false", "false"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 277, characters 7-14", "one", "one"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 278, characters 7-14", "lit", "lit"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 279, characters 7-14", "x", "x"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 280, characters 7-14", "primary", "primary"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 281, characters 7-14", "tuple", "tuple"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 282, characters 7-14", "zero", "zero"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 283, characters 7-14", "one", "one"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 284, characters 7-14", "one", "one"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 285, characters 7-14", "bigint", "bigint"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 286, characters 7-14", "two", "two"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 287, characters 7-14", "two", "two"); }); Mocha.test("a number and a bigint literal with the same digits", () => { - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 272, characters 7-14", numberOrBigintName(id(1)), "number"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 273, characters 7-14", numberOrBigintName(id(1n)), "bigint"); - Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 274, characters 7-14", numberOrBigintName(id("x")), "x"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 291, characters 7-14", numberOrBigintName(id(1)), "number"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 292, characters 7-14", numberOrBigintName(id(1n)), "bigint"); + Test_utils.eq("File \"unboxed_variant_fold_test.res\", line 293, characters 7-14", numberOrBigintName(id("x")), "x"); }); }); diff --git a/tests/tests/src/unboxed_variant_fold_test.res b/tests/tests/src/unboxed_variant_fold_test.res index 14d842dabfa..54ecc3d25fa 100644 --- a/tests/tests/src/unboxed_variant_fold_test.res +++ b/tests/tests/src/unboxed_variant_fold_test.res @@ -17,6 +17,7 @@ type color = | @as("primary") Primary | @as("secondary") Secondary | Color(string) + let colorName = v => switch v { | Color(n) => n @@ -24,6 +25,7 @@ let colorName = v => } @unboxed type number = | @as(1) One | Number(int) + let numberName = v => switch v { | One => "one" @@ -32,6 +34,7 @@ let numberName = v => // No literal constructors at all, so no overlap is possible. @unboxed type pure = I(int) | S(string) + let pureName = v => switch v { | I(_) => "int" @@ -43,6 +46,7 @@ type opt = | @as(null) Nothing | @as(undefined) Missing | Obj({x: int}) + let optName = v => switch v { | Nothing => "null" @@ -51,6 +55,7 @@ let optName = v => } @unboxed type flag = | @as(true) Yes | Str(string) + let flagName = v => switch v { | Yes => "yes" @@ -60,6 +65,7 @@ let flagName = v => // A boolean payload only receives the boolean that is not a literal case. The // first arm can never match (warning 11); folding must not select it either. @unboxed type answer = | @as(true) Yes2 | Answer(bool) + @warning("-11") let answerName = v => switch v { @@ -67,6 +73,7 @@ let answerName = v => | Yes2 => "yes" | Answer(false) => "answer false" } + // Yes2 also covers Answer(true), so this match is exhaustive. let answerName2 = v => switch v { @@ -80,6 +87,7 @@ type mixed = | @as(null) Unset | Toggle(bool) | Label(string) + let mixedName = v => switch v { | Off => "off" @@ -90,6 +98,7 @@ let mixedName = v => // @as(1) and a float payload of 1.0 are one JavaScript number. @unboxed type num = | @as(1) One2 | F(float) + let numName = v => switch v { | One2 => "one" @@ -98,6 +107,7 @@ let numName = v => // An untagged inline record stays an object rather than becoming its payload. @unboxed type rec_ = | @as("empty") Empty | R({y: int}) + let recName = v => switch v { | Empty => "empty" @@ -106,6 +116,7 @@ let recName = v => // The overlapping literal is reachable only through the default arm. @unboxed type c2 = | @as("a") A | @as("b") B | C(string) + let pick = v => switch v { | C(s) => s @@ -115,6 +126,7 @@ let pick = v => // A payload that is itself an untagged constant. @unboxed type inner = | @as("primary") P | I2(string) @unboxed type outer = | @as("x") X | W(inner) + let outerName = v => switch v { | X => "x" @@ -123,6 +135,7 @@ let outerName = v => // An ordinary boxed variant keeps its constructor identity, tag and all. type boxed = | @as("primary") BoxedPrimary | BoxedColor(string) + let boxedName = v => switch v { | BoxedPrimary => "not Color" @@ -131,6 +144,7 @@ let boxedName = v => // Tuple constants emit as arrays, and must not select the object case. @unboxed type objects = Tuple((int, int)) | Record({x: int}) + let objectName = value => switch value { | Tuple(_) => "tuple" @@ -139,6 +153,7 @@ let objectName = value => // The built-in empty-list constructor is the JavaScript number zero. @unboxed type lists = | @as(0) Zero | Values(list<int>) + let listName = value => switch value { | Zero => "zero" @@ -148,6 +163,7 @@ let listName = value => // Bigint constructor spellings can differ while their runtime values agree. @unboxed type bigintInner = | @as(1_0n) DecimalTen @unboxed type bigintOuter = | @as(10n) BigOne | Wrapped(bigintInner) + let bigintName = value => switch value { | BigOne => "one" @@ -156,6 +172,7 @@ let bigintName = value => // Integer constructor tags use the same 32-bit representation as int values. @unboxed type wide = | @as(4294967297) WideOne | WideInt(int) + let wideName = value => switch value { | WideOne => "one" @@ -164,6 +181,7 @@ let wideName = value => // A number and a bigint with the same digits are different values. @unboxed type numberOrBigint = | @as(1) NumberOne | @as(1n) BigintOne | Other(string) + let numberOrBigintName = value => switch value { | NumberOne => "number" @@ -173,6 +191,7 @@ let numberOrBigintName = value => // A bigint payload equal to a bigint literal folds to the literal's case @unboxed type bigintOrPayload = | @as(2n) BigTwo | BigOther(bigint) + let bigintOrPayloadName = value => switch value { | BigTwo => "two" diff --git a/tests/tests/src/unsafe_ppx_test.mjs b/tests/tests/src/unsafe_ppx_test.mjs index 8884aa100f9..8ed436619b9 100644 --- a/tests/tests/src/unsafe_ppx_test.mjs +++ b/tests/tests/src/unsafe_ppx_test.mjs @@ -55,10 +55,10 @@ let empty = Object.keys(3); let v = $$test(1, 2); Mocha.describe("Unsafe_ppx_test", () => { - Mocha.test("unsafe_max", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 56, characters 7-14", 2, max(1, 2))); - Mocha.test("unsafe_test", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 59, characters 7-14", 3, v)); - Mocha.test("unsafe_max2", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 62, characters 7-14", 2, Math.max(1, 2))); - Mocha.test("ffi_keys", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 65, characters 7-14", ["a"], Ffi_js_test.keys({a : 3}))); + Mocha.test("unsafe_max", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 58, characters 7-14", 2, max(1, 2))); + Mocha.test("unsafe_test", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 61, characters 7-14", 3, v)); + Mocha.test("unsafe_max2", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 64, characters 7-14", 2, Math.max(1, 2))); + Mocha.test("ffi_keys", () => Test_utils.eq("File \"unsafe_ppx_test.res\", line 67, characters 7-14", ["a"], Ffi_js_test.keys({a : 3}))); }); export { diff --git a/tests/tests/src/unsafe_ppx_test.res b/tests/tests/src/unsafe_ppx_test.res index c98e97331a9..b0bc5ae6063 100644 --- a/tests/tests/src/unsafe_ppx_test.res +++ b/tests/tests/src/unsafe_ppx_test.res @@ -3,6 +3,7 @@ let x: string = %raw(`"\\x01\\x02\\x03"`) let max: (float, float) => float = %raw("Math.max") let u = v => max(1., v) + /* let max2 : float -> float -> float = [%raw {Math.max} ] */ %%raw(` @@ -14,6 +15,7 @@ function $$test(x,y){ let regression3: (float, float) => float = %raw("Math.max") let regression4: (float, float => float) => float = %raw("Math.max") + let g = a => { let regression: (float, string => 'a) => string = %raw(`function(x,y){ return "" diff --git a/tests/tests/src/untagged_default_arm_test.mjs b/tests/tests/src/untagged_default_arm_test.mjs index 018df971740..bc8cac342bb 100644 --- a/tests/tests/src/untagged_default_arm_test.mjs +++ b/tests/tests/src/untagged_default_arm_test.mjs @@ -98,39 +98,39 @@ Mocha.describe("Untagged_default_arm_test", () => { x: 1 })); logString(id("a")); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 95, characters 7-14", [ + Test_utils.eq("File \"untagged_default_arm_test.res\", line 96, characters 7-14", [ "done", "string", "done" ], logged); }); Mocha.test("an instance handled by the default is not an object case", () => { - Test_utils.eq("File \"untagged_default_arm_test.res\", line 99, characters 7-14", "other", objectOrString(id(new Date()))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 100, characters 7-14", "other", objectOrString(id(/a/))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 101, characters 7-14", "O", objectOrString(id({ + Test_utils.eq("File \"untagged_default_arm_test.res\", line 100, characters 7-14", "other", objectOrString(id(new Date()))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 101, characters 7-14", "other", objectOrString(id(/a/))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 102, characters 7-14", "O", objectOrString(id({ x: 1 }))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 102, characters 7-14", "S", objectOrString(id("s"))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 103, characters 7-14", "other", objectOrString(id(1))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 103, characters 7-14", "S", objectOrString(id("s"))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 104, characters 7-14", "other", objectOrString(id(1))); }); Mocha.test("a literal handled by the default is not a string case", () => { - Test_utils.eq("File \"untagged_default_arm_test.res\", line 107, characters 7-14", "other", textOrRecord(id("lit"))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 108, characters 7-14", "text", textOrRecord(id("lit2"))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 109, characters 7-14", "record", textOrRecord(id({ + Test_utils.eq("File \"untagged_default_arm_test.res\", line 108, characters 7-14", "other", textOrRecord(id("lit"))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 109, characters 7-14", "text", textOrRecord(id("lit2"))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 110, characters 7-14", "record", textOrRecord(id({ x: 1 }))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 110, characters 7-14", "other", textOrRecord(id(1))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 111, characters 7-14", "other", textOrRecord(id(1))); }); - Mocha.test("primitives skip class checks in the two-arm form", () => Test_utils.eq("File \"untagged_default_arm_test.res\", line 114, characters 7-14", "name", twoArmsKind(id("a")))); + Mocha.test("primitives skip class checks in the two-arm form", () => Test_utils.eq("File \"untagged_default_arm_test.res\", line 115, characters 7-14", "name", twoArmsKind(id("a")))); Mocha.test("a value no arm of an incomplete match takes falls through", () => { - Test_utils.eq("File \"untagged_default_arm_test.res\", line 118, characters 7-14", "number, any", pair(id(1), id([]))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 119, characters 7-14", "number, any", pair(id(1), id(null))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 120, characters 7-14", "any, object", pair(id(1), id({}))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 121, characters 7-14", "other", pair(id("a"), id([]))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 119, characters 7-14", "number, any", pair(id(1), id([]))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 120, characters 7-14", "number, any", pair(id(1), id(null))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 121, characters 7-14", "any, object", pair(id(1), id({}))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 122, characters 7-14", "other", pair(id("a"), id([]))); }); Mocha.test("literals skip class checks", () => { - Test_utils.eq("File \"untagged_default_arm_test.res\", line 125, characters 7-14", "one", withLiteralsKind(id(1))); - Test_utils.eq("File \"untagged_default_arm_test.res\", line 126, characters 7-14", "name", withLiteralsKind(id("a"))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 126, characters 7-14", "one", withLiteralsKind(id(1))); + Test_utils.eq("File \"untagged_default_arm_test.res\", line 127, characters 7-14", "name", withLiteralsKind(id("a"))); }); }); diff --git a/tests/tests/src/untagged_default_arm_test.res b/tests/tests/src/untagged_default_arm_test.res index 811f2aa95af..2d0d4230651 100644 --- a/tests/tests/src/untagged_default_arm_test.res +++ b/tests/tests/src/untagged_default_arm_test.res @@ -80,6 +80,7 @@ let pair = (a: JSON.t, b: JSON.t) => @unboxed type stringOrRecord = LogStr(string) | LogRec({x: int}) let logged = [] + let logString = value => { switch value { | LogStr(_) => logged->Array.push("string") diff --git a/tests/tests/src/untagged_hidden_payload_test.mjs b/tests/tests/src/untagged_hidden_payload_test.mjs index aa6c3e0c19b..1c83c3837ab 100644 --- a/tests/tests/src/untagged_hidden_payload_test.mjs +++ b/tests/tests/src/untagged_hidden_payload_test.mjs @@ -13,8 +13,8 @@ function isPayload(v) { Mocha.describe("Untagged_hidden_payload_test", () => { Mocha.test("an interface hiding a payload's class", () => { - Test_utils.eq("File \"untagged_hidden_payload_test.res\", line 14, characters 18-25", true, isPayload(new Date())); - Test_utils.eq("File \"untagged_hidden_payload_test.res\", line 15, characters 18-25", false, false); + Test_utils.eq("File \"untagged_hidden_payload_test.res\", line 15, characters 18-25", true, isPayload(new Date())); + Test_utils.eq("File \"untagged_hidden_payload_test.res\", line 16, characters 18-25", false, false); }); }); diff --git a/tests/tests/src/untagged_hidden_payload_test.res b/tests/tests/src/untagged_hidden_payload_test.res index b5119bdd33e..99680d24927 100644 --- a/tests/tests/src/untagged_hidden_payload_test.res +++ b/tests/tests/src/untagged_hidden_payload_test.res @@ -3,6 +3,7 @@ type t = Date.t @unboxed type v = | @as("n") N | P(t) let make = () => P(Date.make()) + let isPayload = v => switch v { | N => false diff --git a/tests/tests/src/untagged_runtime_annotations_shadow_test.mjs b/tests/tests/src/untagged_runtime_annotations_shadow_test.mjs index 4dcca29bca1..f4170b50330 100644 --- a/tests/tests/src/untagged_runtime_annotations_shadow_test.mjs +++ b/tests/tests/src/untagged_runtime_annotations_shadow_test.mjs @@ -31,13 +31,13 @@ function kind(value) { Mocha.describe("Untagged_runtime_annotations_shadow_test", () => { Mocha.test("a class check reads a shadowed global", () => { - Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 35, characters 7-14", "local module", "local module"); - Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 36, characters 7-14", "shadowed", kind(new (globalThis.UntaggedShadowed)())); + Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 36, characters 7-14", "local module", "local module"); + Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 37, characters 7-14", "shadowed", kind(new (globalThis.UntaggedShadowed)())); }); Mocha.test("a class check at a dotted path reads a shadowed global", () => { - Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 40, characters 7-14", "local module", "local module"); - Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 41, characters 7-14", "klass", kind(new (globalThis.UntaggedNs.Klass)())); - Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 42, characters 7-14", "text", "text"); + Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 41, characters 7-14", "local module", "local module"); + Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 42, characters 7-14", "klass", kind(new (globalThis.UntaggedNs.Klass)())); + Test_utils.eq("File \"untagged_runtime_annotations_shadow_test.res\", line 43, characters 7-14", "text", "text"); }); }); diff --git a/tests/tests/src/untagged_runtime_annotations_shadow_test.res b/tests/tests/src/untagged_runtime_annotations_shadow_test.res index f993f408475..69f1599df93 100644 --- a/tests/tests/src/untagged_runtime_annotations_shadow_test.res +++ b/tests/tests/src/untagged_runtime_annotations_shadow_test.res @@ -10,6 +10,7 @@ globalThis.UntaggedNs = {Klass: class Klass {}} module UntaggedShadowed = { let name = "local module" } + module UntaggedNs = { let name = "local module" } diff --git a/tests/tests/src/untagged_runtime_annotations_test.mjs b/tests/tests/src/untagged_runtime_annotations_test.mjs index 442518c9e35..bbc2911f5bb 100644 --- a/tests/tests/src/untagged_runtime_annotations_test.mjs +++ b/tests/tests/src/untagged_runtime_annotations_test.mjs @@ -204,97 +204,97 @@ function sharedKind(value) { Mocha.describe("Untagged_runtime_annotations_test", () => { Mocha.test("a subclass case is not taken for its superclass", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 270, characters 7-14", "animal", describePet(new UntaggedAnimal())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 271, characters 7-14", "dog", describePet(new UntaggedDog())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 272, characters 7-14", "rex", "rex"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 271, characters 7-14", "animal", describePet(new UntaggedAnimal())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 272, characters 7-14", "dog", describePet(new UntaggedDog())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 273, characters 7-14", "rex", "rex"); }); Mocha.test("a superclass case alone excludes the subclass", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 276, characters 7-14", "animal", onlyAnimal(new UntaggedAnimal())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 277, characters 7-14", "other", onlyAnimal(new UntaggedDog())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 277, characters 7-14", "animal", onlyAnimal(new UntaggedAnimal())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 278, characters 7-14", "other", onlyAnimal(new UntaggedDog())); }); Mocha.test("declaration order does not matter", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 281, characters 7-14", "dog", describeReversed(new UntaggedDog())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 282, characters 7-14", "animal", describeReversed(new UntaggedAnimal())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 282, characters 7-14", "dog", describeReversed(new UntaggedDog())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 283, characters 7-14", "animal", describeReversed(new UntaggedAnimal())); }); Mocha.test("a subclass upcasts to its superclass", () => { let animal = new UntaggedDog(); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 287, characters 7-14", "dog", describePet(animal)); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 288, characters 7-14", "dog", describePet(animal)); }); Mocha.test("classes reached through a module alias", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 291, characters 7-14", "animal", describeAliased(new UntaggedAnimal())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 292, characters 7-14", "dog", describeAliased(new UntaggedDog())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 292, characters 7-14", "animal", describeAliased(new UntaggedAnimal())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 293, characters 7-14", "dog", describeAliased(new UntaggedDog())); }); Mocha.test("typeOf symbol", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 296, characters 7-14", "symbol", keyKind(Symbol.for("key"))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 297, characters 7-14", "text", "text"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 297, characters 7-14", "symbol", keyKind(Symbol.for("key"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 298, characters 7-14", "text", "text"); }); Mocha.test("typeOf string", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 301, characters 7-14", "id", "id"); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 302, characters 7-14", "index", "index"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 302, characters 7-14", "id", "id"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 303, characters 7-14", "index", "index"); }); Mocha.test("a class at a dotted path", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 306, characters 7-14", "locale", localeKind(new Intl.Locale("en"))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 307, characters 7-14", "de", "de"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 307, characters 7-14", "locale", localeKind(new Intl.Locale("en"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 308, characters 7-14", "de", "de"); }); Mocha.test("an annotated type is not wrapped in an option", () => { let animal = new UntaggedAnimal(); - Test_utils.ok("File \"untagged_runtime_annotations_test.res\", line 312, characters 7-14", animal === animal); Test_utils.ok("File \"untagged_runtime_annotations_test.res\", line 313, characters 7-14", animal === animal); + Test_utils.ok("File \"untagged_runtime_annotations_test.res\", line 314, characters 7-14", animal === animal); }); Mocha.test("a phantom type hierarchy", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 317, characters 7-14", "animal", describePhantom(new UntaggedAnimal())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 318, characters 7-14", "dog", describePhantom(new UntaggedDog())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 318, characters 7-14", "animal", describePhantom(new UntaggedAnimal())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 319, characters 7-14", "dog", describePhantom(new UntaggedDog())); }); Mocha.test("a function case excludes class instances", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 322, characters 7-14", "callable", handlerKind(new UntaggedCallable())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 323, characters 7-14", "function", handlerKind(x => x)); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 324, characters 7-14", "other", wideHandlerKind(new UntaggedCallable())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 325, characters 7-14", "other", wideHandlerKind(new UntaggedAnimal())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 326, characters 7-14", "function", wideHandlerKind(x => x)); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 327, characters 7-14", "name", "name"); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 328, characters 7-14", "other", "other"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 323, characters 7-14", "callable", handlerKind(new UntaggedCallable())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 324, characters 7-14", "function", handlerKind(x => x)); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 325, characters 7-14", "other", wideHandlerKind(new UntaggedCallable())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 326, characters 7-14", "other", wideHandlerKind(new UntaggedAnimal())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 327, characters 7-14", "function", wideHandlerKind(x => x)); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 328, characters 7-14", "name", "name"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 329, characters 7-14", "other", "other"); }); Mocha.test("typed arrays of different classes", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 332, characters 7-14", "int8", typedArrayKind(id(new Int8Array([1])))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 333, characters 7-14", "uint8", typedArrayKind(id(new Uint8Array([1])))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 334, characters 7-14", "float64", typedArrayKind(id(new Float64Array([1])))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 333, characters 7-14", "int8", typedArrayKind(id(new Int8Array([1])))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 334, characters 7-14", "uint8", typedArrayKind(id(new Uint8Array([1])))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 335, characters 7-14", "float64", typedArrayKind(id(new Float64Array([1])))); }); Mocha.test("a class declared over an object type", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 338, characters 7-14", "dog", objectOrNameKind(new UntaggedDog())); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 339, characters 7-14", "rex", "rex"); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 339, characters 7-14", "dog", objectOrNameKind(new UntaggedDog())); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 340, characters 7-14", "rex", "rex"); }); Mocha.test("annotations restating a structural kind", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 343, characters 7-14", "2", restatedKind(id(x => x + 1 | 0))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 344, characters 7-14", "3", restatedKind(id({ + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 344, characters 7-14", "2", restatedKind(id(x => x + 1 | 0))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 345, characters 7-14", "3", restatedKind(id({ px: 3 }))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 345, characters 7-14", "a", restatedKind(id("a"))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 346, characters 7-14", "callback", restatedAbstractKind(id(callback))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 347, characters 7-14", "point", restatedAbstractKind(id(point))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 348, characters 7-14", "4", privateOrNameKind(id({ + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 346, characters 7-14", "a", restatedKind(id("a"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 347, characters 7-14", "callback", restatedAbstractKind(id(callback))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 348, characters 7-14", "point", restatedAbstractKind(id(point))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 349, characters 7-14", "4", privateOrNameKind(id({ px: 4 }))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 349, characters 7-14", "a", privateOrNameKind(id("a"))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 350, characters 7-14", "5", jsOrNameKind(id({ + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 350, characters 7-14", "a", privateOrNameKind(id("a"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 351, characters 7-14", "5", jsOrNameKind(id({ pz: 5 }))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 351, characters 7-14", "b", jsOrNameKind(id("b"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 352, characters 7-14", "b", jsOrNameKind(id("b"))); }); Mocha.test("primitive cases are tested before class checks", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 355, characters 7-14", "a", missingKind(id("a"))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 356, characters 7-14", "count", missingKind(id(1))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 356, characters 7-14", "a", missingKind(id("a"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 357, characters 7-14", "count", missingKind(id(1))); }); Mocha.test("a primitive without an arm skips class checks", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 360, characters 7-14", "a", missingOrDefault(id("a"))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 361, characters 7-14", "other", missingOrDefault(id(1))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 361, characters 7-14", "a", missingOrDefault(id("a"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 362, characters 7-14", "other", missingOrDefault(id(1))); }); Mocha.test("a default shared by a primitive and an object case", () => { - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 365, characters 7-14", "date!", sharedKind(id(new Date()))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 366, characters 7-14", "other!", sharedKind(id({ + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 366, characters 7-14", "date!", sharedKind(id(new Date()))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 367, characters 7-14", "other!", sharedKind(id({ x: 1 }))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 367, characters 7-14", "text!", sharedKind(id("a"))); - Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 368, characters 7-14", "other!", sharedKind(id(1))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 368, characters 7-14", "text!", sharedKind(id("a"))); + Test_utils.eq("File \"untagged_runtime_annotations_test.res\", line 369, characters 7-14", "other!", sharedKind(id(1))); }); }); diff --git a/tests/tests/src/untagged_runtime_annotations_test.res b/tests/tests/src/untagged_runtime_annotations_test.res index 1309a448270..eace9e15a28 100644 --- a/tests/tests/src/untagged_runtime_annotations_test.res +++ b/tests/tests/src/untagged_runtime_annotations_test.res @@ -47,6 +47,7 @@ module Zoo = { @instanceOf("UntaggedDog") type dog = private animal @new external makeDog: unit => dog = "UntaggedDog" } + module ZooAlias = Zoo @unboxed diff --git a/tests/tests/src/untagged_variants_spec_test.mjs b/tests/tests/src/untagged_variants_spec_test.mjs index 30668f9e8d7..afce08c6b21 100644 --- a/tests/tests/src/untagged_variants_spec_test.mjs +++ b/tests/tests/src/untagged_variants_spec_test.mjs @@ -219,162 +219,162 @@ function someWithDefined(v) { Mocha.describe("Untagged_variants_spec_test", () => { Mocha.test("rule 1: @unboxed on the type applies to every constructor", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 224, characters 7-14", id(3), 3); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 225, characters 7-14", id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 252, characters 7-14", id(3), 3); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 253, characters 7-14", id({ x: 1 }), { x: 1 }); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 226, characters 7-14", id("WC"), "WC"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 227, characters 7-14", wholeName(id(3)), "WA"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 228, characters 7-14", wholeName(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 254, characters 7-14", id("WC"), "WC"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 255, characters 7-14", wholeName(id(3)), "WA"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 256, characters 7-14", wholeName(id({ x: 1 })), "WB"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 229, characters 7-14", wholeName(id("WC")), "WC"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 257, characters 7-14", wholeName(id("WC")), "WC"); }); Mocha.test("rule 2: representation of each case", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 233, characters 7-14", id("Named"), "Named"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 234, characters 7-14", id("s"), "s"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 235, characters 7-14", id(1), 1); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 236, characters 7-14", id(2.5), 2.5); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 237, characters 7-14", id(3n), 3n); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 238, characters 7-14", id(true), true); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 239, characters 7-14", id(null), null); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 240, characters 7-14", id(undefined), undefined); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 241, characters 7-14", id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 261, characters 7-14", id("Named"), "Named"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 262, characters 7-14", id("s"), "s"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 263, characters 7-14", id(1), 1); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 264, characters 7-14", id(2.5), 2.5); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 265, characters 7-14", id(3n), 3n); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 266, characters 7-14", id(true), true); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 267, characters 7-14", id(null), null); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 268, characters 7-14", id(undefined), undefined); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 269, characters 7-14", id({ x: 1 }), { x: 1 }); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 242, characters 7-14", id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 270, characters 7-14", id({ x: 1 }), { x: 1 }); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 243, characters 7-14", id("v"), "v"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 271, characters 7-14", id("v"), "v"); }); Mocha.test("rule 4: typeof kinds", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 247, characters 7-14", kindName(id("a")), "string"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 248, characters 7-14", kindName(id(1.5)), "number"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 249, characters 7-14", kindName(id(1n)), "bigint"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 250, characters 7-14", kindName(id(false)), "bool"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 251, characters 7-14", kindName(id(x => x)), "function"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 252, characters 7-14", kindName(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 275, characters 7-14", kindName(id("a")), "string"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 276, characters 7-14", kindName(id(1.5)), "number"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 277, characters 7-14", kindName(id(1n)), "bigint"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 278, characters 7-14", kindName(id(false)), "bool"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 279, characters 7-14", kindName(id(x => x)), "function"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 280, characters 7-14", kindName(id({ x: 1 })), "object"); }); Mocha.test("rule 4: tuples are array cases, dicts are object cases", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 256, characters 7-14", tupleName(id([ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 284, characters 7-14", tupleName(id([ 1, "a" ])), "array"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 257, characters 7-14", tupleName(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 285, characters 7-14", tupleName(id({ a: 1 })), "object"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 258, characters 7-14", aliasDictName(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 286, characters 7-14", aliasDictName(id({ a: 1 })), "object"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 259, characters 7-14", aliasDictName(id([1])), "array"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 287, characters 7-14", aliasDictName(id([1])), "array"); }); Mocha.test("rules 4 and 5: instance cases", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 263, characters 7-14", instanceName(id(new Date())), "Date"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 264, characters 7-14", instanceName(id(/a/)), "RegExp"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 265, characters 7-14", instanceName(id(Promise.resolve(1))), "Promise"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 266, characters 7-14", instanceName(id(new Map())), "Map"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 267, characters 7-14", instanceName(id(new Set())), "Set"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 268, characters 7-14", instanceName(id(new WeakMap())), "WeakMap"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 269, characters 7-14", instanceName(id(new WeakSet())), "WeakSet"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 291, characters 7-14", instanceName(id(new Date())), "Date"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 292, characters 7-14", instanceName(id(/a/)), "RegExp"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 293, characters 7-14", instanceName(id(Promise.resolve(1))), "Promise"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 294, characters 7-14", instanceName(id(new Map())), "Map"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 295, characters 7-14", instanceName(id(new Set())), "Set"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 296, characters 7-14", instanceName(id(new WeakMap())), "WeakMap"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 297, characters 7-14", instanceName(id(new WeakSet())), "WeakSet"); let buffer = new ArrayBuffer(8); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 271, characters 7-14", instanceName(id(buffer)), "ArrayBuffer"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 272, characters 7-14", instanceName(id(new DataView(buffer))), "DataView"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 273, characters 7-14", instanceName(id(new Float64Array([1.0]))), "Float64Array"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 274, characters 7-14", instanceName(id("a")), "string"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 299, characters 7-14", instanceName(id(buffer)), "ArrayBuffer"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 300, characters 7-14", instanceName(id(new DataView(buffer))), "DataView"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 301, characters 7-14", instanceName(id(new Float64Array([1.0]))), "Float64Array"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 302, characters 7-14", instanceName(id("a")), "string"); }); Mocha.test("rule 4: the unknown case receives every non-literal value", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 278, characters 7-14", unknownName(id(null)), "null"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 279, characters 7-14", unknownName(id("none")), "none"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 280, characters 7-14", unknownName(id({hd: 1, tl: /* [] */0})), "list"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 281, characters 7-14", unknownName(id(/* [] */0)), "list"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 306, characters 7-14", unknownName(id(null)), "null"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 307, characters 7-14", unknownName(id("none")), "none"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 308, characters 7-14", unknownName(id({hd: 1, tl: /* [] */0})), "list"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 309, characters 7-14", unknownName(id(/* [] */0)), "list"); }); Mocha.test("rule 7: a payload value equal to a literal is that literal's case", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 285, characters 7-14", overlapStringName(id("a")), "LitA"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 286, characters 7-14", overlapStringName(id("b")), "AnyString"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 287, characters 7-14", overlapNumberName(id(1)), "LitOne"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 288, characters 7-14", overlapNumberName(id(2)), "AnyInt"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 289, characters 7-14", overlapBoolName(id(true)), "LitTrue"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 290, characters 7-14", overlapBoolName(id(false)), "AnyBool"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 291, characters 7-14", overlapNullName(id(null)), "LitNull"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 292, characters 7-14", overlapNullName(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 313, characters 7-14", overlapStringName(id("a")), "LitA"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 314, characters 7-14", overlapStringName(id("b")), "AnyString"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 315, characters 7-14", overlapNumberName(id(1)), "LitOne"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 316, characters 7-14", overlapNumberName(id(2)), "AnyInt"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 317, characters 7-14", overlapBoolName(id(true)), "LitTrue"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 318, characters 7-14", overlapBoolName(id(false)), "AnyBool"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 319, characters 7-14", overlapNullName(id(null)), "LitNull"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 320, characters 7-14", overlapNullName(id({ x: 1 })), "AnyObject"); }); Mocha.test("rule 8: instance checks precede typeof checks", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 296, characters 7-14", objectFirstName(id(new Date())), "Date"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 297, characters 7-14", objectFirstName(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 324, characters 7-14", objectFirstName(id(new Date())), "Date"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 325, characters 7-14", objectFirstName(id({ x: 1 })), "object"); }); Mocha.test("rule 8: an int case receives any number", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 301, characters 7-14", intOrStringName(id(1)), "int"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 302, characters 7-14", intOrStringName(id(1.5)), "int"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 303, characters 7-14", intOrStringName(id("1")), "string"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 329, characters 7-14", intOrStringName(id(1)), "int"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 330, characters 7-14", intOrStringName(id(1.5)), "int"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 331, characters 7-14", intOrStringName(id("1")), "string"); }); Mocha.test("rule 9: null and arrays are not objects", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 307, characters 7-14", guardedName(id([])), "array"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 308, characters 7-14", guardedName(id(null)), "null"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 309, characters 7-14", guardedName(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 335, characters 7-14", guardedName(id([])), "array"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 336, characters 7-14", guardedName(id(null)), "null"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 337, characters 7-14", guardedName(id({ x: 1 })), "object"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 310, characters 7-14", guardedObjectOnly(id([])), "other"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 311, characters 7-14", guardedObjectOnly(id(null)), "other"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 312, characters 7-14", guardedObjectOnly(id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 338, characters 7-14", guardedObjectOnly(id([])), "other"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 339, characters 7-14", guardedObjectOnly(id(null)), "other"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 340, characters 7-14", guardedObjectOnly(id({ x: 1 })), "object"); }); Mocha.test("rule 10: a value outside every case lands in the unchecked branch", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 316, characters 7-14", intOrStringName(id(true)), "string"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 318, characters 7-14", "string", "string"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 319, characters 7-14", twoInstancesName({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 344, characters 7-14", intOrStringName(id(true)), "string"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 346, characters 7-14", "string", "string"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 347, characters 7-14", twoInstancesName({ x: 1 }), "RegExp"); let thenable = ({then: (resolve) => resolve(1)}); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 321, characters 7-14", promiseOrFloatName(thenable), "promise"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 349, characters 7-14", promiseOrFloatName(thenable), "promise"); }); Mocha.test("rule 12: option of an untagged variant", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 325, characters 7-14", someWithNull(null), null); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 326, characters 7-14", someWithNull(null) === undefined, false); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 327, characters 7-14", someWithUndefined(id(undefined)) === undefined, false); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 328, characters 7-14", someConstantUndefined === undefined, false); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 329, characters 7-14", someWithUndefined("a"), "a"); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 332, characters 7-14", someWithOpaque(undefined) === undefined, false); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 333, characters 7-14", someWithVariable(undefined) === undefined, false); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 334, characters 7-14", someWithBlob(undefined) === undefined, true); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 335, characters 7-14", someWithDate(undefined) === undefined, true); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 336, characters 7-14", someWithRecord(undefined) === undefined, true); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 337, characters 7-14", someWithInlineRecord(undefined) === undefined, false); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 338, characters 7-14", someWithUnboxedOption(undefined) === undefined, false); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 339, characters 7-14", someWithUnboxedString(undefined) === undefined, true); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 353, characters 7-14", someWithNull(null), null); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 354, characters 7-14", someWithNull(null) === undefined, false); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 355, characters 7-14", someWithUndefined(id(undefined)) === undefined, false); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 356, characters 7-14", someConstantUndefined === undefined, false); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 357, characters 7-14", someWithUndefined("a"), "a"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 360, characters 7-14", someWithOpaque(undefined) === undefined, false); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 361, characters 7-14", someWithVariable(undefined) === undefined, false); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 362, characters 7-14", someWithBlob(undefined) === undefined, true); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 363, characters 7-14", someWithDate(undefined) === undefined, true); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 364, characters 7-14", someWithRecord(undefined) === undefined, true); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 365, characters 7-14", someWithInlineRecord(undefined) === undefined, false); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 366, characters 7-14", someWithUnboxedOption(undefined) === undefined, false); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 367, characters 7-14", someWithUnboxedString(undefined) === undefined, true); }); Mocha.test("rule 5: @notUndefined unboxes option of a variant holding the type", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 343, characters 7-14", someWithDefined(undefined) === undefined, true); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 344, characters 7-14", someWithDefined(5), 5); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 371, characters 7-14", someWithDefined(undefined) === undefined, true); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 372, characters 7-14", someWithDefined(5), 5); }); Mocha.test("rule 13: @tag and @as on a tagged variant", () => { - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 348, characters 7-14", id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 376, characters 7-14", id({ kind: "TA", x: 1 }), { kind: "TA", x: 1 }); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 349, characters 7-14", id({ + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 377, characters 7-14", id({ kind: "bee", y: 1 }), { kind: "bee", y: 1 }); - Test_utils.eq("File \"untagged_variants_spec_test.res\", line 350, characters 7-14", id("TC"), "TC"); + Test_utils.eq("File \"untagged_variants_spec_test.res\", line 378, characters 7-14", id("TC"), "TC"); }); }); diff --git a/tests/tests/src/untagged_variants_spec_test.res b/tests/tests/src/untagged_variants_spec_test.res index e1cc7686d12..f718036cb7d 100644 --- a/tests/tests/src/untagged_variants_spec_test.res +++ b/tests/tests/src/untagged_variants_spec_test.res @@ -14,6 +14,7 @@ external raw: 'a => 'b = "%identity" // Rule 1: `@unboxed` and `@tag` on the type apply to every constructor. @unboxed type whole = WA(int) | WB({x: int}) | WC + let wholeName = v => switch v { | WA(_) => "WA" @@ -33,6 +34,7 @@ type literals = | @as(null) Null | @as(undefined) Undefined | Payload({x: int}) + @unboxed @tag("kind") type tagIgnored = TI({x: int}) | TS(string) @unboxed type asIgnored = | @as("x") AsX(string) | AsY(int) @@ -45,6 +47,7 @@ type kinds = | KBool(bool) | KFunction(int => int) | KObject({x: int}) + let kindName = v => switch v { | KString(_) => "string" @@ -57,13 +60,16 @@ let kindName = v => // Rule 4: arrays, tuples and dicts. @unboxed type tuples = Tuple((int, string)) | TDict(dict<int>) + let tupleName = v => switch v { | Tuple(_) => "array" | TDict(_) => "object" } + type myDict = Dict.t<int> @unboxed type aliasDict = ADict(myDict) | AArray(array<int>) + let aliasDictName = v => switch v { | ADict(_) => "object" @@ -72,6 +78,7 @@ let aliasDictName = v => // Rules 4 and 5: instance cases, written directly and through an alias. type myDate = Date.t + @unboxed type instances = | IDate(myDate) @@ -85,6 +92,7 @@ type instances = | IDataView(DataView.t) | IFloat64(Float64Array.t) | IString(string) + let instanceName = v => switch v { | IDate(_) => "Date" @@ -102,6 +110,7 @@ let instanceName = v => // Rule 4: a payload of no recognized kind is the only payload case. @unboxed type unknown = | @as(null) UNull | @as("none") UNone | UList(list<int>) + let unknownName = v => switch v { | UNull => "null" @@ -111,24 +120,31 @@ let unknownName = v => // Rule 7: literal cases are tested first. @unboxed type overlapString = | @as("a") LitA | AnyString(string) + let overlapStringName = v => switch v { | LitA => "LitA" | AnyString(_) => "AnyString" } + @unboxed type overlapNumber = | @as(1) LitOne | AnyInt(int) + let overlapNumberName = v => switch v { | LitOne => "LitOne" | AnyInt(_) => "AnyInt" } + @unboxed type overlapBool = | @as(true) LitTrue | AnyBool(bool) + let overlapBoolName = v => switch v { | LitTrue => "LitTrue" | AnyBool(_) => "AnyBool" } + @unboxed type overlapNull = | @as(null) LitNull | AnyObject({x: int}) + let overlapNullName = v => switch v { | LitNull => "LitNull" @@ -137,6 +153,7 @@ let overlapNullName = v => // Rule 8: instance checks precede the `typeof` checks. @unboxed type objectFirst = OObject({x: int}) | ODate(Date.t) + let objectFirstName = v => switch v { | OObject(_) => "object" @@ -145,6 +162,7 @@ let objectFirstName = v => // Rule 8: an int case is recognized as any number. @unboxed type intOrString = I(int) | S(string) + let intOrStringName = v => switch v { | I(_) => "int" @@ -153,12 +171,14 @@ let intOrStringName = v => // Rule 9: `null` and arrays do not reach the object case. @unboxed type guarded = GArray(array<int>) | GObject({x: int}) | @as(null) GNull + let guardedName = v => switch v { | GArray(_) => "array" | GObject(_) => "object" | GNull => "null" } + let guardedObjectOnly = v => switch v { | GObject(_) => "object" @@ -167,12 +187,15 @@ let guardedObjectOnly = v => // Rule 10: in a two-way test the second case has no check. @unboxed type twoInstances = TDate(Date.t) | TRegExp(RegExp.t) + let twoInstancesName = v => switch v { | TDate(_) => "Date" | TRegExp(_) => "RegExp" } + @unboxed type promiseOrFloat = PPromise(promise<int>) | PFloat(float) + let promiseOrFloatName = v => switch v { | PPromise(_) => "promise" @@ -200,14 +223,19 @@ type record = {y: option<int>} @unboxed type withRecord = RRecord(record) | RString(string) @inline(never) let someWithRecord = (v: withRecord): option<withRecord> => Some(v) @unboxed type withInlineRecord = INone | IRecord({x: option<int>}) + @inline(never) let someWithInlineRecord = (v: withInlineRecord): option<withInlineRecord> => Some(v) + @unboxed type unboxedOption = {x: option<int>} @unboxed type withUnboxedOption = | @as("n") UONone | UOption(unboxedOption) + @inline(never) let someWithUnboxedOption = (v: withUnboxedOption): option<withUnboxedOption> => Some(v) + @unboxed type unboxedString = {s: string} @unboxed type withUnboxedString = | @as("n") USNone | UString(unboxedString) + @inline(never) let someWithUnboxedString = (v: withUnboxedString): option<withUnboxedString> => Some(v) diff --git a/tests/tests/src/variant.res b/tests/tests/src/variant.res index 5b4aaab9d71..4d402f7c833 100644 --- a/tests/tests/src/variant.res +++ b/tests/tests/src/variant.res @@ -45,6 +45,7 @@ module Path = { | Pident(string) | Pdot(t, string, int) | Papply(t, t) + let same = \"==" let compare = compare } diff --git a/tests/tests/src/variantsMatching.res b/tests/tests/src/variantsMatching.res index 742f4623446..3a3f0cdbbc0 100644 --- a/tests/tests/src/variantsMatching.res +++ b/tests/tests/src/variantsMatching.res @@ -57,6 +57,7 @@ type state = | Empty | Int1(int) | Int2(int) + let st = state => switch state { | Empty => 0 @@ -109,6 +110,7 @@ module CustomizeTags = { module MyUndefined = { @genType @unboxed type t<'a> = | @as(undefined) Undefined | Present('a) + // Note: 'a must not have undefined as value // There can be only one with payload, with 1 argument, to use unboxed @@ -127,6 +129,7 @@ module MyUndefined = { module MyNull = { @genType @unboxed type t<'a> = | @as(null) Null | Present('a) + // Note: 'a must not have null as value // There can be only one with payload, with 1 argument, to use unboxed @@ -148,6 +151,7 @@ module MyNullable = { | @as(null) Null | @as(undefined) Undefined | Present('a) + // Note: 'a must not have null or undefined as value // There can be only one with payload, with 1 argument, to use unboxed @@ -182,6 +186,7 @@ module MyNullableExtended = { | @as(undefined) Undefined | Present('a) | WhyNotAnotherOne + // Note: 'a must be a not have null or something that's not an object as value // There can be only one with payload, with 1 argument, to use unboxed @@ -269,6 +274,7 @@ module TaggedUnions = { module CustomTagNotInline = { @tag("custom-tag") type t = A(int) | B(int) + let a = A(10) let b = B(20) } diff --git a/tests/tests/src/webpack_config.res b/tests/tests/src/webpack_config.res index 81d3a589f62..4edfa5aabf2 100644 --- a/tests/tests/src/webpack_config.res +++ b/tests/tests/src/webpack_config.res @@ -1,6 +1,7 @@ module type Config = { let configx: JSON.t } + module WebpackConfig: Config = { @module external configx: JSON.t = "../../../webpack.config.js" } @@ -13,16 +14,20 @@ module WebpackDevMiddlewareConfig: Config = { external configX: unit => JSON.t = "configX" let configX = configX + module U: { let configX: unit => JSON.t } = { @module("../../../webpack.config.js") @val external configX: unit => JSON.t = "configX" } + @module("List") external hey: unit => unit = "xx" + module A = { @module(("reactX", "List")) external ff: unit => unit = "ff" @module(("reactX", "List")) external ff2: unit => unit = "ff2" } + module B = { @module(("reactV", "List")) external ff: unit => unit = "ff" @module(("reactV", "List")) external ff2: unit => unit = "ff2" diff --git a/tests/tools_tests/ppx/TestPpx.res b/tests/tools_tests/ppx/TestPpx.res index b18c96a8aed..518257b1650 100644 --- a/tests/tools_tests/ppx/TestPpx.res +++ b/tests/tools_tests/ppx/TestPpx.res @@ -31,12 +31,14 @@ external useState: (unit => 'state) => string = "useState" let _ = useState(() => 0) let fpromise = async (promise, _x) => await promise + module Uncurried = { type f1 = int => string type f2 = (int, int) => string } let async_succ = async x => x + 1 + let async_foo = async (x, y) => { let a = async_succ(x) let b = async_succ(y) diff --git a/tests/tools_tests/src/DocExtractionRes.res b/tests/tools_tests/src/DocExtractionRes.res index 444cb8e12c5..c5f70916b26 100644 --- a/tests/tools_tests/src/DocExtractionRes.res +++ b/tests/tools_tests/src/DocExtractionRes.res @@ -27,6 +27,7 @@ let \"SomeConstant" = 12 module SomeInnerModule = { /*** Another module level docstring here.*/ + type status = /** If this is started or not */ | Started(t) diff --git a/tests/tools_tests/src/expected/DocExtractionRes.res.json b/tests/tools_tests/src/expected/DocExtractionRes.res.json index da2ef13a178..1f43a055c2d 100644 --- a/tests/tools_tests/src/expected/DocExtractionRes.res.json +++ b/tests/tools_tests/src/expected/DocExtractionRes.res.json @@ -129,7 +129,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 30, + "line": 31, "col": 3 }, "detail": { @@ -161,7 +161,7 @@ "docstrings": [ "These are all the valid inputs." ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 39, + "line": 40, "col": 3 } }, @@ -173,7 +173,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 41, + "line": 42, "col": 3 } } @@ -186,7 +186,7 @@ "docstrings": [ "Mighty fine module here too!" ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 44, + "line": 45, "col": 8 }, "items": [ @@ -197,7 +197,7 @@ "docstrings": [ "This links another module. Neat." ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 48, + "line": 49, "col": 10 }, "items": [] @@ -210,7 +210,7 @@ "docstrings": [ "Testing what this looks like." ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 52, + "line": 53, "col": 3 } }, @@ -222,7 +222,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 54, + "line": 55, "col": 7 }, "detail": { @@ -256,7 +256,7 @@ ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 57, + "line": 58, "col": 3 }, "detail": { @@ -295,7 +295,7 @@ "docstrings": [ "Callback to get the DOM root..." ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 68, + "line": 69, "col": 3 } } @@ -320,7 +320,7 @@ "docstrings": [ "The type t is stuff." ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 75, + "line": 76, "col": 3 } }, @@ -332,7 +332,7 @@ "docstrings": [ "The maker of stuff!" ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 77, + "line": 78, "col": 3 }, "detail": { @@ -365,7 +365,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 105, + "line": 106, "col": 13 }, "items": [ @@ -377,7 +377,7 @@ "docstrings": [ "main type of this module" ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 113, + "line": 114, "col": 3 } }, @@ -389,7 +389,7 @@ "docstrings": [ "function from t to t" ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 115, + "line": 116, "col": 3 }, "detail": { @@ -434,7 +434,7 @@ "docstrings": [ "main type" ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 129, + "line": 130, "col": 3 } }, @@ -446,7 +446,7 @@ "docstrings": [ "identity function" ], "source": { "filepath": "src/DocExtractionRes.res", - "line": 134, + "line": 135, "col": 7 }, "detail": { @@ -480,7 +480,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 137, + "line": 138, "col": 13 }, "items": [ @@ -492,7 +492,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 138, + "line": 139, "col": 3 } } @@ -517,7 +517,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 142, + "line": 143, "col": 7 } } @@ -531,7 +531,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 145, + "line": 146, "col": 8 }, "items": [ @@ -554,7 +554,7 @@ "docstrings": [], "source": { "filepath": "src/DocExtractionRes.res", - "line": 147, + "line": 148, "col": 9 } } diff --git a/tests/tools_tests/src/expected/FormatDocstringsTest2.res.expected b/tests/tools_tests/src/expected/FormatDocstringsTest2.res.expected index d0bab38fc33..a64c7b99931 100644 --- a/tests/tools_tests/src/expected/FormatDocstringsTest2.res.expected +++ b/tests/tools_tests/src/expected/FormatDocstringsTest2.res.expected @@ -49,6 +49,7 @@ Testing resi code blocks. ```resi type x = int let x: int => string + module M: { let ff: string => int } diff --git a/tests/tools_tests/src/expected/FormatDocstringsTest2.res.extracted.json.expected b/tests/tools_tests/src/expected/FormatDocstringsTest2.res.extracted.json.expected index fc390078b9a..2217ca94ffa 100644 --- a/tests/tools_tests/src/expected/FormatDocstringsTest2.res.extracted.json.expected +++ b/tests/tools_tests/src/expected/FormatDocstringsTest2.res.extracted.json.expected @@ -2,7 +2,7 @@ { "id": "FormatDocstringsTest2.testResi", "name": "testResi", - "code": "type x = int\nlet x: int => string\nmodule M: {\n let ff: string => int\n}" + "code": "type x = int\nlet x: int => string\n\nmodule M: {\n let ff: string => int\n}" }, { "id": "FormatDocstringsTest2.testPipes",