diff --git a/rowan/components/Deployment.ston b/rowan/components/Deployment.ston index 33593ff..eaf2475 100644 --- a/rowan/components/Deployment.ston +++ b/rowan/components/Deployment.ston @@ -8,6 +8,7 @@ RwSimpleProjectLoadComponentV2 { 'Buoy-Collections-GS64-Extensions', 'Buoy-Conditions-Extensions', 'Buoy-Conditions', + 'Buoy-Exception-Handling-Extensions', 'Buoy-Metaprogramming-Extensions', 'Buoy-Metaprogramming-GS64-Extensions' ], @@ -20,10 +21,13 @@ RwSimpleProjectLoadComponentV2 { }, 'Buoy-Collections-GS64-Extensions' : { 'symbolDictName' : 'Globals' - }, + }, 'Buoy-Conditions-Extensions' : { 'symbolDictName' : 'Globals' }, + 'Buoy-Exception-Handling-Extensions' : { + 'symbolDictName' : 'Globals' + }, 'Buoy-Metaprogramming-Extensions' : { 'symbolDictName' : 'Globals' }, diff --git a/rowan/components/Tests.ston b/rowan/components/Tests.ston index 59bc88e..2b82ca0 100644 --- a/rowan/components/Tests.ston +++ b/rowan/components/Tests.ston @@ -9,6 +9,7 @@ RwSimpleProjectLoadComponentV2 { #packageNames : [ 'Buoy-Assertions-Tests', 'Buoy-Conditions-Tests', + 'Buoy-Exception-Handling-Extensions-Tests', 'Buoy-SUnit-Tests' ], #comment : '' diff --git a/source/BaselineOfBuoy/BaselineOfBuoy.class.st b/source/BaselineOfBuoy/BaselineOfBuoy.class.st index 3bcdffb..ab6fcb9 100644 --- a/source/BaselineOfBuoy/BaselineOfBuoy.class.st +++ b/source/BaselineOfBuoy/BaselineOfBuoy.class.st @@ -104,10 +104,10 @@ BaselineOfBuoy >> baselineDynamicBinding: spec [ BaselineOfBuoy >> baselineExceptionHandling: spec [ spec - package: 'Buoy-Exception-Handling'; - group: 'Deployment' with: 'Buoy-Exception-Handling'; - package: 'Buoy-Exception-Handling-Tests' with: [ spec requires: 'Buoy-Exception-Handling' ]; - group: 'Tests' with: 'Buoy-Exception-Handling-Tests' + package: 'Buoy-Exception-Handling-Extensions'; + group: 'Deployment' with: 'Buoy-Exception-Handling-Extensions'; + package: 'Buoy-Exception-Handling-Extensions-Tests' with: [ spec requires: 'Buoy-Exception-Handling-Extensions' ]; + group: 'Tests' with: 'Buoy-Exception-Handling-Extensions-Tests' ] { #category : #baselines } diff --git a/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st b/source/Buoy-Exception-Handling-Extensions-Tests/ExceptionHandlingSystemTest.class.st similarity index 92% rename from source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st rename to source/Buoy-Exception-Handling-Extensions-Tests/ExceptionHandlingSystemTest.class.st index 7e569dd..a0cee09 100644 --- a/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st +++ b/source/Buoy-Exception-Handling-Extensions-Tests/ExceptionHandlingSystemTest.class.st @@ -4,7 +4,7 @@ I'm a test case for the exception handling system. Class { #name : #ExceptionHandlingSystemTest, #superclass : #TestCase, - #category : #'Buoy-Exception-Handling-Tests' + #category : #'Buoy-Exception-Handling-Extensions-Tests' } { #category : #private } @@ -32,25 +32,27 @@ ExceptionHandlingSystemTest >> handleZeroDivideAndReturnWithCaret [ { #category : #'tests - exception sets' } ExceptionHandlingSystemTest >> testCatchingSetsOfExceptions [ - | result | - - result := [ ZeroDivide signal + Warning signal ] - on: Warning , ZeroDivide - do: [ :ex | ex resume: 1 ]. - - self assert: result equals: 2 + self assert: ([ + Warning signal. + false ] + on: Warning , ZeroDivide + do: [ :ex | ex return: true ]). + + self assert: ([ + ZeroDivide signal. + false ] + on: Warning , ZeroDivide + do: [ :ex | ex return: true ]) ] { #category : #'tests - exception sets' } ExceptionHandlingSystemTest >> testCatchingSetsOfExceptionsWithHierarchy [ - | result | - - result := [ ZeroDivide signal + Warning signal ] - on: Notification , Error - do: [ :ex | ex resume: 1 ]. - - self assert: result equals: 2 + self assert: ([ + Warning signal. + false ] + on: Notification , Error + do: [ :ex | ex return: true ]) ] { #category : #'tests - ensure' } @@ -85,19 +87,13 @@ ExceptionHandlingSystemTest >> testEnsureSemanticsWhenNoException [ { #category : #'tests - exception sets' } ExceptionHandlingSystemTest >> testExceptionSetsConcatenation [ - | result | - - result := [ ZeroDivide signal + Warning signal ] - on: Warning , ZeroDivide , ( MessageNotUnderstood , Error ) - do: [ :ex | ex resume: 1 ]. - - self assert: result equals: 2. - - result := [ ZeroDivide signal + Warning signal ] - on: MessageNotUnderstood , Error , ( Warning , ZeroDivide ) - do: [ :ex | ex resume: 1 ]. + self assert: ([ ZeroDivide signal ] + on: Warning , ZeroDivide , (MessageNotUnderstood , Error) + do: [ :ex | ex return: true ]). - self assert: result equals: 2 + self assert: ([ Object new perform: #asdf ] + on: MessageNotUnderstood , Error , (Warning , ZeroDivide) + do: [ :ex | ex return: true ]) ] { #category : #'tests - exception sets' } diff --git a/source/Buoy-Exception-Handling-Extensions-Tests/package.st b/source/Buoy-Exception-Handling-Extensions-Tests/package.st new file mode 100644 index 0000000..97be3ef --- /dev/null +++ b/source/Buoy-Exception-Handling-Extensions-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'Buoy-Exception-Handling-Extensions-Tests' } diff --git a/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st b/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st new file mode 100644 index 0000000..3b23655 --- /dev/null +++ b/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st @@ -0,0 +1,12 @@ +Extension { #name : #BlockClosure } + +{ #category : #'*Buoy-Exception-Handling-Extensions' } +BlockClosure >> on: selector except: exclusionSelector do: action [ + + ^ self + on: selector + do: [ :exception | + (exclusionSelector handles: exception) + ifTrue: [ exception pass ] + ifFalse: [ action value: exception ] ] +] diff --git a/source/Buoy-Exception-Handling-Extensions/package.st b/source/Buoy-Exception-Handling-Extensions/package.st new file mode 100644 index 0000000..6c8ffa1 --- /dev/null +++ b/source/Buoy-Exception-Handling-Extensions/package.st @@ -0,0 +1 @@ +Package { #name : #'Buoy-Exception-Handling-Extensions' } diff --git a/source/Buoy-Exception-Handling-Tests/package.st b/source/Buoy-Exception-Handling-Tests/package.st deleted file mode 100644 index 2a2c404..0000000 --- a/source/Buoy-Exception-Handling-Tests/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Buoy-Exception-Handling-Tests' } diff --git a/source/Buoy-Exception-Handling/BlockClosure.extension.st b/source/Buoy-Exception-Handling/BlockClosure.extension.st deleted file mode 100644 index bb54693..0000000 --- a/source/Buoy-Exception-Handling/BlockClosure.extension.st +++ /dev/null @@ -1,9 +0,0 @@ -Extension { #name : #BlockClosure } - -{ #category : #'*Buoy-Exception-Handling' } -BlockClosure >> on: selector except: exclusionSelector do: action [ - - ^ self - on: selector - exclusionSelector - do: action -] diff --git a/source/Buoy-Exception-Handling/package.st b/source/Buoy-Exception-Handling/package.st deleted file mode 100644 index 98068da..0000000 --- a/source/Buoy-Exception-Handling/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Buoy-Exception-Handling' }