Test case R0190
Full test suiteDevice test case
Test INOUT parameters
This test case it part of the test suite proposed for new devices.
Test case ID: R0190
Language: ST
tests2/t0190.stTYPE POINT: STRUCT X: INT; Y : INT; END_STRUCT; END_TYPE FUNCTION F_R0190: POINT (* adds 1 to the io1 and in to io2, same with X from the points; returns a copy of the original p1 *) VAR_INPUT in : INT; END_VAR VAR_IN_OUT io1,io2 : INT; p1,p2 : POINT; END_VAR VAR pt : POINT; END_VAR io1 := io1 + 1; io2 := io2 + in; pt := p1; // what if the following is done directly? F_R0190 := pt; p1.X := p1.X + 1; p2.X := p2.X + in; END_FUNCTION FUNCTION_BLOCK FB_R0190 (* similar to F_R0190 *) VAR_INPUT in : INT; END_VAR VAR_OUTPUT out : POINT; END_VAR VAR_IN_OUT io1,io2 : SINT; p1,p2 : POINT; END_VAR VAR pt : POINT; END_VAR io1 := io1 + 1; io2 := io2 + INT_TO_SINT(in); pt := p1; // what if the following is done directly? out := pt; p1.X := p1.X + 1; p2.X := p2.X + in; END_FUNCTION_BLOCK PROGRAM TEST_R0190 VAR i,j,k : INT; s1,s2:SINT; zio1 : FB_R0190; px1,px2,px3 : POINT; END_VAR px1.X:=20; px1.Y:=30; px2:=px1; px3:=px1; (* all points initialized to (20,30) *) px3.Y:=40; // function call px3 := F_R0190(in := 3 ,io1 := j , io2 := k, p1:= px1, p2:= px2); (* j=1 k=3 px1=(21,30) px2=(23,30) px3=(20,40) *) _GEB_ASSERT_(j = 1); _GEB_ASSERT_(k = 3); _GEB_ASSERT_(px1.X = 21); _GEB_ASSERT_(px1.Y = 30); _GEB_ASSERT_(px2.X = 23); _GEB_ASSERT_(px2.Y = 30); _GEB_ASSERT_(px3.X = 20); _GEB_ASSERT_(px3.Y = 30); // function call with dup var in out px3 := F_R0190(in := 300 ,io1 := j , io2 := j, p1:= px1, p2:= px1); (* j=302 px1=(322,30) px3=(21,30) *) _GEB_ASSERT_(j = 302); _GEB_ASSERT_(px1.X = 322); _GEB_ASSERT_(px1.Y = 30); _GEB_ASSERT_(px3.X = 21); _GEB_ASSERT_(px3.Y = 30); zio1(in := 300 ,io1 := s1 , io2 := s2, p1:= px1, p2:= px1); END_PROGRAM