Skip to content

Commit 371e9c8

Browse files
test: added some interesting and missing tests.
1 parent 3dfdc8e commit 371e9c8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,25 @@ PMPolynomialTest >> testPolynomialRoots [
242242
self assert: (roots at: 3) - 5 closeTo: 0
243243
]
244244

245+
{ #category : #'iterative algorithms' }
246+
PMPolynomialTest >> testPolynomialRootsForConstant [
247+
| polynomial |
248+
"Here, compute the roots of the quadratic (2x + 1)"
249+
polynomial := PMPolynomial coefficients: #(1).
250+
self should: [ polynomial roots ] raise: Error description: 'Function''s derivative seems to be zero everywhere'.
251+
252+
]
253+
254+
{ #category : #'iterative algorithms' }
255+
PMPolynomialTest >> testPolynomialRootsForLinear [
256+
| polynomial roots |
257+
"Here, compute the roots of the quadratic (2x + 1)"
258+
polynomial := PMPolynomial coefficients: #(1 2).
259+
roots := polynomial roots .
260+
self assert: roots size equals: 1.
261+
self assert: (roots at: 1) closeTo: -0.5 .
262+
]
263+
245264
{ #category : #'iterative algorithms' }
246265
PMPolynomialTest >> testPolynomialRootsForQuadratic [
247266
| polynomial roots |

0 commit comments

Comments
 (0)