Commit b5d3b5b4 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added support for assignments


+ added support for action references
+ added support for assertions

Change-Id: I92702f94b11b222a2efa28fe6ed524fc1b7ae787
Signed-off-by: Philip Makedonski's avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent c3741567
......@@ -1247,6 +1247,18 @@ operation String getFunction() : TTCN!FunctionDef {
return TTCN!FunctionDef.allInstances().select(c|c.name = self).first();
}
operation TDL!DataInstanceUse getDataUseValue() : TTCN!Value {
var value = new TTCN!Value();
value.ref = new TTCN!ReferencedValue();
value.ref.head = new TTCN!Head();
if (self.dataInstance.isValue()) {
value.ref.head.target = self.dataInstance.equivalent().defs.list.first();
} else {
value.ref.head.target = self.dataInstance.equivalent().base;
}
return value;
}
operation TDL!GateReference checkGateReference() : Boolean {
var accepted = false;
if (self.component.role = TDL!ComponentInstanceRole#Tester) {
......@@ -1642,37 +1654,115 @@ operation TDL!UnboundedLoopBehaviour execute() {
}
}
operation TDL!ActionReference execute() {
operation TDL!tdl::Assignment execute() {
//TODO
var ci = self.variable.componentInstance;
if (simulateSUT or ci.role = TDL!ComponentInstanceRole#Tester) {
var sc = self.getMainContext(ci);
var sb = stack.get(sc).last();
var ssl = new TTCN!FunctionStatementList();
var sfs = new TTCN!FunctionStatement();
sfs.basic = new TTCN!BasicStatements();
sfs.basic.assign = new TTCN!Assignment();
sfs.basic.assign.ref = new TTCN!VariableRef();
sfs.basic.assign.ref.ref = new TTCN!ReferencedValue();
sfs.basic.assign.ref.ref.head = new TTCN!Head();
sfs.basic.assign.ref.ref.head.target = self.variable.variable.equivalent();
sfs.basic.assign.expression = self.expression.getDataUseValue();
ssl.statements.add(sfs);
ssl.sc.add(";");
sb.stat.add(ssl);
}
}
operation TDL!Assertion execute() {
var ci = self.componentInstance;
if (simulateSUT or ci.role = TDL!ComponentInstanceRole#Tester) {
var sc = self.getMainContext(ci);
var sb = stack.get(sc).last();
var ssl = new TTCN!FunctionStatementList();
var sfs = new TTCN!FunctionStatement();
sfs.basic = new TTCN!BasicStatements();
sfs.basic.conditional = new TTCN!ConditionalConstruct();
//condition
sfs.basic.conditional.expression = self.condition.getDataUseValue();
//statements - pass
sfs.basic.conditional.statement = new TTCN!StatementBlock();
var psl = new TTCN!FunctionStatementList();
psl.statements.add("pass".getVerdictStatement());
sfs.basic.conditional.statement.stat.add(psl);
//else - otherwise verdict
sfs.basic.conditional.`else` = new TTCN!ElseClause();
sfs.basic.conditional.`else`.statement = new TTCN!StatementBlock();
var osl = new TTCN!FunctionStatementList();
if (self.otherwise.isDefined()) {
osl.statements.add(self.otherwise.getVerdictStatement());
} else {
osl.statements.add("fail".getVerdictStatement());
}
sfs.basic.conditional.`else`.statement.stat.add(osl);
ssl.statements.add(sfs);
ssl.sc.add(";");
sb.stat.add(ssl);
}
}
operation TDL!ActionReference execute() {
var ci = self.componentInstance;
if (simulateSUT or ci.role = TDL!ComponentInstanceRole#Tester) {
var sc = self.getMainContext(ci);
var sb = stack.get(sc).last();
var ssl = new TTCN!FunctionStatementList();
var sfs = new TTCN!FunctionStatement();
sfs.behavior = new TTCN!BehaviourStatements();
sfs.behavior.`function` = new TTCN!FunctionInstance();
sfs.behavior.`function`.ref = self.action.equivalent();
if (not self.actualParameter.isEmpty()) {
var pl = new TTCN!FunctionActualParList();
sfs.behavior.`function`.params = pl;
for (ap in self.actualParameter) {
var p = new TTCN!FunctionActualPar();
p.template = new TTCN!InLineTemplate();
p.template.template = new TTCN!TemplateBody();
p.template.template.simple = new TTCN!SimpleSpec();
p.template.template.simple.expr = ap.dataUse.getDataUseValue();
pl.params.add(p);
}
}
ssl.statements.add(sfs);
ssl.sc.add(";");
sb.stat.add(ssl);
}
}
operation TDL!VerdictAssignment execute() {
//TODO
for (ci in self.getTestDescription().testConfiguration.componentInstance.select(c|simulateSUT or c.role = TDL!ComponentInstanceRole#Tester)) {
var sc = self.getMainContext(ci);
var sb = stack.get(sc).last();
var ssl = new TTCN!FunctionStatementList();
var sfs = new TTCN!FunctionStatement();
sfs.verdict = new TTCN!SetLocalVerdict();
sfs.verdict.expression = new TTCN!Value();
//TODO: handle corresponding verdict properly
if (self.verdict.isKindOf(TDL!DataInstanceUse)) {
sfs.verdict.expression.predef = new TTCN!PredefinedValue();
if (self.verdict.dataInstance.name = "pass") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#pass;
} else if (self.verdict.dataInstance.name = "fail") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#fail;
} else if (self.verdict.dataInstance.name = "inconclusive") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#inconc;
} else {
//TODO
}
} else {
//TODO
}
var sfs = self.verdict.getVerdictStatement();
ssl.statements.add(sfs);
ssl.sc.add(";");
......@@ -1683,6 +1773,47 @@ operation TDL!VerdictAssignment execute() {
}
operation String getVerdictStatement() : TTCN!FunctionStatement {
var sfs = new TTCN!FunctionStatement();
sfs.verdict = new TTCN!SetLocalVerdict();
sfs.verdict.expression = new TTCN!Value();
//TODO: handle corresponding verdict properly
sfs.verdict.expression.predef = new TTCN!PredefinedValue();
if (self = "pass") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#pass;
} else if (self = "fail") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#fail;
} else if (self = "inconclusive") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#inconc;
} else {
//TODO
}
return sfs;
}
operation TDL!DataUse getVerdictStatement() : TTCN!FunctionStatement {
var sfs = new TTCN!FunctionStatement();
sfs.verdict = new TTCN!SetLocalVerdict();
sfs.verdict.expression = new TTCN!Value();
//TODO: handle corresponding verdict properly
if (self.isKindOf(TDL!DataInstanceUse)) {
sfs.verdict.expression.predef = new TTCN!PredefinedValue();
if (self.dataInstance.name = "pass") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#pass;
} else if (self.dataInstance.name = "fail") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#fail;
} else if (self.dataInstance.name = "inconclusive") {
sfs.verdict.expression.predef.verdictType = TTCN!VerdictTypeValue#inconc;
} else {
//TODO
}
} else {
//TODO
}
return sfs;
}
operation TDL!CompoundBehaviour execute() {
//TODO
for (b in self.block.behaviour) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment