Search in sources :

Example 1 with Done_Statement

use of org.eclipse.titan.designer.AST.TTCN3.statements.Done_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 2 with Done_Statement

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

the class Shorthand method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof Timeout_Statement) {
        typename = NAME_TIMEOUT;
    } else if (node instanceof Receive_Port_Statement) {
        typename = NAME_RECEIVE;
    } else if (node instanceof Trigger_Port_Statement) {
        typename = NAME_TRIGGER;
    } else if (node instanceof Getcall_Statement) {
        typename = NAME_GETCALL;
    } else if (node instanceof Catch_Statement) {
        typename = NAME_CATCH;
    } else if (node instanceof Check_Port_Statement) {
        typename = NAME_CHECK;
    } else if (node instanceof Check_Receive_Port_Statement) {
        typename = NAME_CHECK_RECEIVE;
    } else if (node instanceof Check_Getcall_Statement) {
        typename = NAME_CHECK_GETCALL;
    } else if (node instanceof Check_Catch_Statement) {
        typename = NAME_CHECK_CATCH;
    } else if (node instanceof Check_Getreply_Statement) {
        typename = NAME_CHECK_GETREPLY;
    } else if (node instanceof Getreply_Statement) {
        typename = NAME_GETREPLY;
    } else if (node instanceof Done_Statement) {
        typename = NAME_DONE;
    } else if (node instanceof Killed_Statement) {
        typename = NAME_KILLED;
    } else {
        return;
    }
    final Statement s = (Statement) node;
    check(s, problems);
}
Also used : Done_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Done_Statement) Check_Getcall_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getcall_Statement) Killed_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Killed_Statement) Call_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Call_Statement) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Statement) Check_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Port_Statement) Check_Catch_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Catch_Statement) Catch_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Catch_Statement) Getreply_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Getreply_Statement) Alt_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement) Check_Getreply_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getreply_Statement) Trigger_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Trigger_Port_Statement) Timeout_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Timeout_Statement) Getcall_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Getcall_Statement) Killed_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Killed_Statement) Done_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Done_Statement) Check_Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Receive_Port_Statement) Check_Getcall_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getcall_Statement) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Check_Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Receive_Port_Statement) Check_Catch_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Catch_Statement) Catch_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Catch_Statement) Trigger_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Trigger_Port_Statement) Check_Catch_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Catch_Statement) Getcall_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Getcall_Statement) Check_Getcall_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getcall_Statement) Check_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Port_Statement) Getreply_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Getreply_Statement) Check_Getreply_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getreply_Statement) Timeout_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Timeout_Statement) Check_Getreply_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getreply_Statement) Check_Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Check_Receive_Port_Statement)

Aggregations

Alt_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Alt_Statement)2 Done_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Done_Statement)2 Receive_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement)2 Assignment_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement)1 Call_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Call_Statement)1 Catch_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Catch_Statement)1 Check_Catch_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Check_Catch_Statement)1 Check_Getcall_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getcall_Statement)1 Check_Getreply_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Check_Getreply_Statement)1 Check_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Check_Port_Statement)1 Check_Receive_Port_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Check_Receive_Port_Statement)1 Connect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement)1 Definition_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement)1 Disconnect_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement)1 DoWhile_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.DoWhile_Statement)1 Getcall_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Getcall_Statement)1 Getreply_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Getreply_Statement)1 If_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement)1 Killed_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Killed_Statement)1 Map_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement)1