Search in sources :

Example 1 with IntLiteral

use of org.yakindu.base.expressions.expressions.IntLiteral in project statecharts by Yakindu.

the class StextTestFactory method _createValue.

public static PrimitiveValueExpression _createValue(int i) {
    PrimitiveValueExpression assignment = ExpressionsFactory.eINSTANCE.createPrimitiveValueExpression();
    IntLiteral intLit = ExpressionsFactory.eINSTANCE.createIntLiteral();
    intLit.setValue(i);
    assignment.setValue(intLit);
    return assignment;
}
Also used : IntLiteral(org.yakindu.base.expressions.expressions.IntLiteral) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression)

Example 2 with IntLiteral

use of org.yakindu.base.expressions.expressions.IntLiteral in project statecharts by Yakindu.

the class Assert method assertExpressionEquals.

public static void assertExpressionEquals(String expected, Expression current) {
    String currentValue = null;
    if (current instanceof PrimitiveValueExpression) {
        Literal literal = ((PrimitiveValueExpression) current).getValue();
        if (literal instanceof BoolLiteral) {
            currentValue = Boolean.toString(((BoolLiteral) literal).isValue());
        } else if (literal instanceof IntLiteral) {
            currentValue = Long.toString(((IntLiteral) literal).getValue());
        } else if (literal instanceof DoubleLiteral) {
            currentValue = Double.toString(((DoubleLiteral) literal).getValue());
        } else if (literal instanceof FloatLiteral) {
            currentValue = Double.toString(((FloatLiteral) literal).getValue());
        } else if (literal instanceof StringLiteral) {
            currentValue = (((StringLiteral) literal).getValue());
        }
    }
    assertEquals(expected, currentValue);
}
Also used : BoolLiteral(org.yakindu.base.expressions.expressions.BoolLiteral) StringLiteral(org.yakindu.base.expressions.expressions.StringLiteral) FloatLiteral(org.yakindu.base.expressions.expressions.FloatLiteral) FloatLiteral(org.yakindu.base.expressions.expressions.FloatLiteral) StringLiteral(org.yakindu.base.expressions.expressions.StringLiteral) Literal(org.yakindu.base.expressions.expressions.Literal) DoubleLiteral(org.yakindu.base.expressions.expressions.DoubleLiteral) IntLiteral(org.yakindu.base.expressions.expressions.IntLiteral) BoolLiteral(org.yakindu.base.expressions.expressions.BoolLiteral) IntLiteral(org.yakindu.base.expressions.expressions.IntLiteral) DoubleLiteral(org.yakindu.base.expressions.expressions.DoubleLiteral) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression)

Example 3 with IntLiteral

use of org.yakindu.base.expressions.expressions.IntLiteral in project statecharts by Yakindu.

the class SCTResourceTest method testTransitionSerializing.

@Test
public void testTransitionSerializing() throws Exception {
    res.setSerializerEnabled(true);
    Transition transition = createTransition("after 10\n s [true] / 3 * 3");
    res.getContents().add(transition);
    ReactionTrigger trigger = (ReactionTrigger) transition.getTrigger();
    TimeEventSpec timeTrigger = stextFac.createTimeEventSpec();
    timeTrigger.setType(TimeEventType.EVERY);
    timeTrigger.setUnit(TimeUnit.SECOND);
    PrimitiveValueExpression exp = expFac.createPrimitiveValueExpression();
    IntLiteral literal = expFac.createIntLiteral();
    literal.setValue(42);
    exp.setValue(literal);
    timeTrigger.setValue(exp);
    trigger.getTriggers().add(timeTrigger);
    assertEquals("after 10\n s , every 42 s [true] / 3 * 3", transition.getSpecification());
    assertEquals("" + res.getErrors(), 0, res.getErrors().size());
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) Transition(org.yakindu.sct.model.sgraph.Transition) IntLiteral(org.yakindu.base.expressions.expressions.IntLiteral) TimeEventSpec(org.yakindu.sct.model.stext.stext.TimeEventSpec) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) Test(org.junit.Test)

Example 4 with IntLiteral

use of org.yakindu.base.expressions.expressions.IntLiteral in project statecharts by Yakindu.

the class FeatureParameterValueImpl method setValue.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public void setValue(int bool) {
    IntLiteral intLiteral = ExpressionsFactory.eINSTANCE.createIntLiteral();
    intLiteral.setValue(bool);
    setValue(intLiteral);
}
Also used : IntLiteral(org.yakindu.base.expressions.expressions.IntLiteral)

Aggregations

IntLiteral (org.yakindu.base.expressions.expressions.IntLiteral)4 PrimitiveValueExpression (org.yakindu.base.expressions.expressions.PrimitiveValueExpression)3 Test (org.junit.Test)1 BoolLiteral (org.yakindu.base.expressions.expressions.BoolLiteral)1 DoubleLiteral (org.yakindu.base.expressions.expressions.DoubleLiteral)1 FloatLiteral (org.yakindu.base.expressions.expressions.FloatLiteral)1 Literal (org.yakindu.base.expressions.expressions.Literal)1 StringLiteral (org.yakindu.base.expressions.expressions.StringLiteral)1 Transition (org.yakindu.sct.model.sgraph.Transition)1 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)1 TimeEventSpec (org.yakindu.sct.model.stext.stext.TimeEventSpec)1