From feb012a4df846d4c17e187915bb88077ebf1190a Mon Sep 17 00:00:00 2001 From: Mariano Saura Date: Fri, 4 Aug 2023 15:47:18 -0300 Subject: [PATCH 1/5] Add exception handling package --- rowan/components/Deployment.ston | 6 +++++- rowan/components/Tests.ston | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rowan/components/Deployment.ston b/rowan/components/Deployment.ston index ef8866d..58e2755 100644 --- a/rowan/components/Deployment.ston +++ b/rowan/components/Deployment.ston @@ -3,7 +3,8 @@ RwSimpleProjectLoadComponentV2 { #projectNames : [ ], #componentNames : [ ], #packageNames : [ - 'Buoy-Collections-GS64-Extensions' + 'Buoy-Collections-GS64-Extensions' , + 'Buoy-Exception-Handling' ], #conditionalPackageMapSpecs : { 'gemstone' : { @@ -11,6 +12,9 @@ RwSimpleProjectLoadComponentV2 { #packageNameToPlatformPropertiesMap : { 'Buoy-Collections-GS64-Extensions' : { 'symbolDictName' : 'Globals' + } , + 'Buoy-Exception-Handling' : { + 'symbolDictName' : 'Globals' } } } diff --git a/rowan/components/Tests.ston b/rowan/components/Tests.ston index 31f5d8a..3cb0d68 100644 --- a/rowan/components/Tests.ston +++ b/rowan/components/Tests.ston @@ -7,7 +7,8 @@ RwSimpleProjectLoadComponentV2 { 'SUnit-Dependent-Extensions' ], #packageNames : [ - 'Buoy-SUnit-Tests' + 'Buoy-SUnit-Tests' , + 'Buoy-Exception-Handling-Tests' ], #comment : '' } From eb8618f5ec5e69b2e26a1a1a57a2472cbea03671 Mon Sep 17 00:00:00 2001 From: Mariano Saura Date: Fri, 4 Aug 2023 16:03:54 -0300 Subject: [PATCH 2/5] Avoid using #- on BlockClosure>>on:except:do: extension --- source/Buoy-Exception-Handling/BlockClosure.extension.st | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/Buoy-Exception-Handling/BlockClosure.extension.st b/source/Buoy-Exception-Handling/BlockClosure.extension.st index bb54693..3edb1d5 100644 --- a/source/Buoy-Exception-Handling/BlockClosure.extension.st +++ b/source/Buoy-Exception-Handling/BlockClosure.extension.st @@ -4,6 +4,9 @@ Extension { #name : #BlockClosure } BlockClosure >> on: selector except: exclusionSelector do: action [ ^ self - on: selector - exclusionSelector - do: action + on: selector + do: [ :exception | + (exclusionSelector handles: exception) + ifTrue: [ exception pass ] + ifFalse: [ action value: exception ] ] ] From ae132db69577def3b9771f767d4f98da2fd34efc Mon Sep 17 00:00:00 2001 From: Mariano Saura Date: Mon, 7 Aug 2023 13:04:14 -0300 Subject: [PATCH 3/5] Used #return: instead of #resume: on exception set tests because ZeroDivide on GS64 cannot be resumed --- .../ExceptionHandlingSystemTest.class.st | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st b/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st index 7e569dd..371f46d 100644 --- a/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st +++ b/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st @@ -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' } From d9f023cf711974e1518e13cc6d608d0a27622215 Mon Sep 17 00:00:00 2001 From: Mariano Saura Date: Mon, 7 Aug 2023 13:54:28 -0300 Subject: [PATCH 4/5] Fixed previous merge error --- rowan/components/Deployment.ston | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rowan/components/Deployment.ston b/rowan/components/Deployment.ston index 1ee875d..a137d52 100644 --- a/rowan/components/Deployment.ston +++ b/rowan/components/Deployment.ston @@ -21,6 +21,15 @@ RwSimpleProjectLoadComponentV2 { }, 'Buoy-Collections-GS64-Extensions' : { 'symbolDictName' : 'Globals' + }, + 'Buoy-Conditions-Extensions' : { + 'symbolDictName' : 'Globals' + }, + 'Buoy-Metaprogramming-Extensions' : { + 'symbolDictName' : 'Globals' + }, + 'Buoy-Metaprogramming-GS64-Extensions' : { + 'symbolDictName' : 'Globals' } } } From 41e849df7b6ef3de3a5a74d9c51df4274fff0f53 Mon Sep 17 00:00:00 2001 From: Mariano Saura Date: Mon, 7 Aug 2023 15:55:18 -0300 Subject: [PATCH 5/5] Renamed package and updated Rowan specs to compile class in the "Globals" namespace --- rowan/components/Deployment.ston | 5 ++++- rowan/components/Tests.ston | 2 +- source/BaselineOfBuoy/BaselineOfBuoy.class.st | 8 ++++---- .../ExceptionHandlingSystemTest.class.st | 2 +- .../Buoy-Exception-Handling-Extensions-Tests/package.st | 1 + .../BlockClosure.extension.st | 2 +- source/Buoy-Exception-Handling-Extensions/package.st | 1 + source/Buoy-Exception-Handling-Tests/package.st | 1 - source/Buoy-Exception-Handling/package.st | 1 - 9 files changed, 13 insertions(+), 10 deletions(-) rename source/{Buoy-Exception-Handling-Tests => Buoy-Exception-Handling-Extensions-Tests}/ExceptionHandlingSystemTest.class.st (99%) create mode 100644 source/Buoy-Exception-Handling-Extensions-Tests/package.st rename source/{Buoy-Exception-Handling => Buoy-Exception-Handling-Extensions}/BlockClosure.extension.st (83%) create mode 100644 source/Buoy-Exception-Handling-Extensions/package.st delete mode 100644 source/Buoy-Exception-Handling-Tests/package.st delete mode 100644 source/Buoy-Exception-Handling/package.st diff --git a/rowan/components/Deployment.ston b/rowan/components/Deployment.ston index a137d52..eaf2475 100644 --- a/rowan/components/Deployment.ston +++ b/rowan/components/Deployment.ston @@ -8,7 +8,7 @@ RwSimpleProjectLoadComponentV2 { 'Buoy-Collections-GS64-Extensions', 'Buoy-Conditions-Extensions', 'Buoy-Conditions', - 'Buoy-Exception-Handling', + 'Buoy-Exception-Handling-Extensions', 'Buoy-Metaprogramming-Extensions', 'Buoy-Metaprogramming-GS64-Extensions' ], @@ -25,6 +25,9 @@ RwSimpleProjectLoadComponentV2 { '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 3faa994..2b82ca0 100644 --- a/rowan/components/Tests.ston +++ b/rowan/components/Tests.ston @@ -9,7 +9,7 @@ RwSimpleProjectLoadComponentV2 { #packageNames : [ 'Buoy-Assertions-Tests', 'Buoy-Conditions-Tests', - 'Buoy-Exception-Handling-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 99% rename from source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st rename to source/Buoy-Exception-Handling-Extensions-Tests/ExceptionHandlingSystemTest.class.st index 371f46d..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 } 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/BlockClosure.extension.st b/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st similarity index 83% rename from source/Buoy-Exception-Handling/BlockClosure.extension.st rename to source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st index 3edb1d5..3b23655 100644 --- a/source/Buoy-Exception-Handling/BlockClosure.extension.st +++ b/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st @@ -1,6 +1,6 @@ Extension { #name : #BlockClosure } -{ #category : #'*Buoy-Exception-Handling' } +{ #category : #'*Buoy-Exception-Handling-Extensions' } BlockClosure >> on: selector except: exclusionSelector do: action [ ^ self 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/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' }