From a9a955eb8f700ebeab0523640cf48d37a0200c49 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 17 Jan 2024 08:27:36 +0000 Subject: [PATCH] refactor/test: removed a comment, and added a missing test. --- src/Math-Complex/PMComplexNumber.class.st | 6 +++--- src/Math-Tests-Complex/PMComplexNumberTest.class.st | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Math-Complex/PMComplexNumber.class.st b/src/Math-Complex/PMComplexNumber.class.st index 84a95d98..057d347c 100644 --- a/src/Math-Complex/PMComplexNumber.class.st +++ b/src/Math-Complex/PMComplexNumber.class.st @@ -626,9 +626,9 @@ PMComplexNumber >> raisedTo: index [ index isInteger ifTrue: [ ^ self raisedToInteger: index ]. - 0 = index ifTrue: [ ^ self class one ]. "Special case of exponent=0" - 1 = index ifTrue: [ ^ self ]. "Special case of exponent=1" - 0 = self ifTrue: [ "Special case of self = 0" + 0 = index ifTrue: [ ^ self class one ]. + 1 = index ifTrue: [ ^ self ]. + 0 = self ifTrue: [ ^ index < 0 ifTrue: [ (ZeroDivide dividend: self) signal ] ifFalse: [ self ] ]. diff --git a/src/Math-Tests-Complex/PMComplexNumberTest.class.st b/src/Math-Tests-Complex/PMComplexNumberTest.class.st index f9835ef7..341c50c1 100644 --- a/src/Math-Tests-Complex/PMComplexNumberTest.class.st +++ b/src/Math-Tests-Complex/PMComplexNumberTest.class.st @@ -670,6 +670,13 @@ PMComplexNumberTest >> testRaisedToPositiveInteger [ self assert: zCubed closeTo: (0 + 1 i). ] +{ #category : #'testing - mathematical functions' } +PMComplexNumberTest >> testRaisingZeroToThePowerOfNegativeIndex [ + | zero | + zero := PMComplexNumber zero. + self should: [ zero raisedTo: -4 ] raise: ZeroDivide +] + { #category : #tests } PMComplexNumberTest >> testRandom [ | random c r |