minor refactor to tidy up the API
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user