@@ -192,6 +192,27 @@ defmodule ComplexTest do
192192 assert_close Complex . acoth ( 1.0049698 ) , a
193193 end
194194
195+ for { m , f } <- [ { Kernel , :inspect } , { String.Chars.Complex , :to_string } , { Complex , :to_string } ] do
196+ test "#{ m } .#{ f } /1" do
197+ assert "1.0+1.0i" == apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , 1.0 ) ] )
198+ assert "1.0-1.0i" == apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , - 1.0 ) ] )
199+ assert "1.0+0.0i" == apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , 0.0 ) ] )
200+ assert "1.0+0.0i" == apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , - 0.0 ) ] )
201+
202+ assert "1.0-1.0i" ==
203+ apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , 1.0 ) |> Complex . conjugate ( ) ] )
204+
205+ assert "1.0+1.0i" ==
206+ apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , - 1.0 ) |> Complex . conjugate ( ) ] )
207+
208+ assert "1.0+0.0i" ==
209+ apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , 0.0 ) |> Complex . conjugate ( ) ] )
210+
211+ assert "1.0+0.0i" ==
212+ apply ( unquote ( m ) , unquote ( f ) , [ Complex . new ( 1.0 , - 0.0 ) |> Complex . conjugate ( ) ] )
213+ end
214+ end
215+
195216 defp assert_close ( left , right , opts \\ [ ] ) do
196217 eps = opts [ :eps ] || 1.0e-5
197218
0 commit comments