Skip to content

Commit

Permalink
tests: illustrate issue ocaml#1671
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Sep 21, 2023
1 parent 18d7a55 commit 02bd7d8
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test-dirs/with-ppx/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
(locks ../server-tests/merlin_server))

(cram
(applies_to issue1660-deriving-compare)
(applies_to issue1660-deriving-compare issue1671-string)
(enabled_if (= %{env:MERLIN_TESTS=default} all)))
124 changes: 124 additions & 0 deletions tests/test-dirs/with-ppx/issue1671-string.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
$ cat >dune-project <<EOF
> (lang dune 2.0)
> EOF

$ cat >main.ml <<EOF
> let f x =
> [%string
> "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
> %{x}"]
> ;;
> print_endline @@ f "42";;
> EOF

$ cat >dune <<EOF
> (executable
> (name main)
> (preprocess (pps ppx_string)))

$ dune build @check

$ dune exec ./main.exe
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 42

FIX upstream: locs issued by the ppx does not enable Merlin to work as expected
$ $MERLIN single type-enclosing -position 3:7 \
> -filename main.ml <main.ml
{
"class": "return",
"value": [
{
"start": {
"line": 1,
"col": 6
},
"end": {
"line": 3,
"col": 97
},
"type": "string -> string",
"tail": "no"
}
],
"notifications": []
}

FIXME: Merlin should ignore hidden nodes in occurrences results to prevent
broken renaming
$ $MERLIN single occurrences -identifier-at 1:6 \
> -filename main.ml <main.ml

$ $MERLIN single dump -what typedtree -filename main.ml <main.ml
{
"class": "return",
"value": "[
structure_item (main.ml[1,0+0]..main.ml[3,21+97])
Tstr_value Nonrec
[
<def>
pattern (main.ml[1,0+4]..main.ml[1,0+5])
Tpat_var \"f/273\"
expression (main.ml[1,0+6]..main.ml[3,21+97]) ghost
Texp_function
Nolabel
[
<case>
pattern (main.ml[1,0+6]..main.ml[1,0+7])
Tpat_var \"x/275\"
expression (main.ml[2,10+2]..main.ml[3,21+97])
attribute \"merlin.hide\"
[]
Texp_apply
expression (main.ml[2,10+2]..main.ml[3,21+97])
Texp_ident \"Stdlib!.String.concat\"
[
<arg>
Nolabel
expression (main.ml[2,10+2]..main.ml[3,21+97])
Texp_constant Const_string(\"\",(main.ml[2,10+2]..main.ml[3,21+97]),None)
<arg>
Nolabel
expression (main.ml[2,10+2]..main.ml[3,21+97])
Texp_construct \"::\"
[
expression (main.ml[3,21+5]..main.ml[3,21+91]) ghost
Texp_constant Const_string(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \",(main.ml[3,21+5]..main.ml[3,21+91]) ghost,None)
expression (main.ml[2,10+2]..main.ml[3,21+97])
Texp_construct \"::\"
[
expression (main.ml[3,21+93]..main.ml[3,21+94])
Texp_ident \"x/275\"
expression (main.ml[2,10+2]..main.ml[3,21+97])
Texp_construct \"[]\"
[]
]
]
]
]
]
structure_item (main.ml[5,122+0]..main.ml[5,122+23])
Tstr_eval
expression (main.ml[5,122+0]..main.ml[5,122+23])
Texp_apply
expression (main.ml[5,122+0]..main.ml[5,122+13])
Texp_ident \"Stdlib!.print_endline\"
[
<arg>
Nolabel
expression (main.ml[5,122+17]..main.ml[5,122+23])
Texp_apply
expression (main.ml[5,122+17]..main.ml[5,122+18])
Texp_ident \"f/273\"
[
<arg>
Nolabel
expression (main.ml[5,122+19]..main.ml[5,122+23])
Texp_constant Const_string(\"42\",(main.ml[5,122+20]..main.ml[5,122+22]),None)
]
]
]
",
"notifications": []
}

0 comments on commit 02bd7d8

Please sign in to comment.