References

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

Test case ID: R0297
Language: ST

Code:
tests2/t0297.st
 
PROGRAM TEST_R0297
    
    VAR
     X,Y : INT;
     R1 : REFERENCE TO INT;
     R2 : REFERENCE TO INT;
     RA : REFERENCE TO REAL;
     A1 : ARRAY [ 1 .. 3 ] OF REAL;
     D1,D2 : REAL; 
    END_VAR
    VAR_TEMP
         Z:INT;
    END_VAR
    
    X:=10;
    Y:=20;
    Z:=30;
    D1 := 1.2;
    R1 REF= X;
    R2 REF= Y;
    RA REF= D1;
    D2 := RA; 
    RA := 2.3;
    _GEB_ASSERT_EQFLOAT_(D1 , 2.3);
    _GEB_ASSERT_EQFLOAT_(D2 , 1.2);
    R1 := 11 + R1 + R2; // X:= 11 + 10 + 20 = 41  
    R2 REF= Z;
    Z := Z + 1;   // Z:=31
    R2 := R2 + 1; // Z:=32
    R2 := Z + 1;  // Z:=33
    Z := R2 + 1;  // Z:=34
     
    A1[1] := 10.0;
    A1[2] := 20.0;
    A1[3] := 30.0;
    RA REF= A1[2];
    RA := 40.0;
    D1 := RA;
    RA REF= A1[1];
    D2 := RA;
    
_GEB_ASSERT_EQFLOAT_(D1 , 40.0);
_GEB_ASSERT_EQFLOAT_(D2 , 10.0);
_GEB_ASSERT_(X = 41);
_GEB_ASSERT_(Y = 20);
_GEB_ASSERT_(Z = 34);
    
END_PROGRAM