equal
deleted
inserted
replaced
1 "{ Package: 'exept:regression' }" |
1 "{ Package: 'stx:goodies/regression' }" |
2 |
2 |
3 "{ NameSpace: RegressionTests }" |
3 "{ NameSpace: RegressionTests }" |
4 |
4 |
5 TestCase subclass:#DelayTest |
5 TestCase subclass:#DelayTest |
6 instanceVariableNames:'' |
6 instanceVariableNames:'' |
30 |n verbose| |
30 |n verbose| |
31 |
31 |
32 verbose := false. |
32 verbose := false. |
33 |
33 |
34 [ |
34 [ |
35 n := 0. |
35 n := 0. |
36 [n < 10] whileTrue:[ |
36 [n < 10] whileTrue:[ |
37 Delay waitForSeconds:0.1. |
37 Delay waitForSeconds:0.1. |
38 verbose ifTrue:[ Transcript showCR:n ]. |
38 verbose ifTrue:[ Transcript showCR:n ]. |
39 n := n + 1. |
39 n := n + 1. |
40 ] |
40 ] |
41 ] forkAt:(Processor activePriority - 1). |
41 ] forkAt:(Processor activePriority - 1). |
42 |
42 |
43 self assert:(n == nil). "because the process has lower prio and should not run" |
43 self assert:(n == nil). "because the process has lower prio and should not run" |
44 |
44 |
45 Delay waitForSeconds:0.05. |
45 Delay waitForSeconds:0.05. |
61 |n verbose| |
61 |n verbose| |
62 |
62 |
63 verbose := false. |
63 verbose := false. |
64 n := 0. |
64 n := 0. |
65 [ |
65 [ |
66 [n < 10] whileTrue:[ |
66 [n < 10] whileTrue:[ |
67 Delay waitForSeconds:0.1. |
67 Delay waitForSeconds:0.1. |
68 verbose ifTrue:[ Transcript showCR:n ]. |
68 verbose ifTrue:[ Transcript showCR:n ]. |
69 n := n + 1. |
69 n := n + 1. |
70 ] |
70 ] |
71 ] forkAt:(Processor activePriority + 1). |
71 ] forkAt:(Processor activePriority + 1). |
72 |
72 |
73 self assert:(n == 0) description:'thread with delays should not have started yet'. |
73 self assert:(n == 0) description:'thread with delays should not have started yet'. |
74 Delay waitForSeconds:1.1. |
74 Delay waitForSeconds:1.1. |
75 self assert:(n == 10) description:('thread with delays should have finished by now (n=%d)' bindWith:n). |
75 self assert:(n == 10) description:('thread with delays should have finished by now (n=%d)' bindWith:n). |
86 the millisecond computation..." |
86 the millisecond computation..." |
87 |
87 |
88 |stillWaiting watchDogBite| |
88 |stillWaiting watchDogBite| |
89 |
89 |
90 [ |
90 [ |
91 watchDogBite := false. |
91 watchDogBite := false. |
92 stillWaiting := true. |
92 stillWaiting := true. |
93 Delay waitForSeconds:1000000. |
93 Delay waitForSeconds:1000000. |
94 stillWaiting := false. |
94 stillWaiting := false. |
95 ] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:1000. |
95 ] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:1000. |
96 |
96 |
97 self assert:stillWaiting. |
97 self assert:stillWaiting. |
98 self assert:watchDogBite. |
98 self assert:watchDogBite. |
99 |
99 |
109 |
109 |
110 |longDelay waitTime watchDogBite| |
110 |longDelay waitTime watchDogBite| |
111 |
111 |
112 longDelay := Delay forSeconds:1000000. |
112 longDelay := Delay forSeconds:1000000. |
113 [ |
113 [ |
114 Delay waitForSeconds:2. |
114 Delay waitForSeconds:2. |
115 longDelay resume. |
115 longDelay resume. |
116 ] fork. |
116 ] fork. |
117 |
117 |
118 waitTime := Time secondsToRun:[ |
118 waitTime := Time secondsToRun:[ |
119 "never wait longer than 10 seconds" |
119 "never wait longer than 10 seconds" |
120 [ |
120 [ |
121 longDelay wait. |
121 longDelay wait. |
122 ] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:10000. |
122 ] valueWithWatchDog:[ watchDogBite := true] afterMilliseconds:10000. |
123 ]. |
123 ]. |
124 self assert:watchDogBite ~~ true. |
124 self assert:watchDogBite ~~ true. |
125 self assert:waitTime < 10. |
125 self assert:waitTime < 10. |
126 |
126 |
127 " |
127 " |