author | Patrik Svestka <patrik.svestka@gmail.com> |
Fri, 19 Feb 2021 13:58:24 +0100 | |
branch | jv |
changeset 2603 | 6ac9ae0a4987 |
parent 1567 | e17701a073f9 |
permissions | -rwxr-xr-x |
1447 | 1 |
"{ Package: 'stx:goodies/regression' }" |
704 | 2 |
|
3 |
"{ NameSpace: RegressionTests }" |
|
4 |
||
5 |
TestCase subclass:#CachedValueTest |
|
6 |
instanceVariableNames:'subProcesses' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'tests-Regression' |
|
10 |
! |
|
11 |
||
12 |
||
13 |
!CachedValueTest methodsFor:'test'! |
|
14 |
||
15 |
test01_validityDuration |
|
16 |
|cv didCompute| |
|
17 |
||
18 |
didCompute := false. |
|
19 |
cv := CachedValue compute:[didCompute := true. Date today dayOfWeek] validityDuration:(0.5 seconds). |
|
20 |
self assert:(cv isValid not). |
|
21 |
self assert:(didCompute not). |
|
22 |
self assert:(cv value = Date today dayOfWeek). |
|
23 |
self assert:(cv isValid). |
|
24 |
self assert:(didCompute). |
|
25 |
||
26 |
Delay waitForSeconds:1. |
|
27 |
didCompute := false. |
|
28 |
self assert:(cv isValid not). |
|
29 |
self assert:(didCompute not). |
|
30 |
self assert:(cv value = Date today dayOfWeek). |
|
31 |
self assert:(cv isValid). |
|
32 |
self assert:(didCompute). |
|
33 |
! |
|
34 |
||
35 |
test02_expirationTime |
|
36 |
|cv exceptionRaised| |
|
37 |
||
38 |
cv := CachedValue value:123 expirationTime:(Timestamp now + 0.5 seconds). |
|
39 |
self assert:(cv isValid). |
|
40 |
Delay waitForSeconds:1. |
|
41 |
self assert:(cv isValid not). |
|
42 |
||
43 |
exceptionRaised := false. |
|
44 |
CachedValue::ValueExpiredException handle:[:ex | |
|
45 |
exceptionRaised := true. |
|
46 |
] do:[ |
|
47 |
cv value |
|
48 |
]. |
|
49 |
self assert:exceptionRaised. |
|
50 |
! ! |
|
51 |
||
52 |
!CachedValueTest class methodsFor:'documentation'! |
|
53 |
||
54 |
version |
|
55 |
^ '$Header$' |
|
56 |
! |
|
57 |
||
58 |
version_CVS |
|
59 |
^ '$Header$' |
|
60 |
! ! |
|
1567
e17701a073f9
Added abstract VMSpawningTestCase
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1447
diff
changeset
|
61 |