Initial commit
This commit is contained in:
commit
84c5bceb81
12 changed files with 968 additions and 0 deletions
53
spec/rules_spec.cpp
Normal file
53
spec/rules_spec.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include "rule.h"
|
||||
#include "transition_map.h"
|
||||
#include <igloo/igloo_alt.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace igloo;
|
||||
using namespace tree_sitter::rules;
|
||||
|
||||
Describe(Rules) {
|
||||
Describe(transitions) {
|
||||
Symbol symbol1 = Symbol(1);
|
||||
Symbol symbol2 = Symbol(2);
|
||||
Symbol symbol3 = Symbol(3);
|
||||
|
||||
It(handles_symbols) {
|
||||
AssertThat(
|
||||
symbol1.transitions(),
|
||||
EqualsContainer(TransitionMap<Rule>(
|
||||
{ symbol1.copy() },
|
||||
{ new Blank() }
|
||||
), TransitionMap<Rule>::elements_equal));
|
||||
}
|
||||
|
||||
It(handles_choices) {
|
||||
AssertThat(
|
||||
Choice(symbol1, symbol2).transitions(),
|
||||
EqualsContainer(TransitionMap<Rule>(
|
||||
{ symbol1.copy(), symbol2.copy() },
|
||||
{ new Blank(), new Blank() }
|
||||
), TransitionMap<Rule>::elements_equal));
|
||||
}
|
||||
|
||||
It(handles_sequences) {
|
||||
AssertThat(
|
||||
Seq(symbol1, symbol2).transitions(),
|
||||
EqualsContainer(TransitionMap<Rule>(
|
||||
{ symbol1.copy() },
|
||||
{ symbol2.copy() }
|
||||
), TransitionMap<Rule>::elements_equal));
|
||||
}
|
||||
|
||||
It(handles_choices_with_common_starting_symbols) {
|
||||
AssertThat(
|
||||
Choice(
|
||||
Seq(symbol1, symbol2),
|
||||
Seq(symbol1, symbol3)).transitions(),
|
||||
EqualsContainer(TransitionMap<Rule>(
|
||||
{ symbol1.copy() },
|
||||
{ new Choice(symbol2, symbol3) }
|
||||
), TransitionMap<Rule>::elements_equal));
|
||||
}
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue