@@ -7,7 +7,7 @@ mod tests {
77 } ;
88 use itertools:: Itertools ;
99 use pretty_assertions:: assert_eq;
10- use samlang_heap:: { Heap , ModuleReference } ;
10+ use samlang_heap:: { Heap , ModuleReference , PStr } ;
1111 use std:: collections:: HashMap ;
1212
1313 #[ test]
@@ -992,27 +992,65 @@ class Main {
992992
993993 #[ test]
994994 fn autocomplete_test_6 ( ) {
995- let mod_ref = ModuleReference :: DUMMY ;
995+ let heap = & mut Heap :: new ( ) ;
996+ let mod_ref = heap. alloc_module_reference ( vec ! [ PStr :: UPPER_A ] ) ;
996997 let state = ServerState :: new (
997998 Heap :: new ( ) ,
998999 false ,
999- HashMap :: from ( [ (
1000- mod_ref,
1001- r#"
1000+ HashMap :: from ( [
1001+ (
1002+ mod_ref,
1003+ r#"
10021004class Main {
1003- function main(a: Developer): Developer = a.
1005+ function main1(a: Developer): Developer = a.
1006+ function main2(): Developer = Developer.
1007+ function main3(): Developer = Process.
10041008}
10051009class Developer {
10061010 private method f(): unit = {}
10071011 method b(): unit = {}
10081012}
10091013"#
1010- . to_string ( ) ,
1011- ) ] ) ,
1014+ . to_string ( ) ,
1015+ ) ,
1016+ ( ModuleReference :: DUMMY , "class Other {}" . to_string ( ) ) ,
1017+ ] ) ,
10121018 ) ;
10131019 assert_eq ! (
10141020 "b [kind=Method, detail=b(): unit]" ,
1015- completion:: auto_complete( & state, & mod_ref, Position ( 2 , 45 ) )
1021+ completion:: auto_complete( & state, & mod_ref, Position ( 2 , 46 ) )
1022+ . iter( )
1023+ . map( completion:: AutoCompletionItem :: to_string)
1024+ . join( "\n " )
1025+ ) ;
1026+ assert_eq ! (
1027+ r#"
1028+ Main [kind=Class, detail=class Main]
1029+ Other [kind=Class, detail=class Other]
1030+ Process [kind=Class, detail=class Process]
1031+ Str [kind=Class, detail=class Str]
1032+ Developer [kind=Class, detail=class Developer]
1033+ "#
1034+ . trim( ) ,
1035+ completion:: auto_complete( & state, & mod_ref, Position ( 3 , 39 ) )
1036+ . iter( )
1037+ . map( completion:: AutoCompletionItem :: to_string)
1038+ . join( "\n " )
1039+ ) ;
1040+ assert_eq ! (
1041+ "init [kind=Function, detail=init(): Developer]" ,
1042+ completion:: auto_complete( & state, & mod_ref, Position ( 3 , 42 ) )
1043+ . iter( )
1044+ . map( completion:: AutoCompletionItem :: to_string)
1045+ . join( "\n " )
1046+ ) ;
1047+ assert_eq ! (
1048+ r#"
1049+ panic [kind=Function, detail=panic(a0: Str): T]
1050+ println [kind=Function, detail=println(a0: Str): unit]
1051+ "#
1052+ . trim( ) ,
1053+ completion:: auto_complete( & state, & mod_ref, Position ( 4 , 40 ) )
10161054 . iter( )
10171055 . map( completion:: AutoCompletionItem :: to_string)
10181056 . join( "\n " )
0 commit comments