Files
kotlin-fork/libraries/stdlib/test/template/LocaleTemplateTest.kt
T
2012-03-14 20:17:30 +00:00

43 lines
1.2 KiB
Kotlin

package template
import kotlin.template.*
import kotlin.test.assertEquals
import junit.framework.TestCase
import java.util.Date
import java.util.Locale
class LocaleTemplateTest : TestCase() {
fun testDefaultLocale() : Unit {
format(LocaleFormatter())
}
fun testFrance() : Unit {
format(LocaleFormatter(Locale.FRANCE.sure()))
}
fun testGermany() : Unit {
format(LocaleFormatter(Locale.GERMANY.sure()))
}
fun format(formatter: LocaleFormatter): Unit {
val name = "James"
// TODO currently numbers cause: java.lang.ClassNotFoundException: jet.Number
//val price: Double = 1.99
val now = Date()
// Code generated by the following template expression:
//
// val actual = format.toLocale("hello $name!")
// TODO will use a tuple soon
//val actual = formatter.format(StringTemplate(Tuple2<String,String>("hello ", name))
val actual = StringTemplate(array("hello ", name,
// TODO currently numbers cause: java.lang.ClassNotFoundException: jet.Number
// " price ", price,
" data ", now)).toString(formatter)
println("Got text: $actual")
}
}