-
-
Notifications
You must be signed in to change notification settings - Fork 6
Document structs, maps, keyword lists via testing & fix accidental key replacement bug #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5ec59d1
Add tests for user defined structs
angelikatyborska 9dc4cfd
Reps are valid Elixir code so give me syntax coloring
angelikatyborska b31d782
Add test for standard lib structs
angelikatyborska 79e2f5b
Add more user-defined structs tests
angelikatyborska 8239fcb
Add test for accidental struct key replacement
angelikatyborska fc1915d
Add a maps test
angelikatyborska 519f78d
Add keyword list test
angelikatyborska d2fc2d3
Try to fix unwanted key replacement and see what else breaks
angelikatyborska 35a36cb
Handle function names in special module attributes in key-value pairs
angelikatyborska 80c602a
Exchange variable names in type specs with when
angelikatyborska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"Placeholder_1": "BitStuff", | ||
"placeholder_2": "powers_of_two", | ||
"placeholder_3": "only", | ||
"placeholder_4": "zero" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule Placeholder_1 do | ||
import Bitwise, only: [:bsl] | ||
|
||
def placeholder_2 do | ||
placeholder_3 = "something" | ||
placeholder_4 = 1 | ||
[zero: placeholder_4, one: bsl(1, 1), two: bsl(1, 2), three: bsl(1, 3)] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule BitStuff do | ||
import Bitwise, only: [:bsl] | ||
|
||
def powers_of_two do | ||
only = "something" | ||
zero = 1 | ||
|
||
[ | ||
zero: zero, | ||
one: bsl(1, 1), | ||
two: bsl(1, 2), | ||
three: bsl(1, 3), | ||
] | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Placeholder_1": "Clock", | ||
"placeholder_2": "midnight", | ||
"placeholder_3": "hour", | ||
"placeholder_4": "tick", | ||
"placeholder_5": "clock", | ||
"placeholder_6": "minute" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Placeholder_1 do | ||
def placeholder_2() do | ||
placeholder_3 = 0 | ||
%{hour: placeholder_3, minute: 0, second: 0} | ||
end | ||
|
||
def placeholder_4(placeholder_5) do | ||
placeholder_6 = placeholder_5.minute + 1 | ||
%{minute: placeholder_6 | placeholder_5} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
defmodule Clock do | ||
def midnight() do | ||
hour = 0 | ||
|
||
%{ | ||
hour: hour, | ||
minute: 0, | ||
second: 0 | ||
} | ||
end | ||
|
||
def tick(clock) do | ||
minute = clock.minute + 1 | ||
%{minute: minute | clock} | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"Placeholder_1": "Clock", | ||
"placeholder_2": "midnight", | ||
"placeholder_3": "hour", | ||
"placeholder_4": "hour_regex" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Placeholder_1 do | ||
def placeholder_2() do | ||
placeholder_3 = 0 | ||
%Time{calendar: Calendar.ISO, hour: placeholder_3, microsecond: {0, 0}, minute: 0, second: 0} | ||
end | ||
|
||
def placeholder_4() do | ||
%Regex{ | ||
opts: "", | ||
re_pattern: | ||
{:re_pattern, 0, 0, 0, | ||
<<69, 82, 67, 80, 81, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 58, 0, 0, | ||
0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
131, 0, 13, 7, 7, 29, 58, 7, 7, 29, 58, 7, 7, 120, 0, 13, 0>>}, | ||
re_version: {"8.44 2020-02-12", :little}, | ||
source: "\\d\\d:\\d\\d:\\d\\d" | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule Clock do | ||
def midnight() do | ||
hour = 0 | ||
|
||
%Time{ | ||
calendar: Calendar.ISO, | ||
hour: hour, | ||
microsecond: {0, 0}, | ||
minute: 0, | ||
second: 0 | ||
} | ||
end | ||
|
||
def hour_regex() do | ||
%Regex{ | ||
opts: "", | ||
re_pattern: {:re_pattern, 0, 0, 0, | ||
<<69, 82, 67, 80, 81, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 255, 255, 255, 255, | ||
255, 255, 255, 255, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, 13, | ||
7, 7, 29, 58, 7, 7, 29, 58, 7, 7, 120, 0, 13, 0>>}, | ||
re_version: {"8.44 2020-02-12", :little}, | ||
source: "\\d\\d:\\d\\d:\\d\\d" | ||
} | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Placeholder_1": "Car", | ||
"Placeholder_2": "VroomVroom", | ||
"Placeholder_3": "Automobile", | ||
"placeholder_4": "create", | ||
"placeholder_5": "color", | ||
"placeholder_6": "repaint", | ||
"placeholder_7": "car", | ||
"placeholder_8": "fake_create", | ||
"placeholder_9": "authorize_driver" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
defmodule Placeholder_1 do | ||
defstruct [:wheels, :doors, :color] | ||
end | ||
|
||
defmodule Placeholder_2 do | ||
defstruct [:cars, :driving_licence] | ||
alias Placeholder_1, as: Placeholder_3 | ||
|
||
def placeholder_4(placeholder_5) do | ||
%Placeholder_1{color: placeholder_5, wheels: 4, doors: 2} | ||
end | ||
|
||
def placeholder_6(placeholder_7, placeholder_5) do | ||
%Placeholder_3{color: placeholder_5 | placeholder_7} | ||
end | ||
|
||
def placeholder_8(placeholder_5) do | ||
%{color: placeholder_5, wheels: 4, doors: 2} | ||
end | ||
|
||
def placeholder_9() do | ||
%__MODULE__{driving_licence: "I can totally drive a car"} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule Car do | ||
defstruct [:wheels, :doors, :color] | ||
end | ||
|
||
defmodule VroomVroom do | ||
defstruct [:cars, :driving_licence] | ||
alias Car, as: Automobile | ||
|
||
def create(color) do | ||
%Car{color: color, wheels: 4, doors: 2} | ||
end | ||
|
||
def repaint(car, color) do | ||
%Automobile{color: color | car} | ||
end | ||
|
||
def fake_create(color) do | ||
# map, not a struct, hence "fake" | ||
%{color: color, wheels: 4, doors: 2} | ||
end | ||
|
||
def authorize_driver() do | ||
%__MODULE__{ | ||
driving_licence: "I can totally drive a car" | ||
} | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, we will want these user defined keys to be replaced as mentionned in #37, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes