Global vars in FB and functions

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

Test case ID: R0005
Language: ST

Code:
tests2/t0005.st

PROGRAM T0005A
    VAR_GLOBAL    
        GL1T0005 : INT := 11;    
    END_VAR
    VAR_GLOBAL CONSTANT
        GL1T0005C : INT := 120;    
    END_VAR
    VAR_EXTERNAL 
        GL2T0005 : INT;    
    END_VAR

    GL1T0005 := GL1T0005+2;  // GL2T0005 := 11+2
    GL2T0005 := GL2T0005+3;  // GL2T0005 := 22+3 

    _GEB_ASSERT_(GL1T0005 = 13);
    _GEB_ASSERT_(GL2T0005 = 25);
    

END_PROGRAM

PROGRAM T0005B
    VAR_EXTERNAL 
        GL1T0005 : INT; 
    END_VAR
    VAR_GLOBAL    
        GL2T0005 : INT := 22;    
    END_VAR
    VAR    
        fb3 : FB3_T0005; 
        X : INT;
    END_VAR

    GL1T0005 := GL1T0005 + 5;  
    GL2T0005 := GL2T0005 + 7;
    _GEB_ASSERT_(GL1T0005 = 18);
    _GEB_ASSERT_(GL2T0005 = 32);
    fb3(i:=20);
    _GEB_ASSERT_(GL2T0005 = 52);
    X := F_T0005(7);
    _GEB_ASSERT_(X = 127);
    fb3();
END_PROGRAM


(* adds input value to both global vars *)
FUNCTION_BLOCK FB3_T0005 
    VAR_EXTERNAL 
        GL1T0005 : INT; 
        GL2T0005 : INT; 
    END_VAR
    VAR_INPUT 
        i : INT; 
    END_VAR
    VAR_OUTPUT 
        o : INT; 
    END_VAR

    GL1T0005 := GL1T0005 + i;
    GL2T0005 := GL2T0005 + i;
    o := i;
END_FUNCTION_BLOCK

(* uses read only global *)
FUNCTION F_T0005 : INT
     VAR_EXTERNAL CONSTANT GL1T0005C : INT; END_VAR
    VAR_INPUT 
        i : INT; 
    END_VAR

    F_T0005 := i + GL1T0005C;
END_FUNCTION