Improve punctuation in Structs koans
This commit is contained in:
@@ -5,12 +5,12 @@ defmodule Structs do
|
||||
defstruct [:name, :age ]
|
||||
end
|
||||
|
||||
koan "structs are defined and named after a module" do
|
||||
koan "Structs are defined and named after a module" do
|
||||
person = %Person{}
|
||||
assert person == :__
|
||||
end
|
||||
|
||||
koan "you can access the fields of a struct" do
|
||||
koan "You can access the fields of a struct" do
|
||||
nobody = %Person{}
|
||||
assert nobody.age == :__
|
||||
end
|
||||
@@ -20,19 +20,19 @@ defmodule Structs do
|
||||
assert joe.name == :__
|
||||
end
|
||||
|
||||
koan "update fields with the pipe '|' operator" do
|
||||
koan "Update fields with the pipe '|' operator" do
|
||||
joe = %Person{name: "Joe", age: 23}
|
||||
older = %{ joe | age: joe.age + 10}
|
||||
assert older.age == :__
|
||||
end
|
||||
|
||||
koan "the original struct is not affected by updates" do
|
||||
koan "The original struct is not affected by updates" do
|
||||
joe = %Person{name: "Joe", age: 23}
|
||||
assert %{ joe | age: joe.age + 10}.age == 33
|
||||
assert %{ joe | age: joe.age + 10}.age == :__
|
||||
assert joe.age == :__
|
||||
end
|
||||
|
||||
koan "you can pattern match into the fields of a struct" do
|
||||
koan "You can pattern match into the fields of a struct" do
|
||||
%Person{age: age} = %Person{age: 22, name: "Silvia"}
|
||||
assert age == :__
|
||||
end
|
||||
@@ -41,13 +41,16 @@ defmodule Structs do
|
||||
defstruct passengers: 0, maker: :boeing
|
||||
end
|
||||
|
||||
koan "or onto the type of the struct itself" do
|
||||
assert is_a_plane(%Plane{passengers: 417, maker: :boeing}) == :__
|
||||
def plane?(%Plane{}), do: true
|
||||
def plane?(_), do: false
|
||||
|
||||
koan "Or onto the type of the struct itself" do
|
||||
assert plane?(%Plane{passengers: 417, maker: :boeing}) == :__
|
||||
assert plane?(%Person{}) == :__
|
||||
end
|
||||
|
||||
def is_a_plane(%Plane{}), do: true
|
||||
|
||||
koan "are basically maps" do
|
||||
koan "Are basically maps" do
|
||||
silvia = %Person{age: 22, name: "Silvia"}
|
||||
|
||||
assert Map.fetch!(silvia, :age) == :__
|
||||
|
||||
@@ -110,9 +110,9 @@ defmodule KoansHarnessTest do
|
||||
nil,
|
||||
"Joe",
|
||||
33,
|
||||
23,
|
||||
{:multiple, [33, 23]},
|
||||
22,
|
||||
true,
|
||||
{:multiple, [true, false]},
|
||||
22,
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user