From f98b0699f5c17597039ec28a724a62c1ea1b3a1c Mon Sep 17 00:00:00 2001 From: Felipe Sere Date: Mon, 21 Mar 2016 19:38:39 +0000 Subject: [PATCH] Improve punctuation in Structs koans --- lib/koans/07_structs.ex | 23 +++++++++++++---------- test/koans_harness_test.exs | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/koans/07_structs.ex b/lib/koans/07_structs.ex index 4a7c178..f54abfe 100644 --- a/lib/koans/07_structs.ex +++ b/lib/koans/07_structs.ex @@ -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) == :__ diff --git a/test/koans_harness_test.exs b/test/koans_harness_test.exs index 411b25a..3c2fffd 100644 --- a/test/koans_harness_test.exs +++ b/test/koans_harness_test.exs @@ -110,9 +110,9 @@ defmodule KoansHarnessTest do nil, "Joe", 33, - 23, + {:multiple, [33, 23]}, 22, - true, + {:multiple, [true, false]}, 22, ]