Skip to content

Commit

Permalink
test: repro #840 (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Jul 23, 2024
1 parent 15affd0 commit ae18db0
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions ppx/test/hover.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Test some locations in reason-react components, reproduces #840

$ cat >dune-project <<EOF
> (lang dune 3.13)
> (using melange 0.1)
> EOF

$ cat >dune <<EOF
> (melange.emit
> (alias foo)
> (target foo)
> (libraries reason-react)
> (emit_stdlib false)
> (preprocess
> (pps melange.ppx reason-react-ppx)))
> EOF

$ cat >component.ml <<EOF
> let[@react.component] make ~foo ~bar =
> (div
> ~children:[ React.string foo; bar |> string_of_int |> React.string ]
> () [@JSX])
> EOF
$ dune build @foo

Let's test hovering over parts of the component

`React.string`:

$ ocamlmerlin single type-enclosing -position 3:25 -verbosity 0 \
> -filename component.ml < component.ml | jq '.value'
[
{
"start": {
"line": 3,
"col": 17
},
"end": {
"line": 3,
"col": 29
},
"type": "string -> React.element",
"tail": "no"
},
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 4,
"col": 15
},
"type": "< bar : int; foo : string > Js.t -> React.element",
"tail": "no"
}
]

The `foo` variable inside the component body

$ ocamlmerlin single type-enclosing -position 3:31 -verbosity 0 \
> -filename component.ml < component.ml | jq '.value'
[
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 4,
"col": 15
},
"type": "< bar : int; foo : string > Js.t -> React.element",
"tail": "no"
}
]

0 comments on commit ae18db0

Please sign in to comment.