Skip to content

Commit 9e0964e

Browse files
authored
Merge pull request #331 from jordanmontt/fixed-several-tests-due-to-float-precision
Fixed several tests due to float precision
2 parents d8d6fc0 + aff39d0 commit 9e0964e

File tree

72 files changed

+1020
-882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1020
-882
lines changed

src/Math-Tests-Accuracy/PMAccuracyFindKeyTest.class.st

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,43 @@
22
This test case exercises the findKey: message with some regression tests.
33
"
44
Class {
5-
#name : #PMAccuracyFindKeyTest,
6-
#superclass : #TestCase,
5+
#name : 'PMAccuracyFindKeyTest',
6+
#superclass : 'TestCase',
77
#instVars : [
88
'accuracy'
99
],
10-
#category : #'Math-Tests-Accuracy'
10+
#category : 'Math-Tests-Accuracy',
11+
#package : 'Math-Tests-Accuracy'
1112
}
1213

13-
{ #category : #tests }
14+
{ #category : 'tests' }
1415
PMAccuracyFindKeyTest >> assertKeyFor: selector equals: expected [
1516
self assert: (accuracy findKey: selector) equals: expected
1617
]
1718

18-
{ #category : #running }
19+
{ #category : 'running' }
1920
PMAccuracyFindKeyTest >> setUp [
2021
super setUp.
2122
accuracy := PMAccuracyTestExample new
2223
]
2324

24-
{ #category : #tests }
25+
{ #category : 'tests' }
2526
PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorCorrespondsToNonExistentProperty [
2627
| selector |
2728
selector := 'NonExistent'.
2829

2930
self assertKeyFor: selector equals: 'AllTheRest'
3031
]
3132

32-
{ #category : #tests }
33+
{ #category : 'tests' }
3334
PMAccuracyFindKeyTest >> testFindKeyReturnsAllTheRestStringWhenSelectorIsInitialize [
3435
| selector |
3536
selector := 'initialize'.
3637

3738
self assertKeyFor: selector equals: 'AllTheRest'
3839
]
3940

40-
{ #category : #tests }
41+
{ #category : 'tests' }
4142
PMAccuracyFindKeyTest >> testFindKeyReturnsPropertyWhenSelectorIsSuffixOfInitializePropertyMessage [
4243
| selector |
4344
selector := 'Aaa'.

src/Math-Tests-Accuracy/PMAccuracyTest.class.st

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,44 @@
22
AccuracyTest uses AccuracyTestExample
33
"
44
Class {
5-
#name : #PMAccuracyTest,
6-
#superclass : #TestCase,
5+
#name : 'PMAccuracyTest',
6+
#superclass : 'TestCase',
77
#instVars : [
88
'a',
99
'dp'
1010
],
11-
#category : #'Math-Tests-Accuracy'
11+
#category : 'Math-Tests-Accuracy',
12+
#package : 'Math-Tests-Accuracy'
1213
}
1314

14-
{ #category : #initialization }
15+
{ #category : 'initialization' }
1516
PMAccuracyTest >> initialize [
1617
super initialize.
1718
dp := PMAccuracyTestExample decimalPlaces
1819
]
1920

20-
{ #category : #running }
21+
{ #category : 'running' }
2122
PMAccuracyTest >> setUp [
2223
super setUp.
2324
a := PMAccuracyTestExample new.
2425
PMAccuracyTestExample decimalPlaces: 3
2526
]
2627

27-
{ #category : #running }
28+
{ #category : 'running' }
2829
PMAccuracyTest >> tearDown [
2930
PMAccuracyTestExample decimalPlaces: dp.
3031
super tearDown
3132
]
3233

33-
{ #category : #tests }
34+
{ #category : 'tests' }
3435
PMAccuracyTest >> testArgumentAt [
3536
self assert: (a argumentAt: 'Aaa') equals: #(#(false) #(true)).
3637
self assert: (a argumentAt: 'Bbb') equals: #(#('a') #('AG')).
3738
self assert: (a argumentAt: 'Ddd') isNil.
3839
self assert: (a argumentAt: 'Ccc') equals: #(#(1) #(1.1) #(0.9))
3940
]
4041

41-
{ #category : #tests }
42+
{ #category : 'tests' }
4243
PMAccuracyTest >> testAsArray [
4344
self assert: (a asArray: 'bla') equals: #('bla').
4445
self assert: (a asArray: #('bla')) equals: #('bla').
@@ -47,7 +48,7 @@ PMAccuracyTest >> testAsArray [
4748
equals: #('bla')
4849
]
4950

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

63-
{ #category : #tests }
64+
{ #category : 'tests' }
6465
PMAccuracyTest >> testCalcErrorOfRealResult [
6566
self assert: (a calcErrorOf: 0.7 realResult: 0.7) equals: 0.
6667
self assert: (a calcErrorOf: 0.7 realResult: 0.0) equals: -100.
@@ -74,14 +75,14 @@ PMAccuracyTest >> testCalcErrorOfRealResult [
7475
equals: Float infinity negated
7576
]
7677

77-
{ #category : #tests }
78+
{ #category : 'tests' }
7879
PMAccuracyTest >> testDecimalPlaces [
7980
self assert: a class decimalPlaces equals: 3.
8081
a class decimalPlaces: 2.
8182
self assert: a class decimalPlaces equals: 2
8283
]
8384

84-
{ #category : #tests }
85+
{ #category : 'tests' }
8586
PMAccuracyTest >> testExtractFromResultsReturnsAllElementsWhenOnlyOneIsTrue [
8687
| argument results |
8788
results := a
@@ -94,7 +95,7 @@ PMAccuracyTest >> testExtractFromResultsReturnsAllElementsWhenOnlyOneIsTrue [
9495
self assert: argument equals: #(#(false) #(true))
9596
]
9697

97-
{ #category : #tests }
98+
{ #category : 'tests' }
9899
PMAccuracyTest >> testExtractFromResultsReturnsTheCorrectIndexedElementWhenOnlyOneIsFalse [
99100
| argument results |
100101
results := a
@@ -107,7 +108,7 @@ PMAccuracyTest >> testExtractFromResultsReturnsTheCorrectIndexedElementWhenOnlyO
107108
self assert: argument equals: #(true)
108109
]
109110

110-
{ #category : #tests }
111+
{ #category : 'tests' }
111112
PMAccuracyTest >> testExtremeCollectionmax [
112113
| c |
113114
c := #(4 4 2).
@@ -122,7 +123,7 @@ PMAccuracyTest >> testExtremeCollectionmax [
122123
equals: (Array with: Float infinity with: Float infinity with: Float infinity)
123124
]
124125

125-
{ #category : #tests }
126+
{ #category : 'tests' }
126127
PMAccuracyTest >> testFormat [
127128
self
128129
assert: (a format: #(1 'rez' 1.8899))
@@ -134,7 +135,7 @@ PMAccuracyTest >> testFormat [
134135
self assert: (a format: 0 - Float infinity) equals: #('-Infinity')
135136
]
136137

137-
{ #category : #tests }
138+
{ #category : 'tests' }
138139
PMAccuracyTest >> testFormatTypePostfix [
139140
| r |
140141
r := a format: #(1 'rez' 1.8899) type: 'x' postfix: '%%'.
@@ -145,7 +146,7 @@ PMAccuracyTest >> testFormatTypePostfix [
145146
equals: 'x: 1.0%% , rez%% , 1.89%% : 1.89 , true '
146147
]
147148

148-
{ #category : #tests }
149+
{ #category : 'tests' }
149150
PMAccuracyTest >> testFormatTypePostfixTree [
150151
| t |
151152
t := KeyedTree new.
@@ -165,7 +166,7 @@ PMAccuracyTest >> testFormatTypePostfixTree [
165166
yourself)
166167
]
167168

168-
{ #category : #tests }
169+
{ #category : 'tests' }
169170
PMAccuracyTest >> testGetters [
170171

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

178-
{ #category : #tests }
179+
{ #category : 'tests' }
179180
PMAccuracyTest >> testIfSeveralterations [
180181
a iterations: 2.
181182
self assert: (a ifSeveralterations: [ 1 ]) equals: 1.
182183
a iterations: 1.
183184
self assert: (a ifSeveralterations: [ 1 ]) equals: a
184185
]
185186

186-
{ #category : #tests }
187+
{ #category : 'tests' }
187188
PMAccuracyTest >> testIterations [
188189

189190
| s d |
@@ -199,18 +200,18 @@ PMAccuracyTest >> testIterations [
199200
self assert: (d atPath: #( 'Ddd' 'data' )) equals: #( #( 2 3 ) #( 2 3 ) ).
200201
s := d atPath: #( 'Ddd' 'error' ).
201202
self assert: s first closeTo: -45.
202-
self assert: s second closeTo: -26.6666667
203+
self assert: s second closeTo: -26.6666667 precision: 0.00001
203204
]
204205

205-
{ #category : #tests }
206+
{ #category : 'tests' }
206207
PMAccuracyTest >> testNumberOfDifferentParametersAt [
207208
self assert: (a numberOfDifferentParametersAt: 'Aaa') equals: 2.
208209
self assert: (a numberOfDifferentParametersAt: 'Ccc') equals: 2.
209210
self assert: (a numberOfDifferentParametersAt: 'Ddd') equals: 1.
210211
self assert: (a numberOfDifferentParametersAt: 'Fff') equals: 1
211212
]
212213

213-
{ #category : #tests }
214+
{ #category : 'tests' }
214215
PMAccuracyTest >> testNumberOfDifferentResultsAt [
215216
self assert: (a numberOfDifferentResultsAt: 'Aaa') equals: 2.
216217
self assert: (a numberOfDifferentResultsAt: 'Bbb') equals: 2.
@@ -219,15 +220,15 @@ PMAccuracyTest >> testNumberOfDifferentResultsAt [
219220
self assert: (a numberOfDifferentResultsAt: 'Eee') equals: 2
220221
]
221222

222-
{ #category : #tests }
223+
{ #category : 'tests' }
223224
PMAccuracyTest >> testParameterAt [
224225
self assert: (a parameterAt: 'Aaa') equals: #(#(1 2) #(3 2.8888)).
225226
self assert: (a parameterAt: 'Bbb') equals: #(#(1) #(3)).
226227
self assert: (a parameterAt: 'Ddd') isNil.
227228
self assert: (a parameterAt: 'Fff') isNil
228229
]
229230

230-
{ #category : #tests }
231+
{ #category : 'tests' }
231232
PMAccuracyTest >> testPrintOn [
232233
| s |
233234
s := WriteStream on: String new.
@@ -244,14 +245,14 @@ PMAccuracyTest >> testPrintOn [
244245
Report for: PMAccuracyTestExample')
245246
]
246247

247-
{ #category : #tests }
248+
{ #category : 'tests' }
248249
PMAccuracyTest >> testReport [
249250
self assert: a report equals: ''.
250251
a run.
251252
self assert: (a report beginsWith: 'Report for: PMAccuracyTestExample')
252253
]
253254

254-
{ #category : #tests }
255+
{ #category : 'tests' }
255256
PMAccuracyTest >> testResultsKeyForAtPosition [
256257
self assert: (a resultsKeyFor: 'Aaa' AtPosition: 2) equals: #(4 4).
257258
self assert: (a resultsKeyFor: 'Bbb' AtPosition: 1) equals: #(2).
@@ -284,7 +285,7 @@ PMAccuracyTest >> testResultsKeyForAtPosition [
284285
equals: #(0 1 0 -2 3)
285286
]
286287

287-
{ #category : #tests }
288+
{ #category : 'tests' }
288289
PMAccuracyTest >> testRun [
289290
a run.
290291
a run: 'Bbb'.
@@ -301,7 +302,7 @@ test Bbb').
301302
equals: #('Ccc' 'Eee')
302303
]
303304

304-
{ #category : #tests }
305+
{ #category : 'tests' }
305306
PMAccuracyTest >> testSetUp [
306307
self assert: a count equals: 0.
307308
a performCheck: 'Fff'.
@@ -311,7 +312,7 @@ PMAccuracyTest >> testSetUp [
311312
self assert: a count equals: 16 / 5
312313
]
313314

314-
{ #category : #tests }
315+
{ #category : 'tests' }
315316
PMAccuracyTest >> testTreeTypeData [
316317
| aTree |
317318
aTree := KeyedTree new.
@@ -325,7 +326,7 @@ PMAccuracyTest >> testTreeTypeData [
325326
yourself)
326327
]
327328

328-
{ #category : #tests }
329+
{ #category : 'tests' }
329330
PMAccuracyTest >> testperformCheck [
330331
| b |
331332
a extractFromResults: 'bla' which: 2 onlyOne: false. "for setting numberOfResults"

0 commit comments

Comments
 (0)