RegressionTests__DelayTest.st
author Claus Gittinger <cg@exept.de>
Sun, 31 Jul 2011 18:45:52 +0200
changeset 592 86f714dd5523
parent 586 09a3e838d002
child 626 c6e1a12161b3
permissions -rw-r--r--
class definition added:6 methods

"{ Package: 'exept:regression' }"

"{ NameSpace: RegressionTests }"

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


!DelayTest class methodsFor:'others'!

version_CVS
    ^ '$Header$'
! !

!DelayTest class methodsFor:'queries'!

coveredClasses
    ^ Array with:Delay

    "Created: / 05-07-2011 / 09:51:28 / cg"
! !

!DelayTest methodsFor:'tests'!

test1
    |n|

    [
        n := 0.
        [n < 10] whileTrue:[
           Delay waitForSeconds:0.1.
           Transcript showCR:n.
           n := n + 1.
        ]
    ] forkAt:(Processor activePriority - 1).

    self assert:(n == nil).

    Delay waitForSeconds:0.1.

    self assert:(n == 0).

    Delay waitForSeconds:1.5.

    self assert:(n == 10).

    "
     self basicNew test1
    "
!

test2
    |n|

    [
        n := 0.
        [n < 10] whileTrue:[
           Delay waitForSeconds:0.1.
           Transcript showCR:n.
           n := n + 1.
        ]
    ] forkAt:(Processor activePriority + 1).

    self assert:(n == 0).
    Delay waitForSeconds:1.1.
    self assert:(n == 10).

    "
     self basicNew test2
    "
!

test3_longDelay
    "in stx6.2.1, the following does not wait, due to an overflow in
     the millisecond computation..."

    |stillWaiting watchDogBite|

    [
        watchDogBite := false.
        stillWaiting := true.
        Delay waitForSeconds:1000000.
        stillWaiting := false.
    ] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:1000.

    self assert:stillWaiting.
    self assert:watchDogBite.

    "
     self basicNew test3_longDelay
    "

    "Created: / 31-07-2011 / 18:44:53 / cg"
! !

!DelayTest class methodsFor:'documentation'!

version
    ^ '$Header$'
! !