tree-sitter/spec/compiler/rules/rules_spec.cpp

25 lines
586 B
C++
Raw Normal View History

2013-11-07 13:24:01 -08:00
#include "spec_helper.h"
#include "rule.h"
2013-11-05 22:15:19 -08:00
2014-01-11 17:08:32 -08:00
using namespace rules;
START_TEST
2014-01-11 17:08:32 -08:00
describe("constructing rules", []() {
rule_ptr symbol1 = sym("1");
rule_ptr symbol2 = sym("2");
rule_ptr symbol3 = sym("3");
2014-01-11 17:08:32 -08:00
it("constructs binary trees", [&]() {
AssertThat(
seq({ symbol1, symbol2, symbol3 }),
EqualsPointer(seq({ seq({ symbol1, symbol2 }), symbol3 })));
AssertThat(
choice({ symbol1, symbol2, symbol3 }),
EqualsPointer(choice({ choice({ symbol1, symbol2 }), symbol3 })));
});
});
END_TEST