Skip to content

Commit

Permalink
tests: add type-enclosing/letop
Browse files Browse the repository at this point in the history
  • Loading branch information
trefis committed Jul 2, 2019
1 parent e857af8 commit 6d7f0c4
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/type-enclosing/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(alias
(name runtest)
(deps (:t letop.t) letop.ml)
(enabled_if (>= %{ocaml_version} 4.08.0))
(action
(progn
(setenv MERLIN %{exe:../merlin-wrapper}
(run %{bin:mdx} test --syntax=cram %{t}))
(diff? %{t} %{t}.corrected))))
5 changes: 5 additions & 0 deletions tests/type-enclosing/letop.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let (let*) o f = Option.map

let plus_two tbl key =
let* foo = Hashtbl.find_opt tbl key in
foo + 2
184 changes: 184 additions & 0 deletions tests/type-enclosing/letop.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
Various parts of the letop:

- The operator:

$ $MERLIN single type-enclosing -position 4:3 -verbosity 0 \
> -filename ./letop.ml < ./letop.ml | jq ".value[0:2]"
[
{
"start": {
"line": 4,
"col": 2
},
"end": {
"line": 5,
"col": 9
},
"type": "('a -> 'b) -> 'a option -> 'b option",
"tail": "no"
},
{
"start": {
"line": 3,
"col": 17
},
"end": {
"line": 5,
"col": 9
},
"type": "'a -> ('b -> 'c) -> 'b option -> 'c option",
"tail": "no"
}
]

- The pattern:

$ $MERLIN single type-enclosing -position 4:8 -verbosity 0 \
> -filename ./letop.ml < ./letop.ml | jq ".value[0:2]"
[
{
"start": {
"line": 4,
"col": 7
},
"end": {
"line": 4,
"col": 10
},
"type": "int",
"tail": "no"
},
{
"start": {
"line": 4,
"col": 2
},
"end": {
"line": 5,
"col": 9
},
"type": "('a -> 'b) -> 'a option -> 'b option",
"tail": "no"
}
]

- The rhs:

$ $MERLIN single type-enclosing -position 4:22 -verbosity 0 \
> -filename ./letop.ml < ./letop.ml | jq ".value[0:2]"
[
{
"start": {
"line": 4,
"col": 13
},
"end": {
"line": 4,
"col": 29
},
"type": "('a, 'b) Hashtbl.t -> 'a -> 'b option",
"tail": "no"
},
{
"start": {
"line": 4,
"col": 2
},
"end": {
"line": 5,
"col": 9
},
"type": "('a -> 'b) -> 'a option -> 'b option",
"tail": "no"
}
]

$ $MERLIN single type-enclosing -position 4:31 -verbosity 0 \
> -filename ./letop.ml < ./letop.ml | jq ".value[0:2]"
[
{
"start": {
"line": 4,
"col": 2
},
"end": {
"line": 5,
"col": 9
},
"type": "('a -> 'b) -> 'a option -> 'b option",
"tail": "no"
},
{
"start": {
"line": 3,
"col": 17
},
"end": {
"line": 5,
"col": 9
},
"type": "'a -> ('b -> 'c) -> 'b option -> 'c option",
"tail": "no"
}
]

$ $MERLIN single type-enclosing -position 4:35 -verbosity 0 \
> -filename ./letop.ml < ./letop.ml | jq ".value[0:2]"
[
{
"start": {
"line": 4,
"col": 2
},
"end": {
"line": 5,
"col": 9
},
"type": "('a -> 'b) -> 'a option -> 'b option",
"tail": "no"
},
{
"start": {
"line": 3,
"col": 17
},
"end": {
"line": 5,
"col": 9
},
"type": "'a -> ('b -> 'c) -> 'b option -> 'c option",
"tail": "no"
}
]

- After the in:

$ $MERLIN single type-enclosing -position 5:3 -verbosity 0 \
> -filename ./letop.ml < ./letop.ml | jq ".value[0:2]"
[
{
"start": {
"line": 5,
"col": 2
},
"end": {
"line": 5,
"col": 5
},
"type": "int",
"tail": "no"
},
{
"start": {
"line": 5,
"col": 2
},
"end": {
"line": 5,
"col": 5
},
"type": "int",
"tail": "no"
}
]

0 comments on commit 6d7f0c4

Please sign in to comment.