Skip to content

Commit

Permalink
Added more tests and more exception cases
Browse files Browse the repository at this point in the history
  • Loading branch information
daniilsavchuk committed Jun 2, 2017
1 parent cdcb525 commit 8383790
Show file tree
Hide file tree
Showing 2 changed files with 405 additions and 11 deletions.
25 changes: 19 additions & 6 deletions src/parser/WDL/entities/WDLWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,12 @@ export default class WDLWorkflow {
resolveBinding(node, step, parentStep) {
const nodeValue = node.attributes.value;
const declaration = node.attributes.key.source_string;
if (declaration) {
const expression = extractExpression(nodeValue);
const expression = extractExpression(nodeValue);

if (step.i[declaration]) {
step.i[declaration].bind(WDLWorkflow.getPortForBinding(this.workflowStep, parentStep, expression));
} else {
throw new WDLParserError(`Undeclared variable trying to be assigned: call '${step.name}' --> '${declaration}'`);
}
}

Expand Down Expand Up @@ -250,7 +253,17 @@ export default class WDLWorkflow {
const startStep = WDLWorkflow.findStepInStructureRecursively(this.workflowStep, i.lhs);

if (startStep) {
this.workflowStep.o[i.to].bind(startStep.o[i.rhs]);
if (startStep.o[i.rhs]) {
this.workflowStep.o[i.to].bind(startStep.o[i.rhs]);
} else {
throw new WDLParserError(
`In '${this.workflowStep.name}'
output block undeclared variable is referenced: '${i.lhs}.${i.rhs}'`);
}
} else {
throw new WDLParserError(
`In '${this.workflowStep.name}'
output block undeclared call is referenced: '${i.lhs}'`);
}
});
});
Expand Down Expand Up @@ -323,17 +336,17 @@ export default class WDLWorkflow {
if (outputStep.o[rhsPart]) {
binder = outputStep.o[rhsPart];
} else {
throw new WDLParserError(`Undeclared variable ${lhsPart}.${rhsPart} referencing`);
throw new WDLParserError(`Undeclared variable is referenced: '${lhsPart}.${rhsPart}'`);
}
} else {
throw new WDLParserError(`Undeclared call ${lhsPart} referencing`);
throw new WDLParserError(`Undeclared call is referenced: '${lhsPart}'`);
}
} else if (expression.type === 'identifier') {
const desiredStep = WDLWorkflow.groupNameResolver(parent, expression.string);
if (desiredStep) {
binder = desiredStep.i[expression.string];
} else {
throw new WDLParserError(`Undeclared variable ${expression.string} referencing`);
throw new WDLParserError(`Undeclared variable is referenced: '${expression.string}'`);
}
}

Expand Down
Loading

0 comments on commit 8383790

Please sign in to comment.