Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 9 additions & 8 deletions src/Math-Tests-Accuracy/PMAccuracyFindKeyTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@
This test case exercises the findKey: message with some regression tests.
"
Class {
#name : #PMAccuracyFindKeyTest,
#superclass : #TestCase,
#name : 'PMAccuracyFindKeyTest',
#superclass : 'TestCase',
#instVars : [
'accuracy'
],
#category : #'Math-Tests-Accuracy'
#category : 'Math-Tests-Accuracy',
#package : 'Math-Tests-Accuracy'
}

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyFindKeyTest >> assertKeyFor: selector equals: expected [
self assert: (accuracy findKey: selector) equals: expected
]

{ #category : #running }
{ #category : 'running' }
PMAccuracyFindKeyTest >> setUp [
super setUp.
accuracy := PMAccuracyTestExample new
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorCorrespondsToNonExistentProperty [
| selector |
selector := 'NonExistent'.

self assertKeyFor: selector equals: 'AllTheRest'
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorIsInitialize [
| selector |
selector := 'initialize'.

self assertKeyFor: selector equals: 'AllTheRest'
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyFindKeyTest >> testFindKeyReturnsPropertyWhenSelectorIsSuffixOfInitializePropertyMessage [
| selector |
selector := 'Aaa'.
Expand Down
63 changes: 32 additions & 31 deletions src/Math-Tests-Accuracy/PMAccuracyTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,44 @@
AccuracyTest uses AccuracyTestExample
"
Class {
#name : #PMAccuracyTest,
#superclass : #TestCase,
#name : 'PMAccuracyTest',
#superclass : 'TestCase',
#instVars : [
'a',
'dp'
],
#category : #'Math-Tests-Accuracy'
#category : 'Math-Tests-Accuracy',
#package : 'Math-Tests-Accuracy'
}

{ #category : #initialization }
{ #category : 'initialization' }
PMAccuracyTest >> initialize [
super initialize.
dp := PMAccuracyTestExample decimalPlaces
]

{ #category : #running }
{ #category : 'running' }
PMAccuracyTest >> setUp [
super setUp.
a := PMAccuracyTestExample new.
PMAccuracyTestExample decimalPlaces: 3
]

{ #category : #running }
{ #category : 'running' }
PMAccuracyTest >> tearDown [
PMAccuracyTestExample decimalPlaces: dp.
super tearDown
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testArgumentAt [
self assert: (a argumentAt: 'Aaa') equals: #(#(false) #(true)).
self assert: (a argumentAt: 'Bbb') equals: #(#('a') #('AG')).
self assert: (a argumentAt: 'Ddd') isNil.
self assert: (a argumentAt: 'Ccc') equals: #(#(1) #(1.1) #(0.9))
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testAsArray [
self assert: (a asArray: 'bla') equals: #('bla').
self assert: (a asArray: #('bla')) equals: #('bla').
Expand All @@ -47,7 +48,7 @@ PMAccuracyTest >> testAsArray [
equals: #('bla')
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testCalcDeviationsInMax [
| r c |
c := #(#(1 2 3) #(2 3 6)).
Expand All @@ -60,7 +61,7 @@ PMAccuracyTest >> testCalcDeviationsInMax [
equals: (Array with: (100 / 3) asFloat with: (100 / 3) asFloat with: 50)
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testCalcErrorOfRealResult [
self assert: (a calcErrorOf: 0.7 realResult: 0.7) equals: 0.
self assert: (a calcErrorOf: 0.7 realResult: 0.0) equals: -100.
Expand All @@ -74,14 +75,14 @@ PMAccuracyTest >> testCalcErrorOfRealResult [
equals: Float infinity negated
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testDecimalPlaces [
self assert: a class decimalPlaces equals: 3.
a class decimalPlaces: 2.
self assert: a class decimalPlaces equals: 2
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testExtractFromResultsReturnsAllElementsWhenOnlyOneIsTrue [
| argument results |
results := a
Expand All @@ -94,7 +95,7 @@ PMAccuracyTest >> testExtractFromResultsReturnsAllElementsWhenOnlyOneIsTrue [
self assert: argument equals: #(#(false) #(true))
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testExtractFromResultsReturnsTheCorrectIndexedElementWhenOnlyOneIsFalse [
| argument results |
results := a
Expand All @@ -107,7 +108,7 @@ PMAccuracyTest >> testExtractFromResultsReturnsTheCorrectIndexedElementWhenOnlyO
self assert: argument equals: #(true)
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testExtremeCollectionmax [
| c |
c := #(4 4 2).
Expand All @@ -122,7 +123,7 @@ PMAccuracyTest >> testExtremeCollectionmax [
equals: (Array with: Float infinity with: Float infinity with: Float infinity)
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testFormat [
self
assert: (a format: #(1 'rez' 1.8899))
Expand All @@ -134,7 +135,7 @@ PMAccuracyTest >> testFormat [
self assert: (a format: 0 - Float infinity) equals: #('-Infinity')
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testFormatTypePostfix [
| r |
r := a format: #(1 'rez' 1.8899) type: 'x' postfix: '%%'.
Expand All @@ -145,7 +146,7 @@ PMAccuracyTest >> testFormatTypePostfix [
equals: 'x: 1.0%% , rez%% , 1.89%% : 1.89 , true '
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testFormatTypePostfixTree [
| t |
t := KeyedTree new.
Expand All @@ -165,7 +166,7 @@ PMAccuracyTest >> testFormatTypePostfixTree [
yourself)
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testGetters [

| r |
Expand All @@ -175,15 +176,15 @@ PMAccuracyTest >> testGetters [
self assert: r equals: #( #( #( 1 ) #( 3 ) ) #( #( 'a' ) #( 'AG' ) ) #( #( 2 ) #( 3 ) ) 2 2 )
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testIfSeveralterations [
a iterations: 2.
self assert: (a ifSeveralterations: [ 1 ]) equals: 1.
a iterations: 1.
self assert: (a ifSeveralterations: [ 1 ]) equals: a
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testIterations [

| s d |
Expand All @@ -199,18 +200,18 @@ PMAccuracyTest >> testIterations [
self assert: (d atPath: #( 'Ddd' 'data' )) equals: #( #( 2 3 ) #( 2 3 ) ).
s := d atPath: #( 'Ddd' 'error' ).
self assert: s first closeTo: -45.
self assert: s second closeTo: -26.6666667
self assert: s second closeTo: -26.6666667 precision: 0.00001
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testNumberOfDifferentParametersAt [
self assert: (a numberOfDifferentParametersAt: 'Aaa') equals: 2.
self assert: (a numberOfDifferentParametersAt: 'Ccc') equals: 2.
self assert: (a numberOfDifferentParametersAt: 'Ddd') equals: 1.
self assert: (a numberOfDifferentParametersAt: 'Fff') equals: 1
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testNumberOfDifferentResultsAt [
self assert: (a numberOfDifferentResultsAt: 'Aaa') equals: 2.
self assert: (a numberOfDifferentResultsAt: 'Bbb') equals: 2.
Expand All @@ -219,15 +220,15 @@ PMAccuracyTest >> testNumberOfDifferentResultsAt [
self assert: (a numberOfDifferentResultsAt: 'Eee') equals: 2
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testParameterAt [
self assert: (a parameterAt: 'Aaa') equals: #(#(1 2) #(3 2.8888)).
self assert: (a parameterAt: 'Bbb') equals: #(#(1) #(3)).
self assert: (a parameterAt: 'Ddd') isNil.
self assert: (a parameterAt: 'Fff') isNil
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testPrintOn [
| s |
s := WriteStream on: String new.
Expand All @@ -244,14 +245,14 @@ PMAccuracyTest >> testPrintOn [
Report for: PMAccuracyTestExample')
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testReport [
self assert: a report equals: ''.
a run.
self assert: (a report beginsWith: 'Report for: PMAccuracyTestExample')
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testResultsKeyForAtPosition [
self assert: (a resultsKeyFor: 'Aaa' AtPosition: 2) equals: #(4 4).
self assert: (a resultsKeyFor: 'Bbb' AtPosition: 1) equals: #(2).
Expand Down Expand Up @@ -284,7 +285,7 @@ PMAccuracyTest >> testResultsKeyForAtPosition [
equals: #(0 1 0 -2 3)
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testRun [
a run.
a run: 'Bbb'.
Expand All @@ -301,7 +302,7 @@ test Bbb').
equals: #('Ccc' 'Eee')
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testSetUp [
self assert: a count equals: 0.
a performCheck: 'Fff'.
Expand All @@ -311,7 +312,7 @@ PMAccuracyTest >> testSetUp [
self assert: a count equals: 16 / 5
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testTreeTypeData [
| aTree |
aTree := KeyedTree new.
Expand All @@ -325,7 +326,7 @@ PMAccuracyTest >> testTreeTypeData [
yourself)
]

{ #category : #tests }
{ #category : 'tests' }
PMAccuracyTest >> testperformCheck [
| b |
a extractFromResults: 'bla' which: 2 onlyOne: false. "for setting numberOfResults"
Expand Down
Loading
Loading