Fix bug where ts_stack_pop results were backwards for some stack configurations

This commit is contained in:
Max Brunsfeld 2015-10-28 12:10:45 -07:00
parent 36eae5d5e9
commit f5d861a019
3 changed files with 24 additions and 5 deletions

View file

@ -344,17 +344,30 @@ describe("Stack", [&]() {
describe("when there is one path that leads to two different heads", [&]() {
it("returns two entries with the same array of trees", [&]() {
/*
* A0__B1__C2__D3__G6__H7.
* \__E4__F5__/
*/
ts_stack_push(stack, 0, stateH, trees[7]);
/*
* A0__B1__C2__D3.
* \__E4__F5.
*/
StackPopResultList pop = ts_stack_pop(stack, 0, 1, false);
StackPopResultList pop = ts_stack_pop(stack, 0, 2, false);
AssertThat(ts_stack_head_count(stack), Equals(2));
AssertThat(pop.size, Equals(2));
AssertThat(pop.contents[0].index, Equals(0));
AssertThat(pop.contents[0].tree_count, Equals(2));
AssertThat(pop.contents[0].trees[0], Equals(trees[6]));
AssertThat(pop.contents[0].trees[1], Equals(trees[7]));
AssertThat(pop.contents[1].index, Equals(1));
AssertThat(pop.contents[0].trees, Equals(pop.contents[1].trees));
AssertThat(pop.contents[1].tree_count, Equals(2));
AssertThat(pop.contents[1].trees[0], Equals(trees[6]));
AssertThat(pop.contents[1].trees[1], Equals(trees[7]));
});
});