Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions exercises/practice/grade-school/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[6d0a30e4-1b4e-472e-8e20-c41702125667]
description = "Adding a student adds them to the sorted roster"

[c125dab7-2a53-492f-a99a-56ad511940d8]
description = "A student can't be in two different grades"
include = false

[a0c7b9b8-0e89-47f8-8b4a-c50f885e79d1]
description = "A student can only be added to the same grade in the roster once"
reimplements = "c125dab7-2a53-492f-a99a-56ad511940d8"

[233be705-dd58-4968-889d-fb3c7954c9cc]
description = "Adding more student adds them to the sorted roster"
description = "Adding more students adds them to the sorted roster"

[75a51579-d1d7-407c-a2f8-2166e984e8ab]
description = "Adding students to different grades adds them to the same sorted roster"

[6a03b61e-1211-4783-a3cc-fc7f773fba3f]
description = "A student cannot be added to more than one grade in the sorted roster"
reimplements = "c125dab7-2a53-492f-a99a-56ad511940d8"

[a3f0fb58-f240-4723-8ddc-e644666b85cc]
description = "Roster returns an empty list if there are no students enrolled"

Expand Down
11 changes: 10 additions & 1 deletion exercises/practice/grade-school/test/school_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ defmodule SchoolTest do
assert actual == %{2 => ["Aimee"]}
end

test "a student can't be in two different grades" do
test "a student can only be added to the same grade once" do
actual =
@db
|> School.add("Aimee", 2)
|> School.add("Aimee", 2)

assert actual == %{2 => ["Aimee"]}
end

test "a student cannot be added to more than one grade" do
actual =
@db
|> School.add("Aimee", 2)
Expand Down
7 changes: 6 additions & 1 deletion exercises/practice/markdown/.meta/example.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ defmodule Markdown do

defp process(t = "#" <> _) do
[h, tail] = String.split(t, " ", parts: 2)
wrap_in_html_tag(tail, "h#{byte_size(h)}")

if byte_size(h) < 7 do
wrap_in_html_tag(tail, "h#{byte_size(h)}")
else
wrap_in_html_tag(t, "p")
end
end

defp process("*" <> t) do
Expand Down
30 changes: 27 additions & 3 deletions exercises/practice/markdown/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[e75c8103-a6b8-45d9-84ad-e68520545f6e]
description = "parses normal text as a paragraph"
Expand All @@ -20,9 +27,26 @@ description = "with h1 header level"
[d0f7a31f-6935-44ac-8a9a-1e8ab16af77f]
description = "with h2 header level"

[9df3f500-0622-4696-81a7-d5babd9b5f49]
description = "with h3 header level"

[50862777-a5e8-42e9-a3b8-4ba6fcd0ed03]
description = "with h4 header level"

[ee1c23ac-4c86-4f2a-8b9c-403548d4ab82]
description = "with h5 header level"

[13b5f410-33f5-44f0-a6a7-cfd4ab74b5d5]
description = "with h6 header level"

[6dca5d10-5c22-4e2a-ac2b-bd6f21e61939]
description = "with h7 header level"
include = false

[81c0c4db-435e-4d77-860d-45afacdad810]
description = "h7 header level is a paragraph"
reimplements = "6dca5d10-5c22-4e2a-ac2b-bd6f21e61939"

[25288a2b-8edc-45db-84cf-0b6c6ee034d6]
description = "unordered lists"

Expand Down
3 changes: 2 additions & 1 deletion exercises/practice/markdown/lib/markdown.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ defmodule Markdown do
end

defp process(t) do
if String.starts_with?(t, "#") || String.starts_with?(t, "*") do
if (String.starts_with?(t, "#") && !String.starts_with?(t, "#######")) ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes my eyes bleed, so... perfect!

String.starts_with?(t, "*") do
if String.starts_with?(t, "#") do
enclose_with_header_tag(parse_header_md_level(t))
else
Expand Down
28 changes: 28 additions & 0 deletions exercises/practice/markdown/test/markdown_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,41 @@ defmodule MarkdownTest do
assert Markdown.parse(input) == expected
end

# @tag :pending
test "with h3 header level" do
input = "### This will be an h3"
expected = "<h3>This will be an h3</h3>"
assert Markdown.parse(input) == expected
end

# @tag :pending
test "with h4 header level" do
input = "#### This will be an h4"
expected = "<h4>This will be an h4</h4>"
assert Markdown.parse(input) == expected
end

# @tag :pending
test "with h5 header level" do
input = "##### This will be an h5"
expected = "<h5>This will be an h5</h5>"
assert Markdown.parse(input) == expected
end

# @tag :pending
test "with h6 header level" do
input = "###### This will be an h6"
expected = "<h6>This will be an h6</h6>"
assert Markdown.parse(input) == expected
end

# @tag :pending
test "h7 header level is a paragraph" do
input = "####### This will not be an h7"
expected = "<p>####### This will not be an h7</p>"
assert Markdown.parse(input) == expected
end

# @tag :pending
test "unordered lists" do
input = "* Item 1\n* Item 2"
Expand Down