From 2bb757ae597d57643e723a7c3279650cdd173b3d Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 22 Jan 2008 17:51:40 +0000 Subject: applied path for #325, update scalac man pages --- test/files/run/bug0325.check | 15 +++++++++++++++ test/files/run/bug0325.scala | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/files/run/bug0325.check create mode 100644 test/files/run/bug0325.scala (limited to 'test/files') 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 + "\")") + } +} -- cgit v1.2.3