@@ -233,5 +233,79 @@ describe('Complex numbers', () => {
233233 expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
234234 expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
235235 } ) ;
236+
237+ xtest ( 'Exponential resulting in a number with real and imaginary part' , ( ) => {
238+ const expected = new ComplexNumber ( 1 , 1 ) ;
239+ const actual = new ComplexNumber ( Math . LN2 / 2 , Math . PI / 4 ) . exp ;
240+
241+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
242+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
243+ } ) ;
244+ } ) ;
245+
246+ describe ( 'Operations between real numbers and complex numbers' , ( ) => {
247+ xtest ( 'Add real number to complex number' , ( ) => {
248+ const expected = new ComplexNumber ( 6 , 2 ) ;
249+ const actual = new ComplexNumber ( 1 , 2 ) . add ( new ComplexNumber ( 5 , 0 ) ) ;
250+
251+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
252+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
253+ } ) ;
254+
255+ xtest ( 'Add complex number to real number' , ( ) => {
256+ const expected = new ComplexNumber ( 6 , 2 ) ;
257+ const actual = new ComplexNumber ( 5 , 0 ) . add ( new ComplexNumber ( 1 , 2 ) ) ;
258+
259+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
260+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
261+ } ) ;
262+
263+ xtest ( 'Subtract real number from complex number' , ( ) => {
264+ const expected = new ComplexNumber ( 1 , 7 ) ;
265+ const actual = new ComplexNumber ( 5 , 7 ) . sub ( new ComplexNumber ( 4 , 0 ) ) ;
266+
267+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
268+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
269+ } ) ;
270+
271+ xtest ( 'Subtract complex number from real number' , ( ) => {
272+ const expected = new ComplexNumber ( - 1 , - 7 ) ;
273+ const actual = new ComplexNumber ( 4 , 0 ) . sub ( new ComplexNumber ( 5 , 7 ) ) ;
274+
275+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
276+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
277+ } ) ;
278+
279+ xtest ( 'Multiply complex number by real number' , ( ) => {
280+ const expected = new ComplexNumber ( 10 , 25 ) ;
281+ const actual = new ComplexNumber ( 2 , 5 ) . mul ( new ComplexNumber ( 5 , 0 ) ) ;
282+
283+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
284+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
285+ } ) ;
286+
287+ xtest ( 'Multiply real number by complex number' , ( ) => {
288+ const expected = new ComplexNumber ( 10 , 25 ) ;
289+ const actual = new ComplexNumber ( 5 , 0 ) . mul ( new ComplexNumber ( 2 , 5 ) ) ;
290+
291+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
292+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
293+ } ) ;
294+
295+ xtest ( 'Divide complex number by real number' , ( ) => {
296+ const expected = new ComplexNumber ( 1 , 10 ) ;
297+ const actual = new ComplexNumber ( 10 , 100 ) . div ( new ComplexNumber ( 10 , 0 ) ) ;
298+
299+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
300+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
301+ } ) ;
302+
303+ xtest ( 'Divide real number by complex number' , ( ) => {
304+ const expected = new ComplexNumber ( 2.5 , - 2.5 ) ;
305+ const actual = new ComplexNumber ( 5 , 0 ) . div ( new ComplexNumber ( 1 , 1 ) ) ;
306+
307+ expect ( actual . real ) . toBeCloseTo ( expected . real ) ;
308+ expect ( actual . imag ) . toBeCloseTo ( expected . imag ) ;
309+ } ) ;
236310 } ) ;
237311} ) ;
0 commit comments