98 lines
7.6 KiB
Elixir
98 lines
7.6 KiB
Elixir
|
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
|
||
|
Code.load_file("twelve_days.exs", __DIR__)
|
||
|
end
|
||
|
|
||
|
ExUnit.start()
|
||
|
# , exclude: :pending)
|
||
|
ExUnit.configure(trace: true)
|
||
|
|
||
|
defmodule TwelveDaysTest do
|
||
|
use ExUnit.Case
|
||
|
|
||
|
describe "verse" do
|
||
|
# @tag :pending
|
||
|
test "first verse" do
|
||
|
assert TwelveDays.verse(1) ==
|
||
|
"On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree."
|
||
|
end
|
||
|
|
||
|
@tag :pending
|
||
|
test "sixth verse" do
|
||
|
assert TwelveDays.verse(6) ==
|
||
|
"On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."
|
||
|
end
|
||
|
|
||
|
@tag :pending
|
||
|
test "last verse" do
|
||
|
assert TwelveDays.verse(12) ==
|
||
|
"On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree."
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe "verses" do
|
||
|
@tag :pending
|
||
|
test "1-3" do
|
||
|
assert TwelveDays.verses(1, 3) ==
|
||
|
"""
|
||
|
On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.
|
||
|
On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
"""
|
||
|
|> String.trim()
|
||
|
end
|
||
|
|
||
|
@tag :pending
|
||
|
test "4-6" do
|
||
|
assert TwelveDays.verses(4, 6) ==
|
||
|
"""
|
||
|
On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
"""
|
||
|
|> String.trim()
|
||
|
end
|
||
|
|
||
|
@tag :pending
|
||
|
test "1-12" do
|
||
|
assert TwelveDays.verses(1, 12) ==
|
||
|
"""
|
||
|
On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.
|
||
|
On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the seventh day of Christmas my true love gave to me, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the eleventh day of Christmas my true love gave to me, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
"""
|
||
|
|> String.trim()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe "sing" do
|
||
|
@tag :pending
|
||
|
test "all 12 verses" do
|
||
|
assert TwelveDays.sing() ==
|
||
|
"""
|
||
|
On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.
|
||
|
On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the seventh day of Christmas my true love gave to me, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the eleventh day of Christmas my true love gave to me, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
|
||
|
"""
|
||
|
|> String.trim()
|
||
|
end
|
||
|
end
|
||
|
end
|