summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/string-extractor.check4
-rw-r--r--test/files/run/string-extractor.scala30
2 files changed, 34 insertions, 0 deletions
diff --git a/test/files/run/string-extractor.check b/test/files/run/string-extractor.check
new file mode 100644
index 0000000000..7268e44da9
--- /dev/null
+++ b/test/files/run/string-extractor.check
@@ -0,0 +1,4 @@
+by
+BY
+oTheClown
+nope
diff --git a/test/files/run/string-extractor.scala b/test/files/run/string-extractor.scala
new file mode 100644
index 0000000000..4fb977df0b
--- /dev/null
+++ b/test/files/run/string-extractor.scala
@@ -0,0 +1,30 @@
+final class StringExtract(val s: String) extends AnyVal {
+ def isEmpty = (s eq null) || (s == "")
+ def get = this
+ def length = s.length
+ def lengthCompare(n: Int) = s.length compare n
+ def apply(idx: Int): Char = s charAt idx
+ def head: Char = s charAt 0
+ def tail: String = s drop 1
+ def drop(n: Int): StringExtract = new StringExtract(s drop n)
+
+ override def toString = s
+}
+
+object Bippy {
+ def unapplySeq(x: Any): StringExtract = new StringExtract("" + x)
+}
+
+object Test {
+ def f(x: Any) = x match {
+ case Bippy('B' | 'b', 'O' | 'o', 'B' | 'b', xs @ _*) => xs
+ case _ => "nope"
+ }
+
+ def main(args: Array[String]): Unit = {
+ println(f("Bobby"))
+ println(f("BOBBY"))
+ println(f("BoBoTheClown"))
+ println(f("TomTomTheClown"))
+ }
+}