Add toString() to Any, fix all tests

#KT-4517 Fixed
This commit is contained in:
Alexander Udalov
2014-02-06 23:43:12 +04:00
parent 6127d53eac
commit 3dcd85bdb4
55 changed files with 110 additions and 72 deletions
@@ -6,7 +6,7 @@ import java.util.ArrayList
public class ChangeEvent(val source: Any, val name: String, val oldValue: Any?, val newValue: Any?) {
var propogationId: Any? = null
public fun toString() : String = "ChangeEvent($name, $oldValue, $newValue)"
override fun toString(): String = "ChangeEvent($name, $oldValue, $newValue)"
}
public trait ChangeListener {
@@ -15,7 +15,7 @@ class StringTemplate(val values : Array<Any?>) {
/**
* Converts the template into a String
*/
public fun toString() : String {
override fun toString() : String {
val out = StringBuilder()
forEach{ out.append(it) }
return out.toString()
@@ -93,7 +93,7 @@ public open class ToStringFormatter : Formatter {
var nullString : String = "null"
public open fun toString() : String = "ToStringFormatter"
override fun toString() : String = "ToStringFormatter"
public override fun format(out : Appendable, value : Any?) {
if (value == null) {
@@ -121,7 +121,7 @@ public val defaultLocale : Locale = Locale.getDefault()
*/
public open class LocaleFormatter(val locale : Locale = defaultLocale) : ToStringFormatter() {
public override fun toString() : String = "LocaleFormatter{$locale}"
override fun toString() : String = "LocaleFormatter{$locale}"
public var numberFormat : NumberFormat = NumberFormat.getInstance(locale)!!
@@ -151,7 +151,7 @@ public open class LocaleFormatter(val locale : Locale = defaultLocale) : ToStrin
*/
public class HtmlFormatter(locale : Locale = defaultLocale) : LocaleFormatter(locale) {
public override fun toString() : String = "HtmlFormatter{$locale}"
override fun toString() : String = "HtmlFormatter{$locale}"
public override fun format(out : Appendable, value : Any?) {
if (value is Node) {
+1 -1
View File
@@ -5,7 +5,7 @@ import kotlin.test.*
import org.junit.Test
class Item(val name: String, val rating: Int): Comparable<Item> {
fun toString() = "Item($name, $rating)"
override fun toString() = "Item($name, $rating)"
public override fun compareTo(other: Item): Int {
return compareBy(this, other, { rating }, { name })
+1 -1
View File
@@ -6,7 +6,7 @@ import org.junit.Test as test
class ListTest {
test fun toString() {
test fun _toString() {
val data = arrayList("foo", "bar")
assertEquals("[foo, bar]", data.toString())
}
@@ -22,7 +22,7 @@ class Customer() : ChangeSupport() {
$city = value
}
fun toString() = "Customer($name, $city)"
override fun toString() = "Customer($name, $city)"
}
class MyChangeListener() : ChangeListener {
+1 -1
View File
@@ -33,7 +33,7 @@ class Failure(val message : String) : ParseResult<Nothing> {
}
open class Token(val text : String) {
fun toString() = text
override fun toString() = text
}
object LPAR : Token("(")
object RPAR : Token(")")