Skip to content

Commit

Permalink
refactor-open: add a test for functor application paths
Browse files Browse the repository at this point in the history
  • Loading branch information
trefis committed Jul 15, 2021
1 parent 26cff15 commit 74a64af
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 0 deletions.
144 changes: 144 additions & 0 deletions tests/test-dirs/refactor-open/functor-app.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
FIXME: functor applications in type paths are not handled

Unqualifying inside application paths:

$ $MERLIN single refactor-open -action unqualify -position 26:10 \
> -filename test.ml < test.ml
{
"class": "return",
"value": [
{
"start": {
"line": 28,
"col": 44
},
"end": {
"line": 28,
"col": 53
},
"content": "C"
},
{
"start": {
"line": 29,
"col": 12
},
"end": {
"line": 29,
"col": 24
},
"content": "Make"
},
{
"start": {
"line": 29,
"col": 26
},
"end": {
"line": 29,
"col": 35
},
"content": "C"
},
{
"start": {
"line": 31,
"col": 12
},
"end": {
"line": 31,
"col": 24
},
"content": "Make"
},
{
"start": {
"line": 36,
"col": 19
},
"end": {
"line": 36,
"col": 28
},
"content": "C"
},
{
"start": {
"line": 37,
"col": 13
},
"end": {
"line": 37,
"col": 25
},
"content": "Make"
}
],
"notifications": []
}

Qualifying inside application paths:

$ $MERLIN single refactor-open -action qualify -position 26:10 \
> -filename test.ml < test.ml
{
"class": "return",
"value": [
{
"start": {
"line": 33,
"col": 13
},
"end": {
"line": 33,
"col": 17
},
"content": "Wrapper.Make"
},
{
"start": {
"line": 33,
"col": 19
},
"end": {
"line": 33,
"col": 20
},
"content": "Wrapper.C"
},
{
"start": {
"line": 34,
"col": 13
},
"end": {
"line": 34,
"col": 17
},
"content": "Wrapper.Make"
},
{
"start": {
"line": 36,
"col": 13
},
"end": {
"line": 36,
"col": 17
},
"content": "Wrapper.Make"
},
{
"start": {
"line": 37,
"col": 27
},
"end": {
"line": 37,
"col": 28
},
"content": "Wrapper.C"
}
],
"notifications": []
}
42 changes: 42 additions & 0 deletions tests/test-dirs/refactor-open/functor-app.t/test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module Wrapper = struct
module type S = sig
type t
val x : t
end

module Make (X : S) = struct
include X

let () = ignore x
end

module C = struct
type t = char
let x = 'a'
end
end

module I = struct
type t = int
let x = 42
end

module Hammer = Wrapper

open Wrapper

module MC = Hammer (* just because *).Make (Wrapper.C)
module MD = Wrapper.Make (Wrapper.C)

module MI = Wrapper.Make (I)

module MC2 = Make (C)
module MI2 = Make (I)

module MC3 = Make (Wrapper.C)
module MC4 = Wrapper.Make (C)

type t1 = Wrapper.Make(Wrapper.C).t
type t2 = Make(Wrapper.C).t
type t3 = Wrapper.Make(C).t
type t4 = Make(C).t

0 comments on commit 74a64af

Please sign in to comment.