RegressionTests__EnumerationTests.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 1447 2351db93aa5b
child 1500 d406a10b2965
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding

"{ Encoding: utf8 }"

"{ Package: 'stx:goodies/regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#EnumerationTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression-Collections'
!


!EnumerationTests class methodsFor:'tests'!

testArrayKeysAndValuesDo
    "test GC while enumerating an array"

    |a|

    a := (1 to:100) asArray.

    10 timesRepeat:[
	a keysAndValuesDo:[:index :val |
	    ObjectMemory scavenge.
	    index printString.
	    ObjectMemory scavenge.
	    val printString.
	]
    ]

    "
     self testArrayKeysAndValuesDo
    "
! !

!EnumerationTests methodsFor:'tests'!

testArrayKeysAndValuesDo
    "test GC while enumerating an array"

    |a|

    a := (1 to:100) asArray.

    10 timesRepeat:[
	a keysAndValuesDo:[:index :val |
	    ObjectMemory scavenge.
	    index printString.
	    ObjectMemory scavenge.
	    val printString.
	]
    ]

    "
     self new testArrayKeysAndValuesDo
    "

    "Modified (comment): / 10-10-2011 / 13:48:48 / cg"
!

testWeakArrayKeysAndValuesDo
    "test GC while enumerating an array"

    |a w|

    a := WeakArray new:100.
    w := WeakArray new:100.
    1 to:a size do:[:i |
	|o|

	o := Object new.
	a at:i put:o.
	w at:i put:o.
    ].

    w keysAndValuesDo:[:index :val |
	self assert:(val class == Object).
    ].

    w keysAndValuesDo:[:index :val |
	index == 5 ifTrue:[
	    a at:7 put:nil.
	    ObjectMemory scavenge
	].
	index == 7 ifTrue:[
	    self assert:(val class == SmallInteger).
	]
    ]

    "
     self new testWeakArrayKeysAndValuesDo
    "

    "Created: / 10-10-2011 / 12:51:43 / cg"
! !

!EnumerationTests class methodsFor:'documentation'!

version
    ^ '$Header$'
! !