1
exercism fetch elixir pig-latin

pig_latin_test.exs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
  Code.load_file("pig_latin.exs", __DIR__)
end

ExUnit.start
ExUnit.configure exclude: :pending, trace: true

defmodule PigLatinTest do
  use ExUnit.Case

  describe "ay is added to words that start with vowels" do
    #@tag :pending
    test "word beginning with a" do
      assert PigLatin.translate("apple") == "appleay"
    end

    @tag :pending
    test "word beginning with e" do
      assert PigLatin.translate("ear") == "earay"
    end

    @tag :pending
    test "word beginning with i" do
      assert PigLatin.translate("igloo") == "iglooay"
    end

    @tag :pending
    test "word beginning with o" do
      assert PigLatin.translate("object") == "objectay"
    end

    @tag :pending
    test "word beginning with u" do
      assert PigLatin.translate("under") == "underay"
    end

    @tag :pending
    test "word beginning with a vowel and followed by a qu" do
      assert PigLatin.translate("equal") == "equalay"
    end
  end

  describe "first consonant letters and ay are moved to the end of words that start with consonants" do
    @tag :pending
    test "word beginning with p" do
      assert PigLatin.translate("pig") == "igpay"
    end

    @tag :pending
    test "word beginning with k" do
      assert PigLatin.translate("koala") == "oalakay"
    end

    @tag :pending
    test "word beginning with y" do
      assert PigLatin.translate("yellow") == "ellowyay"
    end

    @tag :pending
    test "word beginning with x" do
      assert PigLatin.translate("xenon") == "enonxay"
    end

    @tag :pending
    test "word beginning with q without a following u" do
      assert PigLatin.translate("qat") == "atqay"
    end

    @tag :pending
    test "word beginning with two consonants" do
      assert PigLatin.translate("pleasure") == "easureplay"
    end

    @tag :pending
    test "word beginning with three consonants" do
      assert PigLatin.translate("stringify") == "ingifystray"
    end

    @tag :pending
    test "word beginning with a serie of consonants : aliens speak Pig Latin too" do
      assert PigLatin.translate("zkrrkrkrkrzzzkewk") == "ewkzkrrkrkrkrzzzkay"
    end
  end

  describe "some letter clusters are treated like a single consonant" do
    @tag :pending
    test "word beginning with ch" do
      assert PigLatin.translate("chair") == "airchay"
    end

    @tag :pending
    test "word beginning with qu" do
      assert PigLatin.translate("queen") == "eenquay"
    end

    @tag :pending
    test "word beginning with qu and a preceding consonant" do
      assert PigLatin.translate("square") == "aresquay"
    end

    @tag :pending
    test "word beginning with th" do
      assert PigLatin.translate("therapy") == "erapythay"
    end

    @tag :pending
    test "word beginning with thr" do
      assert PigLatin.translate("thrush") == "ushthray"
    end

    @tag :pending
    test "word beginning with sch" do
      assert PigLatin.translate("school") == "oolschay"
    end
  end

  describe "some letter clusters are treated like a single vowel" do
    @tag :pending
    test "word beginning with yt" do
      assert PigLatin.translate("yttria") == "yttriaay"
    end

    @tag :pending
    test "word beginning with xr" do
      assert PigLatin.translate("xray") == "xrayay"
    end
  end

  describe "phrases are translated" do
    @tag :pending
    test "a whole phrase" do
      assert PigLatin.translate("quick fast run") == "ickquay astfay unray"
    end
  end
end