@@ -45,17 +45,17 @@ PMComplexTest >> testAdaptToCollectionAndSend [
4545 self assert: (arr * c at: 2 ) equals: c
4646]
4747
48- { #category : #tests }
49- PMComplexTest >> testAddPolynomial [
48+ { #category : #' testing - arithmetic ' }
49+ PMComplexTest >> testAddingToAPolynomial [
5050 | c poly |
5151 c := 6 - 6 i.
5252 poly := PMPolynomial coefficients: #(1 1 1) .
5353 self assert: (poly + c at: 0 ) equals: 7 - 6 i.
5454 self assert: (c + poly at: 0 ) equals: 7 - 6 i
5555]
5656
57- { #category : #tests }
58- PMComplexTest >> testAdding [
57+ { #category : #' testing - arithmetic ' }
58+ PMComplexTest >> testAddingTwoComplexNumbers [
5959 " self run: #testAdding"
6060
6161 | c |
@@ -247,7 +247,7 @@ PMComplexTest >> testComplexCollection [
247247 do: [ :one :two | self assert: 2 * one equals: two ]
248248]
249249
250- { #category : #tests }
250+ { #category : #' testing - arithmetic ' }
251251PMComplexTest >> testComplexConjugate [
252252
253253 self assert: (5 - 6i) complexConjugate equals: (5 + 6i).
@@ -341,16 +341,8 @@ PMComplexTest >> testCreation [
341341 self assert: c imaginary equals: 5
342342]
343343
344- { #category : #tests }
345- PMComplexTest >> testDividingPolynomial [
346- | c poly |
347- c := 4 + 4 i.
348- poly := PMPolynomial coefficients: #(1 0 1) .
349- self assert: poly / c equals: 1 / c * poly
350- ]
351-
352- { #category : #tests }
353- PMComplexTest >> testDivision1 [
344+ { #category : #' testing - arithmetic' }
345+ PMComplexTest >> testDividingALargeComplexNumbersByItself [
354346 " self run: #testDivision1"
355347 " self debug: #testDivision1"
356348
@@ -367,6 +359,14 @@ PMComplexTest >> testDivision1 [
367359
368360]
369361
362+ { #category : #' testing - arithmetic' }
363+ PMComplexTest >> testDividingPolynomialByAComplexNumber [
364+ | c poly |
365+ c := 4 + 4 i.
366+ poly := PMPolynomial coefficients: #(1 0 1) .
367+ self assert: poly / c equals: 1 / c * poly
368+ ]
369+
370370{ #category : #' testing - equality' }
371371PMComplexTest >> testEqualsIsReflexive [
372372 | z |
@@ -479,14 +479,23 @@ PMComplexTest >> testLog [
479479 self assert: (2 + 0 i log: 2 ) equals: 1
480480]
481481
482- { #category : #tests }
482+ { #category : #' testing - arithmetic ' }
483483PMComplexTest >> testMultiplyByI [
484484 | c |
485485 c := 5 - 6 i.
486486 self assert: c * 1 i equals: c i
487487]
488488
489- { #category : #tests }
489+ { #category : #' testing - arithmetic' }
490+ PMComplexTest >> testMultiplyingByPolynomials [
491+ | c poly |
492+ c := 1 + 1 i.
493+ poly := PMPolynomial coefficients: #(1) .
494+ self assert: (c * poly at: 0 ) equals: c.
495+ self assert: (poly * c at: 0 ) equals: c
496+ ]
497+
498+ { #category : #' testing - arithmetic' }
490499PMComplexTest >> testNegated [
491500 " self run: #testNegated"
492501
@@ -585,7 +594,7 @@ PMComplexTest >> testRandom [
585594 self assert: r abs < c abs
586595]
587596
588- { #category : #tests }
597+ { #category : #' testing - arithmetic ' }
589598PMComplexTest >> testReciprocal [
590599 " self run: #testReciprocal"
591600
@@ -607,7 +616,7 @@ PMComplexTest >> testReciprocalError [
607616
608617]
609618
610- { #category : #tests }
619+ { #category : #' testing - arithmetic ' }
611620PMComplexTest >> testSecureDivision1 [
612621 " self run: #testSecureDivision1"
613622 " self debug: #testSecureDivision1"
@@ -620,7 +629,7 @@ PMComplexTest >> testSecureDivision1 [
620629
621630]
622631
623- { #category : #tests }
632+ { #category : #' testing - arithmetic ' }
624633PMComplexTest >> testSecureDivision2 [
625634 " self run: #testSecureDivision2"
626635 " self debug: #testSecureDivision2"
@@ -792,8 +801,8 @@ PMComplexTest >> testSquared [
792801 self assert: c2 real equals: 0
793802]
794803
795- { #category : #tests }
796- PMComplexTest >> testSubtractToPolynomial [
804+ { #category : #' testing - arithmetic ' }
805+ PMComplexTest >> testSubtractingPolynomials [
797806 | c poly |
798807 poly := PMPolynomial coefficients: #(1 2 3) .
799808 c := 1 + 3 i.
@@ -825,15 +834,6 @@ PMComplexTest >> testTanh [
825834 self assert: (c2 imaginary closeTo: c tanh imaginary).
826835]
827836
828- { #category : #tests }
829- PMComplexTest >> testTimesPolynomial [
830- | c poly |
831- c := 1 + 1 i.
832- poly := PMPolynomial coefficients: #(1) .
833- self assert: (c * poly at: 0 ) equals: c.
834- self assert: (poly * c at: 0 ) equals: c
835- ]
836-
837837{ #category : #' testing - equality' }
838838PMComplexTest >> testTwoComplexNumbersWithDifferentImaginaryPartsAreNotEqual [
839839 | z w |
@@ -861,6 +861,11 @@ PMComplexTest >> testWeCanWriteComplexNumbersWhoseRealAndImaginaryPartsAreFracti
861861 self assert: (z imaginary) equals: (Fraction numerator: 4 denominator: 5 ).
862862]
863863
864+ { #category : #' testing - arithmetic' }
865+ PMComplexTest >> testWeCannotTakeReciprocalOfZeroComplexNumbers [
866+ self should: [ PMComplex zero reciprocal ] raise: ZeroDivide .
867+ ]
868+
864869{ #category : #' testing - expressing complex numbers' }
865870PMComplexTest >> testWeCannotWriteFractionsOfComplexNumbersWithDenominatorNormalized [
866871
0 commit comments