Patrick Rein uploaded a new version of KernelTests to project The Trunk: http://source.squeak.org/trunk/KernelTests-pre.445.mcz
==================== Summary ====================
Name: KernelTests-pre.445 Author: pre Time: 28 July 2023, 10:18:48.347752 am UUID: 0372ac3c-5ca6-f446-9c1e-710ccc2fdd5b Ancestors: KernelTests-mt.444
Tests for Compiler-pre.493. Also moves tests concerning future sends to a dedicated test case class.
=============== Diff against KernelTests-mt.444 ===============
Item was added: + Object subclass: #FutureMock + instanceVariableNames: 'methodsCalled' + classVariableNames: '' + poolDictionaries: '' + category: 'KernelTests-Processes'!
Item was added: + ----- Method: FutureMock>>futureDo:at:args: (in category 'futures - mocked') ----- + futureDo: aSelector at: deltaMSecs args: args + + self methodsCalled add: #do.!
Item was added: + ----- Method: FutureMock>>futureSend:at:args: (in category 'futures - mocked') ----- + futureSend: aSelector at: deltaMSecs args: args + + self methodsCalled add: #send.!
Item was added: + ----- Method: FutureMock>>methodSend: (in category 'mock') ----- + methodSend: anObject + + "NOP"!
Item was added: + ----- Method: FutureMock>>methodsCalled (in category 'accessing') ----- + methodsCalled + + ^ methodsCalled ifNil: [methodsCalled := Set new]!
Item was added: + TestCase subclass: #FutureTest + instanceVariableNames: '' + classVariableNames: '' + poolDictionaries: '' + category: 'KernelTests-Processes'!
Item was added: + ----- Method: FutureTest>>testFutureAtEndOfBlockYieldsPromise (in category 'tests') ----- + testFutureAtEndOfBlockYieldsPromise + + | result | + result := [(2 future: 100) + 3] value. + self assert: result isPromise.!
Item was added: + ----- Method: FutureTest>>testFutureRejectionInvisibleError (in category 'tests') ----- + testFutureRejectionInvisibleError + | p | + p := 1 future / 0. + p whenRejected: []. "Installing a rejection handler is enough to cause the exception to be swallowed." + self assert: (self waitUntil: [p isRejected] orCycleCount: 100). + self assert: p isRejected. + self assert: ZeroDivide equals: p error class.!
Item was added: + ----- Method: FutureTest>>testFutureRejectionVisibleError (in category 'tests') ----- + testFutureRejectionVisibleError + | p exceptionSeen | + exceptionSeen := false. + p := 1 future / 0. + [ + self assert: (self waitUntil: [p isRejected] orCycleCount: 100) + ] on: ZeroDivide do: [:ex | exceptionSeen := true ]. + self assert: exceptionSeen. + self assert: p isRejected. + self assert: ZeroDivide equals: p error class.!
Item was added: + ----- Method: FutureTest>>testFutureResolution (in category 'tests') ----- + testFutureResolution + | p | + p := 3 future + 4. + self assert: (self waitUntil: [p isResolved] orCycleCount: 100). + self assert: p isResolved. + self assert: 7 equals: p value.!
Item was added: + ----- Method: FutureTest>>testFutureStoredInVariableYieldsPromise (in category 'tests') ----- + testFutureStoredInVariableYieldsPromise + + | result | + result := (2 future: 100) + 3. + self assert: result isPromise.!
Item was added: + ----- Method: FutureTest>>testFutureWithUnusedReturnValueLeadsToFutureDo (in category 'tests') ----- + testFutureWithUnusedReturnValueLeadsToFutureDo + + | mock | + mock := FutureMock new. + [(mock future: 1) methodSend: 3. 5 negated] value. + self waitUntil: [mock methodsCalled notEmpty] orCycleCount: 50. + self + assert: (mock methodsCalled includes: #do); + deny: (mock methodsCalled includes: #send).!
Item was added: + ----- Method: FutureTest>>waitUntil:orCycleCount: (in category 'private') ----- + waitUntil: aBlock orCycleCount: anInteger + "This is a gross hack that depends on running the tests in Morphic. + We simply repeatedly do a cycle of the interaction loop, which happens + to also be the way that the queue of pending futures gets serviced." + | counter | + counter := 0. + [ + aBlock value ifTrue: [^ true]. + Project current world doOneSubCycle. + counter := counter + 1. + counter >= anInteger ifTrue: [^ false]. + ] repeat!
Item was removed: - ----- Method: PromiseTest>>testFutureRejectionInvisibleError (in category 'tests - future') ----- - testFutureRejectionInvisibleError - | p | - p := 1 future / 0. - p whenRejected: []. "Installing a rejection handler is enough to cause the exception to be swallowed." - self assert: (self waitUntil: [p isRejected] orCycleCount: 100). - self assert: p isRejected. - self assert: ZeroDivide equals: p error class.!
Item was removed: - ----- Method: PromiseTest>>testFutureRejectionVisibleError (in category 'tests - future') ----- - testFutureRejectionVisibleError - | p | - p := 1 future / 0. - [ - self assert: (self waitUntil: [p isRejected] orCycleCount: 100) - ] on: ZeroDivide do: [:ex | "Fall through." ]. - self assert: p isRejected. - self assert: ZeroDivide equals: p error class.!
Item was removed: - ----- Method: PromiseTest>>testFutureResolution (in category 'tests - future') ----- - testFutureResolution - | p | - p := 3 future + 4. - self assert: (self waitUntil: [p isResolved] orCycleCount: 100). - self assert: p isResolved. - self assert: 7 equals: p value.!
Item was removed: - ----- Method: PromiseTest>>waitUntil:orCycleCount: (in category 'private') ----- - waitUntil: aBlock orCycleCount: anInteger - "This is a gross hack that depends on running the tests in Morphic. - We simply repeatedly do a cycle of the interaction loop, which happens - to also be the way that the queue of pending futures gets serviced." - | counter | - counter := 0. - [ - aBlock value ifTrue: [^ true]. - Project current world doOneSubCycle. - counter := counter + 1. - counter >= anInteger ifTrue: [^ false]. - ] repeat!
packages@lists.squeakfoundation.org