@@ -545,6 +545,76 @@ function! s:typeHighlightGroup(testname, value)
545
545
endtry
546
546
endfunc
547
547
548
+ function ! Test_goFunction () abort
549
+ syntax on
550
+
551
+ let l: tests = {
552
+ \ ' StandardFunction' : {' group' : ' goFunction' , ' value' : " F\x1f (){}" },
553
+ \ ' GenericFunction' : {' group' : ' goFunction' , ' value' : " G\x1f [T any](_ T){}" },
554
+ \ }
555
+
556
+ let g: go_highlight_functions = 1
557
+ for l: kv in items (l: tests )
558
+ let l: actual = s: functionHighlightGroup (l: kv [0 ], l: kv [1 ].value)
559
+ call assert_equal (l: kv [1 ].group, l: actual , l: kv [0 ])
560
+ endfor
561
+ unlet g: go_highlight_functions
562
+ endfunc
563
+
564
+ function ! s: functionHighlightGroup (testname, value)
565
+ let l: package = tolower (a: testname )
566
+ let l: dir = gotest#write_file (printf (' %s/%s.go' , l: package , a: testname ), [
567
+ \ printf (' package %s' , l: package ),
568
+ \ ' ' ,
569
+ \ printf (' func %s' , a: value ),
570
+ \ ])
571
+
572
+ try
573
+ let l: pos = getcurpos ()
574
+ let l: actual = synIDattr (synID (l: pos [1 ], l: pos [2 ], 1 ), ' name' )
575
+ return l: actual
576
+ finally
577
+ call delete (l: dir , ' rf' )
578
+ endtry
579
+ endfunc
580
+
581
+ function ! Test_goFunctionCall () abort
582
+ syntax on
583
+
584
+ let l: tests = {
585
+ \ ' StandardFunctionCall' : {' group' : ' goFunctionCall' , ' value' : " f\x1f ()" },
586
+ \ ' GenericFunctionCall' : {' group' : ' goFunctionCall' , ' value' : " g\x1f [int](i)" },
587
+ \ }
588
+
589
+ let g: go_highlight_function_calls = 1
590
+ for l: kv in items (l: tests )
591
+ let l: actual = s: functionCallHighlightGroup (l: kv [0 ], l: kv [1 ].value)
592
+ call assert_equal (l: kv [1 ].group, l: actual , l: kv [0 ])
593
+ endfor
594
+ unlet g: go_highlight_function_calls
595
+ endfunc
596
+
597
+ function ! s: functionCallHighlightGroup (testname, value)
598
+ let l: package = tolower (a: testname )
599
+ let l: dir = gotest#write_file (printf (' %s/%s.go' , l: package , a: testname ), [
600
+ \ printf (' package %s' , l: package ),
601
+ \ ' ' ,
602
+ \ ' func f() {}' ,
603
+ \ ' func g[T any](i T) {}' ,
604
+ \ ' func init() {' ,
605
+ \ printf (" \t %s" , a: value ),
606
+ \ ' }' ,
607
+ \ ])
608
+
609
+ try
610
+ let l: pos = getcurpos ()
611
+ let l: actual = synIDattr (synID (l: pos [1 ], l: pos [2 ], 1 ), ' name' )
612
+ return l: actual
613
+ finally
614
+ call delete (l: dir , ' rf' )
615
+ endtry
616
+ endfunc
617
+
548
618
" restore Vi compatibility settings
549
619
let &cpo = s: cpo_save
550
620
unlet s: cpo_save
0 commit comments