From 554a69fe3887b16b31bf9dc6ceedf94ef6ec4db7 Mon Sep 17 00:00:00 2001 From: connnnal <216976529+connnnal@users.noreply.github.com> Date: Sun, 6 Jul 2025 18:50:10 +0100 Subject: Using-by-ptr tests --- tests/completions_test.odin | 67 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 7312217..2f6901b 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -3363,6 +3363,73 @@ ast_completion_inline_using :: proc(t: ^testing.T) { test.expect_completion_details(t, &source, "", {"Foo.a: int", "Foo.b: int"}) } +@(test) +ast_completion_vtable_using :: proc(t: ^testing.T) { + source := test.Source { + main = `package main + + IUnknown :: struct { + using _iunknown_vtable: ^IUnknown_VTable, + } + + IUnknownVtbl :: IUnknown_VTable + IUnknown_VTable :: struct { + QueryInterface: proc "system" (This: ^IUnknown, riid: REFIID, ppvObject: ^rawptr) -> HRESULT, + AddRef: proc "system" (This: ^IUnknown) -> ULONG, + Release: proc "system" (This: ^IUnknown) -> ULONG, + } + + main :: proc() { + foo: ^IUnknown + foo->{*} + } + `, + } + + test.expect_completion_details( + t, + &source, + "->", + { + `IUnknown.QueryInterface: proc(This: ^IUnknown, riid: REFIID, ppvObject: ^rawptr) -> HRESULT`, + `IUnknown.AddRef: proc(This: ^IUnknown) -> ULONG`, + `IUnknown.Release: proc(This: ^IUnknown) -> ULONG`, + }, + ) +} + +@(test) +ast_complete_ptr_using :: proc(t: ^testing.T) { + source := test.Source { + main = `package main + + B :: struct { + foo: int, + } + + A :: struct { + using b: ^B, + using a: ^struct { + f: int, + }, + } + + main :: proc() { + a: A + a.foo = 2 + } + + main :: proc() { + foo: A + foo.{*} + } + `, + } + + test.expect_completion_details(t, &source, "", {`A.b: ^test.B`, `A.a: ^test.struct`, `A.foo: int`, `A.f: int`}) + +} + @(test) ast_completion_poly_struct_another_package :: proc(t: ^testing.T) { packages := make([dynamic]test.Package, context.temp_allocator) -- cgit v1.2.3