Skip to content

Commit

Permalink
New and improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Nov 17, 2023
1 parent 359f745 commit 2c9e846
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tests/test-dirs/occurrences/issue1410.t
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
FIXME: No result is returned, we could expect the one occurrence of None.
No result is returned, we could expect the one occurrence of None.
$ $MERLIN single occurrences -identifier-at 3:3 -filename opt.ml <<EOF | \
> jq '.value'
> (* test case *)
> let f ?(x=1) () = 2 ;;
> None
> EOF
[]
[
{
"start": {
"line": 3,
"col": 0
},
"end": {
"line": 3,
"col": 4
}
}
]

$ $MERLIN single occurrences -identifier-at 3:3 -filename opt.ml <<EOF | \
> jq '.value'
> (* test case *)
> let f () = 2 ;;
> None
> EOF
[]
[
{
"start": {
"line": 3,
"col": 0
},
"end": {
"line": 3,
"col": 4
}
}
]
54 changes: 54 additions & 0 deletions tests/test-dirs/occurrences/no-ml.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
$ cat >oui_ml.ml <<'EOF'
> type t = int
> EOF

$ cat >no_ml.mli <<'EOF'
> include module type of Oui_ml
> EOF

$ cat >main.ml <<'EOF'
> let (x : No_ml.t) = 42
> open No_ml
> let (y : t) = 43
> EOF

$ $OCAMLC -bin-annot -c oui_ml.ml no_ml.mli

$ $MERLIN single occurrences -scope project -identifier-at 1:15 \
> -filename main.ml <main.ml | jq '.value'
[
{
"file": "$TESTCASE_ROOT/main.ml",
"start": {
"line": 1,
"col": 15
},
"end": {
"line": 1,
"col": 16
}
},
{
"file": "$TESTCASE_ROOT/main.ml",
"start": {
"line": 3,
"col": 9
},
"end": {
"line": 3,
"col": 10
}
}
]



$ $MERLIN single locate -look-for ml -position 1:15 \
> -filename main.ml <main.ml | jq '.value'
{
"file": "$TESTCASE_ROOT/oui_ml.ml",
"pos": {
"line": 1,
"col": 5
}
}
146 changes: 146 additions & 0 deletions tests/test-dirs/occurrences/only-local.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
Some occurrences are only available locally an dnot part of the global index

$ cat >local.ml <<'EOF'
> type t = int
> let x : int = 42
> EOF

Predef:
$ $MERLIN single occurrences -identifier-at 2:9 \
> -filename local.ml <local.ml | jq '.value'
[
{
"start": {
"line": 1,
"col": 9
},
"end": {
"line": 1,
"col": 12
}
},
{
"start": {
"line": 2,
"col": 8
},
"end": {
"line": 2,
"col": 11
}
}
]


Predef constructors:
$ cat >local.ml <<'EOF'
> let _ = None
> let None = None
> EOF

$ $MERLIN single occurrences -identifier-at 1:10 \
> -filename local.ml <local.ml | jq '.value'
[
{
"start": {
"line": 1,
"col": 8
},
"end": {
"line": 1,
"col": 12
}
},
{
"start": {
"line": 2,
"col": 4
},
"end": {
"line": 2,
"col": 8
}
},
{
"start": {
"line": 2,
"col": 11
},
"end": {
"line": 2,
"col": 15
}
}
]

true / false
$ cat >local.ml <<'EOF'
> let _ = true
> let _ = true
> EOF

$ $MERLIN single occurrences -identifier-at 1:10 \
> -filename local.ml <local.ml | jq '.value'
[
{
"start": {
"line": 1,
"col": 8
},
"end": {
"line": 1,
"col": 12
}
},
{
"start": {
"line": 2,
"col": 8
},
"end": {
"line": 2,
"col": 12
}
}
]

unit
$ cat >local.ml <<'EOF'
> let _ = ()
> let f () = ()
> EOF

$ $MERLIN single occurrences -identifier-at 1:9 \
> -filename local.ml <local.ml | jq '.value'
[
{
"start": {
"line": 1,
"col": 8
},
"end": {
"line": 1,
"col": 10
}
},
{
"start": {
"line": 2,
"col": 6
},
"end": {
"line": 2,
"col": 8
}
},
{
"start": {
"line": 2,
"col": 11
},
"end": {
"line": 2,
"col": 13
}
}
]

0 comments on commit 2c9e846

Please sign in to comment.