-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 192: Have Number Provide Complex Conjugate Message (#235)
* Added a complexConjugate message to the Short Float. * Moved the method to the parent class. * Added a failing test to get passing for next session * Integer now responds to the complexConjugate message. * Moved the methods up to Number * Tested that the complex conjugate of a real fraction is itself. * We cannot instanciate a fraction whose numerator and denominator are complex numbers. It may be that we need to normalise the denominator first. * We can now write fractions of complex numbers that have already been normalized. * Added a test to demonstrate that we can write a complex number whose real and imaginary parts are Fractions. * Remove unnecessary comment. * Corrected the name of the test method. * May not make sense to convert a complex number to an integer, so inlined method and corrected a programmer test. * Clarified the category of the tests. * Clarified the category of the messages.
- Loading branch information
1 parent
b3633ef
commit 3f5808f
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Class { | ||
#name : #PMNumberTest, | ||
#superclass : #TestCase, | ||
#category : #'Math-Tests-Complex' | ||
} | ||
|
||
{ #category : #'complex conjugation' } | ||
PMNumberTest >> testComplexConjugateOfAnIntegerIsAnInteger [ | ||
|complexConjugateOfInteger| | ||
|
||
complexConjugateOfInteger := -5 complexConjugate. | ||
|
||
self assert: complexConjugateOfInteger equals: -5. | ||
] | ||
|
||
{ #category : #'complex conjugation' } | ||
PMNumberTest >> testComplexConjugateOfRealFractionIsARealFraction [ | ||
| complexConjugateOfFraction | | ||
complexConjugateOfFraction := (Fraction numerator: 1 denominator: 6) complexConjugate. | ||
|
||
self assert: complexConjugateOfFraction equals: (Fraction numerator: 1 denominator: 6) . | ||
] | ||
|
||
{ #category : #'complex conjugation' } | ||
PMNumberTest >> testComplexConjugateOfRealNumberIsItself [ | ||
|realNumber| | ||
realNumber := 4.5 complexConjugate. | ||
|
||
self assert: realNumber equals: 4.5 | ||
] |