diff --git a/spec/runtime/node_spec.cc b/spec/runtime/node_spec.cc index 989898fc..76876035 100644 --- a/spec/runtime/node_spec.cc +++ b/spec/runtime/node_spec.cc @@ -224,7 +224,7 @@ describe("Node", []() { }); }); - describe("next_concrete_sibling(), prev_concrete_sibling()", [&]() { + describe("next_named_sibling(), prev_concrete_sibling()", [&]() { it("returns the node's next and previous siblings", [&]() { TSNode number_node = ts_node_named_child(array_node, 0); TSNode false_node = ts_node_named_child(array_node, 1); @@ -261,6 +261,8 @@ describe("Node", []() { AssertThat(ts_node_name(leaf, document), Equals("number")); AssertThat(ts_node_pos(leaf).bytes, Equals(index)); AssertThat(ts_node_size(leaf).bytes, Equals(3)); + AssertThat(ts_node_start_point(leaf), Equals({ 3, 2 })); + AssertThat(ts_node_end_point(leaf), Equals({ 3, 5 })); }); }); @@ -272,10 +274,16 @@ describe("Node", []() { AssertThat(ts_node_pos(leaf).bytes, Equals(index)); AssertThat(ts_node_size(leaf).bytes, Equals(3)); + AssertThat(ts_node_start_point(leaf), Equals({ 6, 4 })); + AssertThat(ts_node_end_point(leaf), Equals({ 6, 7 })); + leaf = ts_node_named_descendent_for_range(array_node, index + 1, index + 2); AssertThat(ts_node_name(leaf, document), Equals("string")); AssertThat(ts_node_pos(leaf).bytes, Equals(index)); AssertThat(ts_node_size(leaf).bytes, Equals(3)); + + AssertThat(ts_node_start_point(leaf), Equals({ 6, 4 })); + AssertThat(ts_node_end_point(leaf), Equals({ 6, 7 })); }); }); @@ -288,6 +296,9 @@ describe("Node", []() { size_t object_index = input_string.find("{"); AssertThat(ts_node_pos(node).bytes, Equals(object_index)); AssertThat(ts_node_size(node).bytes, Equals(19)); + + AssertThat(ts_node_start_point(node), Equals({ 5, 2 })); + AssertThat(ts_node_end_point(node), Equals({ 7, 3 })); }); it("does not return invisible nodes (repeats)", [&]() { @@ -297,17 +308,22 @@ describe("Node", []() { size_t array_index = input_string.find("["); AssertThat(ts_node_pos(node).bytes, Equals(array_index)); AssertThat(ts_node_size(node).bytes, Equals(41)); + + AssertThat(ts_node_start_point(node), Equals({ 2, 0 })); + AssertThat(ts_node_end_point(node), Equals({ 8, 1 })); }); }); }); - describe("find_concrete_for_range(start, end)", [&]() { + describe("descendent_for_range(start, end)", [&]() { it("returns the smallest concrete node that spans the given range", [&]() { size_t colon_index = input_string.find(":"); TSNode node1 = ts_node_descendent_for_range(array_node, colon_index, colon_index); AssertThat(ts_node_name(node1, document), Equals(":")); AssertThat(ts_node_pos(node1).bytes, Equals(colon_index)); AssertThat(ts_node_size(node1).bytes, Equals(1)); + AssertThat(ts_node_start_point(node1), Equals({ 6, 7 })); + AssertThat(ts_node_end_point(node1), Equals({ 6, 8 })); size_t index = input_string.find("\":"); TSNode node2 = ts_node_descendent_for_range(array_node, index, index + 2); @@ -316,6 +332,8 @@ describe("Node", []() { size_t object_index = input_string.find("{"); AssertThat(ts_node_pos(node2).bytes, Equals(object_index)); AssertThat(ts_node_size(node2).bytes, Equals(19)); + AssertThat(ts_node_start_point(node2), Equals({ 5, 2 })); + AssertThat(ts_node_end_point(node2), Equals({ 7, 3 })); }); }); });