Search in sources :

Example 6 with Setverdict_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement in project titan.EclipsePlug-ins by eclipse.

the class Def_Testcase_Writer method writeTestCaseFunction.

public String writeTestCaseFunction(StatementBlock tcStatementBlock) {
    int testcaseSize = tcStatementBlock.getSize();
    for (int j = 0; j < testcaseSize; j++) {
        if (tcStatementBlock.getStatementByIndex(j) instanceof Definition_Statement) {
            Definition_Statement tc_defStatement = (Definition_Statement) tcStatementBlock.getStatementByIndex(j);
            defCounter++;
            defValueCounter++;
            writeDefinitionStatement(tc_defStatement);
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Assignment_Statement) {
            Assignment_Statement tc_assignStatement = (Assignment_Statement) tcStatementBlock.getStatementByIndex(j);
            assignCounter++;
            testCaseString.append(writeAssignmentStatement(tc_assignStatement));
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Connect_Statement) {
            Connect_Statement tc_connectStatement = (Connect_Statement) tcStatementBlock.getStatementByIndex(j);
            connectCounter++;
            writeConnectStatement(tc_connectStatement);
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Unknown_Start_Statement) {
            Unknown_Start_Statement tc_startStatement = (Unknown_Start_Statement) tcStatementBlock.getStatementByIndex(j);
            writeUnknownStartStatement(tc_startStatement);
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Done_Statement) {
            testCaseString.append("hc.done(\"all component\");" + "\r\n");
        // TODO: where is all coming from?
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Map_Statement) {
            Map_Statement tc_mapStatement = (Map_Statement) tcStatementBlock.getStatementByIndex(j);
            mapCounter++;
            writeMapStatement(tc_mapStatement);
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof If_Statement) {
            If_Statement tc_ifStatement = (If_Statement) tcStatementBlock.getStatementByIndex(j);
            tcIfConditionCounter++;
            writeIfStatement(tc_ifStatement);
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Setverdict_Statement) {
            Setverdict_Statement tc_setVerdictStatement = (Setverdict_Statement) tcStatementBlock.getStatementByIndex(j);
            writeSetVerdictStatement(tc_setVerdictStatement);
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof DoWhile_Statement) {
            doWhileCounter++;
            DoWhile_Statement doWhileStatement = (DoWhile_Statement) tcStatementBlock.getStatementByIndex(j);
            String test = doWhileStatement.getExpression().toString();
            testCaseString.append("do{" + "\r\n");
            this.writeTestCaseFunction(doWhileStatement.getStatementBlock());
            testCaseString.append("while(" + doWhileExpressions.get(doWhileCounter) + ".getValue());\r\n");
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Send_Statement) {
            Send_Statement tc_SendStatement = (Send_Statement) tcStatementBlock.getStatementByIndex(j);
            sendCounter++;
            testCaseString.append(writeSendStatement(tc_SendStatement));
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Receive_Port_Statement) {
            Receive_Port_Statement tc_ReceiveStatement = (Receive_Port_Statement) tcStatementBlock.getStatementByIndex(j);
            receiveCounter++;
            blockStatementBlockStatementWriter = true;
            testCaseString.append(writeReceiveStatement(tc_ReceiveStatement));
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Unknown_Stop_Statement) {
            Unknown_Stop_Statement tc_StopStatement = (Unknown_Stop_Statement) tcStatementBlock.getStatementByIndex(j);
            writeUnknownStopStatement(tc_StopStatement);
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Alt_Statement) {
            altStatementCounter++;
            altStatements.get(altStatementCounter).setTimerInfo(isThereAStartedTimer, currentTimerName);
            testCaseString.append(altStatements.get(altStatementCounter).getJavaSource());
        } else if (tcStatementBlock.getStatementByIndex(j) instanceof Disconnect_Statement) {
            Disconnect_Statement tc_disconnectStatement = (Disconnect_Statement) tcStatementBlock.getStatementByIndex(j);
            disconnectCounter++;
            writeDisconnectStatement(tc_disconnectStatement);
        } else if ((tcStatementBlock.getStatementByIndex(j) instanceof StatementBlock_Statement) && !blockStatementBlockStatementWriter) {
            StatementBlock_Statement tc_statementBlockStatement = (StatementBlock_Statement) tcStatementBlock.getStatementByIndex(j);
            blockStatementBlockStatementWriter = false;
            testCaseString.append("{\r\n");
            blockWriter = true;
            writeTestCaseFunction(tc_statementBlockStatement.getStatementBlock());
            blockWriter = false;
            testCaseString.append("}\r\n");
        }
    }
    if (!blockWriter) {
        testCaseString.append("}" + "\r\n");
    }
    return testCaseString.toString();
}
Also used : Done_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Done_Statement) Connect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement) Definition_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement) DoWhile_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.DoWhile_Statement) StatementBlock_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock_Statement) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Assignment_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement) Unknown_Stop_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement) Send_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement) Disconnect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement) Unknown_Start_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement) Alt_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) Map_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement) Setverdict_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement)

Example 7 with Setverdict_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement 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 8 with Setverdict_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement 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

Setverdict_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Setverdict_Statement)6 Verdict_Value (org.eclipse.titan.designer.AST.TTCN3.values.Verdict_Value)6 Alt_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement)3 Assignment_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement)3 Send_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement)3 Definition_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement)2 DoWhile_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.DoWhile_Statement)2 Receive_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement)2 Unknown_Start_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement)2 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)1 AltGuard (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard)1 AltGuards (org.eclipse.titan.designer.AST.TTCN3.statements.AltGuards)1 Connect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement)1 Disconnect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement)1 Done_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Done_Statement)1 If_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement)1 LogArguments (org.eclipse.titan.designer.AST.TTCN3.statements.LogArguments)1 Map_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement)1 Operation_Altguard (org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard)1 Repeat_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Repeat_Statement)1