Skip to content

Commit 40ff17f

Browse files
committed
Use better assert for better error logs
1 parent 6afe9b1 commit 40ff17f

File tree

13 files changed

+347
-342
lines changed

13 files changed

+347
-342
lines changed

src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st

Lines changed: 221 additions & 218 deletions
Large diffs are not rendered by default.

src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,17 @@ PMDualNumberTest >> testConjugated [
9999

100100
{ #category : #tests }
101101
PMDualNumberTest >> testConverting [
102+
102103
| a |
103-
self assert: zeroc asInteger == 0.
104-
self assert: three asInteger == 3.
104+
self assert: zeroc asInteger identicalTo: 0.
105+
self assert: three asInteger identicalTo: 3.
105106
self assert: onec asFloat isFloat.
106107
self deny: onec isFloat.
107108
self assert: onec asFloat equals: 1.
108109
a := three negated asFloat.
109110
self assert: a isFloat.
110111
self assert: a equals: -3.
111-
self assert: (PMDualNumber value: -3.7 eps: 2) asInteger == -3
112+
self assert: (PMDualNumber value: -3.7 eps: 2) asInteger identicalTo: -3
112113
]
113114

114115
{ #category : #'tests-mathematical functions' }

src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ PMHyperDualNumberTest >> testAbs [
4848

4949
{ #category : #tests }
5050
PMHyperDualNumberTest >> testAccessing [
51+
5152
self assert: three eps equals: 1.
5253
self assert: three value equals: 3.
5354
self assert: three eps2 equals: 1.
5455
self assert: three eps1eps2 equals: 0.
5556
three eps1eps2: 2.
5657
three eps2: 2.
57-
self assert: three eps2 == 2.
58+
self assert: three eps2 identicalTo: 2.
5859
self assert: three eps1eps2 equals: 2
5960
]
6061

@@ -124,16 +125,17 @@ PMHyperDualNumberTest >> testArcTan [
124125

125126
{ #category : #tests }
126127
PMHyperDualNumberTest >> testConverting [
128+
127129
| a |
128-
self assert: zeroc asInteger == 0.
129-
self assert: three asInteger == 3.
130+
self assert: zeroc asInteger identicalTo: 0.
131+
self assert: three asInteger identicalTo: 3.
130132
self assert: onec asFloat isFloat.
131133
self deny: onec isFloat.
132134
self assert: onec asFloat equals: 1.
133135
a := three negated asFloat.
134136
self assert: a isFloat.
135137
self assert: a equals: -3.
136-
self assert: (PMDualNumber value: -3.7 eps: 2) asInteger == -3
138+
self assert: (PMDualNumber value: -3.7 eps: 2) asInteger identicalTo: -3
137139
]
138140

139141
{ #category : #'tests-mathematical functions' }

src/Math-Tests-Complex/PMComplexNumberTest.class.st

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,9 @@ PMComplexNumberTest >> testProductWithVector [
601601
PMComplexNumberTest >> testPureImaginaryNumbersAreNotEqualToObjectsOfADifferentType [
602602

603603
self deny: 1 i isNil.
604-
self deny: nil = 1 i.
605-
self deny: 1 i = #( 1 2 3 ).
606-
self deny: #( 1 2 3 ) = 1 i
604+
self deny: nil equals: 1 i.
605+
self deny: 1 i equals: #( 1 2 3 ).
606+
self deny: #( 1 2 3 ) equals: 1 i
607607
]
608608

609609
{ #category : #'testing - expressing complex numbers' }

src/Math-Tests-Distributions/PMKolmogorovSmirnov1SampleTest.class.st

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ PMKolmogorovSmirnov1SampleTest >> testCorrectPopulationProbabilistic [
3838

3939
{ #category : #tests }
4040
PMKolmogorovSmirnov1SampleTest >> testRejectOfEqualityHypothesesForSampleVersusDistribution [
41+
4142
| sample |
4243
"The data below are taken from http://www.maths.qmul.ac.uk/~bb/CTS_Chapter3_Students.pdf"
43-
sample := #(-1.2 0.2 -0.6 0.8 -1.0).
44-
test := PMKolmogorovSmirnov1Sample
45-
compareData: sample
46-
withDistribution: distribution.
44+
sample := #( -1.2 0.2 -0.6 0.8 -1.0 ).
45+
test := PMKolmogorovSmirnov1Sample compareData: sample withDistribution: distribution.
4746

48-
self
49-
assert: (test rejectEqualityHypothesisWithAlpha: 0.05)
50-
equals: false
47+
self deny: (test rejectEqualityHypothesisWithAlpha: 0.05)
5148
]
5249

5350
{ #category : #tests }

src/Math-Tests-Distributions/PMKolmogorovSmirnov2SampleTest.class.st

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@ PMKolmogorovSmirnov2SampleTest >> testRejectOfEqualityHypothesesForTwoSamples [
2020
"
2121

2222
| ks |
23-
ks := PMKolmogorovSmirnov2Sample
24-
compareData: #(1.2 1.4 1.9 3.7 4.4 4.8 9.7 17.3 21.1 28.4)
25-
withData: #(5.6 6.5 6.6 6.9 9.2 10.4 10.6 19.3).
23+
ks := PMKolmogorovSmirnov2Sample compareData: #( 1.2 1.4 1.9 3.7 4.4 4.8 9.7 17.3 21.1 28.4 ) withData: #( 5.6 6.5 6.6 6.9 9.2 10.4 10.6 19.3 ).
2624

27-
self
28-
assert: (ks rejectEqualityHypothesisWithAlpha: 0.05)
29-
equals: true
25+
self assert: (ks rejectEqualityHypothesisWithAlpha: 0.05)
3026
]
3127

3228
{ #category : #tests }

src/Math-Tests-FunctionFit/PMAnotherChromosomeManagerTest.class.st

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,20 @@ PMAnotherChromosomeManagerTest >> testAccessing [
3737

3838
{ #category : #tests }
3939
PMAnotherChromosomeManagerTest >> testCrossOver [
40-
|a|
41-
1 to: 20 do: [:i| a:=cm crossover: #(1 2 3) and: #(4 5 6).
42-
1 to:2 do:[:index|
43-
self assert: (#(1 4) includes: ((a at: index) first)).
44-
self assert: (#(2 5)includes:((a at: index) at: 2)).
45-
self assert: (#(3 6) includes:((a at: index) at: 3)).].
46-
self deny: (((a at: 1)at: 2)=((a at: 2)at: 2)).
47-
self deny: (((a at: 1)at: 1)=((a at: 2)at: 1)).
48-
self deny: (((a at: 1)at: 3)=((a at: 2)at: 3)).
49-
a].
50-
a:= a collect: [:g|g first].
51-
self assert: ((a occurrencesOf: #(1 2 3))<20)
40+
41+
| a |
42+
1 to: 20 do: [ :i |
43+
a := cm crossover: #( 1 2 3 ) and: #( 4 5 6 ).
44+
1 to: 2 do: [ :index |
45+
self assert: (#( 1 4 ) includes: (a at: index) first).
46+
self assert: (#( 2 5 ) includes: ((a at: index) at: 2)).
47+
self assert: (#( 3 6 ) includes: ((a at: index) at: 3)) ].
48+
self deny: ((a at: 1) at: 2) equals: ((a at: 2) at: 2).
49+
self deny: ((a at: 1) at: 1) equals: ((a at: 2) at: 1).
50+
self deny: ((a at: 1) at: 3) equals: ((a at: 2) at: 3).
51+
a ].
52+
a := a collect: [ :g | g first ].
53+
self assert: (a occurrencesOf: #( 1 2 3 )) < 20
5254
]
5355

5456
{ #category : #tests }
@@ -142,14 +144,15 @@ PMAnotherChromosomeManagerTest >> testProcessand [
142144

143145
{ #category : #tests }
144146
PMAnotherChromosomeManagerTest >> testRandomizePopulation [
145-
|g|
146-
self setHammersleyTest: true.
147-
g :=cm population first.
148-
self setHammersleyTest: false.
149-
self deny: (cm population first =g).
150-
g :=cm population first.
151-
self setHammersleyTest: false.
152-
self deny: (cm population first =g)
147+
148+
| g |
149+
self setHammersleyTest: true.
150+
g := cm population first.
151+
self setHammersleyTest: false.
152+
self deny: cm population first equals: g.
153+
g := cm population first.
154+
self setHammersleyTest: false.
155+
self deny: cm population first equals: g
153156
]
154157

155158
{ #category : #tests }

src/Math-Tests-KDTree/PMNNStoreTest.class.st

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,104 +13,107 @@ PMNNStoreTest >> testCopy [
1313
"a separate copy method is necessary because of this scenario"
1414

1515
| a b |
16-
a := PMNNStore withAll: #(1 2 4).
16+
a := PMNNStore withAll: #( 1 2 4 ).
1717
b := a copy.
1818
self assert: b equals: a.
1919
self assert: b hash equals: a hash.
2020
b sortFor: nil.
21-
self deny: b = a. "here is the problem"
22-
self deny: b hash = a hash
21+
self deny: b equals: a. "here is the problem"
22+
self deny: b hash equals: a hash
2323
]
2424

2525
{ #category : #tests }
2626
PMNNStoreTest >> testCopyEmpty [
27+
2728
| n m |
28-
n := PMNNStore newFrom: #(#(1 $a) #(3 1.0) #(0 '2')).
29+
n := PMNNStore newFrom: #( #( 1 $a ) #( 3 1.0 ) #( 0 '2' ) ).
2930
n := n copyEmpty.
3031
self assert: n isEmpty.
3132
n
32-
add: #(2 10);
33-
add: #(1 100).
33+
add: #( 2 10 );
34+
add: #( 1 100 ).
3435
self deny: n isEmpty.
35-
self assert: n maxDistance equals: Float infinity. "because it is not yet full"
36-
self assert: n data equals: #(100 10).
36+
self assert: n maxDistance equals: Float infinity. "because it is not yet full"
37+
self assert: n data equals: #( 100 10 ).
3738
m := n copyEmpty.
38-
self assert: m size equals: 2. "size is reduced now"
39+
self assert: m size equals: 2. "size is reduced now"
3940
m
40-
add: #(2 10);
41-
add: #(1 100).
42-
self deny: m = n.
41+
add: #( 2 10 );
42+
add: #( 1 100 ).
43+
self deny: m equals: n.
4344
self assert: m completeData equals: n completeData
4445
]
4546

4647
{ #category : #tests }
4748
PMNNStoreTest >> testEqual [
49+
4850
| a b |
49-
b := #(#(1 $a) #(3 1.0) #(0 '2')).
51+
b := #( #( 1 $a ) #( 3 1.0 ) #( 0 '2' ) ).
5052
a := PMNNStore newFrom: b.
51-
self deny: a = b.
52-
b := PMNNStore newFrom: #(#(1 $a) #(3 1.0) #(0 2)).
53-
self deny: a = b.
53+
self deny: a equals: b.
54+
b := PMNNStore newFrom: #( #( 1 $a ) #( 3 1.0 ) #( 0 2 ) ).
55+
self deny: a equals: b.
5456
b := a copyEmpty.
55-
self deny: a = b.
56-
b addAll: #(#(3 1.0) #(1 $a) #(4 true) #(0 '2')).
57+
self deny: a equals: b.
58+
b addAll: #( #( 3 1.0 ) #( 1 $a ) #( 4 true ) #( 0 '2' ) ).
5759
self assert: a equals: b.
58-
b add: #(2 nil).
59-
self deny: a = b.
60+
b add: #( 2 nil ).
61+
self deny: a equals: b.
6062
b := PMNNStore new: 3.
6163
a := PMNNStore new: 2.
62-
a add: #(2 nil).
63-
b add: #(2 nil).
64-
self deny: a = b.
65-
self deny: b hash = a hash
64+
a add: #( 2 nil ).
65+
b add: #( 2 nil ).
66+
self deny: a equals: b.
67+
self deny: b hash equals: a hash
6668
]
6769

6870
{ #category : #tests }
6971
PMNNStoreTest >> testExtremeCase [
72+
7073
| n |
7174
n := PMNNStore new.
72-
n sortFor: nil. "this should indeed always be possible and shouldnt raise an error!"
75+
n sortFor: nil. "this should indeed always be possible and shouldnt raise an error!"
7376
self assert: n isFull.
74-
n add: #(1 1). "adding should also always be possible, although it will not be added in this case"
75-
self deny: n maxDistance = 1.
76-
n
77-
add: (Array with: (0 - Float infinity) with: 1). "and this extreme case too."
77+
n add: #( 1 1 ). "adding should also always be possible, although it will not be added in this case"
78+
self deny: n maxDistance equals: 1.
79+
n add: (Array with: 0 - Float infinity with: 1). "and this extreme case too."
7880
self assert: n isEmpty.
79-
self assert: n data equals: #().
80-
self should: [ n add: (Array with: nil with: 1) ] raise: Error "but this should always raise an error (not only in NNStores with size 0), also in subclasses, otherwise one can have strange bugs"
81+
self assert: n data equals: #( ).
82+
self should: [ n add: (Array with: nil with: 1) ] raise: Error "but this should always raise an error (not only in NNStores with size 0), also in subclasses, otherwise one can have strange bugs"
8183
]
8284

8385
{ #category : #tests }
8486
PMNNStoreTest >> testInitialize [
87+
8588
| a b |
86-
a := PMNNStore newFrom: #(#(4 $a) #(5 1.0) #(6 '2')).
87-
b := (PMNNStore newFrom: #(#(4 $a) #(5 1.0) #(6 '2'))) initialize.
88-
self deny: a = b.
89+
a := PMNNStore newFrom: #( #( 4 $a ) #( 5 1.0 ) #( 6 '2' ) ).
90+
b := (PMNNStore newFrom: #( #( 4 $a ) #( 5 1.0 ) #( 6 '2' ) )) initialize.
91+
self deny: a equals: b.
8992
a initialize.
9093
self assert: a equals: b.
91-
b add: #(4 $a).
92-
self deny: a = b.
93-
a add: #(4 $a).
94+
b add: #( 4 $a ).
95+
self deny: a equals: b.
96+
a add: #( 4 $a ).
9497
self assert: a equals: b.
95-
a add: #(5 1.0).
96-
self deny: a = b
98+
a add: #( 5 1.0 ).
99+
self deny: a equals: b
97100
]
98101

99102
{ #category : #tests }
100103
PMNNStoreTest >> testInitialize2 [
101104
"a separate = method is necessary because of this scenario with resetting"
102105

103106
| a b c |
104-
a := (PMNNStore newFrom: #(#(1 $a) #(3 1.0) #(0 '2'))) initialize. "initialize = resetting"
105-
b := (PMNNStore newFrom: #(#(1 $a) #(3 false) #(0 '2'))) initialize.
106-
self assert: a equals: b. "first problematic part"
107-
c := #(#(3 true) #(2 1)).
107+
a := (PMNNStore newFrom: #( #( 1 $a ) #( 3 1.0 ) #( 0 '2' ) )) initialize. "initialize = resetting"
108+
b := (PMNNStore newFrom: #( #( 1 $a ) #( 3 false ) #( 0 '2' ) )) initialize.
109+
self assert: a equals: b. "first problematic part"
110+
c := #( #( 3 true ) #( 2 1 ) ).
108111
a addAll: c.
109112
b addAll: c.
110-
self assert: a equals: b. "second problematic part"
111-
c := #(2 nil).
113+
self assert: a equals: b. "second problematic part"
114+
c := #( 2 nil ).
112115
a add: c.
113-
self deny: a = b.
116+
self deny: a equals: b.
114117
b add: c.
115118
self assert: a equals: b
116119
]

src/Math-Tests-Number-Extensions/PMNumberExtensionsTest.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Class {
66

77
{ #category : #tests }
88
PMNumberExtensionsTest >> testArTanh [
9-
self assert: 0 arTanh = 0.0 arTanh.
9+
10+
self assert: 0 arTanh equals: 0.0 arTanh.
1011
self assert: 1 arTanh isFloat.
1112
self assert: 1 arTanh equals: 1.0 arTanh
1213
]

src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ PMFloatingPointMachineTestCase >> testMachinePrecisionSmallestNumberNotZero [
7777

7878
{ #category : #precision }
7979
PMFloatingPointMachineTestCase >> testUniqueInstance [
80+
8081
| mach1 mach2 mach3 |
8182
mach1 := PMFloatingPointMachine new.
8283
mach2 := PMFloatingPointMachine new.
83-
self assert: mach1 == mach2.
84+
self assert: mach1 identicalTo: mach2.
8485
PMFloatingPointMachine reset.
8586
mach3 := PMFloatingPointMachine new.
8687
self shouldnt: [ mach3 == mach2 ]

0 commit comments

Comments
 (0)