Fix block width when communicating with references [#21]

This commit is contained in:
David Evans 2017-11-26 16:26:38 +00:00
parent c60f2fa0f9
commit 82a2c1a219
4 changed files with 55 additions and 5 deletions

View File

@ -2713,10 +2713,12 @@ define('sequence/Generator',['core/ArrayUtilities'], (array) => {
let colAgents = agents.map(this.convertAgent); let colAgents = agents.map(this.convertAgent);
this.validateAgents(colAgents, {allowGrouped: true}); this.validateAgents(colAgents, {allowGrouped: true});
colAgents = this.expandGroupedAgentConnection(colAgents);
const allAgents = array.flatMap(colAgents, this.expandGroupedAgent);
this.defineAgents(allAgents);
colAgents = this.expandGroupedAgentConnection(colAgents);
const agentNames = colAgents.map(Agent.getName); const agentNames = colAgents.map(Agent.getName);
this.defineAgents(colAgents);
const implicitBegin = (agents const implicitBegin = (agents
.filter(Agent.hasFlag('begin', false)) .filter(Agent.hasFlag('begin', false))

File diff suppressed because one or more lines are too long

View File

@ -689,10 +689,12 @@ define(['core/ArrayUtilities'], (array) => {
let colAgents = agents.map(this.convertAgent); let colAgents = agents.map(this.convertAgent);
this.validateAgents(colAgents, {allowGrouped: true}); this.validateAgents(colAgents, {allowGrouped: true});
colAgents = this.expandGroupedAgentConnection(colAgents);
const allAgents = array.flatMap(colAgents, this.expandGroupedAgent);
this.defineAgents(allAgents);
colAgents = this.expandGroupedAgentConnection(colAgents);
const agentNames = colAgents.map(Agent.getName); const agentNames = colAgents.map(Agent.getName);
this.defineAgents(colAgents);
const implicitBegin = (agents const implicitBegin = (agents
.filter(Agent.hasFlag('begin', false)) .filter(Agent.hasFlag('begin', false))

View File

@ -1271,6 +1271,52 @@ defineDescribe('Sequence Generator', ['./Generator'], (Generator) => {
]})).toThrow(new Error('Agent B is hidden behind group at line 1')); ]})).toThrow(new Error('Agent B is hidden behind group at line 1'));
}); });
it('encompasses entire reference boxes in block statements', () => {
const sequenceR = generator.generate({stages: [
PARSED.beginAgents(['A', 'B', 'C', 'D']),
PARSED.groupBegin('BC', ['B', 'C'], {label: 'Foo'}),
PARSED.blockBegin('if', 'abc'),
PARSED.connect(['BC', 'D']),
PARSED.blockEnd(),
PARSED.endAgents(['BC']),
]});
expect(sequenceR.agents).toEqual([
{name: '[', anchorRight: true},
{name: 'A', anchorRight: false},
{name: '__BLOCK1[', anchorRight: true},
{name: '__BLOCK0[', anchorRight: true},
{name: 'B', anchorRight: false},
{name: 'C', anchorRight: false},
{name: '__BLOCK0]', anchorRight: false},
{name: 'D', anchorRight: false},
{name: '__BLOCK1]', anchorRight: false},
{name: ']', anchorRight: false},
]);
const sequenceL = generator.generate({stages: [
PARSED.beginAgents(['A', 'B', 'C', 'D']),
PARSED.groupBegin('BC', ['B', 'C'], {label: 'Foo'}),
PARSED.blockBegin('if', 'abc'),
PARSED.connect(['BC', 'A']),
PARSED.blockEnd(),
PARSED.endAgents(['BC']),
]});
expect(sequenceL.agents).toEqual([
{name: '[', anchorRight: true},
{name: '__BLOCK1[', anchorRight: true},
{name: 'A', anchorRight: false},
{name: '__BLOCK0[', anchorRight: true},
{name: 'B', anchorRight: false},
{name: 'C', anchorRight: false},
{name: '__BLOCK0]', anchorRight: false},
{name: '__BLOCK1]', anchorRight: false},
{name: 'D', anchorRight: false},
{name: ']', anchorRight: false},
]);
});
it('rejects unterminated blocks', () => { it('rejects unterminated blocks', () => {
expect(() => generator.generate({stages: [ expect(() => generator.generate({stages: [
PARSED.blockBegin('if', 'abc'), PARSED.blockBegin('if', 'abc'),