1
exercism fetch cfml pig-latin

PigLatinTest.cfc

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
component extends="testbox.system.BaseSpec" {

	function beforeAll(){
	  SUT = createObject( 'PigLatin' );
	}

	function run(){
	
		describe( "My PigLatin class", function(){			

			describe( 'ay is added to words that start with vowels', function(){

				it( 'word beginning with a', function(){
					expect( SUT.translate( input='apple' ) ).toBe( 'appleay' );
				});

				it( 'word beginning with e', function(){
					expect( SUT.translate( input='ear' ) ).toBe( 'earay' );
				});

				it( 'word beginning with i', function(){
					expect( SUT.translate( input='igloo' ) ).toBe( 'iglooay' );
				});

				it( 'word beginning with o', function(){
					expect( SUT.translate( input='object' ) ).toBe( 'objectay' );
				});

				it( 'word beginning with u', function(){
					expect( SUT.translate( input='under' ) ).toBe( 'underay' );
				});

				it( 'word beginning with a vowel and followed by a qu', function(){
					expect( SUT.translate( input='equal' ) ).toBe( 'equalay' );
				});

			});

			describe( 'first letter and ay are moved to the end of words that start with consonants', function(){

				it( 'word beginning with p', function(){
					expect( SUT.translate( input='pig' ) ).toBe( 'igpay' );
				});

				it( 'word beginning with k', function(){
					expect( SUT.translate( input='koala' ) ).toBe( 'oalakay' );
				});

				it( 'word beginning with y', function(){
					expect( SUT.translate( input='yellow' ) ).toBe( 'ellowyay' );
				});

				it( 'word beginning with x', function(){
					expect( SUT.translate( input='xenon' ) ).toBe( 'enonxay' );
				});

				it( 'word beginning with q without a following u', function(){
					expect( SUT.translate( input='qat' ) ).toBe( 'atqay' );
				});

			});

			describe( 'some letter clusters are treated like a single consonant', function(){

				it( 'word beginning with ch', function(){
					expect( SUT.translate( input='chair' ) ).toBe( 'airchay' );
				});

				it( 'word beginning with qu', function(){
					expect( SUT.translate( input='queen' ) ).toBe( 'eenquay' );
				});

				it( 'word beginning with qu and a preceding consonant', function(){
					expect( SUT.translate( input='square' ) ).toBe( 'aresquay' );
				});

				it( 'word beginning with th', function(){
					expect( SUT.translate( input='therapy' ) ).toBe( 'erapythay' );
				});

				it( 'word beginning with thr', function(){
					expect( SUT.translate( input='thrush' ) ).toBe( 'ushthray' );
				});

				it( 'word beginning with sch', function(){
					expect( SUT.translate( input='school' ) ).toBe( 'oolschay' );
				});

			});

			describe( 'some letter clusters are treated like a single vowel', function(){

				it( 'word beginning with yt', function(){
					expect( SUT.translate( input='yttria' ) ).toBe( 'yttriaay' );
				});

				it( 'word beginning with xr', function(){
					expect( SUT.translate( input='xray' ) ).toBe( 'xrayay' );
				});

			});

			describe( 'phrases are translated', function(){

				it( 'a whole phrase', function(){
					expect( SUT.translate( input='quick fast run' ) ).toBe( 'ickquay astfay unray' );
				});

			});

		});
		
	}
 
}