A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.875.mcz
==================== Summary ====================
Name: Collections-ct.875
Author: ct
Time: 16 February 2020, 3:32:23.116 pm
UUID: 61ea773b-1408-c040-a712-09238ee6fe2f
Ancestors: Collections-topa.873
Extends and realigns version of #findFirst: and #findLast:.
=============== Diff against Collections-topa.873 ===============
Item was changed:
----- Method: SequenceableCollection>>findFirst: (in category 'enumerating') -----
findFirst: aBlock
- "Return the index of my first element for which aBlock evaluates as true."
+ ^ self findFirst: aBlock startingAt: 1!
- | index |
- index := 0.
- [(index := index + 1) <= self size] whileTrue:
- [(aBlock value: (self at: index)) ifTrue: [^index]].
- ^ 0!
Item was added:
+ ----- Method: SequenceableCollection>>findFirst:ifNone: (in category 'enumerating') -----
+ findFirst: aBlock ifNone: anotherBlock
+
+ ^ self findFirst: aBlock startingAt: 1 ifNone: anotherBlock!
Item was added:
+ ----- Method: SequenceableCollection>>findFirst:startingAt: (in category 'enumerating') -----
+ findFirst: aBlock startingAt: minIndex
+
+ ^ self findFirst: aBlock startingAt: minIndex ifNone: [0]!
Item was added:
+ ----- Method: SequenceableCollection>>findFirst:startingAt:ifNone: (in category 'enumerating') -----
+ findFirst: aBlock startingAt: minIndex ifNone: anotherBlock
+ "Return the index of my first element with index >= minIndex for which aBlock evaluates as true. If no element is found, return the value of anotherBlock."
+
+ | index |
+ index := minIndex - 1.
+ [(index := index + 1) <= self size] whileTrue:
+ [(aBlock value: (self at: index)) ifTrue: [^index]].
+ ^ anotherBlock value!
Item was changed:
----- Method: SequenceableCollection>>findLast: (in category 'enumerating') -----
findLast: aBlock
- "Return the index of my last element for which aBlock evaluates as true."
+ ^ self findLast: aBlock startingAt: 1!
- | index |
- index := self size + 1.
- [(index := index - 1) >= 1] whileTrue:
- [(aBlock value: (self at: index)) ifTrue: [^index]].
- ^ 0!
Item was added:
+ ----- Method: SequenceableCollection>>findLast:ifNone: (in category 'enumerating') -----
+ findLast: aBlock ifNone: anotherBlock
+
+ ^ self findLast: aBlock startingAt: 1 ifNone: anotherBlock!
Item was changed:
----- Method: SequenceableCollection>>findLast:startingAt: (in category 'enumerating') -----
+ findLast: aBlock startingAt: minIndex
- findLast: aBlock startingAt: i
- "Return the index of my last element with index >= i for which aBlock evaluates as true."
+ ^ self findLast: aBlock startingAt: minIndex ifNone: [0]!
- | index |
- index := self size + 1.
- [(index := index - 1) >= i] whileTrue:
- [(aBlock value: (self at: index)) ifTrue: [^index]].
- ^ 0!
Item was added:
+ ----- Method: SequenceableCollection>>findLast:startingAt:ifNone: (in category 'enumerating') -----
+ findLast: aBlock startingAt: minIndex ifNone: anotherBlock
+ "Return the index of my last element with index >= minIndex for which aBlock evaluates as true. If no element is found, return the value of anotherBlock."
+
+ | index |
+ index := self size + 1.
+ [(index := index - 1) >= minIndex] whileTrue:
+ [(aBlock value: (self at: index)) ifTrue: [^index]].
+ ^ anotherBlock value!
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.871.mcz
==================== Summary ====================
Name: Collections-ct.871
Author: ct
Time: 30 December 2019, 3:06:02.364602 pm
UUID: 235b9546-6ad3-b547-8661-38c5f2a98374
Ancestors: Collections-nice.868
Refactor CharacterClass >> #constantNames: Use reflection instead of hardcoding all names. With this change, further characters such as Character arrowLeft are printed legibly.
=============== Diff against Collections-nice.868 ===============
Item was changed:
----- Method: Character class>>constantNames (in category 'private') -----
constantNames
+ ^ self class methodsInCategory: #'accessing untypeable characters'!
- ^ #( backspace cr delete escape lf null newPage space tab ).!
Christoph Thiede uploaded a new version of SUnit to project The Inbox:
http://source.squeak.org/inbox/SUnit-ct.130.mcz
==================== Summary ====================
Name: SUnit-ct.130
Author: ct
Time: 24 September 2020, 11:28:31.626426 am
UUID: 43df5072-3a69-634c-946a-ec59903c2519
Ancestors: SUnit-pre.122
Deprecates TestResult class >> #error and replaces sends to it with #exError. It is a bad and erroneous practice to override #error in a way that does not signal an error but returns a class object.
=============== Diff against SUnit-pre.122 ===============
Item was changed:
----- Method: SUnitTest>>testDialectLocalizedException (in category 'tests') -----
testDialectLocalizedException
self
should: [TestResult signalFailureWith: 'Foo']
raise: TestResult failure.
self
should: [TestResult signalErrorWith: 'Foo']
+ raise: TestResult exError.!
- raise: TestResult error.
-
- !
Item was changed:
----- Method: SUnitTest>>testException (in category 'tests') -----
testException
self
should: [self error: 'foo']
+ raise: TestResult exError!
- raise: TestResult error
- !
Item was changed:
----- Method: SUnitTest>>testWithExceptionDo (in category 'tests') -----
testWithExceptionDo
self
should: [self error: 'foo']
+ raise: TestResult exError
- raise: TestResult error
withExceptionDo: [:exception |
self assert: (exception description includesSubstring: 'foo')
+ ]!
- ]
- !
Item was changed:
----- Method: TestResult class>>error (in category 'exceptions') -----
error
+
+ self deprecated: 'ct: Send #exError to retrieve an exception class or #error: to signal an error, depending on what you need.'.
+ ^ self exError!
- ^self exError
- !
Item was changed:
----- Method: TestResult class>>signalErrorWith: (in category 'exceptions') -----
signalErrorWith: aString
+ ^ self exError signal: aString!
- self error signal: aString
- !
Christoph Thiede uploaded a new version of SUnit to project The Inbox:
http://source.squeak.org/inbox/SUnit-ct.124.mcz
==================== Summary ====================
Name: SUnit-ct.124
Author: ct
Time: 20 March 2020, 8:01:47.398237 pm
UUID: d936b6a0-e7c7-2742-a817-35fa6511a15a
Ancestors: SUnit-mt.121
Proposal for discussion: Adds assertion message #should:raise:then: to allow for interactively working with expected exceptions. If you like, we could also talk about #should:raise:that: (however, I still like BlockClosure >> #handles:*).
Examples:
TestCase new in: [:test |
test
should: [
test
should: [self error: #foo]
raise: Error
then: #pass]
raise: UnhandledError.
test
should: [self error: #foo]
raise: Error
then: [:ex |
test assert: #foo equals: ex messageText].
]
* See exception patterns: http://forum.world.st/The-Inbox-Kernel-ct-1292-mcz-tp5109282p5109284.html
=============== Diff against SUnit-mt.121 ===============
Item was added:
+ ----- Method: TestCase>>should:raise:then: (in category 'accessing') -----
+ should: aBlock raise: anExceptionalEvent then: aHandlerBlock
+
+ | raised result |
+ raised := false.
+ result := aBlock
+ on: anExceptionalEvent
+ do: [:ex |
+ raised := true.
+ aHandlerBlock cull: ex].
+ self assert: raised.
+ ^ result!
Christoph Thiede uploaded a new version of SUnit to project The Inbox:
http://source.squeak.org/inbox/SUnit-ct.129.mcz
==================== Summary ====================
Name: SUnit-ct.129
Author: ct
Time: 24 September 2020, 10:42:52.868426 am
UUID: 92e68d23-8472-5d48-96d3-8435bd56ac14
Ancestors: SUnit-pre.122
Proposal: Catch warnings and halts in test case execution as well as Errors.
Catching (Error, Warning, Halt) is a common pattern to be (relatively) sure that no debugger will occur during an operation. For related usages, see Morph >> #fullBounds, WorldState >> #displayWorldSafely:, and many other places. IMO it is no desired behavior that the whole test execution, i.e. in a TestRunner, is interrupted because any method under test contains a halt or raises a DeprecationWarning, for example. Instead, the test should be listed as red.
For a similar discussion, see https://github.com/hpi-swa/smalltalkCI/issues/470. I believe we already had talked about this on squeak-dev, but if I remember correctly, I cannot find the thread again.
=============== Diff against SUnit-pre.122 ===============
Item was changed:
----- Method: TestCase>>timeout:after: (in category 'private') -----
timeout: aBlock after: seconds
"Evaluate the argument block. Time out if the evaluation is not
complete after the given number of seconds. Handle the situation
that a timeout may occur after a failure (during debug)"
| theProcess delay watchdog |
"the block will be executed in the current process"
theProcess := Processor activeProcess.
delay := Delay forSeconds: seconds.
"make a watchdog process"
watchdog := [
delay wait. "wait for timeout or completion"
theProcess ifNotNil:[ theProcess signalException:
(TestFailure new messageText: 'Test timed out') ]
] newProcess.
"Watchdog needs to run at high priority to do its job (but not at timing priority)"
watchdog priority: Processor timingPriority-1.
"catch the timeout signal"
watchdog resume. "start up the watchdog"
+ ^[aBlock on: TestFailure, (Error, Warning, Halt) do: [:ex|
- ^[aBlock on: TestFailure, Error, Halt do:[:ex|
theProcess := nil.
ex pass.
]] ensure:[ "evaluate the receiver"
theProcess := nil. "it has completed, so ..."
delay delaySemaphore signal. "arrange for the watchdog to exit"
]!
Item was added:
+ ----- Method: TestResult class>>exAllErrors (in category 'exceptions') -----
+ exAllErrors
+ ^ self exError, Warning, Halt
+ !
Item was changed:
----- Method: TestResult>>runCase: (in category 'running') -----
runCase: aTestCase
| testCasePassed timeToRun |
testCasePassed := true.
[timeToRun := [aTestCase runCase] timeToRunWithoutGC]
on: self class failure
do: [:signal |
failures add: aTestCase.
testCasePassed := false.
signal return: false]
+ on: self class exAllErrors
- on: self class error
do: [:signal |
errors add: aTestCase.
testCasePassed := false.
signal return: false].
testCasePassed ifTrue: [passed add: aTestCase].
self durations at: aTestCase put: timeToRun.!
David T. Lewis uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-ct.71.mcz
==================== Summary ====================
Name: Sound-ct.71
Author: ct
Time: 1 September 2020, 2:07:15.07999 am
UUID: 0d91a1bf-41cb-834c-ab0c-fa2ad832e408
Ancestors: Sound-nice.69
Fixes wave sound streaming on non-filestream objects. The endianness was inverted because #int16: already uses Big Endian. This did not sound well - listen yourself in an unpatched image: :-)
array := ByteArray streamContents: [:stream |
PluckedSound bachFugue storeWAVSamplesOn: stream].
(FileStream fileNamed: 'bachFugue.wav') binary in: [:stream |
[array do: [:ea | stream nextPut: ea]]
ensure: [stream close]].
(SampledSound fromWaveFileNamed: 'bachFugue.wav') play.
Please review in detail as this is one of my first contacts to the Sound system!
=============== Diff against Sound-nice.69 ===============
Item was changed:
----- Method: AbstractSound>>storeSampleCount:bigEndian:on: (in category 'file i/o') -----
storeSampleCount: samplesToStore bigEndian: bigEndianFlag on: aBinaryStream
"Store my samples on the given stream at the current SoundPlayer sampling rate. If bigFlag is true, then each 16-bit sample is stored most-significant byte first (AIFF files), otherwise it is stored least-significant byte first (WAV files). If self isStereo is true, both channels are stored, creating a stereo file. Otherwise, only the left channel is stored, creating a mono file."
+ | bufSize stereoBuffer reverseBytes streamDirect |
- | bufSize stereoBuffer reverseBytes |
self reset.
bufSize := (2 * self samplingRate rounded) min: samplesToStore. "two second buffer"
stereoBuffer := SoundBuffer newStereoSampleCount: bufSize.
+ streamDirect := aBinaryStream isKindOf: StandardFileStream.
+ reverseBytes := (bigEndianFlag xor: Smalltalk isBigEndian) xor: streamDirect not.
- reverseBytes := bigEndianFlag ~= (Smalltalk isBigEndian).
'Storing audio...'
displayProgressFrom: 0 to: samplesToStore during: [:bar | | remaining out |
remaining := samplesToStore.
[remaining > 0] whileTrue: [
bar value: samplesToStore - remaining.
stereoBuffer primFill: 0. "clear the buffer"
self playSampleCount: (bufSize min: remaining) into: stereoBuffer startingAt: 1.
out := self isStereo
ifTrue: [stereoBuffer]
ifFalse: [stereoBuffer extractLeftChannel].
reverseBytes ifTrue: [out reverseEndianness].
+ streamDirect
- (aBinaryStream isKindOf: StandardFileStream)
ifTrue: [ "optimization for files: write sound buffer directly to file"
aBinaryStream next: (out size // 2) putAll: out startingAt: 1] "size in words"
ifFalse: [ "for non-file streams:"
1 to: out monoSampleCount do: [:i | aBinaryStream int16: (out at: i)]].
+ remaining := remaining - bufSize]].!
- remaining := remaining - bufSize]].
- !