@@ -198,6 +198,26 @@ def test_constructor(self):
198198 for y in range (array3 .GetLength (1 )):
199199 self .assertEqual (array3 [x , y ], 0 )
200200
201+ def test_constructor_nonzero_lowerbound (self ):
202+ # 1-based
203+ arr = System .Array [int ]((1 , 2 ), base = 1 )
204+ self .assertEqual (arr .Rank , 1 )
205+ self .assertEqual (arr .Length , 2 )
206+ self .assertEqual (arr .GetLowerBound (0 ), 1 )
207+ self .assertEqual (arr .GetUpperBound (0 ), 2 )
208+ self .assertEqual (arr [1 ], 1 )
209+ self .assertEqual (arr [2 ], 2 )
210+ for i in range (1 , 3 ):
211+ self .assertEqual (arr [i ], i )
212+
213+ def test_repr (self ):
214+ from System import Array
215+ arr = Array [int ]((5 , 1 ), base = 1 )
216+ s = repr (arr )
217+ self .assertEqual (s , "Array[int]((5, 1), base=1)" )
218+ array4eval = eval (s , globals (), locals ())
219+ self .assertEqual (arr , array4eval )
220+
201221 def test_nonzero_lowerbound (self ):
202222 a = System .Array .CreateInstance (int , (5 ,), (5 ,))
203223 for i in range (5 , 5 + a .Length ): a [i ] = i
@@ -208,7 +228,7 @@ def test_nonzero_lowerbound(self):
208228 self .assertEqual (a [- 1 :- 3 :- 1 ], System .Array [int ]((9 ,8 )))
209229 self .assertEqual (a [- 1 ], 9 )
210230
211- self .assertEqual (repr (a ), 'Array[int]((5, 6, 7, 8, 9), base: 5)' )
231+ self .assertEqual (repr (a ), 'Array[int]((5, 6, 7, 8, 9), base= 5)' )
212232
213233 a = System .Array .CreateInstance (int , (5 ,), (15 ,))
214234 b = System .Array .CreateInstance (int , (5 ,), (20 ,))
@@ -320,9 +340,7 @@ def test_base_negative(self):
320340
321341 # test slice indexing
322342 # 1-dim array [-1, 0, 1]
323- arr1 = System .Array .CreateInstance (int , (3 ,), (- 1 ,))
324- for i in range (- 1 , 2 ):
325- arr1 [i ] = i
343+ arr1 = System .Array [int ]((- 1 , 0 , 1 ), base = - 1 )
326344 self .assertEqual (arr1 [- 1 :1 ], System .Array [int ]((- 1 , 0 )))
327345 self .assertEqual (arr1 [- 2 :1 ], System .Array [int ]((- 1 , 0 )))
328346 self .assertEqual (arr1 [0 :], System .Array [int ]((0 , 1 )))
0 commit comments