Skip to content

Commit

Permalink
test: added some missing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
hemalvarambhia committed Jan 6, 2024
1 parent 9b8c274 commit d557e73
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/Math-Tests-Complex/PMComplexNumberTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -639,17 +639,42 @@ PMComplexNumberTest >> testRaisedTo [

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToInteger [
| c c3 z expected |

| c c3 |
c := 5 - 6 i.
c3 := c * c * c.
self assert: (c raisedToInteger: -3) equals: c3 reciprocal.

z := (3 sqrt / 2) + (1/2) i.
self assert: (c raisedToInteger: -3) equals: c3 reciprocal
]

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToNegativeInteger [

| z expected |
z := 3 sqrt / 2 + (1 / 2) i.
"Here, we appeal to de Moivre's theorem to compute the expected answer"
expected := 0 - 1 i.
self assert: (z raisedTo: -3) closeTo: expected
]

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToPositiveNumber [
| z expected |
z := (3 sqrt / 2) + (1/2) i.
"Here, we appeal to de Moivre's theorem to compute the expected answer"
expected := 0 + 1 i.
self assert: (z raisedTo: 3) closeTo: expected.
]

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToZero [

| z expected |
z := 3 sqrt / 2 + (1 / 2) i.
"Here, we appeal to de Moivre's theorem to compute the expected answer"
expected := 1 .
self assert: (z raisedTo: 0) equals: expected
]

{ #category : #tests }
PMComplexNumberTest >> testRandom [
| random c r |
Expand Down

0 comments on commit d557e73

Please sign in to comment.