Type conversions

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

Test case ID: R0001
Language: ST

Code:
tests2/t0001.st
// type conversions 
PROGRAM T0001
VAR
    I1,I2,I3 : INT;
    SI1,SI2,SI3 : SINT;
    USI1,USI2 : USINT;
    B1,B2: BOOL;
    W1, W2 : WORD;
     R1, R2 : REAL;
     LR1, LR2 : LREAL;
    S1 : STRING;
END_VAR

    S1 := 'Testing';
    S1 := LEFT(S1,2); 
    S1 := LEFT(S1,BYTE#2); (* automatic castin BYTE -> INT -  S1='Te' *) 
    I1 := -(INT#-8192 - 16#20);     // 8224
    I1 := NEG(-I1); (* NEG is non-standard *)      //    8224
    SI1 := 16;
    USI1 := SI1;
    USI1 := USI1*3 + SINT_TO_USINT(SI1)/2; (* not necessary but legal USI1=56*)
    I1 := SINT_TO_INT(SI1) - I1 ;     (* SINT_TO_INT no necessary here *) (* I1= -8208    *)
    _GEB_ASSERT_(I1 = INT#-8208 );    
    W1 := AND(INT#254,USINT#11);     (* automatic casting to INT -> WORD  W1=0xA *)  
    I2 :=  INT#-57;             (*      test    C comment inside ST comment */ *)   
    LR1 := INT_TO_REAL(I2) - 0.23 ; // -57.2300
    _GEB_ASSERT_EQDOUBLE_(LR1 , -57.23 );    
    _GEB_ASSERT_EQDOUBLE_(LR2 , 0.0 );    
    SI1 := INT_TO_SINT(I2);    (* necessary - narrowing conversion SI1 *) // -57
    SI2 := BYTE#32 / USINT#4;    (* implicit conversion *)  // 8
    I2 := BYTE#32 / BYTE#4 + MUL(WORD#320 , BYTE#4);  // 8 + 128 = 1288 = 0x508
    B2 := 1=2;
    B1 := INT_TO_BOOL(20000); (* true *)
    W2 := BOOL_TO_WORD(B1) OR INT_TO_WORD(I2);    (* 0x1 | 0x508 =0x509 *)
    I3    := LREAL_TO_INT(LR1);    
    SI3 := WORD_TO_SINT(IN:=W2,EN:=TRUE);    
    _GEB_ASSERT_(I2 = INT#1288 );    
    _GEB_ASSERT_(B1 = TRUE );
    _GEB_ASSERT_(B2 = FALSE );
    _GEB_ASSERT_EQFLOAT_(R1 , 0.0 );    
    _GEB_ASSERT_EQFLOAT_(R2 , 0.0 );
    _GEB_ASSERT_(S1 = 'Te');    
    _GEB_ASSERT_(SI1 = SINT#-57);    
    _GEB_ASSERT_(SI2 = SINT#8);    
    _GEB_ASSERT_(USI1 = SINT#56);    
    _GEB_ASSERT_(USI2 = SINT#0);    
    _GEB_ASSERT_(W1 = 16#0a);    
    _GEB_ASSERT_(W2 = 16#509);    
END_PROGRAM