From 897242458bf418700b3905b26434eee51f78ef2d Mon Sep 17 00:00:00 2001 From: James Strachan Date: Mon, 12 Mar 2012 12:37:13 +0000 Subject: [PATCH] added an example of a composable template --- .../language/StringExpressionExampleTest.kt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 libraries/testlib/test/language/StringExpressionExampleTest.kt diff --git a/libraries/testlib/test/language/StringExpressionExampleTest.kt b/libraries/testlib/test/language/StringExpressionExampleTest.kt new file mode 100644 index 00000000000..4a8181e575f --- /dev/null +++ b/libraries/testlib/test/language/StringExpressionExampleTest.kt @@ -0,0 +1,38 @@ +package language + +import kotlin.util.* +import java.util.* + +import junit.framework.TestCase + +class Product(val name: String, val price: Double) { +} + +class Customer(val name: String, val products: List) { +} + + +fun customerTemplate(customer: Customer) = """ + + +

Hello ${customer.name}

+ +

lets do some kool stuff

+ +""" + +fun productSnippet(product: Product) = "
  • ${product.name}. Price : ${product.price}
  • " + +// TODO support number formatting methods? +// fun productSnippet(product: Product) = "
  • ${product.name}. Price : ${product.price.format('## ###,00')}
  • " + + +class StringExpressionExampleTest : TestCase() { + val customer = Customer("James", arrayList(Product("Beer", 1.99), Product("Wine", 5.99))) + + fun testExpressions(): Unit { + println(customerTemplate(customer)) + } +} \ No newline at end of file