summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-01-22 17:51:40 +0000
committermichelou <michelou@epfl.ch>2008-01-22 17:51:40 +0000
commit2bb757ae597d57643e723a7c3279650cdd173b3d (patch)
tree8c0ec6ba9e93e4c910d12dc822b857a08463f4ea /test/files
parentcb1daed658c64908503aa7b4c082a76ddd50c239 (diff)
downloadscala-2bb757ae597d57643e723a7c3279650cdd173b3d.tar.gz
scala-2bb757ae597d57643e723a7c3279650cdd173b3d.tar.bz2
scala-2bb757ae597d57643e723a7c3279650cdd173b3d.zip
applied path for #325, update scalac man pages
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/bug0325.check15
-rw-r--r--test/files/run/bug0325.scala45
2 files changed, 60 insertions, 0 deletions
diff --git a/test/files/run/bug0325.check b/test/files/run/bug0325.check
new file mode 100644
index 0000000000..71d1f3feb5
--- /dev/null
+++ b/test/files/run/bug0325.check
@@ -0,0 +1,15 @@
+
+
+RichString split("x]") returned List(a]b) when expecting List(a, b)
+RichString split("&&") returned List(a&b) when expecting List(a, b)
+RichString split("\x") returned List(a\b) when expecting List(a, b)
+RichString split("[x") returned List(a[b) when expecting List(a, b)
+RichString split("^x") returned List(a^b) when expecting List(a, b)
+RichString split("x-z") returned List(a-b) when expecting List(a, b)
+
+RS split("x]") returned List(a]b) when expecting List(a, b)
+RS split("&&") returned List(a&b) when expecting List(a, b)
+RS split("\x") returned List(a\b) when expecting List(a, b)
+RS split("[x") returned List(a[b) when expecting List(a, b)
+RS split("^x") returned List(a^b) when expecting List(a, b)
+RS split("x-z") returned List(a-b) when expecting List(a, b)
diff --git a/test/files/run/bug0325.scala b/test/files/run/bug0325.scala
new file mode 100644
index 0000000000..18193ff960
--- /dev/null
+++ b/test/files/run/bug0325.scala
@@ -0,0 +1,45 @@
+case class RS(self: String) {
+ def split(separator: Char): Array[String] = self.split("\\Q"+separator+"\\E")
+
+ def split(separators: Array[Char]): Array[String] = {
+ val re = separators.foldLeft("[\\Q")(_+_) + "\\E]"
+ self.split(re)
+ }
+}
+
+object Test {
+ def expect = List("a","b")
+ def test(f: => Array[String], which: String) {
+ try {
+ val ret = f.toList
+ if (ret != expect) {
+ println(which + " returned " + ret + " when expecting " + expect)
+ }
+ } catch {
+ case e@_ => println(which + " failed with " + e.getClass)
+ }
+ }
+
+ def main(args: Array[String]) {
+ val badChars = "?*{+([\\^.$"
+
+ for (c <- badChars)
+ test(("a"+c+"b").split(c),"RichString split('"+ c + "')")
+ println
+
+ for (c <- badChars)
+ test(RS("a"+c+"b").split(c),"RS split('"+ c + "')")
+ println
+
+ val badCases = List(
+ ']' -> "x]", '&' -> "&&",'\\' -> "\\x", '[' -> "[x",
+ '^' -> "^x", '-' -> "x-z"
+ )
+ for ((c,str) <- badCases)
+ test(("a"+c+"b").split(str.toArray),"RichString split(\""+ str + "\")")
+ println
+
+ for ((c,str) <- badCases)
+ test(RS("a"+c+"b").split(str.toArray),"RS split(\""+ str + "\")")
+ }
+}