@@ -200,6 +200,26 @@ def test_constructor(self):
200200 for y in range (array3 .GetLength (1 )):
201201 self .assertEqual (array3 [x , y ], 0 )
202202
203+ def test_constructor_nonzero_lowerbound (self ):
204+ # 1-based
205+ arr = System .Array [int ]((1 , 2 ), base = 1 )
206+ self .assertEqual (arr .Rank , 1 )
207+ self .assertEqual (arr .Length , 2 )
208+ self .assertEqual (arr .GetLowerBound (0 ), 1 )
209+ self .assertEqual (arr .GetUpperBound (0 ), 2 )
210+ self .assertEqual (arr [1 ], 1 )
211+ self .assertEqual (arr [2 ], 2 )
212+ for i in range (1 , 3 ):
213+ self .assertEqual (arr [i ], i )
214+
215+ def test_repr (self ):
216+ from System import Array
217+ arr = Array [int ]((5 , 1 ), base = 1 )
218+ s = repr (arr )
219+ self .assertEqual (s , "Array[int]((5, 1), base=1)" )
220+ array4eval = eval (s , globals (), locals ())
221+ self .assertEqual (arr , array4eval )
222+
203223 def test_nonzero_lowerbound (self ):
204224 a = System .Array .CreateInstance (int , (5 ,), (5 ,))
205225 for i in range (5 , 5 + a .Length ): a [i ] = i
@@ -210,7 +230,7 @@ def test_nonzero_lowerbound(self):
210230 self .assertEqual (a [- 1 :- 3 :- 1 ], System .Array [int ]((9 ,8 )))
211231 self .assertEqual (a [- 1 ], 9 )
212232
213- self .assertEqual (repr (a ), 'Array[int]((5, 6, 7, 8, 9), base: 5)' )
233+ self .assertEqual (repr (a ), 'Array[int]((5, 6, 7, 8, 9), base= 5)' )
214234
215235 a = System .Array .CreateInstance (int , (5 ,), (15 ,))
216236 b = System .Array .CreateInstance (int , (5 ,), (20 ,))
@@ -322,9 +342,7 @@ def test_base_negative(self):
322342
323343 # test slice indexing
324344 # 1-dim array [-1, 0, 1]
325- arr1 = System .Array .CreateInstance (int , (3 ,), (- 1 ,))
326- for i in range (- 1 , 2 ):
327- arr1 [i ] = i
345+ arr1 = System .Array [int ]((- 1 , 0 , 1 ), base = - 1 )
328346 self .assertEqual (arr1 [- 1 :1 ], System .Array [int ]((- 1 , 0 )))
329347 self .assertEqual (arr1 [- 2 :1 ], System .Array [int ]((- 1 , 0 )))
330348 self .assertEqual (arr1 [0 :], System .Array [int ]((0 , 1 )))
0 commit comments