Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for complex numbers #325

Merged
merged 23 commits into from
Jan 18, 2024
Merged
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
af69a66
test: added a test for positive integer.
hemalvarambhia Jan 11, 2024
ccd3076
test: added some missing tests.
hemalvarambhia Jan 11, 2024
7abf584
refactor: corrected the category.
hemalvarambhia Jan 11, 2024
d64a1bd
test: changed the test data to cos(pi/3) + i sin(pi/3).
hemalvarambhia Jan 15, 2024
f96485e
comment: added documentation that shows how to get the answer using D…
hemalvarambhia Jan 15, 2024
f4d8a3c
test: added another missing test.
hemalvarambhia Jan 15, 2024
a04e512
refactor: made the test name shorter and hopefully more concise.
hemalvarambhia Jan 15, 2024
eca5b1d
fix: corrected the documentation.
hemalvarambhia Jan 15, 2024
abf6a61
test: demonstrated that sending raiseToInteger: with floating point n…
hemalvarambhia Jan 15, 2024
45b4d3c
refactor: clarified the name of a method.
hemalvarambhia Jan 15, 2024
1a0b3ca
refactor: ComplexNumber is a Whole Value and we can assert equality.
hemalvarambhia Jan 15, 2024
fdae061
refactor: Inline Variable as it is not paying its rent.
hemalvarambhia Jan 15, 2024
ede673d
test: simplified the test a little.
hemalvarambhia Jan 16, 2024
baaa8a3
refactor: extracted computations to local variables.
hemalvarambhia Jan 16, 2024
ec19743
refactor: extracted writing complex numbers in polar coordinates to t…
hemalvarambhia Jan 16, 2024
2e882c9
refactor: corrected the name of the test.
hemalvarambhia Jan 16, 2024
94e6d49
refactor: renamed the test to make it clear we are writing complex nu…
hemalvarambhia Jan 16, 2024
4ad4f60
refactor: clarified the names of some message arguments.
hemalvarambhia Jan 17, 2024
bca0a1f
Removed the comment, as the code is self-explanatory.
hemalvarambhia Jan 17, 2024
91af93f
refactor: Rename Variable where we clarify the name of a variable.
hemalvarambhia Jan 17, 2024
9aaedf0
chore: corrected the name of the comment.
hemalvarambhia Jan 17, 2024
a9a955e
refactor/test: removed a comment, and added a missing test.
hemalvarambhia Jan 17, 2024
b04f7c9
test: added another missing test.
hemalvarambhia Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Math-Tests-Complex/PMComplexNumberTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,15 @@ PMComplexNumberTest >> testRaisedTo [
self assert: c3 imaginary closeTo: c imaginary
]

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

| z expected |
z := 0 + 1 i.
hernanmd marked this conversation as resolved.
Show resolved Hide resolved
expected := 3 sqrt / 2 + (1 / 2) i.
self assert: (z raisedTo: 1 / 3) closeTo: expected
]

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToInteger [
| c c3 |
Expand All @@ -646,6 +655,21 @@ PMComplexNumberTest >> testRaisedToInteger [
self assert: c3 reciprocal equals: (c raisedToInteger: -3)
]

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToNegativeInteger [
| z |
z := (3 sqrt / 2) + (1 / 2) i.
self assert: (z raisedTo: -3) closeTo: (0 - 1 i).
]

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToPositiveInteger [
| z zCubed |
z := (3 sqrt / 2) + (1 / 2) i.
zCubed := (z raisedTo: 3) .
self assert: zCubed closeTo: (0 + 1 i).
]

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