exercism / exercism/elixir-representer
Normalize struct names
- Langage dominant
- Elixir
- Étoiles
- 11
- Forks
- 8
- Merge moyen
- 11 j 3 h
- PR mergées (30 j)
- 1
Description
This is mentioned in #29.
Struct names should be replaced by placeholders as well.
## Example input
```elixir
defmodule Something do
defstruct [:a, :b]
def something(%Something{a: a}), do: %Something{a: 2 * a}
def something_else(%__MODULE__{a: a}), do: %__MODULE__{a: 3 * a}
end
```
## Desired output
```elixir
defmodule(PLACEHOLDER_1) do
defstruct([:a, :b])
def(PLACEHOLDER_2(%PLACEHOLDER_1{a: PLACEHOLDER_3})) do
%PLACEHOLDER_1{a: 2 * PLACEHOLDER_3}
end
def(PLACEHOLDER_4(%__MODULE__{a: PLACEHOLDER_3})) do
%__MODULE__{a: 3 * PLACEHOLDER_3}
end
end
```
I think `__MODULE__` should not be replaced, because it means different things in different modules. It's already normalized, in a way...
## Current output
```elixir
defmodule(PLACEHOLDER_1) do
defstruct([:a, :b])
def(PLACEHOLDER_2(%Something{a: PLACEHOLDER_3})) do
%Something{a: 2 * PLACEHOLDER_3}
end
def(PLACEHOLDER_4(%__MODULE__{a: PLACEHOLDER_3})) do
%__MODULE__{a: 3 * PLACEHOLDER_3}
end
end
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.