Test case R0105
Full test suiteDevice test case
Function calls inside loops
This test case it part of the test suite proposed for new devices.
Test case ID: R0105
Language: ST
tests2/t0105.st(* Function : returns SUMX = X+Y+1.0 and sets Z = X + 1.1, increments 2nd arg Y in 0.5, *) FUNCTION SUMX_R0105 : REAL VAR_INPUT X : REAL; END_VAR VAR_IN_OUT Y : REAL; END_VAR VAR_OUTPUT Z : REAL; END_VAR VAR W : REAL := 1.7; END_VAR W := W - 0.7; // W=1.0 ; to check init SUMX_R0105 := X + Y + W; Y := Y + 0.5 ; Z := X + W + 0.1; END_FUNCTION PROGRAM R0105 VAR X1,Y1,Z1,R1,X2,Z2,R2 : REAL; i : INT; END_VAR X1 := 10.0; Y1 := 5.0; X2 := 11.0; FOR i := 1 TO 5 BY 1 DO R1 := SUMX_R0105( X := X1, Y := Y1, Z => Z1 ); (* after each iteration we should have R1 Y1 16 5.5 16.5 6. 17 6.5 17.5 7. 18 7.5 *) END_FOR; (* what to do with Fnction calls that omit input_output? *) FOR i := 1 TO 100 BY 1 DO R2 := SUMX_R0105(X:=1.8, Y := X2, Z => Z2 ); (* R2 Z2 63.3 2.9 *) END_FOR; _GEB_ASSERT_EQFLOAT_(R1 , 18.0); _GEB_ASSERT_EQFLOAT_(R2 , 63.3); _GEB_ASSERT_EQFLOAT_(X2 , 61.0); _GEB_ASSERT_EQFLOAT_(Y1 , 7.5); _GEB_ASSERT_EQFLOAT_(Z1 , 11.1); _GEB_ASSERT_EQFLOAT_(Z2 , 2.9); END_PROGRAM