Add unit test for stack
- Also, fix bug where trees pushed onto the stack were not retained
This commit is contained in:
parent
baec9f2c9a
commit
63cde3967c
7 changed files with 188 additions and 7 deletions
8
spec/runtime/helpers/tree_helpers.cc
Normal file
8
spec/runtime/helpers/tree_helpers.cc
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include "helpers/tree_helpers.h"
|
||||
|
||||
ts_tree ** tree_array(std::vector<ts_tree *> trees) {
|
||||
ts_tree ** result = (ts_tree **)calloc(trees.size(), sizeof(ts_tree *));
|
||||
for (size_t i = 0; i < trees.size(); i++)
|
||||
result[i] = trees[i];
|
||||
return result;
|
||||
}
|
||||
5
spec/runtime/helpers/tree_helpers.h
Normal file
5
spec/runtime/helpers/tree_helpers.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include "tree_sitter/runtime.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
ts_tree ** tree_array(std::vector<ts_tree *> trees);
|
||||
Loading…
Add table
Add a link
Reference in a new issue