From 8967e82581ffff7bb53fe94cfd3d8f123b0c6a5b Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 17:17:58 +0100 Subject: [PATCH 01/23] Classified some complex conjugation tests with a clearly named category. --- src/Math-Tests-Complex/PMComplexTest.class.st | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index e0ec78b8..3d15b686 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -389,60 +389,54 @@ PMComplexTest >> testHash [ self assert: aComplex copy hash equals: aComplex hash ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfConjugateComplex [ self assert: ((3 + 2i) isComplexConjugateOf: (3 - 2i)) ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfConjugateComplexAndReal [ self assert: ((5 + 0i) isComplexConjugateOf: 5) ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfConjugateRealAndComplex [ self assert: (5 isComplexConjugateOf: (5 - 0i)) ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfDifferentReal [ self deny: (-5 isComplexConjugateOf: 5) ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfNonConjugateComplexAndReal [ self deny: ((5 + 3i) isComplexConjugateOf: 5) ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfNonConjugateDifferentComplex [ self deny: ((-0.5 - 1i) isComplexConjugateOf: (3 - 2i)) ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfNonConjugateRealAndComplex [ self deny: (5 isComplexConjugateOf: (5 - 3i)) ] -{ #category : #tests } +{ #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfSameComplex [ self deny: ((3 - 2i) isComplexConjugateOf: (3 - 2i)) ] -{ #category : #tests } -PMComplexTest >> testIsComplexConjugateOfSameReal [ - - self assert: (5 isComplexConjugateOf: 5) -] - { #category : #tests } PMComplexTest >> testIsComplexNumberOnComplex [ @@ -783,6 +777,12 @@ PMComplexTest >> testTanh [ self assert: (c2 imaginary closeTo: c tanh imaginary). ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugateOfAnIntegerIsItself [ + + self assert: (5 isComplexConjugateOf: 5) +] + { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | From c6fec7dbbfa8abd059d8ed673bead4d60e06e7c1 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 17:21:33 +0100 Subject: [PATCH 02/23] Removed what feels like an obsolete test. --- src/Math-Tests-Complex/PMComplexTest.class.st | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 3d15b686..e2deb43d 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -395,18 +395,6 @@ PMComplexTest >> testIsComplexConjugateOfConjugateComplex [ self assert: ((3 + 2i) isComplexConjugateOf: (3 - 2i)) ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfConjugateComplexAndReal [ - - self assert: ((5 + 0i) isComplexConjugateOf: 5) -] - -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfConjugateRealAndComplex [ - - self assert: (5 isComplexConjugateOf: (5 - 0i)) -] - { #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfDifferentReal [ @@ -777,6 +765,12 @@ PMComplexTest >> testTanh [ self assert: (c2 imaginary closeTo: c tanh imaginary). ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugateOfAPureRealNumberIsItself [ + + self assert: ((5 + 0i) isComplexConjugateOf: 5) +] + { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugateOfAnIntegerIsItself [ From 9b521e04e38d4a1c2b0fabe31c40e664e5fd561b Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 17:25:51 +0100 Subject: [PATCH 03/23] Clarified the name of a test. --- src/Math-Tests-Complex/PMComplexTest.class.st | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index e2deb43d..1710ec66 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -419,12 +419,6 @@ PMComplexTest >> testIsComplexConjugateOfNonConjugateRealAndComplex [ self deny: (5 isComplexConjugateOf: (5 - 3i)) ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfSameComplex [ - - self deny: ((3 - 2i) isComplexConjugateOf: (3 - 2i)) -] - { #category : #tests } PMComplexTest >> testIsComplexNumberOnComplex [ @@ -777,6 +771,12 @@ PMComplexTest >> testThatComplexConjugateOfAnIntegerIsItself [ self assert: (5 isComplexConjugateOf: 5) ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugationIsNotSymmetric [ + + self deny: ((3 - 2i) isComplexConjugateOf: (3 - 2i)) +] + { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | From e6c24f108ad4945d1829e4575049ea72bed62c42 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 17:28:55 +0100 Subject: [PATCH 04/23] Clarified the name of a test message. --- src/Math-Tests-Complex/PMComplexTest.class.st | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 1710ec66..e67974d0 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -389,12 +389,6 @@ PMComplexTest >> testHash [ self assert: aComplex copy hash equals: aComplex hash ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfConjugateComplex [ - - self assert: ((3 + 2i) isComplexConjugateOf: (3 - 2i)) -] - { #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfDifferentReal [ @@ -777,6 +771,11 @@ PMComplexTest >> testThatComplexConjugationIsNotSymmetric [ self deny: ((3 - 2i) isComplexConjugateOf: (3 - 2i)) ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugationYieldsANumberWithTheSameRealPartAndNegativeImaginaryPart [ + self assert: (3 + 2 i isComplexConjugateOf: 3 - 2 i) +] + { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | From 84d694d3a06fcb001ad5608d8e706f9ab40547ea Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 17:30:00 +0100 Subject: [PATCH 05/23] Removed an obsolete test. --- src/Math-Tests-Complex/PMComplexTest.class.st | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index e67974d0..55fdf2fb 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -389,12 +389,6 @@ PMComplexTest >> testHash [ self assert: aComplex copy hash equals: aComplex hash ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfDifferentReal [ - - self deny: (-5 isComplexConjugateOf: 5) -] - { #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfNonConjugateComplexAndReal [ From 23837dec3a37289b46c4c579bbecb3c44b243f7e Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 17:32:35 +0100 Subject: [PATCH 06/23] Removed some obsolete tests. --- src/Math-Tests-Complex/PMComplexTest.class.st | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 55fdf2fb..4b9858ca 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -389,24 +389,12 @@ PMComplexTest >> testHash [ self assert: aComplex copy hash equals: aComplex hash ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfNonConjugateComplexAndReal [ - - self deny: ((5 + 3i) isComplexConjugateOf: 5) -] - { #category : #'testing - complex conjugation' } PMComplexTest >> testIsComplexConjugateOfNonConjugateDifferentComplex [ self deny: ((-0.5 - 1i) isComplexConjugateOf: (3 - 2i)) ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfNonConjugateRealAndComplex [ - - self deny: (5 isComplexConjugateOf: (5 - 3i)) -] - { #category : #tests } PMComplexTest >> testIsComplexNumberOnComplex [ From 3a910d4b6165763f8540524112042f40aedc553c Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 17:47:29 +0100 Subject: [PATCH 07/23] Added some missing tests that assert the properties of complex conjugation. --- src/Math-Tests-Complex/PMComplexTest.class.st | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 4b9858ca..4e816bac 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -747,12 +747,46 @@ PMComplexTest >> testThatComplexConjugateOfAnIntegerIsItself [ self assert: (5 isComplexConjugateOf: 5) ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugationIsAnInvolution [ + | z | + z := -9 + 24 i. + + self assert: z complexConjugate complexConjugate equals: -9 + 24 i +] + +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugationIsDistributiveOverAddition [ + | z w | + z := -3 + 6 i. + w := 10 - 4 i. + + self assert: (z + w) complexConjugate equals: (z complexConjugate + w complexConjugate) +] + +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugationIsDistributiveOverDivision [ + | z w | + z := 6 - 15 i. + w := 10 + 5 i. + + self assert: (z / w) complexConjugate equals: z complexConjugate / w complexConjugate +] + { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugationIsNotSymmetric [ self deny: ((3 - 2i) isComplexConjugateOf: (3 - 2i)) ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugationLeavesModulusUnchanged [ + | z | + z := 3 - 4 i. + + self assert: z complexConjugate abs equals: 5 +] + { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugationYieldsANumberWithTheSameRealPartAndNegativeImaginaryPart [ self assert: (3 + 2 i isComplexConjugateOf: 3 - 2 i) From 999182fce78359e903cb948c6f74cad36925856b Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 18:17:57 +0100 Subject: [PATCH 08/23] Made the message more concise. --- src/Math-Tests-Complex/PMComplexTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 4e816bac..32b9fbe6 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -780,7 +780,7 @@ PMComplexTest >> testThatComplexConjugationIsNotSymmetric [ ] { #category : #'testing - complex conjugation' } -PMComplexTest >> testThatComplexConjugationLeavesModulusUnchanged [ +PMComplexTest >> testThatComplexConjugationPreservesModulus [ | z | z := 3 - 4 i. From 6f2d3415ef18fe36aba5572c7e6f0c55b53af1b1 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 18:23:43 +0100 Subject: [PATCH 09/23] Extract computation of the complex conjugate to an intention-revealing temporary variable. --- src/Math-Complex/PMComplex.class.st | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Math-Complex/PMComplex.class.st b/src/Math-Complex/PMComplex.class.st index 50593e8b..be33894e 100644 --- a/src/Math-Complex/PMComplex.class.st +++ b/src/Math-Complex/PMComplex.class.st @@ -544,7 +544,9 @@ PMComplex >> isComplexConjugateOf: aNumber [ { #category : #testing } PMComplex >> isComplexConjugateOfAComplexNumber: aComplexNumber [ "Answer true if self and aComplexNumber are complex conjugates of each other. The complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign." - ^ (aComplexNumber real = real) and: [ aComplexNumber imaginary = (-1 * imaginary) ] + | conjugate | + conjugate := self complexConjugate . + ^ (aComplexNumber real = conjugate real) and: [ aComplexNumber imaginary = conjugate imaginary ] ] { #category : #testing } From c4d89b20308c9e56ce77b8cce77af432673e76f2 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 18:27:39 +0100 Subject: [PATCH 10/23] Simplified the predicate. --- src/Math-Complex/PMComplex.class.st | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-Complex/PMComplex.class.st b/src/Math-Complex/PMComplex.class.st index be33894e..a2ba4b52 100644 --- a/src/Math-Complex/PMComplex.class.st +++ b/src/Math-Complex/PMComplex.class.st @@ -543,10 +543,10 @@ PMComplex >> isComplexConjugateOf: aNumber [ { #category : #testing } PMComplex >> isComplexConjugateOfAComplexNumber: aComplexNumber [ + "Answer true if self and aComplexNumber are complex conjugates of each other. The complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign." - | conjugate | - conjugate := self complexConjugate . - ^ (aComplexNumber real = conjugate real) and: [ aComplexNumber imaginary = conjugate imaginary ] + + ^ self complexConjugate = aComplexNumber ] { #category : #testing } From 93dd8a04ad841df3d8411c692ff1283d7d007597 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 19:01:01 +0100 Subject: [PATCH 11/23] Clarified the name of the test. --- src/Math-Tests-Complex/PMComplexTest.class.st | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 32b9fbe6..cf942a02 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -735,6 +735,11 @@ PMComplexTest >> testTanh [ self assert: (c2 imaginary closeTo: c tanh imaginary). ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatComplexConjugateHasEqualRealPartAndAnImaginaryPartWithEqualMagnitudeButOppositeSign [ + self assert: (3 + 2 i isComplexConjugateOf: 3 - 2 i) +] + { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugateOfAPureRealNumberIsItself [ @@ -787,11 +792,6 @@ PMComplexTest >> testThatComplexConjugationPreservesModulus [ self assert: z complexConjugate abs equals: 5 ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testThatComplexConjugationYieldsANumberWithTheSameRealPartAndNegativeImaginaryPart [ - self assert: (3 + 2 i isComplexConjugateOf: 3 - 2 i) -] - { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | From 0e8b48f0a760031949cfff437a1f63c91af72a08 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 19:11:22 +0100 Subject: [PATCH 12/23] Made the return statement match the selector. --- src/Math-Complex/PMComplex.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Complex/PMComplex.class.st b/src/Math-Complex/PMComplex.class.st index a2ba4b52..d8f1731d 100644 --- a/src/Math-Complex/PMComplex.class.st +++ b/src/Math-Complex/PMComplex.class.st @@ -546,7 +546,7 @@ PMComplex >> isComplexConjugateOfAComplexNumber: aComplexNumber [ "Answer true if self and aComplexNumber are complex conjugates of each other. The complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign." - ^ self complexConjugate = aComplexNumber + ^ self = aComplexNumber complexConjugate ] { #category : #testing } From 3fcf89be6b729c03ba367d02437eae73b68b3ded Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 19:38:17 +0100 Subject: [PATCH 13/23] Clarified a test name. --- src/Math-Tests-Complex/PMComplexTest.class.st | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index cf942a02..9c6e5ed9 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -389,12 +389,6 @@ PMComplexTest >> testHash [ self assert: aComplex copy hash equals: aComplex hash ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testIsComplexConjugateOfNonConjugateDifferentComplex [ - - self deny: ((-0.5 - 1i) isComplexConjugateOf: (3 - 2i)) -] - { #category : #tests } PMComplexTest >> testIsComplexNumberOnComplex [ @@ -792,6 +786,12 @@ PMComplexTest >> testThatComplexConjugationPreservesModulus [ self assert: z complexConjugate abs equals: 5 ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatTwoEntirelyDifferentComplexNumbersAreNotComplexConjugatesOfEachOther [ + + self deny: ((-0.5 - 1i) isComplexConjugateOf: (3 - 2i)) +] + { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | From cadac644068e913ed307266737358f1352a1199c Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 19:38:47 +0100 Subject: [PATCH 14/23] Improved code formatting. --- src/Math-Tests-Complex/PMComplexTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 9c6e5ed9..f7270f4b 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -769,7 +769,7 @@ PMComplexTest >> testThatComplexConjugationIsDistributiveOverDivision [ z := 6 - 15 i. w := 10 + 5 i. - self assert: (z / w) complexConjugate equals: z complexConjugate / w complexConjugate + self assert: (z / w) complexConjugate equals: (z complexConjugate / w complexConjugate) ] { #category : #'testing - complex conjugation' } From 99b6c0a1d7bcab55820d8e7bed3aa14669b2ee31 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 19:44:45 +0100 Subject: [PATCH 15/23] Made the category consistent with the tests for ComplexNumber --- src/Math-Tests-Complex/PMNumberTest.class.st | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-Tests-Complex/PMNumberTest.class.st b/src/Math-Tests-Complex/PMNumberTest.class.st index bbed9c0e..99679edc 100644 --- a/src/Math-Tests-Complex/PMNumberTest.class.st +++ b/src/Math-Tests-Complex/PMNumberTest.class.st @@ -4,7 +4,7 @@ Class { #category : #'Math-Tests-Complex' } -{ #category : #'complex conjugation' } +{ #category : #'testing - complex conjugation' } PMNumberTest >> testComplexConjugateOfAnIntegerIsAnInteger [ |complexConjugateOfInteger| @@ -13,7 +13,7 @@ PMNumberTest >> testComplexConjugateOfAnIntegerIsAnInteger [ self assert: complexConjugateOfInteger equals: -5. ] -{ #category : #'complex conjugation' } +{ #category : #'testing - complex conjugation' } PMNumberTest >> testComplexConjugateOfRealFractionIsARealFraction [ | complexConjugateOfFraction | complexConjugateOfFraction := (Fraction numerator: 1 denominator: 6) complexConjugate. @@ -21,7 +21,7 @@ PMNumberTest >> testComplexConjugateOfRealFractionIsARealFraction [ self assert: complexConjugateOfFraction equals: (Fraction numerator: 1 denominator: 6) . ] -{ #category : #'complex conjugation' } +{ #category : #'testing - complex conjugation' } PMNumberTest >> testComplexConjugateOfRealNumberIsItself [ |realNumber| realNumber := 4.5 complexConjugate. From 1f6365b7af4f8ad77e75de3be4f9a98c4d52c402 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:06:22 +0100 Subject: [PATCH 16/23] Exercise the complexConjugate message directly. --- src/Math-Tests-Complex/PMComplexTest.class.st | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index f7270f4b..88a98b3a 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -731,13 +731,18 @@ PMComplexTest >> testTanh [ { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugateHasEqualRealPartAndAnImaginaryPartWithEqualMagnitudeButOppositeSign [ - self assert: (3 + 2 i isComplexConjugateOf: 3 - 2 i) + | z | + z := 3 + 2 i. + + self assert: z complexConjugate equals: 3 - 2 i ] { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugateOfAPureRealNumberIsItself [ - - self assert: ((5 + 0i) isComplexConjugateOf: 5) + | z | + z := 5 + 0 i. + + self assert: z complexConjugate equals: 5. ] { #category : #'testing - complex conjugation' } From 50ee46dbd08bde3f9cc3c5094fab18b8e9fb132d Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:07:20 +0100 Subject: [PATCH 17/23] Removed duplicate test - this is already in PMNumberTest. --- src/Math-Tests-Complex/PMComplexTest.class.st | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 88a98b3a..71b04645 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -745,12 +745,6 @@ PMComplexTest >> testThatComplexConjugateOfAPureRealNumberIsItself [ self assert: z complexConjugate equals: 5. ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testThatComplexConjugateOfAnIntegerIsItself [ - - self assert: (5 isComplexConjugateOf: 5) -] - { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugationIsAnInvolution [ | z | From f5e66f11dbf8bc25fbb2072e4f7f6188bda13866 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:10:40 +0100 Subject: [PATCH 18/23] Exercise the complexConjugate message directly. --- src/Math-Tests-Complex/PMComplexTest.class.st | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 71b04645..760919e8 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -773,8 +773,10 @@ PMComplexTest >> testThatComplexConjugationIsDistributiveOverDivision [ { #category : #'testing - complex conjugation' } PMComplexTest >> testThatComplexConjugationIsNotSymmetric [ - - self deny: ((3 - 2i) isComplexConjugateOf: (3 - 2i)) + | z | + z := 3 - 2 i. + + self deny: z complexConjugate equals: z ] { #category : #'testing - complex conjugation' } From d677792e4a3e70836cba8add353de9fd473fa537 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:12:19 +0100 Subject: [PATCH 19/23] Exercise complexConjugate directly. --- src/Math-Tests-Complex/PMComplexTest.class.st | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 760919e8..b8c3ef5b 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -789,8 +789,10 @@ PMComplexTest >> testThatComplexConjugationPreservesModulus [ { #category : #'testing - complex conjugation' } PMComplexTest >> testThatTwoEntirelyDifferentComplexNumbersAreNotComplexConjugatesOfEachOther [ - - self deny: ((-0.5 - 1i) isComplexConjugateOf: (3 - 2i)) + | z | + z := -0.5 - 1 i. + + self deny: z complexConjugate equals: (3 - 2i) ] { #category : #tests } From 4d022caced60fb85d2f80f63fe76d55225560699 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:16:51 +0100 Subject: [PATCH 20/23] Added tests that exercise isComplexConjugateOf directly. --- src/Math-Tests-Complex/PMComplexTest.class.st | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index b8c3ef5b..a45209aa 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -795,6 +795,22 @@ PMComplexTest >> testThatTwoEntirelyDifferentComplexNumbersAreNotComplexConjugat self deny: z complexConjugate equals: (3 - 2i) ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatWeCanIdentifyThatTwoComplexNumbersAreComplexConjugates [ + | z | + z := 3 - 2 i. + + self assert: (z isComplexConjugateOf: (3 + 2 i)) +] + +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testThatWeCanIdentifyThatTwoComplexNumbersAreNotComplexConjugatesOfEachOther [ + | z | + z := -4 - 8 i. + + self deny: (z isComplexConjugateOf: 13 + 12 i) +] + { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | From fba37a1de745266e232607285ddb87238519812d Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:19:15 +0100 Subject: [PATCH 21/23] Made the test name consistent. --- src/Math-Tests-Complex/PMComplexTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index a45209aa..18d50fa4 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -796,7 +796,7 @@ PMComplexTest >> testThatTwoEntirelyDifferentComplexNumbersAreNotComplexConjugat ] { #category : #'testing - complex conjugation' } -PMComplexTest >> testThatWeCanIdentifyThatTwoComplexNumbersAreComplexConjugates [ +PMComplexTest >> testThatWeCanIdentifyThatTwoComplexNumbersAreComplexConjugatesOfEachOther [ | z | z := 3 - 2 i. From 194876988b79a0068eebb7b14ab73ae2e281fcf3 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:24:34 +0100 Subject: [PATCH 22/23] Made the test names a little more concise. --- src/Math-Tests-Complex/PMComplexTest.class.st | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 18d50fa4..2e60d651 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -796,21 +796,13 @@ PMComplexTest >> testThatTwoEntirelyDifferentComplexNumbersAreNotComplexConjugat ] { #category : #'testing - complex conjugation' } -PMComplexTest >> testThatWeCanIdentifyThatTwoComplexNumbersAreComplexConjugatesOfEachOther [ +PMComplexTest >> testThatWeCanIdentifyTwoComplexNumbersAsBeingComplexConjugatesOfEachOther [ | z | z := 3 - 2 i. self assert: (z isComplexConjugateOf: (3 + 2 i)) ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testThatWeCanIdentifyThatTwoComplexNumbersAreNotComplexConjugatesOfEachOther [ - | z | - z := -4 - 8 i. - - self deny: (z isComplexConjugateOf: 13 + 12 i) -] - { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | @@ -838,6 +830,14 @@ PMComplexTest >> testTwoComplexNumbersWithDifferentRealPartsAreNotEqual [ self deny: z equals: w. ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testWeCanIdentifyTwoComplexNumbersAsNotBeingComplexConjugatesOfEachOther [ + | z | + z := -4 - 8 i. + + self deny: (z isComplexConjugateOf: 13 + 12 i) +] + { #category : #'testing - expressing complex numbers' } PMComplexTest >> testWeCanWriteComplexNumbersWhoseRealAndImaginaryPartsAreFractions [ | z | From 6307f898ba165e8893774b3ee0f13c742a50c16c Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Tue, 19 Apr 2022 20:26:01 +0100 Subject: [PATCH 23/23] Made the test name more similar/consistent. --- src/Math-Tests-Complex/PMComplexTest.class.st | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st index 2e60d651..699ee6dd 100644 --- a/src/Math-Tests-Complex/PMComplexTest.class.st +++ b/src/Math-Tests-Complex/PMComplexTest.class.st @@ -795,14 +795,6 @@ PMComplexTest >> testThatTwoEntirelyDifferentComplexNumbersAreNotComplexConjugat self deny: z complexConjugate equals: (3 - 2i) ] -{ #category : #'testing - complex conjugation' } -PMComplexTest >> testThatWeCanIdentifyTwoComplexNumbersAsBeingComplexConjugatesOfEachOther [ - | z | - z := 3 - 2 i. - - self assert: (z isComplexConjugateOf: (3 + 2 i)) -] - { #category : #tests } PMComplexTest >> testTimesPolynomial [ | c poly | @@ -830,6 +822,14 @@ PMComplexTest >> testTwoComplexNumbersWithDifferentRealPartsAreNotEqual [ self deny: z equals: w. ] +{ #category : #'testing - complex conjugation' } +PMComplexTest >> testWeCanIdentifyTwoComplexNumbersAsBeingComplexConjugatesOfEachOther [ + | z | + z := 3 - 2 i. + + self assert: (z isComplexConjugateOf: (3 + 2 i)) +] + { #category : #'testing - complex conjugation' } PMComplexTest >> testWeCanIdentifyTwoComplexNumbersAsNotBeingComplexConjugatesOfEachOther [ | z |