use of org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value in project titan.EclipsePlug-ins by eclipse.
the class Setverdict_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (myStatementBlock.getMyDefinition() == null) {
location.reportSemanticError(INCONTROLPART);
}
if (verdictValue != null) {
verdictValue.setLoweridToReference(timestamp);
// to force its checking
final IValue last = verdictValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temp = verdictValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temp) {
case TYPE_VERDICT:
if (Value_type.VERDICT_VALUE.equals(last.getValuetype()) && Verdict_type.ERROR.equals(((Verdict_Value) last).getValue())) {
verdictValue.getLocation().reportSemanticError(ERRORCANNOTBESET);
}
if (Value_type.VERDICT_VALUE.equals(last.getValuetype()) && !Verdict_type.PASS.equals(((Verdict_Value) last).getValue()) && verdictReason == null) {
getLocation().reportConfigurableSemanticProblem(reportSetverdictWithoutReason, MessageFormat.format(WITHOUT_REASON, ((Verdict_Value) last).getValue()));
}
break;
default:
verdictValue.getLocation().reportSemanticError(OPERANDERROR);
verdictValue.setIsErroneous(true);
break;
}
}
if (verdictReason != null) {
verdictReason.check(timestamp);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value in project titan.EclipsePlug-ins by eclipse.
the class Def_Function_Writer method writeReceiveStatement.
public String writeReceiveStatement(Receive_Port_Statement currentStatement) {
StringBuilder testCaseString = new StringBuilder("");
String receiveStatement = "";
// no alt guard && any port recieve
if (receivePortReference.get(receiveCounter).equals("any port")) {
receiveStatement = "anyPortReceive(true)";
} else {
// no alt guard && typed port recieve
if (receiveType.get(receiveCounter).equals("_TYPED_PARAM_")) {
if (receiveAnyValValue.get(receiveCounter) != null) {
receiveStatement = "(" + receiveAnyValValue.get(receiveCounter) + "=" + receivePortReference.get(receiveCounter) + ".receive_" + receiveValue.get(receiveCounter) + "(true))!=null";
} else {
}
} else {
// no alt guard && normal port recieve
receiveStatement = receivePortReference.get(receiveCounter) + ".receive(" + receiveValue.get(receiveCounter) + ",true)!=null";
}
if (receiveValue.get(receiveCounter).startsWith("Templates")) {
receiveType.set(receiveCounter, "Templates");
}
}
testCaseString.append("if(" + receiveStatement + "){\r\n");
testCaseString.append("rownum=" + currentStatement.getLocation().getLine() + ";\r\n");
if (receiveType.get(receiveCounter).equals("Templates")) {
String methodName = receiveValue.get(receiveCounter);
if (methodName.endsWith("()") && methodName.startsWith("Templates.")) {
methodName = (String) methodName.subSequence(10, methodName.length() - 2);
}
testCaseString.append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \"" + nodeName + "\", \"RECEIVE event on port " + receivePortReference.get(receiveCounter) + ":\\n " + methodName + ":=\" + " + receiveValue.get(receiveCounter) + ".toString(), true);" + "\r\n");
} else if (receiveType.get(receiveCounter).equals("any port")) {
testCaseString.append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \"" + nodeName + "\", \"RECEIVE event on port any port\", true);" + "\r\n");
} else if (receiveType.get(receiveCounter).equals("_TYPED_PARAM_")) {
testCaseString.append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \"" + nodeName + "\", \"RECEIVE event on port " + receivePortReference.get(receiveCounter) + ": type " + receiveValue.get(receiveCounter) + "\", true);" + "\r\n");
} else {
testCaseString.append(" TTCN3Logger.writeLog(\"mtc\", \"PORTEVENT\", sourcefilename, rownum, \"function\", \"" + nodeName + "\", \"RECEIVE event on port " + receivePortReference.get(receiveCounter) + ":\" + " + receiveValue.get(receiveCounter) + ".toString(), true);" + "\r\n");
}
for (int i = 0; i < receiveStatements.get(receiveCounter).getSize(); i++) {
if (receiveStatements.get(receiveCounter).getStatementByIndex(i) instanceof Setverdict_Statement) {
Setverdict_Statement setVerdictStatement = (Setverdict_Statement) receiveStatements.get(receiveCounter).getStatementByIndex(i);
String verdict = "";
if (setVerdictStatement.getVerdictValue() instanceof Verdict_Value) {
Verdict_Value verdictValue = (Verdict_Value) setVerdictStatement.getVerdictValue();
if (verdictValue.getValue().toString().equals("PASS")) {
verdict = "pass";
} else if (verdictValue.getValue().toString().equals("INCONC")) {
verdict = "inconc";
} else {
verdict = "fail";
}
}
testCaseString.append("rownum=" + setVerdictStatement.getLocation().getLine() + ";\r\n");
testCaseString.append("TTCN3Logger.writeLog(\"mtc\", \"VERDICTOP\", sourcefilename, rownum, \"function\", \"" + nodeName + "\", \"setverdict(" + verdict + "): \" + getVerdict() + \" -> " + verdict + "\", true);" + "\r\n");
testCaseString.append("setVerdict(\"" + verdict + "\");" + "\r\n");
}
}
testCaseString.append("}\r\n");
return testCaseString.toString();
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value in project titan.EclipsePlug-ins by eclipse.
the class Def_Testcase_Writer method writeSetVerdictStatement.
public void writeSetVerdictStatement(Setverdict_Statement tc_setVerdictStatement) {
Verdict_Value tc_VerdictValue = (Verdict_Value) tc_setVerdictStatement.getVerdictValue();
testCaseString.append("rownum=" + tc_setVerdictStatement.getLocation().getLine() + ";\r\n");
if (tc_VerdictValue.getValue().toString().equals("PASS")) {
testCaseString.append("setVerdict(\"pass\")" + ";\r\n");
} else if (tc_VerdictValue.getValue().toString().equals("FAIL")) {
testCaseString.append("setVerdict(\"fail\")" + ";\r\n");
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value in project titan.EclipsePlug-ins by eclipse.
the class VerdictWithoutReason method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (!(node instanceof Setverdict_Statement)) {
return;
}
final Setverdict_Statement s = (Setverdict_Statement) node;
final Value verdictValue = s.getVerdictValue();
if (verdictValue == null) {
return;
}
final CompilationTimeStamp ct = CompilationTimeStamp.getBaseTimestamp();
final Type_type temp = verdictValue.getExpressionReturntype(ct, Expected_Value_type.EXPECTED_TEMPLATE);
if (Type_type.TYPE_VERDICT != temp) {
return;
}
final LogArguments verdictReason = s.getVerdictReason();
if (Value_type.VERDICT_VALUE.equals(verdictValue.getValuetype()) && !Verdict_type.PASS.equals(((Verdict_Value) verdictValue).getValue()) && verdictReason == null) {
final String msg = MessageFormat.format(WITHOUT_REASON, ((Verdict_Value) verdictValue).getValue());
problems.report(s.getLocation(), msg);
}
}
Aggregations