diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-12-01 15:57:52 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-12-01 16:09:38 +0100 |
commit | 32b756494e7a6316156e6915827ac986b91b3997 (patch) | |
tree | 8a05447d65123257dace5d1afd78c739bec837bc /test/junit | |
parent | 073ebbd20ce9775260b83a78ecf9ed6a3e6d3d9e (diff) | |
download | scala-32b756494e7a6316156e6915827ac986b91b3997.tar.gz scala-32b756494e7a6316156e6915827ac986b91b3997.tar.bz2 scala-32b756494e7a6316156e6915827ac986b91b3997.zip |
SI-8022 Backwards compatibility for Regex#unapplySeq
The change in ce1bbfe / SI-6406 introduced overloads of
`unapplySeq` with wider static and dynmaic result types
than the now-deprecated alternative that accepted `Any`.
This is subtly source incompatible and the change was noticed
in Specs2.
This commit uses `List` as the static and runtime type for
the new overloads.
For consistency, the same is done for the new method added
in SI-7737 / 93e9623.
Diffstat (limited to 'test/junit')
-rw-r--r-- | test/junit/scala/util/matching/RegexTest.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/junit/scala/util/matching/RegexTest.scala b/test/junit/scala/util/matching/RegexTest.scala new file mode 100644 index 0000000000..d25842cc57 --- /dev/null +++ b/test/junit/scala/util/matching/RegexTest.scala @@ -0,0 +1,30 @@ + +package scala.util.matching + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class RegexTest { + @Test def t8022CharSequence(): Unit = { + val full = """.*: (.)$""".r + val text = " When I use this operator: *" + // Testing 2.10.x compatibility of the return types of unapplySeq + val x :: Nil = full.unapplySeq(text: Any).get + val y :: Nil = full.unapplySeq(text: CharSequence).get + assertEquals("*", x) + assertEquals("*", y) + } + + @Test def t8022Match(): Unit = { + val R = """(\d)""".r + val matchh = R.findFirstMatchIn("a1").get + // Testing 2.10.x compatibility of the return types of unapplySeq + val x :: Nil = R.unapplySeq(matchh: Any).get + val y :: Nil = R.unapplySeq(matchh).get + assertEquals("1", x) + assertEquals("1", y) + } +} |