Operators

This test case it part of the test suite proposed for new devices.

Test case ID: R0026
Language: ST

Code:
tests2/t0026.st

PROGRAM Test_R0140


VAR
    (* Primitive data types *)
    I : INT;
    B1,B2,B3,B4 : BOOL;
    W1, W2,W3,W4,W5 : WORD;
    X,Y,Z : REAL;
END_VAR
    
    (*    -------------------------------------------------------------
        Expressions: Binary and unary expressions
        ------------------------------------------------------------- *)
    I := 5 + 1;
    I := 5 - 1;
    I := 9 * 5;
    I := 10 / 3;
    X := 10.0 ** 3.0;   
     (* X := 10.0 ** 3;   THIS WOULD TRIGGER AN ERROR: we dont support EXPT(REAL,INT), only EXPT(REAL, REAL) *)
    I := 10 MOD 3;
    I := - I;
    
    B1 := (10 < 9) OR (10 = 9);
    B2 := 10 > 9;
    B3 := 8 <= 9;
    B4 := 10 <> 9;
    B4 := NOT B4;

    W1 := 1 OR WORD#16#FF;
    W2 := W1 AND WORD#16#0F;
    W3 := W1 XOR W2;

    W4 := WORD#16#10 OR (W2 AND W1);
    W5 := WORD#16#10 | (W2 & W1);
    

    (* Composite expressions *)    
    I := 9 * (5 + REAL_TO_INT(X)) - 7 + 1;
    Z := 9.0 * (5.0 + X) - 7.0 + 1.0;

_GEB_ASSERT_(B1 = 0);
_GEB_ASSERT_(B2 = 1);
_GEB_ASSERT_(B3 = 1);
_GEB_ASSERT_(B4 = 0);
_GEB_ASSERT_(I = 9039);
_GEB_ASSERT_(W1 = 16#ff);
_GEB_ASSERT_(W2 = 16#f);
_GEB_ASSERT_(W3 = 16#f0);
_GEB_ASSERT_(W4 = 16#1f);
_GEB_ASSERT_EQFLOAT_(X , 1000.0);
_GEB_ASSERT_EQFLOAT_(Z , 9039.0);
    

END_PROGRAM