aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-04-06 14:25:02 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-04-06 14:25:02 +0200
commit9652ef501f0085fd5e335427de95482625b2d1ea (patch)
treec81bb7913747f67c44a91a00336d3bac7927dd67 /tests
parent34dc6495d51d8525bd2bc1059a31a27588b08e0c (diff)
Fix issues with objc completion and hover
Diffstat (limited to 'tests')
-rw-r--r--tests/objc_test.odin98
1 files changed, 98 insertions, 0 deletions
diff --git a/tests/objc_test.odin b/tests/objc_test.odin
index c1b38bc..af17c0a 100644
--- a/tests/objc_test.odin
+++ b/tests/objc_test.odin
@@ -46,3 +46,101 @@ cobj_return_type_with_selector_expression :: proc(t: ^testing.T) {
{"Window.initWithContentRect: my_package.Window_initWithContentRect"},
)
}
+
+@(test)
+cobj_return_type_with_selector_expression_2 :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package)
+
+ append(
+ &packages,
+ test.Package {
+ pkg = "my_package",
+ source = `package my_package
+ @(objc_class="NSWindow")
+ Window :: struct { dummy: int}
+
+ @(objc_type=Window, objc_name="alloc", objc_is_class_method=true)
+ Window_alloc :: proc "c" () -> ^Window {
+ }
+ @(objc_type=Window, objc_name="initWithContentRect")
+ Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: BOOL) -> ^Window {
+ }
+ `,
+ },
+ )
+
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ main :: proc() {
+ window := my_package.Window.alloc()->initWithContentRect(
+ {{0, 0}, {500, 400}},
+ {.Titled, .Closable, .Resizable},
+ .Buffered,
+ false,
+ )
+
+ window->{*}
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_details(
+ t,
+ &source,
+ "->",
+ {"Window.initWithContentRect: my_package.Window_initWithContentRect"},
+ )
+}
+
+
+@(test)
+cobj_hover_chained_selector :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package)
+
+ append(
+ &packages,
+ test.Package {
+ pkg = "my_package",
+ source = `package my_package
+ @(objc_class="NSWindow")
+ Window :: struct { dummy: int}
+
+ @(objc_type=Window, objc_name="alloc", objc_is_class_method=true)
+ Window_alloc :: proc "c" () -> ^Window {
+ }
+ @(objc_type=Window, objc_name="initWithContentRect")
+ Window_initWithContentRect :: proc (self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: BOOL) -> ^Window {
+ }
+
+ My_Struct :: struct {
+ dummy: int,
+ }
+ `,
+ },
+ )
+
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ main :: proc() {
+ window := my_package.Window.alloc()->initWithConte{*}ntRect(
+ {{0, 0}, {500, 400}},
+ {.Titled, .Closable, .Resizable},
+ .Buffered,
+ false,
+ )
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_hover(
+ t,
+ &source,
+ "Window.initWithContentRect: proc(self: ^Window, contentRect: Rect, styleMask: WindowStyleMask, backing: BackingStoreType, doDefer: BOOL)",
+ )
+}