Skip to content

Commit 8da7c67

Browse files
refactor: corrected an assertion that Pharo complained about from a style perspective.
1 parent d8d6fc0 commit 8da7c67

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

src/Math-Tests-Polynomials/PMPolynomialTest.class.st

+33-31
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Class {
2-
#name : #PMPolynomialTest,
3-
#superclass : #TestCase,
4-
#category : #'Math-Tests-Polynomials'
2+
#name : 'PMPolynomialTest',
3+
#superclass : 'TestCase',
4+
#category : 'Math-Tests-Polynomials',
5+
#package : 'Math-Tests-Polynomials'
56
}
67

7-
{ #category : #'testing - comparing' }
8+
{ #category : 'testing - comparing' }
89
PMPolynomialTest >> testIsZero [
910
| p1 p2 |
1011
p1 := PMPolynomial coefficients: #(0 0 0 0 0).
@@ -13,7 +14,7 @@ PMPolynomialTest >> testIsZero [
1314
self shouldnt: [ p2 isZero ]
1415
]
1516

16-
{ #category : #'testing - addition' }
17+
{ #category : 'testing - addition' }
1718
PMPolynomialTest >> testPolynomialAddition [
1819

1920
| polynomial expected p q |
@@ -25,7 +26,7 @@ PMPolynomialTest >> testPolynomialAddition [
2526
self assert: (polynomial at: 4) equals: 0
2627
]
2728

28-
{ #category : #'testing - addition' }
29+
{ #category : 'testing - addition' }
2930
PMPolynomialTest >> testPolynomialAdditionIsCommutative [
3031

3132
| p q expected |
@@ -37,7 +38,7 @@ PMPolynomialTest >> testPolynomialAdditionIsCommutative [
3738
self assert: q + p equals: expected
3839
]
3940

40-
{ #category : #'testing - algebra' }
41+
{ #category : 'testing - algebra' }
4142
PMPolynomialTest >> testPolynomialDerivative [
4243
"Code example 2.3"
4344
"
@@ -56,7 +57,7 @@ PMPolynomialTest >> testPolynomialDerivative [
5657
self assert: (derivative at: 4) equals: 0
5758
]
5859

59-
{ #category : #'testing - division' }
60+
{ #category : 'testing - division' }
6061
PMPolynomialTest >> testPolynomialDivision [
6162
| pol1 pol2 polynomial |
6263
pol1 := PMPolynomial coefficients: #(2 -3 1).
@@ -71,17 +72,18 @@ PMPolynomialTest >> testPolynomialDivision [
7172
self assert: (polynomial at: 6) equals: 0
7273
]
7374

74-
{ #category : #'testing - division' }
75+
{ #category : 'testing - division' }
7576
PMPolynomialTest >> testPolynomialDivisionBug [
7677
"identify an error when trying to create a zero dividend"
7778

78-
| pol1 pol2 |
79+
| pol1 pol2 zero|
7980
pol1 := PMPolynomial coefficients: #( 2 -3 1 ).
8081
pol2 := PMPolynomial coefficients: #( -6 23 -20 3 -1 1 ).
81-
self shouldnt: [ pol1 / pol2 ] raise: Error
82+
zero := PMPolynomial coefficients: #(0).
83+
self assert: pol1 / pol2 equals: zero.
8284
]
8385

84-
{ #category : #'testing - arithmetic' }
86+
{ #category : 'testing - arithmetic' }
8587
PMPolynomialTest >> testPolynomialDoubleDispatch [
8688
| n p |
8789
n := 3.2.
@@ -98,7 +100,7 @@ PMPolynomialTest >> testPolynomialDoubleDispatch [
98100
self assert: n - p equals: (p - n) negated
99101
]
100102

101-
{ #category : #'testing - algebra' }
103+
{ #category : 'testing - algebra' }
102104
PMPolynomialTest >> testPolynomialEvaluation [
103105
"Code example 2.2"
104106

@@ -107,7 +109,7 @@ PMPolynomialTest >> testPolynomialEvaluation [
107109
self assert: 0 equals: (polynomial value: 1)
108110
]
109111

110-
{ #category : #'testing - comparing' }
112+
{ #category : 'testing - comparing' }
111113
PMPolynomialTest >> testPolynomialHash [
112114
"polynomial hash is hash of coefficient array"
113115

@@ -123,7 +125,7 @@ PMPolynomialTest >> testPolynomialHash [
123125
self assert: p3 hash equals: p2 hash
124126
]
125127

126-
{ #category : #'testing - algebra' }
128+
{ #category : 'testing - algebra' }
127129
PMPolynomialTest >> testPolynomialIntegral [
128130
"Code example 2.3"
129131

@@ -146,7 +148,7 @@ PMPolynomialTest >> testPolynomialIntegral [
146148
self assert: (polynomial at: 5) equals: 0
147149
]
148150

149-
{ #category : #'testing - algebra' }
151+
{ #category : 'testing - algebra' }
150152
PMPolynomialTest >> testPolynomialIntegralWithConstant [
151153
"Code example 2.3"
152154

@@ -165,7 +167,7 @@ PMPolynomialTest >> testPolynomialIntegralWithConstant [
165167
self assert: (polynomial at: 5) equals: 0
166168
]
167169

168-
{ #category : #'testing - multiplication' }
170+
{ #category : 'testing - multiplication' }
169171
PMPolynomialTest >> testPolynomialMultiplication [
170172
"Code example 2.3"
171173

@@ -177,7 +179,7 @@ PMPolynomialTest >> testPolynomialMultiplication [
177179
self assert: product equals: expected.
178180
]
179181

180-
{ #category : #'testing - multiplication' }
182+
{ #category : 'testing - multiplication' }
181183
PMPolynomialTest >> testPolynomialMultiplicationIsCommutative [
182184

183185
| expected p q |
@@ -192,7 +194,7 @@ PMPolynomialTest >> testPolynomialMultiplicationIsCommutative [
192194
self assert: q * p equals: expected
193195
]
194196

195-
{ #category : #'testing - addition' }
197+
{ #category : 'testing - addition' }
196198
PMPolynomialTest >> testPolynomialNumberAddition [
197199

198200
| polynomial expected p |
@@ -203,7 +205,7 @@ PMPolynomialTest >> testPolynomialNumberAddition [
203205
self assert: (polynomial at: 3) equals: 0
204206
]
205207

206-
{ #category : #'testing - addition' }
208+
{ #category : 'testing - addition' }
207209
PMPolynomialTest >> testPolynomialNumberAdditionInverse [
208210

209211
| polynomial expected p |
@@ -214,7 +216,7 @@ PMPolynomialTest >> testPolynomialNumberAdditionInverse [
214216
self assert: (polynomial at: 3) equals: 0
215217
]
216218

217-
{ #category : #'testing - division' }
219+
{ #category : 'testing - division' }
218220
PMPolynomialTest >> testPolynomialNumberDivision [
219221

220222
| polynomial expected expectedCoefficients p |
@@ -226,7 +228,7 @@ PMPolynomialTest >> testPolynomialNumberDivision [
226228
self assert: (polynomial at: 3) equals: 0
227229
]
228230

229-
{ #category : #'testing - multiplication' }
231+
{ #category : 'testing - multiplication' }
230232
PMPolynomialTest >> testPolynomialNumberMultiplication [
231233

232234
| product expected p |
@@ -237,7 +239,7 @@ PMPolynomialTest >> testPolynomialNumberMultiplication [
237239
self assert: product equals: expected
238240
]
239241

240-
{ #category : #'testing - multiplication' }
242+
{ #category : 'testing - multiplication' }
241243
PMPolynomialTest >> testPolynomialNumberMultiplicationInverse [
242244

243245
| product expected p |
@@ -248,7 +250,7 @@ PMPolynomialTest >> testPolynomialNumberMultiplicationInverse [
248250
self assert: product equals: expected
249251
]
250252

251-
{ #category : #'testing - subtraction' }
253+
{ #category : 'testing - subtraction' }
252254
PMPolynomialTest >> testPolynomialNumberSubtraction [
253255

254256
| polynomial expected |
@@ -258,7 +260,7 @@ PMPolynomialTest >> testPolynomialNumberSubtraction [
258260
self assert: (polynomial at: 3) equals: 0
259261
]
260262

261-
{ #category : #'testing - subtraction' }
263+
{ #category : 'testing - subtraction' }
262264
PMPolynomialTest >> testPolynomialNumberSubtractionInverse [
263265

264266
| polynomial expected |
@@ -268,7 +270,7 @@ PMPolynomialTest >> testPolynomialNumberSubtractionInverse [
268270
self assert: (polynomial at: 3) equals: 0
269271
]
270272

271-
{ #category : #printing }
273+
{ #category : 'printing' }
272274
PMPolynomialTest >> testPolynomialPrintOn [
273275
| poly |
274276
poly := PMPolynomial coefficients: #(1 0 1).
@@ -277,7 +279,7 @@ PMPolynomialTest >> testPolynomialPrintOn [
277279
self assert: poly printString equals: '1'
278280
]
279281

280-
{ #category : #'iterative algorithms' }
282+
{ #category : 'iterative algorithms' }
281283
PMPolynomialTest >> testPolynomialRoots [
282284
"Code Example 5.5"
283285

@@ -290,7 +292,7 @@ PMPolynomialTest >> testPolynomialRoots [
290292
self assert: (roots at: 3) - 5 closeTo: 0
291293
]
292294

293-
{ #category : #'iterative algorithms' }
295+
{ #category : 'iterative algorithms' }
294296
PMPolynomialTest >> testPolynomialRootsConstantsHaveNoRoots [
295297

296298
| constant |
@@ -302,7 +304,7 @@ PMPolynomialTest >> testPolynomialRootsConstantsHaveNoRoots [
302304
description: 'Function''s derivative seems to be zero everywhere'
303305
]
304306

305-
{ #category : #'iterative algorithms' }
307+
{ #category : 'iterative algorithms' }
306308
PMPolynomialTest >> testPolynomialRootsForLinear [
307309

308310
| linearPolynomial roots |
@@ -313,7 +315,7 @@ PMPolynomialTest >> testPolynomialRootsForLinear [
313315
self assert: (roots at: 1) closeTo: -0.5
314316
]
315317

316-
{ #category : #'testing - subtraction' }
318+
{ #category : 'testing - subtraction' }
317319
PMPolynomialTest >> testPolynomialSubtraction [
318320

319321
| polynomial p q expected |
@@ -325,7 +327,7 @@ PMPolynomialTest >> testPolynomialSubtraction [
325327
self assert: (polynomial at: 4) equals: 0
326328
]
327329

328-
{ #category : #'iterative algorithms' }
330+
{ #category : 'iterative algorithms' }
329331
PMPolynomialTest >> testPolynomialWithRepeatedRoots [
330332
| polynomialWithRepeatedRoots roots |
331333
"Here, compute the roots of the quadratic (2x + 1)^2 = 4 x^2 + 4 x + 1"

src/Math-Tests-Polynomials/package.st

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Package { #name : #'Math-Tests-Polynomials' }
1+
Package { #name : 'Math-Tests-Polynomials' }

0 commit comments

Comments
 (0)