[squeak-dev] The Trunk: CollectionsTests-nice.94.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] The Trunk: CollectionsTests-nice.94.mcz

commits-2
Nicolas Cellier uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-nice.94.mcz

==================== Summary ====================

Name: CollectionsTests-nice.94
Author: nice
Time: 14 September 2009, 9:12:38 am
UUID: cfdd7c4e-f5a3-4b9f-8a18-f6993de90be2
Ancestors: CollectionsTests-ar.93

Add a few tests for #removeAll
Far from complete... but better than nothing

=============== Diff against CollectionsTests-ar.93 ===============

Item was added:
+ ----- Method: SetTest>>testRemoveAll (in category 'tests') -----
+ testRemoveAll
+ "Allows one to remove all elements of a collection"
+
+ | c1 c2 s2 |
+ c1 := full.
+ c2 := c1 copy.
+ s2 := c2 size.
+
+ c1 removeAll.
+
+ self assert: c1 size = 0.
+ self assert: c2 size = s2 description: 'the copy has not been modified'.!

Item was added:
+ ----- Method: BagTest>>testRemoveAll (in category 'tests') -----
+ testRemoveAll
+ "Allows one to remove all elements of a collection"
+
+ | c1 c2 s2 |
+ c1 := #(10 9 8 7 5 4 4 2) asBag.
+ c2 := c1 copy.
+ s2 := c2 size.
+
+ c1 removeAll.
+
+ self assert: c1 size = 0.
+ self assert: c2 size = s2 description: 'the copy has not been modified'.!

Item was added:
+ ----- Method: SortedCollectionTest>>testRemoveAll (in category 'basic') -----
+ testRemoveAll
+ "Allows one to remove all elements of a collection"
+
+ | c1 c2 s2 |
+ c1 := #(10 9 8 7 5 4 4 2) asSortedCollection: [:a :b | a >= b].
+ c2 := c1 copy.
+ s2 := c2 size.
+
+ c1 removeAll.
+
+ self assert: c1 size = 0.
+ self assert: c2 size = s2 description: 'the copy has not been modified'.
+
+ c1 add: 13; add: 14.
+ self assert: (c1 first = 14 and: [c1 second = 13])  description: 'the sortBlock has been preserved'.!

Item was added:
+ ----- Method: OrderedCollectionTest>>testRemoveAll (in category 'testsRemoving') -----
+ testRemoveAll
+ "Allows one to remove all elements of a collection"
+
+ | c1 c2 s2 |
+ c1 := #(2 3 4 6) asOrderedCollection.
+ c1 addAll: (1 to: 200).
+ c2 := c1 copy.
+ s2 := c2 size.
+
+ c1 removeAll.
+
+ self assert: c1 size = 0.
+ self assert: c2 size = s2 description: 'the copy has not been modified'
+ !

Item was added:
+ ----- Method: DictionaryTest>>testRemoveAll (in category 'tests') -----
+ testRemoveAll
+ "Allows one to remove all elements of a collection"
+
+ | dict1 dict2 s2 |
+ dict1 := Dictionary new.
+ dict1 at: #a put:1 ; at: #b put: 2.
+ dict2 := dict1 copy.
+ s2 := dict2 size.
+
+ dict1 removeAll.
+
+ self assert: dict1 size = 0.
+ self assert: dict2 size = s2 description: 'the copy has not been modified'.!

Item was added:
+ ----- Method: LinkedListTest>>testRemoveAll (in category 'testing') -----
+ testRemoveAll
+ | list2 |
+ list add: link1.
+ list add: link2.
+ list add: link3.
+ list add: link4.
+ list2 := list copy.
+ list removeAll.
+
+ self assert: list size = 0.
+ self assert: list2 size = 4 description: 'the copy has not been modified'!