Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure Macro.to_binary work with unary not

  • Loading branch information...
commit 8b66976c96a5b15c2c357c5d0322dc57bdb4fed7 1 parent 36e6261
@josevalim josevalim authored
View
4 lib/elixir/lib/macro.ex
@@ -246,6 +246,10 @@ defmodule Macro do
end
# Unary ops
+ def to_binary({ :not, _, [arg] }) do
+ "not " <> to_binary(arg)
+ end
+
def to_binary({ op, _, [arg] }) when op in unary_ops do
atom_to_binary(op, :utf8) <> to_binary(arg)
end
View
2  lib/elixir/test/elixir/macro_test.exs
@@ -245,6 +245,8 @@ defmodule MacroTest do
end
test :unary_ops_to_binary do
+ assert Macro.to_binary(quote do: not 1) == "not 1"
+ assert Macro.to_binary(quote do: not foo) == "not foo"
assert Macro.to_binary(quote do: -1) == "-1"
assert Macro.to_binary(quote do: @foo(bar)) == "@foo(bar)"
end
Please sign in to comment.
Something went wrong with that request. Please try again.