From 69aa2506d089fb158dc60ebbc6d8f0003602fa1b Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 9 Aug 2023 17:51:58 -0300 Subject: [PATCH 1/8] Add CI action to verify component loading --- .github/workflows/loading-gs64-components.yml | 19 ++++++++++++++++++ .github/workflows/notify.yml | 4 +--- .github/workflows/unit-tests.yml | 2 +- README.md | 7 ++++++- ...s.ston => Dependent-SUnit-Extensions.ston} | 2 +- rowan/components/Tests.ston | 2 +- .../Buoy-Dependent-SUnit-Extensions.ston | 20 +++++++++++++++++++ rowan/specs/Buoy-Deployment.ston | 17 ++++++++++++++++ 8 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/loading-gs64-components.yml rename rowan/components/{SUnit-Dependent-Extensions.ston => Dependent-SUnit-Extensions.ston} (93%) create mode 100644 rowan/specs/Buoy-Dependent-SUnit-Extensions.ston create mode 100644 rowan/specs/Buoy-Deployment.ston diff --git a/.github/workflows/loading-gs64-components.yml b/.github/workflows/loading-gs64-components.yml new file mode 100644 index 0000000..1c89ce8 --- /dev/null +++ b/.github/workflows/loading-gs64-components.yml @@ -0,0 +1,19 @@ +name: 'GS64 Components Loading' + +on: [push,pull_request,workflow_dispatch] + +jobs: + component-loading: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + load-spec: [ Deployment, Dependent-Sunit-Extensions ] + name: GS64 + ${{ matrix.load-spec }} + steps: + - uses: actions/checkout@v3 + - name: Load component in image + uses: ba-st-actions/gs64-ci@v1 + with: + project_name: 'Buoy' + load_spec: 'Buoy-${{ matrix.load-spec }}' diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml index bfe0828..bc6862d 100644 --- a/.github/workflows/notify.yml +++ b/.github/workflows/notify.yml @@ -1,8 +1,6 @@ name: Release Notifications -on: - release: - types: [published] +on: workflow_dispatch jobs: notify: diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 5db7169..54d6f8e 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,4 +1,4 @@ -name: Unit Tests +name: Pharo Unit Tests on: [push,pull_request,workflow_dispatch] diff --git a/README.md b/README.md index 344d60b..789c0cb 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,23 @@ This project aims to complement [Pharo](https://www.pharo.org) and [GS64](https://gemtalksystems.com/products/gs64/) adding useful extensions. -[![Unit Tests](https://github.com/ba-st/Buoy/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/unit-tests.yml) +[![Pharo - Unit Tests](https://github.com/ba-st/Buoy/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/unit-tests.yml) +[![GS64 - Unit Tests](https://github.com/ba-st/Buoy/actions/workflows/unit-tests-gs64.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/unit-tests-gs64.yml) [![Coverage Status](https://codecov.io/github/ba-st/Buoy/coverage.svg?branch=release-candidate)](https://codecov.io/gh/ba-st/Buoy/branch/release-candidate) + [![Baseline Groups](https://github.com/ba-st/Buoy/actions/workflows/loading-groups.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/loading-groups.yml) [![Markdown Lint](https://github.com/ba-st/Buoy/actions/workflows/markdown-lint.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/markdown-lint.yml) [![GitHub release](https://img.shields.io/github/release/ba-st/Buoy.svg)](https://github.com/ba-st/Buoy/releases/latest) + [![Pharo 7.0](https://img.shields.io/badge/Pharo-7.0-informational)](https://pharo.org) [![Pharo 8.0](https://img.shields.io/badge/Pharo-8.0-informational)](https://pharo.org) [![Pharo 9.0](https://img.shields.io/badge/Pharo-9.0-informational)](https://pharo.org) [![Pharo 10](https://img.shields.io/badge/Pharo-10-informational)](https://pharo.org) [![Pharo 11](https://img.shields.io/badge/Pharo-11-informational)](https://pharo.org) +[![GS64 3.6.6](https://img.shields.io/badge/GS64-3.6.6-informational)](https://gemtalksystems.com/products/gs64/) + Quick links - [**Explore the docs**](docs/README.md) diff --git a/rowan/components/SUnit-Dependent-Extensions.ston b/rowan/components/Dependent-SUnit-Extensions.ston similarity index 93% rename from rowan/components/SUnit-Dependent-Extensions.ston rename to rowan/components/Dependent-SUnit-Extensions.ston index 40c92e5..a5d6a2c 100644 --- a/rowan/components/SUnit-Dependent-Extensions.ston +++ b/rowan/components/Dependent-SUnit-Extensions.ston @@ -1,5 +1,5 @@ RwSimpleProjectLoadComponentV2 { - #name : 'SUnit-Dependent-Extensions', + #name : 'Dependent-SUnit-Extensions', #condition : 'sunit', #projectNames : [ ], #componentNames : [ ], diff --git a/rowan/components/Tests.ston b/rowan/components/Tests.ston index f8c6e68..02327da 100644 --- a/rowan/components/Tests.ston +++ b/rowan/components/Tests.ston @@ -4,7 +4,7 @@ RwSimpleProjectLoadComponentV2 { #projectNames : [ ], #componentNames : [ 'Deployment', - 'SUnit-Dependent-Extensions' + 'Dependent-SUnit-Extensions' ], #packageNames : [ 'Buoy-Assertions-Tests', diff --git a/rowan/specs/Buoy-Dependent-SUnit-Extensions.ston b/rowan/specs/Buoy-Dependent-SUnit-Extensions.ston new file mode 100644 index 0000000..700726e --- /dev/null +++ b/rowan/specs/Buoy-Dependent-SUnit-Extensions.ston @@ -0,0 +1,20 @@ +RwLoadSpecificationV2 { + #specName: 'Buoy-CI', + #projectName : 'Buoy', + #diskUrl : '/opt/gemstone/projects/Buoy', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'Dependent-SUnit-Extensions' + ], + #platformProperties : { + 'gemstone' : { + 'allusers' : { + #defaultSymbolDictName : 'Buoy' + } + } + }, + #customConditionalAttributes : [ + 'sunit' + ], + #comment : 'Loading spec for Dependent-SUnit-Extensions' +} diff --git a/rowan/specs/Buoy-Deployment.ston b/rowan/specs/Buoy-Deployment.ston new file mode 100644 index 0000000..07570dd --- /dev/null +++ b/rowan/specs/Buoy-Deployment.ston @@ -0,0 +1,17 @@ +RwLoadSpecificationV2 { + #specName: 'Buoy-CI', + #projectName : 'Buoy', + #diskUrl : '/opt/gemstone/projects/Buoy', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'Deployment' + ], + #platformProperties : { + 'gemstone' : { + 'allusers' : { + #defaultSymbolDictName : 'Buoy' + } + } + }, + #comment : 'Loading spec for Deployment' +} From 8b81d4493abf5cfd6690455c8ebf0184b8dc7926 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 9 Aug 2023 17:56:40 -0300 Subject: [PATCH 2/8] Fix load spec name --- .github/workflows/loading-gs64-components.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/loading-gs64-components.yml b/.github/workflows/loading-gs64-components.yml index 1c89ce8..f6ace8f 100644 --- a/.github/workflows/loading-gs64-components.yml +++ b/.github/workflows/loading-gs64-components.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - load-spec: [ Deployment, Dependent-Sunit-Extensions ] + load-spec: [ Deployment, Dependent-SUnit-Extensions ] name: GS64 + ${{ matrix.load-spec }} steps: - uses: actions/checkout@v3 From a6006d20c4cf55b7ec72c733bedf65e7c301e8c1 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 9 Aug 2023 21:28:13 -0300 Subject: [PATCH 3/8] Update docs to details GS64 support --- README.md | 3 +- docs/README.md | 8 +++--- docs/reference/Baseline-groups.md | 13 ++++++++- docs/reference/Collections.md | 47 +++++++++++++++++++++++++++++++ docs/reference/MOP.md | 10 +++++++ docs/reference/Math.md | 19 ++++++++++--- docs/reference/SUnit.md | 13 ++++++++- 7 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 docs/reference/MOP.md diff --git a/README.md b/README.md index 789c0cb..07a64b5 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ adding useful extensions. [![Coverage Status](https://codecov.io/github/ba-st/Buoy/coverage.svg?branch=release-candidate)](https://codecov.io/gh/ba-st/Buoy/branch/release-candidate) [![Baseline Groups](https://github.com/ba-st/Buoy/actions/workflows/loading-groups.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/loading-groups.yml) +[![GS64 Components](https://github.com/ba-st/Buoy/actions/workflows/loading-gs64-components.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/loading-gs64-components.yml) [![Markdown Lint](https://github.com/ba-st/Buoy/actions/workflows/markdown-lint.yml/badge.svg)](https://github.com/ba-st/Buoy/actions/workflows/markdown-lint.yml) [![GitHub release](https://img.shields.io/github/release/ba-st/Buoy.svg)](https://github.com/ba-st/Buoy/releases/latest) @@ -46,7 +47,7 @@ Quick links ## Installation -To load the project in a Pharo image follow this [instructions](docs/how-to/how-to-load-in-pharo.md). +To load the project in a Pharo image follow these [instructions](docs/how-to/how-to-load-in-pharo.md). ## Contributing diff --git a/docs/README.md b/docs/README.md index 4d466ae..37c4f88 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,13 +18,13 @@ understanding over specific topics: required values, that can be unknown at the beginning of an execution. See the [related documentation.](reference/BindingsAndOptionals.md) - **Exception Handling**: Extensions to the [exception handling mechanics](reference/ExceptionHandling.md). -- **Meta-programming**: Some abstractions like [namespaces](reference/Namespaces.md) -and [interfaces](reference/Interfaces.md). +- **Meta-programming**: Some abstractions like [namespaces](reference/Namespaces.md), +[interfaces](reference/Interfaces.md) and extensions to the [Object model](reference/MOP.md). - **SUnit**: [Extensions to the SUnit framework](reference/SUnit.md). --- To use the project as a dependency of your project, take a look at: -- [How to use Buoy as a dependency](how-to/how-to-use-as-dependency-in-pharo.md) -- [Baseline groups reference](reference/Baseline-groups.md) +- [Pharo: How to use Buoy as a dependency](how-to/how-to-use-as-dependency-in-pharo.md) +- [Baseline groups & components reference](reference/Baseline-groups.md) diff --git a/docs/reference/Baseline-groups.md b/docs/reference/Baseline-groups.md index dfd0c21..ffc84d7 100644 --- a/docs/reference/Baseline-groups.md +++ b/docs/reference/Baseline-groups.md @@ -1,4 +1,6 @@ -# Baseline Groups +# Baseline Groups & GS 64 Components + +## Pharo Baseline Groups Buoy includes the following groups in its Baseline that can be used as loading targets: @@ -11,3 +13,12 @@ loading targets: particular case it is the same as `Tests` - `Development` will load all the needed packages to develop and contribute to the project + +## GS64 Components + +Buoy includes the following components in its Rowan configuration that can be +used as loading targets: + +- `Deployment` will load all the packages needed in a deployed application +- `Tests` will load the test cases +- `Dependent-SUnit-Extensions` will load extensions to SUnit diff --git a/docs/reference/Collections.md b/docs/reference/Collections.md index 888d872..2858f2c 100644 --- a/docs/reference/Collections.md +++ b/docs/reference/Collections.md @@ -20,6 +20,21 @@ Some examples #( #(1) #(3 1) #(2) ) minUsing: [:array | array first ] >>> 1 ``` +### `Collection` extensions for GS64 + +- `anyOne` is just an alias of `any` +- `collect:as:` evaluates a block with each of the receiver's elements as the + argument collecting the result into an instance of the argument class. +- `count:` counts the number of elements evaluating true for the argument block. +- `detect:ifFound:` evaluates an action block if any of the elements match the + condition block. If no elements match does nothing. +- `detect:ifFound:ifNone:` evaluates an action block if any of the elements match + the condition block. If no elements match evaluates the fail block. +- `ifEmpty:ifNotEmpty:` evaluates one of two blocks depending on the collection emptiness. +- `removeAll` removes all elements of the receiver. +- `select:thenCollect:` filters the elements in the receiver using the condition + block, collecting after the results evaluating the action block. + ## `SequenceableCollection` extensions - `copyFirst:` Copy the first `n` elements of the collection. If `n` is 0 it @@ -67,6 +82,38 @@ Some examples ``` +### `SequenceableCollection` extensions for GS64 + +- `copyAfter:` returns a copy of the receiver after the first occurrence + of the argument up to the end, or empty if no element matches. +- `endsWith:` returns true if the argument is a suffix of the receiver. +- `writeStream` returns a write stream over the receiver. + +## `Dictionary` extensions for GS64 + +- `at:ifPresent:ifAbsentPut:` lookups a value, if any matches evaluates a block, + if no one matches put under the key the result o evaluating the second block. + +## `String` extensions for GS64 + +- `expandMacros` +- `expandMacrosWith:` +- `expandMacrosWith:With:` +- `expandMacrosWith:With:With:` +- `expandMacrosWith:With:With:With:` +- `expandMacrosWithArguments:` + +These methods interpolate the receiver pattern using the provided arguments: + +- `` is replaced by `CR` +- `` is replaced by `LF` +- `` is replaced by the underlying OS line delimiter +- `` is replaced by `TAB` +- `` is replaced by the `printString` of the nth argument +- `` is replaced by the string provided in the nth argument +- `` is replaced by `trueString` or `falseString` + depending on the boolean provided in the nth argument. + ## Circular Iterator A `CircularIterator` provides an abstraction to iterate over a collection diff --git a/docs/reference/MOP.md b/docs/reference/MOP.md new file mode 100644 index 0000000..628f124 --- /dev/null +++ b/docs/reference/MOP.md @@ -0,0 +1,10 @@ +# Meta Object Protocol + +## `Symbol` extensions for GS64 + +- `value:` allows to use a unary symbol as a replacement for a unary block + +## `Class` extensions for GS64 + +- `allLeafSubclasses` returns all the subclasses of the receiver that don't + have further subclasses diff --git a/docs/reference/Math.md b/docs/reference/Math.md index f032cdd..6238bab 100644 --- a/docs/reference/Math.md +++ b/docs/reference/Math.md @@ -7,7 +7,7 @@ The easier way to create a percentage is to send the message `percent` to a number. For example `5 percent` will create an object representing `5%`. - There are two common cases also covered as instance creation methods (`0%` and + There are two common cases also covered as instance creation methods (`0%` and `100%`): ```smalltalk @@ -22,8 +22,8 @@ Percentage ratio: 1. "100%" Percentage ratio: 1/2 "50%" ``` -This percentages can be operated arithmetically with any number or other - percentages. Try printing the following expressions: +These percentages can be operated arithmetically with any number or other +percentages. Try printing the following expressions: ```smalltalk 20 percent * 5. "1" @@ -53,5 +53,16 @@ create one is to send the message `perMille` to a number. 12 perMille "12‰" ``` +## `Number` Extensions for GS64 + +- `isZero` returns true if the receiver equals 0 +- `nthRoot:` returns the nth root of the receiver +- `round:` round the decimal part of the receiver to be limited to the desired + number of decimal digits + +## `Float` Extensions for GS64 + +- `isInfinite` returns true if the receiver is infinite + --- -Some definitions and examples are based on the ones in [Wikipedia](https://en.wikipedia.org/wiki/Percentage) +Some definitions and examples are based on the ones on [Wikipedia](https://en.wikipedia.org/wiki/Percentage) diff --git a/docs/reference/SUnit.md b/docs/reference/SUnit.md index 08cad9e..4930e44 100644 --- a/docs/reference/SUnit.md +++ b/docs/reference/SUnit.md @@ -6,7 +6,18 @@ sequenceable collections have the same elements in the same order - `assert:includes:` asserts that a collection includes an element - `deny:includes:` denies that a collection includes an element -- `should:raise:withMessageText:` asserts that a block raises an specific +- `should:raise:withMessageText:` asserts that a block raises a specific exception including a specific message text - `withTheOnlyOneIn:do:` provides a facility to assert that a collection has only one element and evaluates a block with it + +### `TestAsserter` extensions for GS64 + +- `assert:identicalTo:` asserts that an object is identical to another one +- `deny:identicalTo:` denies that an object is identical to another one +- `assertCollection:hasSameElements:` asserts that two collections have the + same elements +- `fail` will make the test fail +- `should:raise:withExceptionDo:` asserts that a block raises a specific + exception and evaluates the provided block with the signal + \ No newline at end of file From 74a4376bfa88024b8f749907a63bee59bbd5e1c2 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 9 Aug 2023 21:37:37 -0300 Subject: [PATCH 4/8] Fix markdown lint --- docs/reference/Collections.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/Collections.md b/docs/reference/Collections.md index 2858f2c..49c02ee 100644 --- a/docs/reference/Collections.md +++ b/docs/reference/Collections.md @@ -26,7 +26,7 @@ Some examples - `collect:as:` evaluates a block with each of the receiver's elements as the argument collecting the result into an instance of the argument class. - `count:` counts the number of elements evaluating true for the argument block. -- `detect:ifFound:` evaluates an action block if any of the elements match the +- `detect:ifFound:` evaluates an action block if any of the elements match the condition block. If no elements match does nothing. - `detect:ifFound:ifNone:` evaluates an action block if any of the elements match the condition block. If no elements match evaluates the fail block. From a8df0de3fe65e1fc0733a0ac42d78b75564f5000 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 9 Aug 2023 22:12:50 -0300 Subject: [PATCH 5/8] Add more tests --- .../CollectionExtensionsTest.class.st | 123 ++++++++++++++++++ .../StringExtensionsTest.class.st | 45 +++++++ 2 files changed, 168 insertions(+) create mode 100644 source/Buoy-Collections-Tests/StringExtensionsTest.class.st diff --git a/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st b/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st index 7b58649..63c075e 100644 --- a/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st +++ b/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st @@ -50,6 +50,104 @@ CollectionExtensionsTest >> testCopyNoMoreThanLast [ ] +{ #category : #tests } +CollectionExtensionsTest >> testDetectIfFoundIfNoneWhenNobodyIsFound [ + + | wasFound | + wasFound := #( 1 2 3 ) + detect: [ :each | each isNil ] + ifFound: [ true ] + ifNone: [ false ]. + self deny: wasFound +] + +{ #category : #tests } +CollectionExtensionsTest >> testDetectIfFoundIfNoneWhenSomethingIsFound [ + + | wasFound | + wasFound := #( 1 2 3 ) + detect: [ :each | each notNil ] + ifFound: [ :found | + self assert: found equals: 1. + true ] + ifNone: [ false ]. + self assert: wasFound +] + +{ #category : #tests } +CollectionExtensionsTest >> testDetectIfFoundIfNoneWhenSomethingIsFoundIgnoringTheFoundObject [ + + | wasFound | + wasFound := #( 1 2 3 ) + detect: [ :each | each notNil ] + ifFound: [ true ] + ifNone: [ false ]. + self assert: wasFound +] + +{ #category : #tests } +CollectionExtensionsTest >> testDetectIfFoundWhenNobodyIsFound [ + + | collection result | + collection := #( a b c ). + result := collection detect: #isNil ifFound: [ self fail ]. + self assert: result identicalTo: collection +] + +{ #category : #tests } +CollectionExtensionsTest >> testDetectIfFoundWhenSomethingIsFound [ + + | collection result wasFound | + wasFound := false. + collection := #( $a $b $e ). + result := collection detect: #isVowel ifFound: [ :vowel | + self assert: vowel equals: $a. + wasFound := true ]. + self + assert: wasFound; + assert: result identicalTo: collection +] + +{ #category : #tests } +CollectionExtensionsTest >> testDetectIfFoundWhenSomethingIsFoundIgnoringTheFoundObject [ + + | wasFound | + wasFound := false. + #( $a $b ) + detect: [ :each | each notNil ] + ifFound: [ wasFound := true ]. + self assert: wasFound +] + +{ #category : #tests } +CollectionExtensionsTest >> testIfEmptyIfNotEmptyWhenEmpty [ + + | isEmpty | + isEmpty := false. + #( ) ifEmpty: [ isEmpty := true ] ifNotEmpty: [ self fail ]. + self assert: isEmpty +] + +{ #category : #tests } +CollectionExtensionsTest >> testIfEmptyIfNotEmptyWhenNotEmpty [ + + | isNotEmpty | + isNotEmpty := false. + #( 1 ) ifEmpty: [ self fail ] ifNotEmpty: [ isNotEmpty := true ]. + self assert: isNotEmpty +] + +{ #category : #tests } +CollectionExtensionsTest >> testIfEmptyIfNotEmptyWhenNotEmptyUsingNotEmptyValue [ + + | isNotEmpty | + isNotEmpty := false. + #( 1 ) ifEmpty: [ self fail ] ifNotEmpty: [ :collection | + self assert: collection equals: #( 1 ). + isNotEmpty := true ]. + self assert: isNotEmpty +] + { #category : #tests } CollectionExtensionsTest >> testMaxUsing [ @@ -65,6 +163,31 @@ CollectionExtensionsTest >> testMinUsing [ self should: [ #() minUsing: [ :anArray | anArray first ] ] raise: Error ] +{ #category : #tests } +CollectionExtensionsTest >> testRemoveAll [ + + { Set. OrderedCollection. Bag } do: [ :collectionClass | + | collection | + collection := collectionClass withAll: #( 1 2 3 1 ). + self assert: collection notEmpty. + collection removeAll. + self assert: collection isEmpty ] +] + +{ #category : #tests } +CollectionExtensionsTest >> testSelectThenCollect [ + + { Set. OrderedCollection. Bag } do: [ :collectionClass | + | numbers evenDoubles | + numbers := collectionClass withAll: #( 3 2 12 2 16 ). + evenDoubles := numbers + select: [ :each | each even ] + thenCollect: [ :each | each * 2 ]. + self + assert: evenDoubles size equals: numbers size - 1; + assertCollection: evenDoubles hasSameElements: #( 4 24 32 ) ] +] + { #category : #'tests - copying' } CollectionExtensionsTest >> testWithoutFirst [ diff --git a/source/Buoy-Collections-Tests/StringExtensionsTest.class.st b/source/Buoy-Collections-Tests/StringExtensionsTest.class.st new file mode 100644 index 0000000..77f6ac3 --- /dev/null +++ b/source/Buoy-Collections-Tests/StringExtensionsTest.class.st @@ -0,0 +1,45 @@ +Class { + #name : #StringExtensionsTest, + #superclass : #TestCase, + #category : #'Buoy-Collections-Tests' +} + +{ #category : #tests } +StringExtensionsTest >> testExpandMacros [ + + self + assert: '' expandMacros + equals: (String streamContents: [ :stream | + stream + tab; + cr; + lf ]) +] + +{ #category : #tests } +StringExtensionsTest >> testExpandMacrosSkip [ + + self assert: '%<' expandMacros equals: '<' +] + +{ #category : #tests } +StringExtensionsTest >> testExpandMacrosTernary [ + + self + assert: ('<1?success:error>' expandMacrosWith: true) + equals: 'success'; + assert: ('<1?success:error>' expandMacrosWith: false) + equals: 'error' +] + +{ #category : #tests } +StringExtensionsTest >> testExpandMacrosWithArguments [ + + self + assert: ('<1s>' expandMacrosWithArguments: { 'str''ing' }) + equals: 'str''ing'; + assert: ('<1p>' expandMacrosWithArguments: { 'str''ing' }) + equals: '''str''''ing'''; + assert: ('<1p>: <2p>' expandMacrosWith: 'Number' with: 5) + equals: '''Number'': 5' +] From a1095bedc50555377bf80134b22c0bbfeed3bad3 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Wed, 9 Aug 2023 22:20:38 -0300 Subject: [PATCH 6/8] Improve tests --- .../CollectionExtensionsTest.class.st | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st b/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st index 63c075e..a703161 100644 --- a/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st +++ b/source/Buoy-Collections-Tests/CollectionExtensionsTest.class.st @@ -175,17 +175,38 @@ CollectionExtensionsTest >> testRemoveAll [ ] { #category : #tests } -CollectionExtensionsTest >> testSelectThenCollect [ +CollectionExtensionsTest >> testSelectThenCollectOnBag [ - { Set. OrderedCollection. Bag } do: [ :collectionClass | - | numbers evenDoubles | - numbers := collectionClass withAll: #( 3 2 12 2 16 ). - evenDoubles := numbers - select: [ :each | each even ] - thenCollect: [ :each | each * 2 ]. - self - assert: evenDoubles size equals: numbers size - 1; - assertCollection: evenDoubles hasSameElements: #( 4 24 32 ) ] + | numbers evenDoubles | + numbers := Bag withAll: #( 3 2 12 2 16 ). + evenDoubles := numbers + select: [ :each | each even ] + thenCollect: [ :each | each * 2 ]. + self assert: evenDoubles equals: (Bag withAll: #( 4 4 24 32 )) +] + +{ #category : #tests } +CollectionExtensionsTest >> testSelectThenCollectOnOrderedCollection [ + + | numbers evenDoubles | + numbers := OrderedCollection withAll: #( 3 2 12 2 16 ). + evenDoubles := numbers + select: [ :each | each even ] + thenCollect: [ :each | each * 2 ]. + self + assert: evenDoubles + equals: (OrderedCollection withAll: #( 4 24 4 32 )) +] + +{ #category : #tests } +CollectionExtensionsTest >> testSelectThenCollectOnSet [ + + | numbers evenDoubles | + numbers := Set withAll: #( 3 2 12 2 16 ). + evenDoubles := numbers + select: [ :each | each even ] + thenCollect: [ :each | each * 2 ]. + self assert: evenDoubles equals: (Set withAll: #( 4 24 32 )) ] { #category : #'tests - copying' } From e9f37bbea0dc3124b3137134563ee002fac75ff0 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 10 Aug 2023 09:58:36 -0300 Subject: [PATCH 7/8] Add GS64-Development group to the baseline for developing GS64 changes --- source/BaselineOfBuoy/BaselineOfBuoy.class.st | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/source/BaselineOfBuoy/BaselineOfBuoy.class.st b/source/BaselineOfBuoy/BaselineOfBuoy.class.st index 11fde2f..a0ec7f1 100644 --- a/source/BaselineOfBuoy/BaselineOfBuoy.class.st +++ b/source/BaselineOfBuoy/BaselineOfBuoy.class.st @@ -23,7 +23,8 @@ BaselineOfBuoy >> baseline: spec [ baselineMath: spec; baselineMetaprogramming: spec; baselineSUnit: spec; - baselineTools: spec. + baselineTools: spec; + baselineGS64Development: spec. spec group: 'CI' with: 'Tests'; group: 'Development' with: #('Tools' 'Tests') @@ -125,6 +126,31 @@ BaselineOfBuoy >> baselineExceptionHandling: spec [ group: 'Tests' with: 'Buoy-Exception-Handling-Tests' ] +{ #category : #baselines } +BaselineOfBuoy >> baselineGS64Development: spec [ + + spec + package: 'Buoy-GS64-Compatibility' + with: [ spec requires: 'Development' ]; + group: 'GS64-Development' with: 'Buoy-GS64-Compatibility'; + package: 'Buoy-Collections-GS64-Extensions' + with: [ spec requires: 'Buoy-GS64-Compatibility' ]; + group: 'GS64-Development' with: 'Buoy-Collections-GS64-Extensions'; + package: 'Buoy-Math-GS64-Base-Extensions' + with: [ spec requires: 'Buoy-GS64-Compatibility' ]; + group: 'GS64-Development' with: 'Buoy-Math-GS64-Base-Extensions'; + package: 'Buoy-Math-GS64-Extensions' + with: [ spec requires: 'Buoy-GS64-Compatibility' ]; + group: 'GS64-Development' with: 'Buoy-Math-GS64-Extensions'; + package: 'Buoy-Metaprogramming-GS64-Extensions' + with: [ spec requires: 'Buoy-GS64-Compatibility' ]; + group: 'GS64-Development' + with: 'Buoy-Metaprogramming-GS64-Extensions'; + package: 'Buoy-SUnit-GS64-Extensions' + with: [ spec requires: 'Buoy-GS64-Compatibility' ]; + group: 'GS64-Development' with: 'Buoy-SUnit-GS64-Extensions' +] + { #category : #baselines } BaselineOfBuoy >> baselineMath: spec [ From f5a18ff5cc74c194f9ecadd89ff84ecc8e3fe6c8 Mon Sep 17 00:00:00 2001 From: Gabriel Omar Cotelli Date: Thu, 10 Aug 2023 10:12:12 -0300 Subject: [PATCH 8/8] Update docs --- docs/reference/Baseline-groups.md | 6 ++++++ docs/reference/SUnit.md | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/reference/Baseline-groups.md b/docs/reference/Baseline-groups.md index ffc84d7..3eaf253 100644 --- a/docs/reference/Baseline-groups.md +++ b/docs/reference/Baseline-groups.md @@ -14,6 +14,12 @@ loading targets: - `Development` will load all the needed packages to develop and contribute to the project +- `GS64-Development` is an optional group that will load `Development` and all + the packages required to develop changes applicable to GS64. Loading this package + will make dirty other packages in the project but this is expected, just remember + to cherry-pick the changes to commit and don't remove the changed methods in the + Pharo package. + ## GS64 Components Buoy includes the following components in its Rowan configuration that can be diff --git a/docs/reference/SUnit.md b/docs/reference/SUnit.md index 4930e44..736eed3 100644 --- a/docs/reference/SUnit.md +++ b/docs/reference/SUnit.md @@ -20,4 +20,9 @@ - `fail` will make the test fail - `should:raise:withExceptionDo:` asserts that a block raises a specific exception and evaluates the provided block with the signal - \ No newline at end of file + +## `TestCase` extensions + +- `runOnlyInGemStone64:` evaluates the block only if running in GS64 +- `runOnlyInPharo:` evaluates the block only if running in Pharo +- `runOnlyInVAST:` evaluates the block only if running in VAST Platform