@@ -45,17 +45,17 @@ PMComplexTest >> testAdaptToCollectionAndSend [
45
45
self assert: (arr * c at: 2 ) equals: c
46
46
]
47
47
48
- { #category : #tests }
49
- PMComplexTest >> testAddPolynomial [
48
+ { #category : #' testing - arithmetic ' }
49
+ PMComplexTest >> testAddingToAPolynomial [
50
50
| c poly |
51
51
c := 6 - 6 i.
52
52
poly := PMPolynomial coefficients: #(1 1 1) .
53
53
self assert: (poly + c at: 0 ) equals: 7 - 6 i.
54
54
self assert: (c + poly at: 0 ) equals: 7 - 6 i
55
55
]
56
56
57
- { #category : #tests }
58
- PMComplexTest >> testAdding [
57
+ { #category : #' testing - arithmetic ' }
58
+ PMComplexTest >> testAddingTwoComplexNumbers [
59
59
" self run: #testAdding"
60
60
61
61
| c |
@@ -247,7 +247,7 @@ PMComplexTest >> testComplexCollection [
247
247
do: [ :one :two | self assert: 2 * one equals: two ]
248
248
]
249
249
250
- { #category : #tests }
250
+ { #category : #' testing - arithmetic ' }
251
251
PMComplexTest >> testComplexConjugate [
252
252
253
253
self assert: (5 - 6i) complexConjugate equals: (5 + 6i).
@@ -341,16 +341,8 @@ PMComplexTest >> testCreation [
341
341
self assert: c imaginary equals: 5
342
342
]
343
343
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 [
354
346
" self run: #testDivision1"
355
347
" self debug: #testDivision1"
356
348
@@ -367,6 +359,14 @@ PMComplexTest >> testDivision1 [
367
359
368
360
]
369
361
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
+
370
370
{ #category : #' testing - equality' }
371
371
PMComplexTest >> testEqualsIsReflexive [
372
372
| z |
@@ -479,14 +479,23 @@ PMComplexTest >> testLog [
479
479
self assert: (2 + 0 i log: 2 ) equals: 1
480
480
]
481
481
482
- { #category : #tests }
482
+ { #category : #' testing - arithmetic ' }
483
483
PMComplexTest >> testMultiplyByI [
484
484
| c |
485
485
c := 5 - 6 i.
486
486
self assert: c * 1 i equals: c i
487
487
]
488
488
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' }
490
499
PMComplexTest >> testNegated [
491
500
" self run: #testNegated"
492
501
@@ -585,7 +594,7 @@ PMComplexTest >> testRandom [
585
594
self assert: r abs < c abs
586
595
]
587
596
588
- { #category : #tests }
597
+ { #category : #' testing - arithmetic ' }
589
598
PMComplexTest >> testReciprocal [
590
599
" self run: #testReciprocal"
591
600
@@ -607,7 +616,7 @@ PMComplexTest >> testReciprocalError [
607
616
608
617
]
609
618
610
- { #category : #tests }
619
+ { #category : #' testing - arithmetic ' }
611
620
PMComplexTest >> testSecureDivision1 [
612
621
" self run: #testSecureDivision1"
613
622
" self debug: #testSecureDivision1"
@@ -620,7 +629,7 @@ PMComplexTest >> testSecureDivision1 [
620
629
621
630
]
622
631
623
- { #category : #tests }
632
+ { #category : #' testing - arithmetic ' }
624
633
PMComplexTest >> testSecureDivision2 [
625
634
" self run: #testSecureDivision2"
626
635
" self debug: #testSecureDivision2"
@@ -792,8 +801,8 @@ PMComplexTest >> testSquared [
792
801
self assert: c2 real equals: 0
793
802
]
794
803
795
- { #category : #tests }
796
- PMComplexTest >> testSubtractToPolynomial [
804
+ { #category : #' testing - arithmetic ' }
805
+ PMComplexTest >> testSubtractingPolynomials [
797
806
| c poly |
798
807
poly := PMPolynomial coefficients: #(1 2 3) .
799
808
c := 1 + 3 i.
@@ -825,15 +834,6 @@ PMComplexTest >> testTanh [
825
834
self assert: (c2 imaginary closeTo: c tanh imaginary).
826
835
]
827
836
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
-
837
837
{ #category : #' testing - equality' }
838
838
PMComplexTest >> testTwoComplexNumbersWithDifferentImaginaryPartsAreNotEqual [
839
839
| z w |
@@ -861,6 +861,11 @@ PMComplexTest >> testWeCanWriteComplexNumbersWhoseRealAndImaginaryPartsAreFracti
861
861
self assert: (z imaginary) equals: (Fraction numerator: 4 denominator: 5 ).
862
862
]
863
863
864
+ { #category : #' testing - arithmetic' }
865
+ PMComplexTest >> testWeCannotTakeReciprocalOfZeroComplexNumbers [
866
+ self should: [ PMComplex zero reciprocal ] raise: ZeroDivide .
867
+ ]
868
+
864
869
{ #category : #' testing - expressing complex numbers' }
865
870
PMComplexTest >> testWeCannotWriteFractionsOfComplexNumbersWithDenominatorNormalized [
866
871
0 commit comments