--- a/RegressionTests__QueueTest.st Wed Nov 30 13:56:33 2016 +0000
+++ b/RegressionTests__QueueTest.st Thu Dec 08 10:28:07 2016 +0000
@@ -10,6 +10,12 @@
!
+!QueueTest class methodsFor:'queries'!
+
+coveredClassNames
+ ^ #( Queue )
+! !
+
!QueueTest methodsFor:'Testing'!
testBasic1
@@ -147,6 +153,52 @@
"
!
+testChangeCapacity
+ "tests all kinds of boundary conditions in the capacity-change code
+ (i.e. especially wraps)"
+
+ |q|
+
+ #(false true) do:[:wrap |
+ 1 to:10 do:[:fill |
+ 1 to:fill do:[:read |
+ Transcript show:'wrap: '; show:wrap; show:' fill: '; show:fill; show:' read: '; showCR:read.
+
+ q := Queue new:10.
+ self assert:(q capacity == 10).
+ wrap ifTrue:[
+ 1 to:5 do:[:i | q nextPut:#foo ].
+ ].
+
+ 1 to:fill do:[:i | q nextPut:i.
+ (i==1 and:[wrap]) ifTrue:[ 1 to:5 do:[:i | q next ] ].
+ ].
+ "/ (wrap and:[fill==9 and:[read == 8]]) ifTrue:[self halt].
+ read timesRepeat:[ q next ].
+ q capacity:12.
+ self assert:(q capacity == 12).
+ self assert:(q size == (fill-read)).
+ self assert:((Array streamContents:[:s | q do:[:e |s nextPut:e]]) = (read+1 to:fill) asArray).
+ self assert:(q size == (fill-read)).
+ fill==read ifTrue:[
+ self assert:(q isEmpty).
+ self assert:(q notEmpty not).
+ self assert:(q size == 0).
+ self assert:(q nextOrNil == nil).
+ self assert:(q peekOrNil == nil).
+ self should:[q at:1] raise:SubscriptOutOfBoundsError.
+ ] ifFalse:[
+ self assert:(q notEmpty).
+ self assert:(q isEmpty not).
+ self assert:(q at:1) == (read+1).
+ self assert:(q peek) == (read+1).
+ self assert:(q peekOrNil) == (read+1).
+ ].
+ ].
+ ].
+ ].
+!
+
testRemoveAll
0 to:10 do:[:i|
self removeAllSize:10 fill:i.