Skip to content

Commit

Permalink
refactor/test: removed a comment, and added a missing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
hemalvarambhia committed Jan 17, 2024
1 parent 9aaedf0 commit a9a955e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Math-Complex/PMComplexNumber.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ].
Expand Down
7 changes: 7 additions & 0 deletions src/Math-Tests-Complex/PMComplexNumberTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down

0 comments on commit a9a955e

Please sign in to comment.