File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,10 @@ defimpl Inspect, for: Integer do
262262
263263 defp prepend_prefix ( value , :decimal ) , do: value
264264
265+ defp prepend_prefix ( << ?- , value :: binary >> , base ) do
266+ "-" <> prepend_prefix ( value , base )
267+ end
268+
265269 defp prepend_prefix ( value , base ) do
266270 prefix =
267271 case base do
Original file line number Diff line number Diff line change @@ -194,14 +194,17 @@ defmodule Inspect.NumberTest do
194194
195195 test "hex" do
196196 assert inspect ( 100 , base: :hex ) == "0x64"
197+ assert inspect ( - 100 , base: :hex ) == "-0x64"
197198 end
198199
199200 test "octal" do
200201 assert inspect ( 100 , base: :octal ) == "0o144"
202+ assert inspect ( - 100 , base: :octal ) == "-0o144"
201203 end
202204
203205 test "binary" do
204206 assert inspect ( 86 , base: :binary ) == "0b1010110"
207+ assert inspect ( - 86 , base: :binary ) == "-0b1010110"
205208 end
206209
207210 test "float" do
You can’t perform that action at this time.
0 commit comments