Separate spec helpers files for compiler and runtime specs
This commit is contained in:
parent
b167ee84fa
commit
142671c177
24 changed files with 99 additions and 71 deletions
|
|
@ -1,8 +1,8 @@
|
|||
#include "spec_helper.h"
|
||||
#include "runtime_spec_helper.h"
|
||||
|
||||
static ts_tree ** tree_array(vector<ts_tree *> trees) {
|
||||
ts_tree ** result = (ts_tree **)calloc(trees.size(), sizeof(ts_tree *));
|
||||
for (int i = 0; i < trees.size(); i++)
|
||||
for (size_t i = 0; i < trees.size(); i++)
|
||||
result[i] = trees[i];
|
||||
return result;
|
||||
}
|
||||
|
|
@ -14,12 +14,12 @@ static const char *names[] = { "cat", "dog", "pig" };
|
|||
|
||||
describe("trees", []() {
|
||||
ts_tree *tree1, *parent1;
|
||||
|
||||
|
||||
before_each([&]() {
|
||||
tree1 = ts_tree_make_leaf(cat, 0, 0);
|
||||
parent1 = ts_tree_make_node(dog, 1, tree_array({ tree1 }), 0, 0);
|
||||
});
|
||||
|
||||
|
||||
after_each([&]() {
|
||||
ts_tree_release(tree1);
|
||||
ts_tree_release(parent1);
|
||||
|
|
@ -29,20 +29,20 @@ describe("trees", []() {
|
|||
it("returns true for identical trees", [&]() {
|
||||
ts_tree *tree2 = ts_tree_make_leaf(cat, 0, 0);
|
||||
AssertThat(ts_tree_equals(tree1, tree2), Equals(1));
|
||||
|
||||
|
||||
ts_tree *parent2 = ts_tree_make_node(dog, 1, tree_array({ tree2 }), 0, 0);
|
||||
AssertThat(ts_tree_equals(parent1, parent2), Equals(1));
|
||||
|
||||
|
||||
ts_tree_release(tree2);
|
||||
ts_tree_release(parent2);
|
||||
});
|
||||
|
||||
|
||||
it("returns false for trees with different symbols", [&]() {
|
||||
ts_tree *tree2 = ts_tree_make_leaf(pig, 0, 0);
|
||||
AssertThat(ts_tree_equals(tree1, tree2), Equals(0));
|
||||
ts_tree_release(tree2);
|
||||
});
|
||||
|
||||
|
||||
it("returns false for trees with different children", [&]() {
|
||||
ts_tree *tree2 = ts_tree_make_leaf(pig, 0, 0);
|
||||
ts_tree *parent2 = ts_tree_make_node(dog, 1, tree_array({ tree2 }), 0, 0);
|
||||
|
|
@ -52,7 +52,7 @@ describe("trees", []() {
|
|||
ts_tree_release(parent2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("serialization", [&]() {
|
||||
it("returns a readable string", [&]() {
|
||||
AssertThat(string(ts_tree_string(tree1, names)), Equals("(cat)"));
|
||||
|
|
@ -61,4 +61,4 @@ describe("trees", []() {
|
|||
});
|
||||
});
|
||||
|
||||
END_TEST
|
||||
END_TEST
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue