summaryrefslogtreecommitdiff
path: root/tests/examplefiles/example.xtend
blob: f6a51f7ae0abb637d54d0ffe9695567699710c47 (plain)
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
package beer

import static extension beer.BottleSupport.*
import org.junit.Test

class BottleSong {

	@Test
	def void singIt() {
		println(singTheSong(99))
	}
	
	def singTheSong(int all) '''
		«FOR i : all .. 1»
			«i.Bottles» of beer on the wall, «i.bottles» of beer.
			Take one down and pass it around, «(i - 1).bottles» of beer on the wall.
			
		«ENDFOR»
		No more bottles of beer on the wall, no more bottles of beer.
		Go to the store and buy some more, «all.bottles» of beer on the wall.
	'''

	def private java.lang.String bottles(int i) {
		switch i {
			case 0 : 'no more bottles'
			case 1 : 'one bottle'
			default : '''«i» bottles'''
		}.toString
	}	
	
	def String Bottles(int i) {
		bottles(i).toFirstUpper
	}
}