From ee1042f8c6f9981833176acd3fbdb8782f175888 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 24 Apr 2010 07:01:47 +0000 Subject: StringBuilder no longer violates the Seq revers... StringBuilder no longer violates the Seq reverse contract: it returns a new StringBuilder. The behavior formerly found in reverse (updates in place) is now available in reverseContents. Migration warning on reverse. Closes #3327. Also did some StringBuilder rewriting as per discussion with odersky. And took a cleaver to parts of the documentation to get to the good parts a little faster. Review by community. --- test/files/run/stringbuilder.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/files/run/stringbuilder.scala') diff --git a/test/files/run/stringbuilder.scala b/test/files/run/stringbuilder.scala index c669f1c3db..28ddc653a5 100644 --- a/test/files/run/stringbuilder.scala +++ b/test/files/run/stringbuilder.scala @@ -1,5 +1,7 @@ object Test extends Application { val str = "ABCDEFGHIJKLMABCDEFGHIJKLM" + val surrogateStr = "an old Turkic letter: \uD803\uDC22" + type SB = { def indexOf(str: String): Int def indexOf(str: String, fromIndex: Int): Int @@ -29,4 +31,10 @@ object Test extends Application { sameAnswers(_.lastIndexOf("QZV")) sameAnswers(_.lastIndexOf("GHI", 22)) sameAnswers(_.lastIndexOf("KLM", 22)) + + // testing that the "reverse" implementation avoids reversing surrogate pairs + val jsb = new JavaStringBuilder(surrogateStr) reverse + val ssb = new ScalaStringBuilder(surrogateStr) reverseContents ; + + assert(jsb.toString == ssb.toString) } -- cgit v1.2.3