Test case R0085
Full test suiteDevice test case
All variants of function calls
This test case it part of the test suite proposed for new devices.
Test case ID: R0085
Language: ST
tests2/t0085.st(* All types of function calls *) FUNCTION FR0085 : INT VAR_INPUT I1 : INT; I2 : INT; END_VAR VAR_IN_OUT IO1 : INT; END_VAR VAR_OUTPUT O1 : INT; END_VAR FR0085 := I1 + I2; O1 := I1 - I2; IO1 := IO1 + 1; END_FUNCTION PROGRAM R0085 VAR G0,G1,G2 : REAL; GE0,GE1,GE2 : INT; NG1, NG2 : REAL; B1,B2 : BOOL; C1,C2,C3,C4,C5,C6: INT; END_VAR // generic non extensible (DIV) G0 := 60.0/3.0; // operator G1 := DIV(REAL#30.0,3.0); // informal R1 = 30.0/3 = 10.0 G2 := DIV(IN1:= REAL#20.0, IN2:=G1); // formal1 R2 = 20/10 = 2.0 G2 := DIV(IN1:= G1, IN2:=G2+8.0); // generic extensible (ADD) GE0 := SINT#7 + INT#400; // operator GE0 = 407 GE1 := ADD(SINT#2,INT#400,-5); // informal GE1 = 397 // GE2 := ADD(IN1:=SINT#2,IN2:= INT#400,IN4:=10); // this is prohibited GE2 := ADD(IN1 := 2, IN2 := 400, IN3:=10, EN:=TRUE); // formal // non generic (COS) NG1 := COS(0.2); NG2 := COS(IN:=3.1416,ENO=>B1); // custom C1 := FR0085(30,20,C2,C3); C4 := FR0085(I1:=30, I2:=20, IO1:= C5, O1=>C6); _GEB_ASSERT_(B1 = 1); _GEB_ASSERT_EQFLOAT_(G0 , 20.0); _GEB_ASSERT_EQFLOAT_(G1 , 10.0); _GEB_ASSERT_EQFLOAT_(G2 ,1.0); _GEB_ASSERT_(GE0 = 407); _GEB_ASSERT_(GE1 = 397); _GEB_ASSERT_(GE2 = 412); _GEB_ASSERT_EQFLOAT_(NG1 , 0.98007); _GEB_ASSERT_(NG2 = -1.0); END_PROGRAM