Nicolas Cellier uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-nice.101.mcz==================== Summary ====================
Name: CollectionsTests-nice.101
Author: nice
Time: 5 October 2009, 12:26:49 pm
UUID: 43a48a6e-6a25-418f-a9e5-d11b780b1615
Ancestors: CollectionsTests-dtl.100
Add tests from
http://bugs.squeak.org/view.php?id=6535keyBlock and sortBlock are lost when creating a collection of the same species.
=============== Diff against CollectionsTests-dtl.100 ===============
Item was added:
+ ClassTestCase subclass: #KeyedSetTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'CollectionsTests-Unordered'!
+
+ !KeyedSetTest commentStamp: 'nice 5/22/2008 14:12' prior: 0!
+ KeyedSetTest hold sunit tests for class KeyedSet!
Item was added:
+ ----- Method: SortedCollectionTest>>testSpeciesLooseSortBlock (in category 'basic') -----
+ testSpeciesLooseSortBlock
+ "This is a non regression test for
http://bugs.squeak.org/view.php?id=6535"
+
+ | numbers reverseOrder firstThree |
+ numbers := #(1 2 3 4 5).
+ reverseOrder := SortedCollection sortBlock: [:x :y | x > y].
+ reverseOrder addAll: numbers.
+
+ "The elements are inverted"
+ self assert: [reverseOrder asArray = #(5 4 3 2 1)].
+
+ "Copy the first 3 elements"
+ firstThree := reverseOrder copyFrom: 1 to: 3.
+
+ "It appears to work"
+ self assert: [firstThree asArray = #(5 4 3)].
+
+ "but we have lost the sort block"
+ firstThree add: 1.
+
+ " firstThree is now #(1 5 4 3)!! "
+ self assert: [firstThree asArray = #(5 4 3 1)] "fails"!
Item was added:
+ ----- Method: KeyedSetTest>>testSelect (in category 'tests') -----
+ testSelect
+ "this is a non regression test for
http://bugs.squeak.org/view.php?id=6535"
+
+ | ks ks2 |
+
+ "Creare a KeyedSet"
+ ks := KeyedSet keyBlock: [:e | e asInteger \\ 4].
+ ks addAll: #(1.2 1.5 3.8 7.7 9.1 12.4 13.25 14.0 19.2 11.4).
+
+ "There is non more than 4 possible keys (0 1 2 3)"
+ self assert: ks size <= 4.
+
+ "Select some elements"
+ ks2 := ks select: [:e | e fractionPart > 0.5].
+
+ "If keyBlock was preserved, then still no more than 4 keys..."
+ ks2 addAll: #(1.2 1.5 3.8 7.7 9.1 12.4 13.25 14.0 19.2 11.4).
+ self assert: ks2 size <= 4.!