Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GS64: Add Math packages #87

Merged
merged 28 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a5ef1c
Number and subclasses extensions moved to math extensions package
ytsejam78 Aug 7, 2023
b73e89a
Merge branch 'release-candidate' into gs64-math
gcotelli Aug 8, 2023
fea532b
Move test to test package
gcotelli Aug 8, 2023
925a95a
Updated Pharo baseline
ytsejam78 Aug 8, 2023
77b8162
Fixed baseline tests package loading
ytsejam78 Aug 8, 2023
6f54a62
Rowan specs update
ytsejam78 Aug 8, 2023
2189ee1
Added alias for ArithmeticError in preload doit script
ytsejam78 Aug 8, 2023
c683fa7
Fix some tests in GS64
gcotelli Aug 8, 2023
cbaf50c
Merge 2189ee1535931dfe6bfb5d45f53cbcb5e515b287
gcotelli Aug 8, 2023
03639ca
Fix Percentage tests on GS64
gcotelli Aug 9, 2023
3855a39
Fix rounding tests in GS64
gcotelli Aug 9, 2023
23453b0
Move GS64 extensions to its own package
gcotelli Aug 9, 2023
981ac18
Update deployemnt component
gcotelli Aug 9, 2023
c9044c0
Move extensions only needed in GS64
gcotelli Aug 9, 2023
a47c903
Add method to compatibility package
gcotelli Aug 9, 2023
8bb5f55
Add Number>>#nthRoot: to GS package
gcotelli Aug 9, 2023
bc3137a
Move storeOn:base: to pharo specific package
ytsejam78 Aug 9, 2023
0609175
Add conditional block evaluation methods for GS64
ytsejam78 Aug 9, 2023
9611fbb
Add conditional block evaluation for Pharo
ytsejam78 Aug 9, 2023
124a620
Platform conditional asserts on Percentage / PerMille tests
ytsejam78 Aug 9, 2023
8bee1f8
Conditional assertions in tests to get 100% pass on Pharo/GS64
ytsejam78 Aug 9, 2023
644ee8d
Update storeOn: implementation on PartsPerFraction
gcotelli Aug 9, 2023
535583a
Update GS64 implementation for storeValueOn:
gcotelli Aug 9, 2023
6da57fe
Fix storeValueOn:
gcotelli Aug 9, 2023
0008579
Update testCreationShortcut
gcotelli Aug 9, 2023
e1a6005
Use per-mille symbol as string
gcotelli Aug 9, 2023
ca4aa12
Improve precision of PerMilleTest>>#testCreationShortcut
gcotelli Aug 9, 2023
b4c909f
Improve comments for GS64 class placeholders
gcotelli Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion rowan/components/Deployment.ston
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ RwSimpleProjectLoadComponentV2 {
'Buoy-Conditions-Extensions',
'Buoy-Dynamic-Binding',
'Buoy-Exception-Handling-Extensions',
'Buoy-Math',
'Buoy-Math-Extensions',
'Buoy-Math-GS64-Base-Extensions',
'Buoy-Math-GS64-Extensions',
'Buoy-Metaprogramming',
'Buoy-Metaprogramming-Extensions',
Expand Down Expand Up @@ -42,7 +45,10 @@ RwSimpleProjectLoadComponentV2 {
'Buoy-Exception-Handling-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Math-GS64-Extensions' : {
'Buoy-Math-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Math-GS64-Base-Extensions' : {
'symbolDictName' : 'Globals'
},
'Buoy-Metaprogramming-Extensions' : {
Expand Down
1 change: 1 addition & 0 deletions rowan/components/Tests.ston
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RwSimpleProjectLoadComponentV2 {
'Buoy-Conditions-Tests',
'Buoy-Dynamic-Binding-Tests',
'Buoy-Exception-Handling-Tests',
'Buoy-Math-Tests',
'Buoy-Metaprogramming-Tests',
'Buoy-SUnit-Tests'
],
Expand Down
6 changes: 3 additions & 3 deletions rowan/components/scripts/defineExceptionAliases.st
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
| symbolDictionary |
symbolDictionary := Rowan image
symbolDictNamed:'Buoy'
symbolDictNamed: 'Buoy'
ifAbsent: [
Rowan image symbolList createDictionaryNamed: 'Buoy' at: 1.
Rowan image symbolDictNamed:'Buoy'
Rowan image symbolDictNamed: 'Buoy'
].
symbolDictionary at: #SubscriptOutOfBounds put: OffsetError.
symbolDictionary at: #NotFound put: LookupError.

symbolDictionary at: #ArithmeticError put: NumericError.
18 changes: 16 additions & 2 deletions source/BaselineOfBuoy/BaselineOfBuoy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,20 @@ BaselineOfBuoy >> baselineMath: spec [
spec
package: 'Buoy-Math' with: [ spec requires: 'Buoy-Assertions' ];
group: 'Deployment' with: 'Buoy-Math';
package: 'Buoy-Math-Tests' with: [ spec requires: #('Buoy-Math' 'Dependent-SUnit-Extensions') ];
group: 'Tests' with: 'Buoy-Math-Tests'
package: 'Buoy-Math-Extensions'
with: [ spec requires: 'Buoy-Math' ];
group: 'Deployment' with: 'Buoy-Math-Extensions';
package: 'Buoy-Math-Pharo-Extensions'
with: [ spec requires: 'Buoy-Math' ];
group: 'Deployment' with: 'Buoy-Math-Pharo-Extensions';
package: 'Buoy-Math-Tests' with: [
spec requires:
#( 'Buoy-Math-Extensions' 'Buoy-Math-Pharo-Extensions'
'Dependent-SUnit-Extensions' ) ];
group: 'Tests' with: 'Buoy-Math-Tests';
package: 'Buoy-Math-Pharo-Extensions-Tests' with: [
spec requires: 'Buoy-Math-Tests' ];
group: 'Tests' with: 'Buoy-Math-Pharo-Extensions-Tests'
]

{ #category : #baselines }
Expand All @@ -159,6 +171,8 @@ BaselineOfBuoy >> baselineSUnit: spec [
spec
package: 'Buoy-SUnit-Model';
group: 'Dependent-SUnit-Extensions' with: 'Buoy-SUnit-Model';
package: 'Buoy-SUnit-Pharo-Extensions';
group: 'Dependent-SUnit-Extensions' with: 'Buoy-SUnit-Pharo-Extensions';
package: 'Buoy-SUnit-Tests' with: [ spec requires: 'Dependent-SUnit-Extensions' ];
group: 'Tests' with: 'Buoy-SUnit-Tests'
]
Expand Down
11 changes: 11 additions & 0 deletions source/Buoy-GS64-Compatibility/BinaryFloat.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"
BinaryFloat is an abstract class in GS64, the superclass of different implementations of Binary
floating point.
This version is just a placeholder so we can easily create extensions methods to load in GS64 specific
packages.
"
Class {
#name : #BinaryFloat,
#superclass : #Number,
#category : #'Buoy-GS64-Compatibility'
}
8 changes: 5 additions & 3 deletions source/Buoy-GS64-Compatibility/ClassOrganizer.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"
In GS64, a `ClassOrganizer` can answer queries about classes in the image, provides
tools and reports on information on classes and methods and can perform
cross-referencing and fileout.
In GS64, a `ClassOrganizer` can answer queries about classes in the image, provides tools and reports
on information on classes and methods and can perform cross-referencing and fileout.

This version is just a placeholder so we can easily create extension methods referencing this class
in GS64 specific packages.
"
Class {
#name : #ClassOrganizer,
Expand Down
10 changes: 10 additions & 0 deletions source/Buoy-GS64-Compatibility/Collection.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Extension { #name : #Collection }

{ #category : #'*Buoy-GS64-Compatibility' }
Collection >> any [

"Answer a representative sample of the receiver. It raises an error when the collection is empty. This method can be helpful when needing to preinfer the nature of the contents of semi-homogeneous collections."

self emptyCheck.
self do: [ :each | ^ each ]
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Fraction }

{ #category : #'*Buoy-Math' }
{ #category : #'*Buoy-Math-Extensions' }
Fraction >> adaptToFraction: aFraction andSend: selector [

^self perform: selector with: aFraction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Integer }

{ #category : #'*Buoy-Math' }
{ #category : #'*Buoy-Math-Extensions' }
Integer >> adaptToInteger: anInteger andSend: selector [

^ self perform: selector with: anInteger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #Number }

{ #category : #'*Buoy-Math' }
{ #category : #'*Buoy-Math-Extensions' }
Number >> decreasedBy: aPercentage [

AssertionChecker
Expand All @@ -11,7 +11,7 @@ Number >> decreasedBy: aPercentage [
^ self * (Percentage oneHundred - aPercentage)
]

{ #category : #'*Buoy-Math' }
{ #category : #'*Buoy-Math-Extensions' }
Number >> increasedBy: aPercentage [

AssertionChecker
Expand All @@ -22,19 +22,19 @@ Number >> increasedBy: aPercentage [
^ self * (Percentage oneHundred + aPercentage)
]

{ #category : #'*Buoy-Math' }
{ #category : #'*Buoy-Math-Extensions' }
Number >> isPercentage [

^false
]

{ #category : #'*Buoy-Math' }
{ #category : #'*Buoy-Math-Extensions' }
Number >> perMille [

^ PerMille of: self
]

{ #category : #'*Buoy-Math' }
{ #category : #'*Buoy-Math-Extensions' }
Number >> percent [

^ Percentage of: self
Expand Down
1 change: 1 addition & 0 deletions source/Buoy-Math-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Math-Extensions' }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #BinaryFloat }

{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
BinaryFloat >> isInfinite [

^ self kind = #infinity
]
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Extension { #name : #Integer }

{ #category : #'*Buoy-Math-GS64-Extensions' }
{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
Integer >> hashMultiply [
"No need to do something special in GS64"

^ self
]

{ #category : #'*Buoy-Math-GS64-Extensions' }
{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
Integer >> isInteger [
"True for all subclasses of Integer."

Expand Down
31 changes: 31 additions & 0 deletions source/Buoy-Math-GS64-Base-Extensions/Number.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Extension { #name : #Number }

{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
Number >> asNumber [

^ self
]

{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
Number >> isInteger [

^ false
]

{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
Number >> isZero [

^ self = 0
]

{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
Number >> nthRoot: aPositiveInteger [

^ self raisedTo: aPositiveInteger reciprocal
]

{ #category : #'*Buoy-Math-GS64-Base-Extensions' }
Number >> round: numberOfWishedDecimal [

^ self roundTo: (10 raisedTo: numberOfWishedDecimal negated)
]
1 change: 1 addition & 0 deletions source/Buoy-Math-GS64-Base-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Math-GS64-Base-Extensions' }
13 changes: 0 additions & 13 deletions source/Buoy-Math-GS64-Extensions/Number.extension.st

This file was deleted.

25 changes: 25 additions & 0 deletions source/Buoy-Math-GS64-Extensions/PartsPerFraction.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Extension { #name : #PartsPerFraction }

{ #category : #'*Buoy-Math-GS64-Extensions' }
PartsPerFraction >> _coerce: aNumber [

^self class ratio: (ratio _coerce: aNumber)
]

{ #category : #'*Buoy-Math-GS64-Extensions' }
PartsPerFraction >> _generality [

^ ratio _generality + 1
]

{ #category : #'*Buoy-Math-GS64-Extensions' }
PartsPerFraction >> printOn: stream [

self value printOn: stream
]

{ #category : #'*Buoy-Math-GS64-Extensions' }
PartsPerFraction >> printString [

^ String streamContents: [ :stream | self printOn: stream ]
]
8 changes: 8 additions & 0 deletions source/Buoy-Math-GS64-Extensions/PerMille.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : #PerMille }

{ #category : #'*Buoy-Math-GS64-Extensions' }
PerMille >> printOn: stream [

super printOn: stream.
stream nextPutAll: '‰'
]
8 changes: 8 additions & 0 deletions source/Buoy-Math-GS64-Extensions/Percentage.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : #Percentage }

{ #category : #'*Buoy-Math-GS64-Extensions' }
Percentage >> printOn: stream [

super printOn: stream.
stream nextPut: $%
]
10 changes: 10 additions & 0 deletions source/Buoy-Math-Pharo-Extensions-Tests/PerMilleTest.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Extension { #name : #PerMilleTest }

{ #category : #'*Buoy-Math-Pharo-Extensions-Tests' }
PerMilleTest >> testStoreOnBase [

self
assert: ( 0 perMille storeStringBase: 16 ) equals: '16r0 perMille';
assert: ( 1000 perMille storeStringBase: 16 ) equals: '16r3E8 perMille';
assert: ( ( PerMille of: 12 ) storeStringBase: 16 ) equals: '16rC perMille'
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Extension { #name : #PercentageTest }

{ #category : #'*Buoy-Math-Pharo-Extensions-Tests' }
PercentageTest >> testStoreOnBase [

self
assert: ( Percentage zero storeStringBase: 16 ) equals: 'Percentage zero';
assert: ( Percentage oneHundred storeStringBase: 16 ) equals: 'Percentage oneHundred';
assert: ( ( Percentage of: 12 ) storeStringBase: 16 ) equals: 'Percentage of: 16rC'
]
1 change: 1 addition & 0 deletions source/Buoy-Math-Pharo-Extensions-Tests/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Math-Pharo-Extensions-Tests' }
13 changes: 13 additions & 0 deletions source/Buoy-Math-Pharo-Extensions/PartsPerFraction.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #PartsPerFraction }

{ #category : #'*Buoy-Math-Pharo-Extensions' }
PartsPerFraction >> adaptToFraction: aFraction andSend: selector [

^ aFraction adaptToFraction: ratio andSend: selector
]

{ #category : #'*Buoy-Math-Pharo-Extensions' }
PartsPerFraction >> adaptToInteger: anInteger andSend: aSymbol [

^anInteger adaptToInteger: ratio andSend: aSymbol
]
17 changes: 17 additions & 0 deletions source/Buoy-Math-Pharo-Extensions/PerMille.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Extension { #name : #PerMille }

{ #category : #'*Buoy-Math-Pharo-Extensions' }
PerMille >> printOn: aStream base: anInteger [

self value printOn: aStream base: anInteger.
aStream nextPut: $‰
]

{ #category : #'*Buoy-Math-Pharo-Extensions' }
PerMille >> storeOn: aStream base: base [

self value storeOn: aStream base: base.
aStream
space;
nextPutAll: 'perMille'
]
22 changes: 22 additions & 0 deletions source/Buoy-Math-Pharo-Extensions/Percentage.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Extension { #name : #Percentage }

{ #category : #'*Buoy-Math-Pharo-Extensions' }
Percentage >> printOn: aStream base: anInteger [

self value printOn: aStream base: anInteger.
aStream nextPut: $%
]

{ #category : #'*Buoy-Math-Pharo-Extensions' }
Percentage >> storeOn: aStream base: base [

self isWellKnown ifTrue: [ self storeOn: aStream ]
ifFalse: [
aStream
nextPutAll: self class name asString;
space;
nextPutAll: 'of:';
space.
self value storeOn: aStream base: base
]
]
1 change: 1 addition & 0 deletions source/Buoy-Math-Pharo-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Buoy-Math-Pharo-Extensions' }
2 changes: 1 addition & 1 deletion source/Buoy-Math-Tests/BuoyNumberExtensionsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ I'm a Test Case for the extensions defined in this package to Number.
Class {
#name : #BuoyNumberExtensionsTest,
#superclass : #TestCase,
#category : 'Buoy-Math-Tests'
#category : #'Buoy-Math-Tests'
}

{ #category : #tests }
Expand Down
Loading
Loading