@@ -468,6 +468,16 @@ defmodule Kernel.ExpansionTest do
468468 end
469469 end
470470
471+ describe "floats" do
472+ test "cannot be 0.0 inside match" do
473+ assert capture_io ( :stderr , fn -> expand ( quote ( do: 0.0 = 0.0 ) ) end ) =~
474+ "pattern matching on 0.0 is equivalent to matching only on +0.0 from Erlang/OTP 27+"
475+
476+ assert { := , [ ] , [ + 0.0 , + 0.0 ] } = expand ( quote ( do: + 0.0 = 0.0 ) )
477+ assert { := , [ ] , [ - 0.0 , + 0.0 ] } = expand ( quote ( do: - 0.0 = 0.0 ) )
478+ end
479+ end
480+
471481 describe "tuples" do
472482 test "expanded as arguments" do
473483 assert expand ( quote ( do: { after_expansion = 1 , a } ) ) == quote ( do: { after_expansion = 1 , a ( ) } )
@@ -715,8 +725,11 @@ defmodule Kernel.ExpansionTest do
715725 expand ( quote ( do: [ 1 ] ++ 2 ++ [ 3 ] = [ 1 , 2 , 3 ] ) )
716726 end )
717727
718- assert { := , _ , [ - 1 , { { :. , _ , [ :erlang , :- ] } , _ , [ 1 ] } ] } = expand ( quote ( do: - 1 = - 1 ) )
719- assert { := , _ , [ 1 , { { :. , _ , [ :erlang , :+ ] } , _ , [ 1 ] } ] } = expand ( quote ( do: + 1 = + 1 ) )
728+ assert { := , _ , [ - 1 , { { :. , _ , [ :erlang , :- ] } , _ , [ 1 ] } ] } =
729+ expand ( quote ( do: - 1 = - 1 ) )
730+
731+ assert { := , _ , [ 1 , { { :. , _ , [ :erlang , :+ ] } , _ , [ 1 ] } ] } =
732+ expand ( quote ( do: + 1 = + 1 ) )
720733
721734 assert { := , _ , [ [ { :| , _ , [ 1 , [ { :| , _ , [ 2 , 3 ] } ] ] } ] , [ 1 , 2 , 3 ] ] } =
722735 expand ( quote ( do: [ 1 ] ++ [ 2 ] ++ 3 = [ 1 , 2 , 3 ] ) )
0 commit comments