A new version of Tests was added to project The Inbox:
http://source.squeak.org/inbox/Tests-ct.448.mcz ==================== Summary ==================== Name: Tests-ct.448 Author: ct Time: 12 April 2021, 9:19:02.66824 pm UUID: 65aa0e1a-250a-724a-9f04-505db0722916 Ancestors: Tests-nice.447 Revises ExceptionTests >> #testCatchingDefaultAction to work when being debugged/simulated as well. This also decouples the test from the implementation details of UnhandledWarnings. For further reference, see also: https://github.com/LinqLover/SimulationStudio/runs/2319502648?check_suite_focus=true#step:4:441 =============== Diff against Tests-nice.447 =============== Item was changed: ----- Method: ExceptionTests>>testCatchingDefaultAction (in category 'tests - outer') ----- testCatchingDefaultAction + "The #defaultAction method is executed in the context of the signaling environment." + - "The #defaultAction method is executed in the context of the signaling environment. - The defaultAction will raise an UnhandledWarning that should be caught by this handler." | result | + result := [MyTestNotification signalForAction: [MyTestNotification signal: '2nd exception']] + on: MyTestNotification + do: [:ex | '2nd exception caught']. + self assert: '2nd exception caught' equals: result.! - result := [ Warning signal: 'Warning signalled' ] on: UnhandledWarning do: [ :ex | 'UnhandledWarning caught' ]. - self assert: 'UnhandledWarning caught' equals: result! Item was changed: Notification subclass: #MyTestNotification + instanceVariableNames: 'action' - instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Tests-Exceptions'! Item was added: + ----- Method: MyTestNotification class>>signalForAction: (in category 'signaling') ----- + signalForAction: aBlock + + ^ self new + action: aBlock; + signal! Item was added: + ----- Method: MyTestNotification>>action (in category 'accessing') ----- + action + + ^ action! Item was added: + ----- Method: MyTestNotification>>action: (in category 'accessing') ----- + action: aBlock + + action := aBlock! Item was added: + ----- Method: MyTestNotification>>defaultAction (in category 'priv handling') ----- + defaultAction + + self action ifNotNil: [^ self action cull: self]. + + ^ super defaultAction! |
Hi Christoph,
I agree that using Warning and UnhandledWarning is fragile. Especially since we can disable the warnings altogether! But see below... Le lun. 12 avr. 2021 à 21:19, <[hidden email]> a écrit : > > A new version of Tests was added to project The Inbox: > http://source.squeak.org/inbox/Tests-ct.448.mcz > > ==================== Summary ==================== > > Name: Tests-ct.448 > Author: ct > Time: 12 April 2021, 9:19:02.66824 pm > UUID: 65aa0e1a-250a-724a-9f04-505db0722916 > Ancestors: Tests-nice.447 > > Revises ExceptionTests >> #testCatchingDefaultAction to work when being debugged/simulated as well. This also decouples the test from the implementation details of UnhandledWarnings. > > For further reference, see also: https://github.com/LinqLover/SimulationStudio/runs/2319502648?check_suite_focus=true#step:4:441 > > =============== Diff against Tests-nice.447 =============== > > Item was changed: > ----- Method: ExceptionTests>>testCatchingDefaultAction (in category 'tests - outer') ----- > testCatchingDefaultAction > + "The #defaultAction method is executed in the context of the signaling environment." > + > - "The #defaultAction method is executed in the context of the signaling environment. > - The defaultAction will raise an UnhandledWarning that should be caught by this handler." > | result | > + result := [MyTestNotification signalForAction: [MyTestNotification signal: '2nd exception']] > + on: MyTestNotification > + do: [:ex | '2nd exception caught']. I do not understand here: MyTestNotification will be caught, and thus won't have a chance to trigger the defaultAction and 2nd notification right? Maybe you meant something like this: [MyTestNotification signalForAction: [MyTestError signal: '2nd exception']] on: MyTestError do: ... > + on: MyTestNotification > + self assert: '2nd exception caught' equals: result.! > - result := [ Warning signal: 'Warning signalled' ] on: UnhandledWarning do: [ :ex | 'UnhandledWarning caught' ]. > - self assert: 'UnhandledWarning caught' equals: result! > > Item was changed: > Notification subclass: #MyTestNotification > + instanceVariableNames: 'action' > - instanceVariableNames: '' > classVariableNames: '' > poolDictionaries: '' > category: 'Tests-Exceptions'! > > Item was added: > + ----- Method: MyTestNotification class>>signalForAction: (in category 'signaling') ----- > + signalForAction: aBlock > + > + ^ self new > + action: aBlock; > + signal! > > Item was added: > + ----- Method: MyTestNotification>>action (in category 'accessing') ----- > + action > + > + ^ action! > > Item was added: > + ----- Method: MyTestNotification>>action: (in category 'accessing') ----- > + action: aBlock > + > + action := aBlock! > > Item was added: > + ----- Method: MyTestNotification>>defaultAction (in category 'priv handling') ----- > + defaultAction > + > + self action ifNotNil: [^ self action cull: self]. > + > + ^ super defaultAction! > > |
Free forum by Nabble | Edit this page |