Skip to content

Commit

Permalink
Merge a4b6eb5 into 66f3b3a
Browse files Browse the repository at this point in the history
  • Loading branch information
hemalvarambhia committed Dec 28, 2019
2 parents 66f3b3a + a4b6eb5 commit 1f209fe
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 38 deletions.
43 changes: 5 additions & 38 deletions src/Math-Tests-Accuracy/PMAccuracyTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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.
Expand Down
116 changes: 116 additions & 0 deletions src/Math-Tests-Accuracy/PMDataTreeTest.class.st
Original file line number Diff line number Diff line change
@@ -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')
]

0 comments on commit 1f209fe

Please sign in to comment.