Fix begin/end stages not combining correctly [#31]
This commit is contained in:
parent
f8a757c508
commit
0c988e8658
|
@ -2202,15 +2202,14 @@ define('sequence/Generator',['core/ArrayUtilities'], (array) => {
|
|||
const viable = findViableSequentialMergers(subStages);
|
||||
performSequentialMergers(lastViable, viable, lastStages, subStages);
|
||||
|
||||
lastViable = viable;
|
||||
lastStages = subStages;
|
||||
|
||||
if(subStages.length === 0) {
|
||||
stages.splice(i, 1);
|
||||
} else if(stage.type === 'parallel' && subStages.length === 1) {
|
||||
stages.splice(i, 1, subStages[0]);
|
||||
++ i;
|
||||
} else {
|
||||
if(stage.type === 'parallel' && subStages.length === 1) {
|
||||
stages.splice(i, 1, subStages[0]);
|
||||
}
|
||||
lastViable = viable;
|
||||
lastStages = subStages;
|
||||
++ i;
|
||||
}
|
||||
}
|
||||
|
@ -2510,7 +2509,6 @@ define('sequence/Generator',['core/ArrayUtilities'], (array) => {
|
|||
this.currentNest.blockType + ')'
|
||||
);
|
||||
}
|
||||
optimiseStages(this.currentSection.stages);
|
||||
this.currentSection = {
|
||||
header: {
|
||||
type: 'block split',
|
||||
|
@ -2530,7 +2528,6 @@ define('sequence/Generator',['core/ArrayUtilities'], (array) => {
|
|||
if(this.nesting.length <= 1) {
|
||||
throw new Error('Invalid block nesting (too many "end"s)');
|
||||
}
|
||||
optimiseStages(this.currentSection.stages);
|
||||
const nested = this.nesting.pop();
|
||||
this.currentNest = array.last(this.nesting);
|
||||
this.currentSection = array.last(this.currentNest.sections);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -160,15 +160,14 @@ define(['core/ArrayUtilities'], (array) => {
|
|||
const viable = findViableSequentialMergers(subStages);
|
||||
performSequentialMergers(lastViable, viable, lastStages, subStages);
|
||||
|
||||
lastViable = viable;
|
||||
lastStages = subStages;
|
||||
|
||||
if(subStages.length === 0) {
|
||||
stages.splice(i, 1);
|
||||
} else if(stage.type === 'parallel' && subStages.length === 1) {
|
||||
stages.splice(i, 1, subStages[0]);
|
||||
++ i;
|
||||
} else {
|
||||
if(stage.type === 'parallel' && subStages.length === 1) {
|
||||
stages.splice(i, 1, subStages[0]);
|
||||
}
|
||||
lastViable = viable;
|
||||
lastStages = subStages;
|
||||
++ i;
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +467,6 @@ define(['core/ArrayUtilities'], (array) => {
|
|||
this.currentNest.blockType + ')'
|
||||
);
|
||||
}
|
||||
optimiseStages(this.currentSection.stages);
|
||||
this.currentSection = {
|
||||
header: {
|
||||
type: 'block split',
|
||||
|
@ -488,7 +486,6 @@ define(['core/ArrayUtilities'], (array) => {
|
|||
if(this.nesting.length <= 1) {
|
||||
throw new Error('Invalid block nesting (too many "end"s)');
|
||||
}
|
||||
optimiseStages(this.currentSection.stages);
|
||||
const nested = this.nesting.pop();
|
||||
this.currentNest = array.last(this.nesting);
|
||||
this.currentSection = array.last(this.currentNest.sections);
|
||||
|
|
|
@ -563,6 +563,31 @@ defineDescribe('Sequence Generator', ['./Generator'], (Generator) => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('collapses chains of adjacent begin statements', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.beginAgents(['A']),
|
||||
PARSED.beginAgents(['B']),
|
||||
PARSED.beginAgents(['C']),
|
||||
]);
|
||||
expect(sequence.stages).toEqual([
|
||||
GENERATED.beginAgents(['A', 'B', 'C']),
|
||||
any(),
|
||||
]);
|
||||
});
|
||||
|
||||
it('collapses chains of adjacent end statements', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.beginAgents(['A', 'B', 'C']),
|
||||
PARSED.endAgents(['A']),
|
||||
PARSED.endAgents(['B']),
|
||||
PARSED.endAgents(['C']),
|
||||
]);
|
||||
expect(sequence.stages).toEqual([
|
||||
any(),
|
||||
GENERATED.endAgents(['A', 'B', 'C']),
|
||||
]);
|
||||
});
|
||||
|
||||
it('removes superfluous begin statements', () => {
|
||||
const sequence = invoke([
|
||||
PARSED.connect(['A', 'B']),
|
||||
|
|
Loading…
Reference in New Issue