diff --git a/src/Math-Tests-Accuracy/PMAccuracyTest.class.st b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st index d0f5409bb..929834561 100644 --- a/src/Math-Tests-Accuracy/PMAccuracyTest.class.st +++ b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st @@ -19,15 +19,16 @@ PMAccuracyTest >> initialize [ ] { #category : #running } -PMAccuracyTest >> setUp [ +PMAccuracyTest >> setUp [ + super setUp. a := PMAccuracyTestExample new. - PMAccuracyTestExample decimalPlaces: 3. + PMAccuracyTestExample decimalPlaces: 3 ] { #category : #running } -PMAccuracyTest >> tearDown [ +PMAccuracyTest >> tearDown [ PMAccuracyTestExample decimalPlaces: dp. - + super tearDown. ] { #category : #tests } @@ -74,40 +75,6 @@ PMAccuracyTest >> testCalcErrorOfRealResult [ equals: Float infinity negated ] -{ #category : #tests } -PMAccuracyTest >> testDataTree [ - | s | - a run. - self assert: (a dataTree atPath: #('iterations')) equals: 1. - self - assert: (a dataTree atPath: #('names' 'data')) - equals: #('Aaa' 'Bbb' 'Ccc' 'Ddd' 'Eee' 'Fff'). - self - assert: (a dataTree atPath: #('names' 'Aaa' #(1 2) #(4 4))) - equals: - (KeyedTree new - at: 'arguments' put: true; - at: 'data' put: #(#(1 1)); - at: 'error' put: #(300.0 300.0); - at: 'expected result' put: #(4 4); - at: 'result' put: #(1 1); - at: 'type' put: 'result'; - yourself). - self - assert: (a dataTree atPath: #('names' 'Aaa' 'data')) - equals: #(#(1 2) #(3 2.8888)). - self - assert: (a dataTree atPath: #('names' 'Bbb' #(3) 'data')) - equals: #(#(2) #(3)). - s := a dataTree atPath: #('names' 'Ccc' #(3)). - self assert: s keys size equals: 5. - s := a dataTree atPath: #('names' 'Fff' 'error'). - self - assert: (s copyFrom: 1 to: 4) - equals: (Array with: 0 with: Float infinity with: -100.0 with: Float infinity negated). - self assert: (s at: 5) isNaN -] - { #category : #tests } PMAccuracyTest >> testDecimalPlaces [ self assert: a class decimalPlaces equals: 3. diff --git a/src/Math-Tests-Accuracy/PMDataTreeTest.class.st b/src/Math-Tests-Accuracy/PMDataTreeTest.class.st new file mode 100644 index 000000000..4de3357a0 --- /dev/null +++ b/src/Math-Tests-Accuracy/PMDataTreeTest.class.st @@ -0,0 +1,116 @@ +" +Class Name: PMDataTreeTest + +Responsibility: exercising the PMAccuracyTestExample's +dataTree message + +Collaborators: PMAccuracyTestExample +" +Class { + #name : #PMDataTreeTest, + #superclass : #TestCase, + #instVars : [ + 'dp', + 'a' + ], + #category : #'Math-Tests-Accuracy' +} + +{ #category : #initialization } +PMDataTreeTest >> initialize [ + super initialize. + dp := PMAccuracyTestExample decimalPlaces +] + +{ #category : #running } +PMDataTreeTest >> setUp [ + super setUp. + a := PMAccuracyTestExample new. + PMAccuracyTestExample decimalPlaces: 3. +] + +{ #category : #running } +PMDataTreeTest >> tearDown [ + PMAccuracyTestExample decimalPlaces: dp. + super tearDown. +] + +{ #category : #tests } +PMDataTreeTest >> testDataTree [ + | keyedTree | + a run. + keyedTree := a dataTree atPath: #('names' 'Ccc' #(3)). + self assert: keyedTree keys size equals: 5. +] + +{ #category : #tests } +PMDataTreeTest >> testThatDataForAaaIsTheCorrespondingParameter [ + | parameterForAaa | + a run. + + parameterForAaa := #(#(1 2) #(3 2.8888)). + self + assert: (a dataTree atPath: #('names' 'Aaa' 'data')) + equals: parameterForAaa. +] + +{ #category : #tests } +PMDataTreeTest >> testThatKeyedTreeContainsArgsDataErrorResultsAndType [ + "SMELL - it's not easy to determine the true purpose of the + test and, perhaps with the exception of the 'expected result', + how input leads to the output. The test also contains many + 'magic' numbers. + " + a run. + self + assert: (a dataTree atPath: #('names' 'Aaa' #(1 2) #(4 4))) + equals: + (KeyedTree new + at: 'arguments' put: true; + at: 'data' put: #(#(1 1)); + at: 'error' put: #(300.0 300.0); + at: 'expected result' put: #(4 4); + at: 'result' put: #(1 1); + at: 'type' put: 'result'; + yourself) +] + +{ #category : #tests } +PMDataTreeTest >> testThatRunIncrementsTheNumberOfIterations [ + "SMELL - we're really testing run, it seems." + a run. + self assert: (a dataTree atPath: #('iterations')) equals: 1. +] + +{ #category : #tests } +PMDataTreeTest >> testThatTheDataForBbbIsTheDefaultResult [ + "SMELL - magic number. This may be coincidental, but the + expected result in this test is that set in + PMAccuracyTestExample's initialize method. + " + | defaultResultAtInitialisation | + a run. + defaultResultAtInitialisation := #(#(2) #(3)). + self + assert: (a dataTree atPath: #('names' 'Bbb' #(3) 'data')) + equals: defaultResultAtInitialisation +] + +{ #category : #tests } +PMDataTreeTest >> testThatTheErrorForFffIsCorrect [ + | error | + a run. + error := a dataTree atPath: #('names' 'Fff' 'error'). + self + assert: (error copyFrom: 1 to: 4) + equals: (Array with: 0 with: Float infinity with: -100.0 with: Float infinity negated). + self assert: (error at: 5) isNaN. +] + +{ #category : #tests } +PMDataTreeTest >> testThatTheNamesAreInitialisationKeys [ + a run. + self + assert: (a dataTree atPath: #('names' 'data')) + equals: #('Aaa' 'Bbb' 'Ccc' 'Ddd' 'Eee' 'Fff') +]