@@ -61,20 +61,56 @@ test(function () {
6161 Assert::same (2 , $ list ->count ());
6262 Assert::same (2 , count ($ list ));
6363
64+ unset($ list [1 ]);
65+ Assert::same ([
66+ $ mary ,
67+ ], iterator_to_array ($ list ));
68+
69+ $ list ->prepend ('First ' );
70+ Assert::same ('First ' , $ list [0 ], 'Value "First" should be on the start of the array ' );
71+ });
72+
73+
74+ test (function () {
75+ $ list = new ArrayList ;
76+ $ list [] = 'a ' ;
77+ $ list [] = 'b ' ;
6478
6579 Assert::exception (function () use ($ list ) {
66- unset( $ list [-1 ]) ;
80+ $ list [-1 ] = true ;
6781 }, OutOfRangeException::class, 'Offset invalid or out of range ' );
6882
6983 Assert::exception (function () use ($ list ) {
70- unset( $ list [2 ]) ;
84+ $ list [2 ] = true ;
7185 }, OutOfRangeException::class, 'Offset invalid or out of range ' );
86+ });
7287
73- unset($ list [1 ]);
74- Assert::same ([
75- $ mary ,
76- ], iterator_to_array ($ list ));
7788
78- $ list ->prepend ('First ' );
79- Assert::same ('First ' , $ list [0 ], 'Value "First" should be on the start of the array ' );
89+ test (function () {
90+ $ list = new ArrayList ;
91+ $ list [] = 'a ' ;
92+ $ list [] = 'b ' ;
93+
94+ Assert::exception (function () use ($ list ) {
95+ $ tmp = $ list [-1 ];
96+ }, OutOfRangeException::class, 'Offset invalid or out of range ' );
97+
98+ Assert::exception (function () use ($ list ) {
99+ $ tmp = $ list [2 ];
100+ }, OutOfRangeException::class, 'Offset invalid or out of range ' );
101+ });
102+
103+
104+ test (function () {
105+ $ list = new ArrayList ;
106+ $ list [] = 'a ' ;
107+ $ list [] = 'b ' ;
108+
109+ Assert::exception (function () use ($ list ) {
110+ unset($ list [-1 ]);
111+ }, OutOfRangeException::class, 'Offset invalid or out of range ' );
112+
113+ Assert::exception (function () use ($ list ) {
114+ unset($ list [2 ]);
115+ }, OutOfRangeException::class, 'Offset invalid or out of range ' );
80116});
0 commit comments