Skip to content

Commit 8be2044

Browse files
committed
feat: Add tests
1 parent 2f1b192 commit 8be2044

File tree

1 file changed

+267
-2
lines changed

1 file changed

+267
-2
lines changed

compiler/test/suites/grainlsp.re

Lines changed: 267 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,25 @@ let abc = { x: 1 }
219219
),
220220
),
221221
]),
222+
`Assoc([
223+
("title", `String("Add Graindoc")),
224+
("kind", `String("add-graindoc")),
225+
(
226+
"edit",
227+
lsp_text_document_edit(
228+
"file:///a.gr",
229+
[
230+
(
231+
lsp_range(
232+
(1, 4611686018427387871),
233+
(1, 4611686018427387871),
234+
),
235+
"\n/**\n *\n *\n * @example\n *\n * @since\n */",
236+
),
237+
],
238+
),
239+
),
240+
]),
222241
]),
223242
);
224243

@@ -252,6 +271,25 @@ let f = val => {
252271
),
253272
),
254273
]),
274+
`Assoc([
275+
("title", `String("Add Graindoc")),
276+
("kind", `String("add-graindoc")),
277+
(
278+
"edit",
279+
lsp_text_document_edit(
280+
"file:///a.gr",
281+
[
282+
(
283+
lsp_range(
284+
(1, 4611686018427387871),
285+
(1, 4611686018427387871),
286+
),
287+
"\n/**\n *\n *\n *\n * @param val:\n * @returns \n * @example\n *\n * @since\n */",
288+
),
289+
],
290+
),
291+
),
292+
]),
255293
]),
256294
);
257295

@@ -270,7 +308,27 @@ let abc: T = { x: 1 }
270308
("context", `Assoc([("diagnostics", `List([]))])),
271309
]),
272310
),
273-
`Null,
311+
`List([
312+
`Assoc([
313+
("title", `String("Add Graindoc")),
314+
("kind", `String("add-graindoc")),
315+
(
316+
"edit",
317+
lsp_text_document_edit(
318+
"file:///a.gr",
319+
[
320+
(
321+
lsp_range(
322+
(1, 4611686018427387871),
323+
(1, 4611686018427387871),
324+
),
325+
"\n/**\n *\n *\n * @example\n *\n * @since\n */",
326+
),
327+
],
328+
),
329+
),
330+
]),
331+
]),
274332
);
275333

276334
assertLspOutput(
@@ -417,6 +475,25 @@ let f = (x) => {
417475
),
418476
),
419477
]),
478+
`Assoc([
479+
("title", `String("Add Graindoc")),
480+
("kind", `String("add-graindoc")),
481+
(
482+
"edit",
483+
lsp_text_document_edit(
484+
"file:///a.gr",
485+
[
486+
(
487+
lsp_range(
488+
(0, 4611686018427387894),
489+
(0, 4611686018427387894),
490+
),
491+
"\n/**\n *\n *\n *\n * @param x:\n * @returns \n * @example\n *\n * @since\n */",
492+
),
493+
],
494+
),
495+
),
496+
]),
420497
]),
421498
);
422499

@@ -437,7 +514,27 @@ let f = (x) => {
437514
("context", `Assoc([("diagnostics", `List([]))])),
438515
]),
439516
),
440-
`Null,
517+
`List([
518+
`Assoc([
519+
("title", `String("Add Graindoc")),
520+
("kind", `String("add-graindoc")),
521+
(
522+
"edit",
523+
lsp_text_document_edit(
524+
"file:///a.gr",
525+
[
526+
(
527+
lsp_range(
528+
(0, 4611686018427387894),
529+
(0, 4611686018427387894),
530+
),
531+
"\n/**\n *\n *\n *\n * @param x:\n * @returns \n * @example\n *\n * @since\n */",
532+
),
533+
],
534+
),
535+
),
536+
]),
537+
]),
441538
);
442539

443540
assertLspOutput(
@@ -469,6 +566,25 @@ let f = (x) => print(x)
469566
),
470567
),
471568
]),
569+
`Assoc([
570+
("title", `String("Add Graindoc")),
571+
("kind", `String("add-graindoc")),
572+
(
573+
"edit",
574+
lsp_text_document_edit(
575+
"file:///a.gr",
576+
[
577+
(
578+
lsp_range(
579+
(0, 4611686018427387894),
580+
(0, 4611686018427387894),
581+
),
582+
"\n/**\n *\n *\n *\n * @param x:\n * @returns \n * @example\n *\n * @since\n */",
583+
),
584+
],
585+
),
586+
),
587+
]),
472588
]),
473589
);
474590

@@ -501,9 +617,158 @@ let f = () => () => print(1)
501617
),
502618
),
503619
]),
620+
`Assoc([
621+
("title", `String("Add Graindoc")),
622+
("kind", `String("add-graindoc")),
623+
(
624+
"edit",
625+
lsp_text_document_edit(
626+
"file:///a.gr",
627+
[
628+
(
629+
lsp_range(
630+
(0, 4611686018427387894),
631+
(0, 4611686018427387894),
632+
),
633+
"\n/**\n *\n *\n *\n * @returns \n * @example\n *\n * @since\n */",
634+
),
635+
],
636+
),
637+
),
638+
]),
504639
]),
505640
);
506641

642+
assertLspOutput(
643+
"code_action_add_graindoc_module",
644+
"file:///a.gr",
645+
{|module Main
646+
module Test {
647+
let f = 0
648+
}|},
649+
lsp_input(
650+
"textDocument/codeAction",
651+
`Assoc([
652+
("textDocument", `Assoc([("uri", `String("file:///a.gr"))])),
653+
("range", lsp_range((1, 10), (1, 11))),
654+
("context", `Assoc([("diagnostics", `List([]))])),
655+
]),
656+
),
657+
`List([
658+
`Assoc([
659+
("title", `String("Add Graindoc")),
660+
("kind", `String("add-graindoc")),
661+
(
662+
"edit",
663+
lsp_text_document_edit(
664+
"file:///a.gr",
665+
[
666+
(
667+
lsp_range(
668+
(0, 4611686018427387891),
669+
(0, 4611686018427387891),
670+
),
671+
"\n/**\n *\n *\n * @example\n *\n * @since\n */",
672+
),
673+
],
674+
),
675+
),
676+
]),
677+
]),
678+
);
679+
680+
assertLspOutput(
681+
"code_action_add_graindoc_function",
682+
"file:///a.gr",
683+
{|module A
684+
let f = (x0, (x1, x2), x3, (x4, x5)) => 1
685+
|},
686+
lsp_input(
687+
"textDocument/codeAction",
688+
`Assoc([
689+
("textDocument", `Assoc([("uri", `String("file:///a.gr"))])),
690+
("range", lsp_range((1, 6), (1, 7))),
691+
("context", `Assoc([("diagnostics", `List([]))])),
692+
]),
693+
),
694+
`List([
695+
`Assoc([
696+
("title", `String("Add Graindoc")),
697+
("kind", `String("add-graindoc")),
698+
(
699+
"edit",
700+
lsp_text_document_edit(
701+
"file:///a.gr",
702+
[
703+
(
704+
lsp_range(
705+
(0, 4611686018427387894),
706+
(0, 4611686018427387894),
707+
),
708+
"\n/**\n *\n *\n *\n * @param x0:\n * @param 1:\n * @param x3:\n * @param 3:\n * @returns \n * @example\n *\n * @since\n */",
709+
),
710+
],
711+
),
712+
),
713+
]),
714+
]),
715+
);
716+
717+
assertLspOutput(
718+
"code_action_add_graindoc_value",
719+
"file:///a.gr",
720+
{|module A
721+
let f = 0
722+
|},
723+
lsp_input(
724+
"textDocument/codeAction",
725+
`Assoc([
726+
("textDocument", `Assoc([("uri", `String("file:///a.gr"))])),
727+
("range", lsp_range((1, 6), (1, 7))),
728+
("context", `Assoc([("diagnostics", `List([]))])),
729+
]),
730+
),
731+
`List([
732+
`Assoc([
733+
("title", `String("Add Graindoc")),
734+
("kind", `String("add-graindoc")),
735+
(
736+
"edit",
737+
lsp_text_document_edit(
738+
"file:///a.gr",
739+
[
740+
(
741+
lsp_range(
742+
(0, 4611686018427387894),
743+
(0, 4611686018427387894),
744+
),
745+
"\n/**\n *\n *\n * @example\n *\n * @since\n */",
746+
),
747+
],
748+
),
749+
),
750+
]),
751+
]),
752+
);
753+
754+
assertLspOutput(
755+
"code_action_add_graindoc_existing",
756+
"file:///a.gr",
757+
{|module A
758+
/** Existing graindoc */
759+
let f = 0
760+
|},
761+
lsp_input(
762+
"textDocument/codeAction",
763+
`Assoc([
764+
("textDocument", `Assoc([("uri", `String("file:///a.gr"))])),
765+
("range", lsp_range((2, 6), (2, 7))),
766+
("context", `Assoc([("diagnostics", `List([]))])),
767+
]),
768+
),
769+
`Null,
770+
);
771+
507772
assertLspOutput(
508773
"hover_pattern",
509774
"file:///a.gr",

0 commit comments

Comments
 (0)