Permalink
Browse files

added #toEqualAsArrays method in Koan.st to properly test arrays agai…

…nst OrderedCollection and SortedCollection
  • Loading branch information...
1 parent b048330 commit eabb2adf3dfba2222ec64d0fb315b0b4d02611a9 Dmitrii Samoilov committed Apr 3, 2012
Showing with 16 additions and 10 deletions.
  1. +9 −9 src/koans/TestOrderedCollection.st
  2. +1 −1 src/koans/TestSortedCollection.st
  3. +6 −0 src/lib/Koan.st
@@ -20,7 +20,7 @@ Koan subclass: TestOrderedCollection [
orderedCollection := OrderedCollection with: $a with: $b with: $c with: $d with: $e.
- self expect: fillMeIn toEqual: (orderedCollection asArray).
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
self expect: [ OrderedCollection with: 'a' with: 'b' with: 'c' with: 'd' with: 'e' with: 'f' ] toRaise: fillMeIn.
"OrderedCollection responds to most messages that Array responds to."
@@ -31,7 +31,7 @@ Koan subclass: TestOrderedCollection [
orderedCollection := OrderedCollection new addAll: #(5 6 7); yourself.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
]
testAddElements [
@@ -40,19 +40,19 @@ Koan subclass: TestOrderedCollection [
orderedCollection := OrderedCollection with: 1.
orderedCollection addFirst: 2.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
orderedCollection addLast: 3.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
orderedCollection add: 4 afterIndex: 2.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
orderedCollection add: 5 beforeIndex: 2.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
]
testRemoveElements [
@@ -61,15 +61,15 @@ Koan subclass: TestOrderedCollection [
orderedCollection := OrderedCollection with: 1 with: 2 with: 3 with: 4.
orderedCollection removeFirst.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
orderedCollection removeLast.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
orderedCollection removeAtIndex: 1.
- self expect: fillMeIn toEqual: orderedCollection.
+ self expect: fillMeIn toEqualAsArrays: orderedCollection.
]
testAccessingElements [
@@ -25,7 +25,7 @@ Koan subclass: TestSortedCollection [
add: 3;
add: 4.
- self expect: fillMeIn toEqual: sortedCollection.
+ self expect: fillMeIn toEqualAsArrays: sortedCollection.
]
testComparingSortedCollections [
View
@@ -29,6 +29,12 @@ Object subclass: Koan [
ifFalse: [ self setTrackerToFalse: 'Expected value SHOULD equal actual value.' expected: expectedValue actual: actualValue ].
]
+ expect: expectedValue toEqualAsArrays: actualValue [
+ tracker status ifFalse: [^nil].
+ (expectedValue asArray = actualValue asArray)
+ ifFalse: [ self setTrackerToFalse: 'Expected array/collection SHOULD equal actual array/collection.' expected: expectedValue actual: actualValue ].
+ ]
+
expect: expectedValue toNotEqual: actualValue [
tracker status ifFalse: [^nil].
(expectedValue = actualValue)

0 comments on commit eabb2ad

Please sign in to comment.