Skip to content

Commit d4912c5

Browse files
Added another test to demonstrate that the square root of a negative pure imaginary number is a complex number with real and imaginary
parts.
1 parent 4a0cbb4 commit d4912c5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Math-Tests-Complex/PMComplexTest.class.st

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,19 @@ PMComplexTest >> testSquareRootOfANegativeRealNumberIsPureImaginary [
626626
self assert: squareRoot equals: 2 i.
627627
]
628628

629+
{ #category : #tests }
630+
PMComplexTest >> testSquareRootOfNegativePureImaginaryNumberIsAComplexNumberWithRealAndImaginaryParts [
631+
| squareRoot expected pureImaginaryNumber |
632+
pureImaginaryNumber := PMComplex real: 0 imaginary: -4.
633+
634+
squareRoot := pureImaginaryNumber sqrt.
635+
636+
expected := 2 sqrt negated + 2 sqrt i.
637+
self assert: squareRoot real closeTo: expected real.
638+
self assert: squareRoot imaginary closeTo: expected imaginary
639+
640+
]
641+
629642
{ #category : #tests }
630643
PMComplexTest >> testSquareRootOfPositivePureImaginaryNumberIsAComplexNumberWithRealAndImaginaryParts [
631644

0 commit comments

Comments
 (0)