Search in sources :

Example 6 with Verdict_Value

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;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value)

Example 7 with Verdict_Value

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();
}
Also used : Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value) Setverdict_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement)

Example 8 with Verdict_Value

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");
    }
}
Also used : Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value)

Example 9 with Verdict_Value

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);
    }
}
Also used : LogArguments(org.eclipse.titan.designer.AST.TTCN3.statements.LogArguments) CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp) Value(org.eclipse.titan.designer.AST.Value) Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Verdict_Value(org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value) Setverdict_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement)

Aggregations

Verdict_Value (org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value)9 Setverdict_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement)4 IValue (org.eclipse.titan.designer.AST.IValue)3 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)2 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)2 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)2 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)2 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)2 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)2 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)2 Assignment (org.eclipse.titan.designer.AST.Assignment)1 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)1 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 ISubReference (org.eclipse.titan.designer.AST.ISubReference)1 IType (org.eclipse.titan.designer.AST.IType)1 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)1 Reference (org.eclipse.titan.designer.AST.Reference)1 AltGuard (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard)1