Skip to content

Commit

Permalink
refactor: extracted the expected coefficients to a local variable to …
Browse files Browse the repository at this point in the history
…make equating Polynomials simpler.
  • Loading branch information
hemalvarambhia committed Dec 27, 2023
1 parent 8320ec0 commit 4b89858
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Math-Tests-Polynomials/PMPolynomialTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ PMPolynomialTest >> testPolynomialHash [
PMPolynomialTest >> testPolynomialIntegral [
"Code example 2.3"

| polynomial |
polynomial := (PMPolynomial coefficients: #(-3 7 2 1)) integral.
self assert: (polynomial at: 0) equals: 0.
self assert: (polynomial at: 1) equals: -3.
self assert: (polynomial at: 2) equals: 7 / 2.
self assert: (polynomial at: 3) equals: 2 / 3.
self assert: (polynomial at: 4) equals: 1 / 4.
| polynomial expectedCoefficients expected |
polynomial := (PMPolynomial coefficients: #( -3 7 2 1 )) integral.
expectedCoefficients := Array
with: 0
with: -3
with: 7 / 2
with: 2 / 3
with: 1 / 4.
expected := PMPolynomial coefficients: expectedCoefficients.
self assert: (polynomial at: 5) equals: 0
]

Expand Down

0 comments on commit 4b89858

Please sign in to comment.