Test case R0017
Full test suiteDevice test case
Nested arrays/structs with initialization
This test case it part of the test suite proposed for new devices.
Test case ID: R0017
Language: ST
tests2/t0017.stTYPE ARRAY20 : ARRAY [5 .. 8] OF INT9X := [20,2(21)]; // [20,21,21,9] ARRAY22 : ARRAY20 := [22]; // [22,21,21,9] ARRAY4 : ARRAY [15..17] OF ARRAY22 := [[1,2],[77]]; // [1,2,21],[77,21,21],[22,21,21] POINT1 : STRUCT X: INT :=1; Y:INT; END_STRUCT; POINT2 : POINT1 := (Y:=10); INT9X : INT := 9; ARRAY25 : ARRAY [1 .. 2 ] OF INT9X; ARRAY26 : ARRAY [1 .. 2 ] OF ARRAY25; ARRAY27 : ARRAY [1 .. 2 ] OF INT9X := [10]; ARRAY28 : ARRAY [1 .. 2 ] OF ARRAY27; END_TYPE PROGRAM TEST2_R0017 VAR_GLOBAL A4R0017 : ARRAY4; IGR0017 : INT :=3; I2GR0017 : INT9X; END_VAR VAR I9 : INT9X; I3 : INT9X := 3; p : POINT1; p2 : POINT2; //A2P : ARRAY [1 .. 2] OF INT := [20,20]; // DISALLOWED! // A3P : ARRAY2 := [3,4]; // DISALLOWED! //A2 : ARRAY [1 .. 2] OF INT := [10,20]; // DISALLOWED! A0 : ARRAY [1 .. 2] OF INT ; A20 : ARRAY20; // [20,21,21] A22 : ARRAY22; // [22,21,21] AA4 : ARRAY4; // [1,2,21],[77,21,21],[22,21,21] I : INT; A26 : ARRAY26; // [[9,9],[9,9]] A28 : ARRAY28; // [[10,9],[10,9]] END_VAR VAR_TEMP END_VAR I := I+1; A0[1] := A0[1] + 5; // [5,0] AA4[17][7] := 7; // [1,2,21],[77,21,21],[22,21,7] A28[2][2] := 30; // [[10,9],[10,30]] _GEB_ASSERT_(I9= 9 ); _GEB_ASSERT_(I3 = 3 ); _GEB_ASSERT_(A0[1] = 5 ); _GEB_ASSERT_(A0[2] = 0 ); _GEB_ASSERT_(A20[5] = 20 ); _GEB_ASSERT_(A20[6] = 21 ); _GEB_ASSERT_(A20[7] = 21 ); _GEB_ASSERT_(A22[5] = 22 ); _GEB_ASSERT_(A22[6] = 21 ); _GEB_ASSERT_(A22[7] = 21 ); _GEB_ASSERT_(AA4[15][5] = 1 ); _GEB_ASSERT_(AA4[15][6] = 2 ); //_GEB_ASSERT_(AA4[15][7] = 21 ); // Interpreter does not agree _GEB_ASSERT_(AA4[16][5] = 77 ); //_GEB_ASSERT_(AA4[16][6] = 21 ); // Interpreter does not agree //_GEB_ASSERT_(AA4[16][7] = 21 ); // Interpreter does not agree //_GEB_ASSERT_(AA4[17][5] = 21 ); _GEB_ASSERT_(AA4[17][6] = 21 ); _GEB_ASSERT_(AA4[17][7] = 7 ); _GEB_ASSERT_(A26[1][1] = 9 ); _GEB_ASSERT_(A26[2][2] = 9 ); _GEB_ASSERT_(A28[1][1] = 10 ); _GEB_ASSERT_(A28[1][2] = 9 ); _GEB_ASSERT_(A28[2][1] = 10 ); _GEB_ASSERT_(A28[2][2] = 30 ); _GEB_ASSERT_(p2.X = 1); _GEB_ASSERT_(p2.Y = 10); END_PROGRAM