Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6c96651
[issue-106] Improved message names.
hemalvarambhia Jul 7, 2019
8cdadd5
[issue-106] The happy path should not be the guard clause; normally t…
hemalvarambhia Jul 7, 2019
79ce907
[issue-106] Improved the name of the block variable.
hemalvarambhia Jul 7, 2019
81967ac
[issue-106] Moved related code closer together. initRest goes on to p…
hemalvarambhia Jul 7, 2019
d2596fc
[issue-106] The asString message send is redundant.
hemalvarambhia Jul 7, 2019
ce8ccbe
[issue-106] Improved the name of the temp variable.
hemalvarambhia Jul 7, 2019
8b100f2
[issue-106] Improved the names of the block variables.
hemalvarambhia Jul 7, 2019
0183720
[issue-106] The asString is redundant as the tests remain green.
hemalvarambhia Jul 7, 2019
fdc4862
[issue-106] Extracted code to an intention-revealing method.
hemalvarambhia Jul 9, 2019
545dd06
[issue-106] Simplified the calculation of the occurence of a key.
hemalvarambhia Jul 9, 2019
71b5377
[issue-106] Inlined the temporary variable as it is now redundant.
hemalvarambhia Jul 9, 2019
91ef7e1
[issue-106] Extracted an code to an intention-revealing local temp an…
hemalvarambhia Jul 12, 2019
dc4a0d6
[issue-106] Inlined the variable as it over wrote the earlier assignm…
hemalvarambhia Jul 12, 2019
234ed44
[issue-106] The initialize call looks like a special case, so transfo…
hemalvarambhia Jul 12, 2019
1a2af4e
[issue-106] Improved code formatting.
hemalvarambhia Jul 12, 2019
f40c4d8
[issue-106] The check is redundant now because we have got passed the…
hemalvarambhia Jul 12, 2019
a71833c
[issue-106] The nil check is unnecessary now given the ifNone: call. …
hemalvarambhia Jul 13, 2019
d6b5105
[issue-106] Reverted the change as we are only concatenating two stri…
hemalvarambhia Jul 13, 2019
c497a3d
[issue-106] Removed obselete code.
hemalvarambhia Jul 16, 2019
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
58 changes: 30 additions & 28 deletions src/Math-Accuracy-Core/PMAccuracy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,15 @@ PMAccuracy >> extremeCollection: acol max:aBoolean [

{ #category : #private }
PMAccuracy >> findKey [
| s m |
| s selector matchingMessage |
s := thisContext sender.
m := s sender method selector .
^(names detect: [:n| m asString endsWith: n] ifNone: [nil])
ifNil: [ m='initialize'
ifTrue: ['AllTheRest']
ifFalse: [ m := s method selector asString.
self error: m,' called in wrong context'] ]
selector := s sender method selector.
selector = 'initialize'
ifTrue: [ ^ 'AllTheRest' ].
matchingMessage := names
detect: [ :name | selector endsWith: name ]
ifNone: [ '' ].
^ matchingMessage
]

{ #category : #printing }
Expand Down Expand Up @@ -252,31 +253,33 @@ PMAccuracy >> ifSeveralterations: aBlock [
]

{ #category : #'initialize-release' }
PMAccuracy >> initNames [
names := (self class allSelectorsBelow: Object)
select: [ :s | s beginsWith: #check ]
thenCollect: [ :s | s copyFrom: 6 to: s size ].
names := names asArray sort
PMAccuracy >> initRest: aName [
| initializationMessage |
initializationMessage := ('initialize' , aName) asSymbol.
(self respondsTo: initializationMessage)
ifFalse: [ ^ self ].
self perform: initializationMessage
]

{ #category : #'initialize-release' }
PMAccuracy >> initRest: aName [
| i |
i := ('initialize' , aName) asSymbol.
(self respondsTo: i)
ifTrue: [ self perform: i ]
PMAccuracy >> initSubclassSelectorNames [
names := (self class allSelectorsBelow: Object)
select: [ :selectorName | selectorName beginsWith: #check ]
thenCollect: [ :selectorName | selectorName copyFrom: 6 to: selectorName size ].
names := names asArray sort
]

{ #category : #'initialize-release' }
PMAccuracy >> initialize [
self initNames.
parameters := Dictionary new.
arguments := Dictionary new.
results := Dictionary new.
self initSubclassSelectorNames.
names do: [ :name | self initRest: name ].
aStream := WriteStream with: ''.
iterations := 1.
dataTree := KeyedTree new .
names do: [ :n | self initRest: n ]
dataTree := KeyedTree new.

]

{ #category : #accessing }
Expand All @@ -303,6 +306,11 @@ PMAccuracy >> numberOfDifferentResultsAt: aname [
^ no first isCollection ifTrue: [ no size ] ifFalse: [ 1 ]
]

{ #category : #accessing }
PMAccuracy >> occurrencesOf: key In: aResults UpTo: anInteger [
^ (aResults copyFrom: 1 to: anInteger) occurrencesOf: key
]

{ #category : #accessing }
PMAccuracy >> parameter [
| r |
Expand Down Expand Up @@ -394,15 +402,9 @@ PMAccuracy >> resultsKeyFor: aName AtPosition: anInteger [
key := aResults at: anInteger.
key isArray
ifFalse: [ ^ aResults ].
repetitions := 0.
aResults
from: 1
to: anInteger - 1
do: [ :i |
i = key
ifTrue: [ repetitions := repetitions + 1 ] ].
repetitions := self occurrencesOf: key In: aResults UpTo: anInteger - 1.
result := (Array new: key size + repetitions)
replaceFrom: 1
replaceFrom: 1
to: key size
with: key
startingAt: 1.
Expand Down
15 changes: 0 additions & 15 deletions src/Math-Tests-Accuracy/PMAccuracyTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ PMAccuracyTest >> testArgumentAt [
self assert: (a argumentAt: 'Ccc') equals: #(#(1) #(1.1) #(0.9))
]

{ #category : #tests }
PMAccuracyTest >> testArgumentError [
self should: [ a testArgumentError ] raise: Error
]

{ #category : #tests }
PMAccuracyTest >> testAsArray [
self assert: (a asArray: 'bla') equals: #('bla').
Expand Down Expand Up @@ -271,11 +266,6 @@ PMAccuracyTest >> testParameterAt [
self assert: (a parameterAt: 'Fff') isNil
]

{ #category : #tests }
PMAccuracyTest >> testParameterError [
self should: [a testParameterError ]raise: Error
]

{ #category : #tests }
PMAccuracyTest >> testPrintOn [
| s |
Expand All @@ -300,11 +290,6 @@ PMAccuracyTest >> testReport [
self assert: (a report beginsWith: 'Report for: PMAccuracyTestExample')
]

{ #category : #tests }
PMAccuracyTest >> testResultError [
self should: [a testResultError ]raise: Error
]

{ #category : #tests }
PMAccuracyTest >> testResultsKeyForAtPosition [
self assert: (a resultsKeyFor: 'Aaa' AtPosition: 2) equals: #(4 4).
Expand Down
15 changes: 0 additions & 15 deletions src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ PMAccuracyTestExample >> tearDown [
count :=count-(1/5).
]

{ #category : #private }
PMAccuracyTestExample >> testArgumentError [
self argument: #(#(1) #(2)).
]

{ #category : #private }
PMAccuracyTestExample >> testGetterAaa [
^{ self parameter .self argument.self resultsAt: 'Aaa'.self numberOfDifferentParametersAt: 'Aaa'.self numberOfDifferentResultsAt:'Aaa'}
Expand All @@ -124,13 +119,3 @@ PMAccuracyTestExample >> testGetterAaa [
PMAccuracyTestExample >> testGetterBbb [
^{ self parameter .self argument.self resultsAt: 'Bbb'.self numberOfDifferentParametersAt: 'Bbb'.self numberOfDifferentResultsAt:'Bbb'}
]

{ #category : #private }
PMAccuracyTestExample >> testParameterError [
self parameter: #(#(1) #(2)).
]

{ #category : #private }
PMAccuracyTestExample >> testResultError [
self result:#(1).
]