diff options
| -rw-r--r-- | src/common/ast.odin | 7 | ||||
| -rw-r--r-- | tests/hover_test.odin | 41 | ||||
| -rw-r--r-- | tests/signatures_test.odin | 2 |
3 files changed, 37 insertions, 13 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin index 7a32cde..05c651f 100644 --- a/src/common/ast.odin +++ b/src/common/ast.odin @@ -770,7 +770,12 @@ build_string_node :: proc(node: ^ast.Node, builder: ^strings.Builder) { case ^Comp_Lit: build_string(n.type, builder) strings.write_string(builder, "{") - build_string(n.elems, builder) + for elem, i in n.elems { + build_string(elem, builder) + if len(n.elems) - 1 != i { + strings.write_string(builder, ", ") + } + } strings.write_string(builder, "}") case ^Tag_Expr: build_string(n.expr, builder) diff --git a/tests/hover_test.odin b/tests/hover_test.odin index c710fb7..3b6d153 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -18,7 +18,7 @@ ast_hover_default_intialized_parameter :: proc(t: ^testing.T) { packages = {}, }; - test.expect_hover(t, &source, "test.a: bool"); + test.expect_hover(t, &source, "test.a: bool") } @(test) @@ -33,9 +33,9 @@ ast_hover_default_parameter_enum :: proc(t: ^testing.T) { } `, packages = {}, - }; + } - test.expect_hover(t, &source, "test.procedure: proc(called_from: Expr_Called_Type = .None, options := List_Options{})"); + 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) { @@ -47,9 +47,9 @@ ast_hover_parameter :: proc(t: ^testing.T) { } `, packages = {}, - }; + } - test.expect_hover(t, &source, "cool: int"); + test.expect_hover(t, &source, "cool: int") } @(test) @@ -65,7 +65,7 @@ ast_hover_external_package_parameter :: proc(t: ^testing.T) { three: int, } `, - }); + }) source := test.Source { main = `package test import "my_package" @@ -74,9 +74,9 @@ ast_hover_external_package_parameter :: proc(t: ^testing.T) { } `, packages = packages[:], - }; + } - test.expect_hover(t, &source, "test.cool: My_Struct"); + test.expect_hover(t, &source, "test.cool: My_Struct") } @(test) @@ -92,7 +92,7 @@ ast_hover_procedure_package_parameter :: proc(t: ^testing.T) { three: int, } `, - }); + }) source := test.Source { main = `package test import "my_package" @@ -101,7 +101,26 @@ ast_hover_procedure_package_parameter :: proc(t: ^testing.T) { } `, 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, "my_package: package"); + test.expect_hover(t, &source, "test.fa: proc(color_: Color = {255, 255, 255, 255})") } diff --git a/tests/signatures_test.odin b/tests/signatures_test.odin index acc8271..1bb44d5 100644 --- a/tests/signatures_test.odin +++ b/tests/signatures_test.odin @@ -358,7 +358,7 @@ ast_index_builtin_len_proc :: proc(t: ^testing.T) { packages = {}, }; - test.expect_signature_labels(t, &source, {"builtin.len: proc(array: Array_Type) -> int"}); + test.expect_signature_labels(t, &source, {"$builtin.len: proc(array: Array_Type) -> int"}); } @(test) |