RegressionTests__CollectionTests.st
changeset 1282 e64a9d280572
parent 1280 977c1f04083e
child 1299 c9fdd72327a5
child 1477 7a6b9d928845
--- a/RegressionTests__CollectionTests.st	Thu Apr 09 13:58:24 2015 +0200
+++ b/RegressionTests__CollectionTests.st	Wed Jun 24 14:58:17 2015 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "{ Package: 'exept:regression' }"
 
 "{ NameSpace: RegressionTests }"
@@ -1217,6 +1215,36 @@
 "
  self basicNew testSortStability02
 "
+!
+
+testSortedCollectionQueries
+    "test a SortedCollection, where only a single attribute is used for sorting.
+     #include: failed before 2015-06-24"
+    
+    |collection|
+
+    collection := SortedCollection sortBlock:[:a :b | a key < b key ].
+    $a to:$z do:[:l | 
+        1 to:100 do:[:i | 
+            collection add:(Association key:l value:i)
+        ].
+    ].
+     
+    "/ make startIndex > 1 and endIndex < size
+    
+    collection
+        removeFirst;
+        removeLast.
+    collection 
+        keysAndValuesDo:[:eachIndex :eachElement | 
+            self assert:(collection detect:[:el | el = eachElement ]) notNil.
+            self assert:(collection includes:eachElement).
+            self assert:(collection indexOf:eachElement) = eachIndex.
+            self assert:(collection occurrencesOf:eachElement) = 1.
+            self 
+                assert:(collection 
+                        includes:(eachElement copy value:(eachElement value + 1000))) not.
+        ].
 ! !
 
 !CollectionTests methodsFor:'tests-squeak'!