2205
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
92
|
4 |
|
95
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
92
|
7 |
TestCase subclass:#OperationInQueueTests
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
2052
|
11 |
category:'tests-Regression-Processes'
|
92
|
12 |
!
|
|
13 |
|
|
14 |
|
|
15 |
!OperationInQueueTests methodsFor:'tests'!
|
|
16 |
|
|
17 |
test1
|
|
18 |
|op opQ rslt|
|
|
19 |
|
|
20 |
opQ := OperationQueue new.
|
|
21 |
op := [ 1 + 2 ].
|
|
22 |
|
1983
|
23 |
([
|
|
24 |
rslt := opQ scheduleOperation:op.
|
|
25 |
self assert:(rslt == 3)
|
2205
|
26 |
] valueWithTimeout:20 seconds)
|
1983
|
27 |
isNil ifTrue:[
|
2205
|
28 |
self assert:false message:'test did not finish within 20 seconds'
|
1983
|
29 |
].
|
92
|
30 |
|
2205
|
31 |
"Modified: / 29-03-2019 / 15:13:19 / Claus Gittinger"
|
92
|
32 |
!
|
|
33 |
|
|
34 |
test2
|
|
35 |
|op opQ rslt|
|
|
36 |
|
|
37 |
opQ := OperationQueue new.
|
|
38 |
op := 1.
|
|
39 |
|
1983
|
40 |
([
|
|
41 |
rslt := opQ scheduleOperation:op.
|
|
42 |
self assert:(rslt == 1)
|
|
43 |
] valueWithTimeout:10 seconds)
|
|
44 |
isNil ifTrue:[
|
|
45 |
self assert:false message:'test did not finish within 10 seconds'
|
|
46 |
].
|
92
|
47 |
|
1983
|
48 |
"Modified (format): / 03-07-2018 / 11:48:55 / Claus Gittinger"
|
92
|
49 |
!
|
|
50 |
|
|
51 |
test3
|
1447
|
52 |
|op opQ val1 val2 val3 val1b val2b val3b
|
92
|
53 |
rslt rslt1 rslt2 rslt3 p0 p1 p2 p3 rslt1b rslt2b rslt3b p1b p2b p3b sz|
|
|
54 |
|
1983
|
55 |
([
|
|
56 |
opQ := OperationQueue new.
|
|
57 |
opQ consumerProcessPriority:8.
|
|
58 |
|
|
59 |
op := '1'.
|
|
60 |
rslt := opQ scheduleOperation:op.
|
92
|
61 |
|
1983
|
62 |
self assert:(rslt = '1').
|
|
63 |
|
|
64 |
self assert:(opQ size == 0).
|
92
|
65 |
|
1983
|
66 |
p0 := [
|
2213
|
67 |
opQ scheduleOperation:[ Delay waitForSeconds:1.].
|
1983
|
68 |
] fork.
|
92
|
69 |
|
1983
|
70 |
p1 := [
|
2213
|
71 |
rslt1 := opQ scheduleOperation:[val1 := '1'].
|
1983
|
72 |
] fork.
|
92
|
73 |
|
1983
|
74 |
p2 := [
|
2213
|
75 |
rslt2 := opQ scheduleOperation:[val2 := '2'].
|
1983
|
76 |
] fork.
|
92
|
77 |
|
1983
|
78 |
p3 := [
|
2213
|
79 |
rslt3 := opQ scheduleOperation:[val3 := '3'].
|
1983
|
80 |
] fork.
|
|
81 |
|
|
82 |
Delay waitForSeconds:0.5.
|
|
83 |
self assert:((sz := opQ size) == 3).
|
92
|
84 |
|
1983
|
85 |
p1b := [
|
2213
|
86 |
rslt1b := opQ scheduleOperation:[val1b := '1'].
|
1983
|
87 |
] fork.
|
92
|
88 |
|
1983
|
89 |
p2b := [
|
2213
|
90 |
rslt2b := opQ scheduleOperation:[val2b := '2'].
|
1983
|
91 |
] fork.
|
92
|
92 |
|
1983
|
93 |
p3b := [
|
2213
|
94 |
rslt3b := opQ scheduleOperation:[val3b := '3'].
|
1983
|
95 |
] fork.
|
|
96 |
|
2213
|
97 |
Delay waitForSeconds:0.1.
|
|
98 |
self assert:(opQ size == 6).
|
92
|
99 |
|
2213
|
100 |
Delay waitForSeconds:1.
|
1983
|
101 |
self assert:((sz := opQ size) == 0).
|
92
|
102 |
|
1983
|
103 |
self assert:(val1 == rslt1).
|
|
104 |
self assert:(val2 == rslt2).
|
|
105 |
self assert:(val3 == rslt3).
|
|
106 |
self assert:(rslt1 = rslt1b).
|
|
107 |
self assert:(rslt2 = rslt2b).
|
|
108 |
self assert:(rslt3 = rslt3b).
|
|
109 |
self assert:(val1b = rslt1b).
|
|
110 |
self assert:(val2b = rslt2b).
|
|
111 |
self assert:(val3b = rslt3b).
|
|
112 |
] valueWithTimeout:30 seconds)
|
|
113 |
isNil ifTrue:[
|
|
114 |
self assert:false message:'test did not finish within 30 seconds'
|
|
115 |
].
|
|
116 |
|
2213
|
117 |
"Modified: / 02-04-2019 / 15:34:28 / Claus Gittinger"
|
92
|
118 |
! !
|
|
119 |
|
|
120 |
!OperationInQueueTests class methodsFor:'documentation'!
|
|
121 |
|
|
122 |
version
|
|
123 |
^ '$Header$'
|
|
124 |
! !
|
1701
|
125 |
|