aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-04-15 19:56:20 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-04-15 19:56:20 +0200
commit1ff3cccc05724f1a2485edbbace6ac540c4cb485 (patch)
treef72ff54ba467041a0c2db247d46efc53eeb37f2c /tests
parentb4720f71d63f08ec6a734fb79fb0816756484ac6 (diff)
Add proper multi_pointer support and fix range half range op
Diffstat (limited to 'tests')
-rw-r--r--tests/completions_test.odin72
-rw-r--r--tests/definition_test.odin36
2 files changed, 108 insertions, 0 deletions
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 1f73a3e..196230a 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -170,6 +170,24 @@ ast_range_array :: proc(t: ^testing.T) {
}
@(test)
+ast_range_array_2 :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ main :: proc() {
+ ints: []int
+
+ for int_idx in 0..<len(ints) {
+ ints[int_idx] = int_i*
+ }
+ }
+ `,
+ packages = {},
+ };
+
+ test.expect_completion_details(t, &source, ".", {"test.int_idx: int"});
+}
+
+@(test)
ast_completion_identifier_proc_group :: proc(t: ^testing.T) {
source := test.Source {
@@ -948,6 +966,31 @@ ast_non_mutable_variable_struct_completion :: proc(t: ^testing.T) {
}
@(test)
+ast_mutable_variable_struct_completion :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package);
+
+ append(&packages, test.Package {
+ pkg = "my_package",
+ source = `package my_package
+ My_Struct :: struct { a: int }
+ var: My_Struct;
+ `,
+ });
+
+ source := test.Source {
+ main = `package main
+ import "my_package"
+ main :: proc() {
+ my_package.var.*
+ }
+ `,
+ packages = packages[:],
+ };
+
+ test.expect_completion_details(t, &source, ".", {"My_Struct.a: int"});
+}
+
+@(test)
ast_out_of_block_scope_completion :: proc(t: ^testing.T) {
source := test.Source {
main = `package main
@@ -979,6 +1022,35 @@ ast_value_decl_multiple_name_same_type :: proc(t: ^testing.T) {
}
@(test)
+ast_multi_pointer_completion :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package main
+ main :: proc() {
+ faa: [^]int
+ fa*
+ }
+ `,
+ };
+
+ test.expect_completion_details(t, &source, "", {"test.faa: [^]int"});
+}
+
+@(test)
+ast_multi_pointer_indexed_completion :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package main
+ main :: proc() {
+ faa: [^]int
+ sap := faa[1]
+ sa*
+ }
+ `,
+ };
+
+ test.expect_completion_details(t, &source, "", {"test.sap: int"});
+}
+
+@(test)
ast_implicit_named_comp_lit_bitset :: proc(t: ^testing.T) {
source := test.Source {
main = `package main
diff --git a/tests/definition_test.odin b/tests/definition_test.odin
index 612a2d4..f742bc8 100644
--- a/tests/definition_test.odin
+++ b/tests/definition_test.odin
@@ -40,3 +40,39 @@ ast_goto_untyped_value :: proc(t: ^testing.T) {
test.expect_definition_locations(t, &source, {location});
}
+
+
+@(test)
+ast_goto_local_procedure_ret_value :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package main
+ my_function :: proc() -> int {
+ return 0;
+ }
+
+ main :: proc() {
+ xaa := my_function()
+
+
+ xaa
+ }
+ `,
+ packages = {},
+ };
+
+ location := common.Location {
+ range = {
+ start = {
+ line = 5,
+ character = 10,
+ },
+ end = {
+ line = 5,
+ character = 12,
+ },
+ },
+ uri = "file:///test/test.odin",
+ }
+
+ test.expect_definition_locations(t, &source, {location});
+}