From d557e7329df8a5b787ec5c17ed3537c29edf342f Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sat, 6 Jan 2024 18:08:24 +0000 Subject: [PATCH] test: added some missing tests. --- .../PMComplexNumberTest.class.st | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/Math-Tests-Complex/PMComplexNumberTest.class.st b/src/Math-Tests-Complex/PMComplexNumberTest.class.st index c1bc0ac0..464e83bb 100644 --- a/src/Math-Tests-Complex/PMComplexNumberTest.class.st +++ b/src/Math-Tests-Complex/PMComplexNumberTest.class.st @@ -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 |