--- a/RegressionTests__RecursionLockTests.st Wed Dec 06 00:56:35 2017 +0000
+++ b/RegressionTests__RecursionLockTests.st Mon Dec 11 11:05:39 2017 +0000
@@ -264,6 +264,63 @@
threadBstop := true.
"Created: / 04-10-2017 / 08:16:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_critical_07
+
+ [
+ | active |
+
+ active := Processor activeProcess.
+
+ self assert: lock owner isNil.
+ self assert: lock count == 0.
+ [
+ lock critical:[
+ self assert: lock owner == active.
+ self assert: lock count == 1.
+ Error raise.
+ ].
+ self assert: false.
+ ] on: Error do:[:each |
+ self assert: true.
+ ].
+ self assert: lock owner isNil.
+ self assert: lock count == 0.
+ ] fork.
+
+ "Created: / 11-12-2017 / 10:14:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_critical_08
+
+ | p1 p2 |
+
+ p1 := [
+ lock critical:[
+ Delay waitForMilliseconds: 1000.
+ ].
+ ] newProcess.
+
+ p2 := [
+ [
+ Delay waitForMilliseconds: 100. "/ Give p1 chance to lock the thread.
+ self assert: lock owner == p1.
+ self assert: lock count == 1.
+ lock critical:[
+ Delay waitForMilliseconds: 10. "/ Some tiny work
+ ].
+ self assert: false.
+ ] valueWithWatchDog: [
+ self assert: lock owner == p1.
+ self assert: lock count == 1.
+ ] afterMilliseconds: 500.
+ ] newProcess.
+
+ p1 resume.
+ p2 resume.
+
+ "Created: / 11-12-2017 / 10:22:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!RecursionLockTests class methodsFor:'documentation'!