From 4eb18cc8f442821bc4b32a95ec5a588833aec2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Wed, 20 Nov 2024 17:39:33 +0100 Subject: [PATCH] test: show issues with deduplication --- .../test-dirs/type-enclosing/generic-types.t | 240 ++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 tests/test-dirs/type-enclosing/generic-types.t diff --git a/tests/test-dirs/type-enclosing/generic-types.t b/tests/test-dirs/type-enclosing/generic-types.t new file mode 100644 index 0000000000..43157358db --- /dev/null +++ b/tests/test-dirs/type-enclosing/generic-types.t @@ -0,0 +1,240 @@ + $ cat >main.ml <<'EOF' + > let _ = List.map Fun.id [3] + > EOF + +With index 0 only the first type is shown: + $ $MERLIN single type-enclosing -position 1:14 -index 0 \ + > -filename ./main.ml < ./main.ml | jq '.value[0,1]' + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 16 + }, + "type": "('a -> 'b) -> 'a list -> 'b list", + "tail": "no" + } + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 16 + }, + "type": 1, + "tail": "no" + } + +With index 1 only the second is shown (the first is a string so it is always shown): + $ $MERLIN single type-enclosing -position 1:14 -index 1 \ + > -filename ./main.ml < ./main.ml | jq '.value[0,1]' + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 16 + }, + "type": "('a -> 'b) -> 'a list -> 'b list", + "tail": "no" + } + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 16 + }, + "type": "(int -> int) -> int list -> int list", + "tail": "no" + } + + +With index 0 only the first type is shown: + $ $MERLIN single type-enclosing -position 1:10 -index 0 \ + > -filename ./main.ml < ./main.ml + { + "class": "return", + "value": [ + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 12 + }, + "type": "(module Stdlib__List)", + "tail": "no" + }, + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 16 + }, + "type": 1, + "tail": "no" + }, + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 27 + }, + "type": 2, + "tail": "no" + } + ], + "notifications": [] + } + +With index 1 only the second is shown (the first is a string so it is always shown): +FIXME? We don't see the generic version + $ $MERLIN single type-enclosing -position 1:10 -index 1 \ + > -filename ./main.ml < ./main.ml + { + "class": "return", + "value": [ + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 12 + }, + "type": "(module Stdlib__List)", + "tail": "no" + }, + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 16 + }, + "type": "(int -> int) -> int list -> int list", + "tail": "no" + }, + { + "start": { + "line": 1, + "col": 8 + }, + "end": { + "line": 1, + "col": 27 + }, + "type": 2, + "tail": "no" + } + ], + "notifications": [] + } + + $ cat >main.ml <<'EOF' + > module List = struct let map : (int -> int) -> int list -> int list = List.map end + > let _ = List.map Fun.id [3] + > EOF + +FIXME With index 0 only the first type is shown but deduplication failed becauser the +next type was not rendered. + $ $MERLIN single type-enclosing -position 2:14 -index 0 \ + > -filename ./main.ml < ./main.ml + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 8 + }, + "end": { + "line": 2, + "col": 16 + }, + "type": "(int -> int) -> int list -> int list", + "tail": "no" + }, + { + "start": { + "line": 2, + "col": 8 + }, + "end": { + "line": 2, + "col": 16 + }, + "type": 1, + "tail": "no" + }, + { + "start": { + "line": 2, + "col": 8 + }, + "end": { + "line": 2, + "col": 27 + }, + "type": 2, + "tail": "no" + } + ], + "notifications": [] + } + +FIXME With index 1 the list is shorter and the numbering is wrong ! In fact, it +should have been shorter earlier. + $ $MERLIN single type-enclosing -position 2:14 -index 1 \ + > -filename ./main.ml < ./main.ml + { + "class": "return", + "value": [ + { + "start": { + "line": 2, + "col": 8 + }, + "end": { + "line": 2, + "col": 16 + }, + "type": "(int -> int) -> int list -> int list", + "tail": "no" + }, + { + "start": { + "line": 2, + "col": 8 + }, + "end": { + "line": 2, + "col": 27 + }, + "type": 2, + "tail": "no" + } + ], + "notifications": [] + }