package tests import "core:fmt" import "core:testing" import test "src:testing" @(test) ast_hover_default_intialized_parameter :: proc(t: ^testing.T) { source := test.Source { main = `package test my_function :: proc(a := false) { b := a{*}; } `, packages = {}, } test.expect_hover(t, &source, "test.a: bool") } @(test) ast_hover_default_parameter_enum :: proc(t: ^testing.T) { source := test.Source { main = `package test procedure :: proc(called_from: Expr_Called_Type = .None, options := List_Options{}) { } main :: proc() { procedure{*} } `, packages = {}, } test.expect_hover( t, &source, "test.procedure: proc(called_from: Expr_Called_Type = .None, options := List_Options{})", ) } @(test) ast_hover_parameter :: proc(t: ^testing.T) { source := test.Source { main = `package test main :: proc(cool: int) { cool{*} } `, packages = {}, } test.expect_hover(t, &source, "cool: int") } @(test) ast_hover_external_package_parameter :: proc(t: ^testing.T) { packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, test.Package { pkg = "my_package", source = `package my_package My_Struct :: struct { one: int, two: int, three: int, } `, }, ) source := test.Source { main = `package test import "my_package" main :: proc(cool: my_package.My_Struct) { cool{*} } `, packages = packages[:], } test.expect_hover(t, &source, "test.cool: My_Struct") } @(test) ast_hover_procedure_package_parameter :: proc(t: ^testing.T) { packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, test.Package { pkg = "my_package", source = `package my_package My_Struct :: struct { one: int, two: int, three: int, } `, }, ) source := test.Source { main = `package test import "my_package" main :: proc(cool: my_packa{*}ge.My_Struct) { } `, packages = packages[:], } test.expect_hover(t, &source, "my_package: package") } @(test) ast_hover_procedure_with_default_comp_lit :: proc(t: ^testing.T) { source := test.Source { main = `package test Color :: struct { r: int, g: int, b: int, a: int, } fa{*} :: proc(color_ : Color = { 255, 255, 255, 255 }) `, } test.expect_hover( t, &source, "test.fa: proc(color_: Color = {255, 255, 255, 255})", ) } @(test) ast_hover_same_name_in_selector_and_field :: proc(t: ^testing.T) { source := test.Source { main = `package test Color :: struct { color: int, } f :: proc() { color: Color color.colo{*}r } `, } test.expect_hover(t, &source, "Color.color: int") } @(test) ast_hover_on_sliced_result :: proc(t: ^testing.T) { source := test.Source { main = `package test f :: proc() { buf: [420]byte slic{*}e := buf[2:20] } `, } test.expect_hover(t, &source, "test.slice: []byte") } @(test) ast_hover_on_bitset_variable :: proc(t: ^testing.T) { source := test.Source { main = `package test test :: proc () { Foo :: enum {A,B,C} derived_{*}bit_set := bit_set[Foo]{} } `, } test.expect_hover(t, &source, "test.derived_bit_set: bit_set[Foo]") } @(test) ast_hover_struct_field_selector_completion :: proc(t: ^testing.T) { packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, test.Package { pkg = "my_package", source = `package my_package My_Struct :: struct { one: int, two: int, three: int, } `, }, ) source := test.Source { main = `package test import "my_package" My_Foo :: struct { bar: my_package.My_Stru{*}ct, } my_package :: proc() { } `, packages = packages[:], } test.expect_hover(t, &source, "my_package.My_Struct: struct") }