[squeak-dev] The Inbox: KernelTests-jar.416.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Dec 15 17:43:49 UTC 2021


A new version of KernelTests was added to project The Inbox:
http://source.squeak.org/inbox/KernelTests-jar.416.mcz

==================== Summary ====================

Name: KernelTests-jar.416
Author: jar
Time: 15 December 2021, 6:43:46.837426 pm
UUID: ab416082-2b22-824e-8baa-e2f85cc35d17
Ancestors: KernelTests-jar.415

add additional test to complement Kernel-jar.1435 (new #terminate); this test explores three situations when #ensure is the stack's top when a process gets terminated and checks it's correctly unwound based on the exact pc position in the block.

=============== Diff against KernelTests-jar.415 ===============

Item was added:
+ ----- Method: ProcessTest>>testTerminateEnsureAsStackTop (in category 'tests') -----
+ testTerminateEnsureAsStackTop
+ 	"Test #ensure unwind block is executed even when #ensure context is on stack's top."
+ 
+ 	| p1 p2 p3 x1 x2 x3 |
+ 	x1 := x2 := x3 := false.
+ 	
+ 	"p1 is at the beginning of the ensure block and the unwind block hasn't run yet"
+ 	p1 := Process
+ 		forBlock: [[] ensure: [x1 := x1 not]]
+ 		runUntil: [:ctx | ctx isUnwindContext and: [(ctx tempAt: 2) isNil]].
+ 
+ 	"p2 has already set complete to true (tempAt: 2) but the unwind block hasn't run yet"
+ 	p2 := Process
+ 		forBlock: [[] ensure: [x2 := x2 not]]
+ 		runUntil: [:ctx | ctx isUnwindContext and: [(ctx tempAt: 2) notNil]].
+ 
+ 	"p3 has already set complete to true AND the unwind block has run already run;
+ 	we have to verify the unwind block is not executed again during termination"
+ 	p3 := Process
+ 		forBlock: [[] ensure: [x3 := x3 not]]
+ 		runUntil: [:ctx | ctx isUnwindContext and: [ctx willReturn]].
+ 
+ 	"make sure all processes are running and only the p3's unwind block has finished"
+ 	self deny: p1 isTerminated | p2 isTerminated | p3 isTerminated.
+ 	self deny: x1 | x2.
+ 	self assert: x3. "p3 has already run its unwind block; we test it won't run it again"
+ 	"terminate all processes and verify all unwind blocks have finished correctly"
+ 	p1 terminate. p2 terminate. p3 terminate.
+ 	self assert: p1 isTerminated & p2 isTerminated & p3 isTerminated.
+ 	self assert: x1 & x2 & x3!



More information about the Squeak-dev mailing list