Remove redundant functions for Documents

There's no need for a `string` function since one already
exists for Nodes.

Now the root node is always stored on the document. This
means callers of `ts_document_root_node` don't need to release
its return value.
This commit is contained in:
Max Brunsfeld 2014-08-08 12:58:39 -07:00
parent 7ba3953f7e
commit 8da9219c3a
6 changed files with 23 additions and 43 deletions

View file

@ -40,10 +40,8 @@ describe("Document", [&]() {
});
it("parses the document", [&]() {
TSNode *node = ts_document_root_node(doc);
AssertThat(string(ts_node_string(node)), Equals(
AssertThat(string(ts_node_string(ts_document_root_node(doc))), Equals(
"(object (string) (array (number) (number)))"));
ts_node_release(node);
});
});
});
@ -63,7 +61,7 @@ describe("Document", [&]() {
});
it("parses the input", [&]() {
AssertThat(string(ts_document_string(doc)), Equals(
AssertThat(string(ts_node_string(ts_document_root_node(doc))), Equals(
"(object (string) (array (number) (number)))"));
});
@ -83,7 +81,7 @@ describe("Document", [&]() {
});
it("updates the parse tree", [&]() {
AssertThat(string(ts_document_string(doc)), Equals(
AssertThat(string(ts_node_string(ts_document_root_node(doc))), Equals(
"(object (string) (array (number) (number)) (string) (number))"));
});
@ -103,7 +101,7 @@ describe("Document", [&]() {
});
it("updates the parse tree", [&]() {
AssertThat(string(ts_document_string(doc)), Equals(
AssertThat(string(ts_node_string(ts_document_root_node(doc))), Equals(
"(object (string) (number) (string) (array (number) (number)))"));
});

View file

@ -28,7 +28,7 @@ describe("Languages", [&]() {
for (auto &entry : test_entries_for_language(language_name)) {
it(entry.description.c_str(), [&]() {
ts_document_set_input_string(doc, entry.input.c_str());
auto doc_string = ts_document_string(doc);
auto doc_string = ts_node_string(ts_document_root_node(doc));
AssertThat(doc_string, Equals(entry.tree_string.c_str()));
free((void *)doc_string);
});

View file

@ -19,7 +19,6 @@ describe("Node", []() {
after_each([&]() {
ts_document_free(document);
ts_node_release(root);
});
describe("child_count", [&]() {