File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1046,7 +1046,7 @@ defmodule Kernel do
1046
1046
1047
1047
"""
1048
1048
defmacro left + right do
1049
- quote do: :erlang . + ( unquote ( left ) , unquote ( right ) )
1049
+ quote do: __op__ ( :+ , unquote ( left ) , unquote ( right ) )
1050
1050
end
1051
1051
1052
1052
@ doc """
@@ -1059,7 +1059,7 @@ defmodule Kernel do
1059
1059
1060
1060
"""
1061
1061
defmacro left - right do
1062
- quote do: :erlang . - ( unquote ( left ) , unquote ( right ) )
1062
+ quote do: __op__ ( :- , unquote ( left ) , unquote ( right ) )
1063
1063
end
1064
1064
1065
1065
@ doc """
@@ -1100,7 +1100,7 @@ defmodule Kernel do
1100
1100
1101
1101
"""
1102
1102
defmacro left * right do
1103
- quote do: :erlang . * ( unquote ( left ) , unquote ( right ) )
1103
+ quote do: __op__ ( :* , unquote ( left ) , unquote ( right ) )
1104
1104
end
1105
1105
1106
1106
@ doc """
@@ -1117,7 +1117,7 @@ defmodule Kernel do
1117
1117
1118
1118
"""
1119
1119
defmacro left / right do
1120
- quote do: :erlang . / ( unquote ( left ) , unquote ( right ) )
1120
+ quote do: __op__ ( :/ , unquote ( left ) , unquote ( right ) )
1121
1121
end
1122
1122
1123
1123
@ doc """
Original file line number Diff line number Diff line change @@ -4,6 +4,13 @@ defmodule Kernel.FnTest do
4
4
use ExUnit.Case , async: true
5
5
import CompileAssertion
6
6
7
+ test "arithmetic constants on match" do
8
+ assert ( fn 1 + 2 -> :ok end ) . ( 3 ) == :ok
9
+ assert ( fn 1 - 2 -> :ok end ) . ( - 1 ) == :ok
10
+ assert ( fn - 1 -> :ok end ) . ( - 1 ) == :ok
11
+ assert ( fn + 1 -> :ok end ) . ( 1 ) == :ok
12
+ end
13
+
7
14
test "clause with ^" do
8
15
x = 1
9
16
assert ( fn ^ x -> :ok ; _ -> :error end ) . ( 1 ) == :ok
You can’t perform that action at this time.
0 commit comments