Skip to content

Commit

Permalink
vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Sep 27, 2023
1 parent 0548765 commit bed3a75
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 81 deletions.
12 changes: 6 additions & 6 deletions lib/erlex.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Erlex do
defmodule ErlexVendored do
@moduledoc """
Convert Erlang style structs and error messages to equivalent Elixir.
Expand All @@ -7,24 +7,24 @@ defmodule Erlex do
## Usage
Invoke `Erlex.pretty_print/1` wuth the input string.
Invoke `ErlexVendored.pretty_print/1` wuth the input string.
```elixir
iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(),'Elixir.Keyword':t() | map()) -> 'Elixir.Plug.Conn':t()"
iex> Erlex.pretty_print(str)
iex> ErlexVendored.pretty_print(str)
(Plug.Conn.t(), binary() | atom(), Keyword.t() | map()) :: Plug.Conn.t()
```
While the lion's share of the work is done via invoking
`Erlex.pretty_print/1`, other higher order functions exist for further
`ErlexVendored.pretty_print/1`, other higher order functions exist for further
formatting certain messages by running through the Elixir formatter.
Because we know the previous example is a type, we can invoke the
`Erlex.pretty_print_contract/1` function, which would format that
`ErlexVendored.pretty_print_contract/1` function, which would format that
appropriately for very long lines.
```elixir
iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(),'Elixir.Keyword':t() | map(), map() | atom(), non_neg_integer(), binary(), binary(), binary(), binary(), binary()) -> 'Elixir.Plug.Conn':t()"
iex> Erlex.pretty_print_contract(str)
iex> ErlexVendored.pretty_print_contract(str)
(
Plug.Conn.t(),
binary() | atom(),
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
defmodule Erlex.MixProject do
defmodule ErlexVendored.MixProject do
use Mix.Project

@version "0.2.6"
@repo_url "https://github.com/asummers/erlex"

def project do
[
app: :erlex,
app: :erlex_vendored,
version: @version,
elixir: "~> 1.6",
start_permanent: Mix.env() == :prod,
Expand Down
32 changes: 16 additions & 16 deletions test/literals_pretty_print_test.exs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
defmodule Erlex.Test.LiteralsPretyPrintTest do
defmodule ErlexVendored.Test.LiteralsPretyPrintTest do
use ExUnit.Case

test "nil is parsed appropriately" do
input = "nil"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "nil"
assert pretty_printed == expected_output
end

test "true is parsed appropriately" do
input = "true"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "true"
assert pretty_printed == expected_output
end

test "false is parsed appropriately" do
input = "false"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "false"
assert pretty_printed == expected_output
Expand All @@ -30,7 +30,7 @@ defmodule Erlex.Test.LiteralsPretyPrintTest do
[]
"""

pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "[]"
assert pretty_printed == expected_output
Expand All @@ -41,7 +41,7 @@ defmodule Erlex.Test.LiteralsPretyPrintTest do
#{}
"""

pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "%{}"
assert pretty_printed == expected_output
Expand All @@ -52,7 +52,7 @@ defmodule Erlex.Test.LiteralsPretyPrintTest do
{}
"""

pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "{}"
assert pretty_printed == expected_output
Expand All @@ -61,7 +61,7 @@ defmodule Erlex.Test.LiteralsPretyPrintTest do
test "maps are pretty printed appropriately" do
input = ~S"#{'halted':='true'}"

pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "%{:halted => true}"
assert pretty_printed == expected_output
Expand All @@ -70,55 +70,55 @@ defmodule Erlex.Test.LiteralsPretyPrintTest do
test "structs are pretty printed appropriately" do
input = ~S"#{'halted':='true', '__struct__':='Elixir.Plug.Conn'}"

pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "%Plug.Conn{:halted => true}"
assert pretty_printed == expected_output
end

test "ranges are pretty printed appropriately" do
input = "1..5"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "1..5"
assert pretty_printed == expected_output
end

test "zero arg functions in contract are pretty printed appropriately" do
input = "() -> atom()"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "() :: atom()"
assert pretty_printed == expected_output
end

test "empty binary is pretty printed appropriately" do
input = "<<>>"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "<<>>"
assert pretty_printed == expected_output
end

test "sized binary is pretty printed appropriately" do
input = "<<_:64>>"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "<<_ :: 64>>"
assert pretty_printed == expected_output
end

test "unit binary is pretty printed appropriately" do
input = "<<_:_*12>>"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "<<_ :: size(12)>>"
assert pretty_printed == expected_output
end

test "sized list binary is pretty printed appropriately" do
input = "<<_:64,_:_*8>>"
pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

expected_output = "<<_ :: 64, _ :: size(8)>>"
assert pretty_printed == expected_output
Expand All @@ -127,7 +127,7 @@ defmodule Erlex.Test.LiteralsPretyPrintTest do
test "binary as first value in pattern" do
input = "<<<_:8,_:_*1>>,'false'>"

pretty_printed = Erlex.pretty_print(input)
pretty_printed = ErlexVendored.pretty_print(input)

assert pretty_printed == "<<_ :: 8, _ :: size(1)>>, false"
end
Expand Down
Loading

0 comments on commit bed3a75

Please sign in to comment.