Fix references inside groups overflowing edges [#49]

This commit is contained in:
David Evans 2018-02-14 22:59:19 +00:00
parent e4ee5cb2ef
commit 978da1ce04
4 changed files with 26 additions and 3 deletions

View File

@ -2900,7 +2900,7 @@ define('sequence/Generator',['core/ArrayUtilities'], (array) => {
GAgent.make(alias), GAgent.make(alias),
{blocked: true, group: alias} {blocked: true, group: alias}
); );
this.defineGAgents(gAgents); this.defineGAgents([...gAgents, leftGAgent, rightGAgent]);
const {indexL, indexR} = addBounds( const {indexL, indexR} = addBounds(
this.gAgents, this.gAgents,
leftGAgent, leftGAgent,

File diff suppressed because one or more lines are too long

View File

@ -575,7 +575,7 @@ define(['core/ArrayUtilities'], (array) => {
GAgent.make(alias), GAgent.make(alias),
{blocked: true, group: alias} {blocked: true, group: alias}
); );
this.defineGAgents(gAgents); this.defineGAgents([...gAgents, leftGAgent, rightGAgent]);
const {indexL, indexR} = addBounds( const {indexL, indexR} = addBounds(
this.gAgents, this.gAgents,
leftGAgent, leftGAgent,

View File

@ -1611,6 +1611,29 @@ defineDescribe('Sequence Generator', ['./Generator'], (Generator) => {
]); ]);
}); });
it('surrounds references with block bounds', () => {
const sequence = invoke([
PARSED.beginAgents(['A', 'B', 'C', 'D']),
PARSED.blockBegin('if', ''),
PARSED.groupBegin('Bar', ['B', 'C']),
PARSED.endAgents(['Bar']),
PARSED.blockEnd(),
]);
expect(sequence.agents).toEqual([
GENERATED.agent('['),
GENERATED.agent('A'),
GENERATED.agent('__BLOCK0['),
GENERATED.agent('__BLOCK1['),
GENERATED.agent('B'),
GENERATED.agent('C'),
GENERATED.agent('__BLOCK1]'),
GENERATED.agent('__BLOCK0]'),
GENERATED.agent('D'),
GENERATED.agent(']'),
]);
});
it('implicitly adds contained agents to groups', () => { it('implicitly adds contained agents to groups', () => {
const sequence = invoke([ const sequence = invoke([
PARSED.beginAgents(['A', 'B', 'C', 'D', 'E']), PARSED.beginAgents(['A', 'B', 'C', 'D', 'E']),