@@ -136,6 +136,25 @@ CTArray2DTest >> testCannotAccessWithWrongCoordinates [
136136 self should: [ self arrayClass width2Height3 atColumn: 6 atRow: 1 ] raise: SubscriptOutOfBounds
137137]
138138
139+ { #category : ' tests' }
140+ CTArray2DTest >> testColumns [
141+ | foo |
142+ foo := self arrayClass width2Height3.
143+ self assert: foo columns equals: #(#(1 3 5) #(2 4 6) )
144+ ]
145+
146+ { #category : ' tests' }
147+ CTArray2DTest >> testColumnsDo [
148+ | foo array columnIndex |
149+ foo := self arrayClass width2Height3.
150+ array := Array new : 2 .
151+ columnIndex := 1 .
152+ foo columnsDo: [ :column |
153+ array at: columnIndex put: column.
154+ columnIndex := columnIndex + 1 ].
155+ self assert: array equals: #(#(1 3 5) #(2 4 6) )
156+ ]
157+
139158{ #category : ' tests-copying' }
140159CTArray2DTest >> testCopy [
141160 | foo cop |
@@ -211,6 +230,78 @@ CTArray2DTest >> testFromArray [
211230
212231]
213232
233+ { #category : ' tests-enumeration' }
234+ CTArray2DTest >> testFromBottomToTopFromLeftToRightDo [
235+ |foo res |
236+ foo := self arrayClass width2Height3.
237+ res := OrderedCollection new .
238+ foo fromBottomToTopFromLeftToRightDo: [ :each | res add: each ].
239+ self assert: res equals: #(5 3 1 6 4 2) asOrderedCollection
240+ ]
241+
242+ { #category : ' tests-enumeration' }
243+ CTArray2DTest >> testFromBottomToTopFromRightToLeftDo [
244+ |foo res |
245+ foo := self arrayClass width2Height3.
246+ res := OrderedCollection new .
247+ foo fromBottomToTopFromRightToLeftDo: [ :each | res add: each ].
248+ self assert: res equals: #(6 4 2 5 3 1) asOrderedCollection
249+ ]
250+
251+ { #category : ' tests-enumeration' }
252+ CTArray2DTest >> testFromLeftToRightFromBottomToTopDo [
253+ |foo res |
254+ foo := self arrayClass width2Height3.
255+ res := OrderedCollection new .
256+ foo fromLeftToRightFromBottomToTopDo: [ :each | res add: each ].
257+ self assert: res equals: #(5 6 3 4 1 2) asOrderedCollection
258+ ]
259+
260+ { #category : ' tests-enumeration' }
261+ CTArray2DTest >> testFromLeftToRightFromTopToBottomDo [
262+ |foo res |
263+ foo := self arrayClass width2Height3.
264+ res := OrderedCollection new .
265+ foo fromLeftToRightFromTopToBottomDo: [ :each | res add: each ].
266+ self assert: res equals: #(1 2 3 4 5 6) asOrderedCollection
267+ ]
268+
269+ { #category : ' tests-enumeration' }
270+ CTArray2DTest >> testFromRightToLeftFromBottomToTopDo [
271+ |foo res |
272+ foo := self arrayClass width2Height3.
273+ res := OrderedCollection new .
274+ foo fromRightToLeftFromBottomToTopDo: [ :each | res add: each ].
275+ self assert: res equals: #(6 5 4 3 2 1) asOrderedCollection
276+ ]
277+
278+ { #category : ' tests-enumeration' }
279+ CTArray2DTest >> testFromRightToLeftFromTopToBottomDo [
280+ |foo res |
281+ foo := self arrayClass width2Height3.
282+ res := OrderedCollection new .
283+ foo fromRightToLeftFromTopToBottomDo: [ :each | res add: each ].
284+ self assert: res equals: #(2 1 4 3 6 5) asOrderedCollection
285+ ]
286+
287+ { #category : ' tests-enumeration' }
288+ CTArray2DTest >> testFromTopToBottomFromLeftToRightDo [
289+ |foo res |
290+ foo := self arrayClass width2Height3.
291+ res := OrderedCollection new .
292+ foo fromTopToBottomFromLeftToRightDo: [ :each | res add: each ].
293+ self assert: res equals: #(1 3 5 2 4 6) asOrderedCollection
294+ ]
295+
296+ { #category : ' tests-enumeration' }
297+ CTArray2DTest >> testFromTopToBottomFromRightToLeftDo [
298+ |foo res |
299+ foo := self arrayClass width2Height3.
300+ res := OrderedCollection new .
301+ foo fromTopToBottomFromRightToLeftDo: [ :each | res add: each ].
302+ self assert: res equals: #(2 4 6 1 3 5) asOrderedCollection
303+ ]
304+
214305{ #category : ' tests-accessing' }
215306CTArray2DTest >> testHeight [
216307
@@ -225,17 +316,6 @@ CTArray2DTest >> testIndexXY [
225316 self assert: (foo indexX: 2 y: 3 ) equals: (3 - 1 )* (foo width)+ 2
226317]
227318
228- { #category : ' tests' }
229- CTArray2DTest >> testLeftToRightFromBottomToTopDo [
230-
231- | a2d res |
232- a2d := CTArray2D fromArray: #(1 2 3 4 5 6) width: 3 .
233- res := OrderedCollection new .
234- a2d leftToRightFromBottomToTopDo: [ :each | res add: each ].
235- self assert: res equals: #(4 5 6 1 2 3 ) asOrderedCollection
236-
237- ]
238-
239319{ #category : ' tests-printing' }
240320CTArray2DTest >> testPrinting [
241321
0 commit comments