StringBuilder builder and appendln

This commit is contained in:
Ilya Ryzhenkov
2014-06-05 23:20:39 +04:00
committed by Andrey Breslav
parent 0717511abe
commit 516bae17d7
11 changed files with 160 additions and 9 deletions
+2 -3
View File
@@ -40,7 +40,7 @@ public trait Comparable<T> {
library
public trait Appendable {
public open fun append(csq: CharSequence?): Appendable
//public open fun append(csq: CharSequence?, start: Int, end: Int): Appendable
public open fun append(csq: CharSequence?, start: Int, end: Int): Appendable
public open fun append(c: Char): Appendable
}
@@ -48,8 +48,7 @@ library
public class StringBuilder() : Appendable {
override fun append(c: Char): StringBuilder = js.noImpl
override fun append(csq: CharSequence?): StringBuilder = js.noImpl
//TODO
//override fun append(csq: CharSequence?, start: Int, end: Int): StringBuilder = js.noImpl
override fun append(csq: CharSequence?, start: Int, end: Int): StringBuilder = js.noImpl
public fun append(obj: Any?): StringBuilder = js.noImpl
public fun reverse(): StringBuilder = js.noImpl
override fun toString(): String = js.noImpl
@@ -0,0 +1,10 @@
package org.jetbrains.k2js.test.semantics;
import junit.framework.Test;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class StdLibStringBuilderTest extends JsUnitTestBase {
public static Test suite() throws Exception {
return createTestSuiteForFile("libraries/stdlib/test/text/StringBuilderTest.kt");
}
}
@@ -0,0 +1,10 @@
package org.jetbrains.k2js.test.semantics;
import junit.framework.Test;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class StdLibStringTest extends JsUnitTestBase {
public static Test suite() throws Exception {
return createTestSuiteForFile("libraries/stdlib/test/text/StringTest.kt");
}
}
@@ -139,6 +139,7 @@ public abstract class Config {
"/kotlin/Ranges.kt",
"/kotlin/Numbers.kt",
"/kotlin/text/Strings.kt",
"/kotlin/text/StringBuilder.kt",
"/kotlin/dom/Dom.kt",
"/kotlin/test/Test.kt"
);
+9 -2
View File
@@ -649,8 +649,15 @@
function () {
this.string = "";
}, {
append: function (obj) {
this.string = this.string + obj.toString();
append: function (obj, from, to) {
if (from == undefined && to == undefined) {
this.string = this.string + obj.toString();
} else if (to == undefined) {
this.string = this.string + obj.toString().substring(from);
} else {
this.string = this.string + obj.toString().substring(from, to);
}
return this;
},
reverse: function () {