summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-04-24 07:01:47 +0000
committerPaul Phillips <paulp@improving.org>2010-04-24 07:01:47 +0000
commitee1042f8c6f9981833176acd3fbdb8782f175888 (patch)
tree6d9adc517403749140b3f27ab4086ec2a98f0569 /test/files/run
parenta0e5e165c97c01cf0854aeda72e4e9d1d037bb8c (diff)
downloadscala-ee1042f8c6f9981833176acd3fbdb8782f175888.tar.gz
scala-ee1042f8c6f9981833176acd3fbdb8782f175888.tar.bz2
scala-ee1042f8c6f9981833176acd3fbdb8782f175888.zip
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.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/bug3327.check1
-rw-r--r--test/files/run/bug3327.scala8
-rw-r--r--test/files/run/stringbuilder.scala8
3 files changed, 17 insertions, 0 deletions
diff --git a/test/files/run/bug3327.check b/test/files/run/bug3327.check
new file mode 100644
index 0000000000..980a0d5f19
--- /dev/null
+++ b/test/files/run/bug3327.check
@@ -0,0 +1 @@
+Hello World!
diff --git a/test/files/run/bug3327.scala b/test/files/run/bug3327.scala
new file mode 100644
index 0000000000..7e6d3fc210
--- /dev/null
+++ b/test/files/run/bug3327.scala
@@ -0,0 +1,8 @@
+object Test {
+ def main (args : Array[String]) {
+ val b = new StringBuilder
+ b.append ("Hello World!")
+ b.lastIndexOf ('e')
+ println (b.toString)
+ }
+} \ No newline at end of file
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)
}