1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/core/complex
Stephen Ierodiaconou 54cad3123a
[Bug #19004] Complex.polar handles complex singular abs argument
`Complex.polar` accepts Complex values as arguments for the polar form as long
as the value of the complex has no imaginary part (ie it is 'real'). In
`f_complex_polar` this is handled by extracting the real part of the arguments.
However in the case `polar` is called with only a single argument, the absolute
value (abs), then the Complex is created without applying a check on the type
of abs, meaning it is possible to create a Complex where the real part is itself
an instance of a Complex. This change removes the short circuit for the single
argument case meaning the real part extraction is performed correctly
(by f_complex_polar).

Also adds an example to `spec/ruby/core/complex/polar_spec.rb` to check that
the real part of a complex argument is correctly extracted and used in the
resulting Complex real and imaginary parts.
2022-10-23 12:59:06 +09:00
..
shared
abs2_spec.rb
abs_spec.rb
angle_spec.rb
arg_spec.rb
coerce_spec.rb
comparison_spec.rb
conj_spec.rb
conjugate_spec.rb
constants_spec.rb
denominator_spec.rb
divide_spec.rb
eql_spec.rb
equal_value_spec.rb
exponent_spec.rb
fdiv_spec.rb
finite_spec.rb
hash_spec.rb
imag_spec.rb
imaginary_spec.rb
infinite_spec.rb
inspect_spec.rb
integer_spec.rb
magnitude_spec.rb
marshal_dump_spec.rb
minus_spec.rb
multiply_spec.rb
negative_spec.rb
numerator_spec.rb
phase_spec.rb
plus_spec.rb
polar_spec.rb
positive_spec.rb
quo_spec.rb
rationalize_spec.rb
real_spec.rb
rect_spec.rb
rectangular_spec.rb
to_c_spec.rb
to_f_spec.rb
to_i_spec.rb
to_r_spec.rb
to_s_spec.rb
uminus_spec.rb