diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-02-13 11:47:15 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-02-13 11:47:15 -0800 |
commit | 3b93e1fecaa8aa76d36abd327e146c6b16cd453b (patch) | |
tree | 936d7a707ecc93ca62d21759b29df0d5fa7a6385 /test | |
parent | 4554a10bcafce6fb14eb8b123bf76887bb6a8114 (diff) | |
parent | 51800ce0e83daeadf68a90bef4d64734e4721f3a (diff) | |
download | scala-3b93e1fecaa8aa76d36abd327e146c6b16cd453b.tar.gz scala-3b93e1fecaa8aa76d36abd327e146c6b16cd453b.tar.bz2 scala-3b93e1fecaa8aa76d36abd327e146c6b16cd453b.zip |
Merge pull request #4304 from adriaanm/rebase-4219
SI-8818 FreshName extractor forgives suffix
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala | 12 | ||||
-rw-r--r-- | test/junit/scala/tools/testing/AssertUtil.scala | 21 |
2 files changed, 16 insertions, 17 deletions
diff --git a/test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala b/test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala index effbfb2f7c..7796345351 100644 --- a/test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala +++ b/test/junit/scala/tools/nsc/symtab/FreshNameExtractorTest.scala @@ -32,16 +32,16 @@ class FreshNameExtractorTest { val Creator = new FreshNameCreator(prefixes.head) val Extractor = new FreshNameExtractor(prefixes.tail.head) assertThrows[MatchError] { - val Extractor(_) = TermName(Creator.newName("foo")) + TermName(Creator.newName("foo")) match { case Extractor(_) => } } } - @Test @org.junit.Ignore // SI-8818 - def extractionsFailsIfNameDoesntEndWithNumber = { - val Creator = new FreshNameCreator(prefixes.head) + @Test + def `no numeric suffix? no problem!` = { + val Creator = new FreshNameCreator(prefixes.head) val Extractor = new FreshNameExtractor(prefixes.head) - assertThrows[MatchError] { - val Extractor(_) = TermName(Creator.newName("foo") + "bar") + TermName(Creator.newName("foo") + "bar") match { + case Extractor(_) => } } } diff --git a/test/junit/scala/tools/testing/AssertUtil.scala b/test/junit/scala/tools/testing/AssertUtil.scala index d29f9a473f..d798f2e53e 100644 --- a/test/junit/scala/tools/testing/AssertUtil.scala +++ b/test/junit/scala/tools/testing/AssertUtil.scala @@ -36,21 +36,20 @@ object AssertUtil { } } - /** Check if throwable T (or a subclass) was thrown during evaluation of f, and that its message - * satisfies the `checkMessage` predicate. If any other exception will be re-thrown. + /** Check that throwable T (or a subclass) was thrown during evaluation of `body`, + * and that its message satisfies the `checkMessage` predicate. + * Any other exception is propagated. */ - def assertThrows[T <: Throwable](f: => Any, + def assertThrows[T <: Throwable](body: => Any, checkMessage: String => Boolean = s => true) (implicit manifest: Manifest[T]): Unit = { - try f - catch { - case e: Throwable if checkMessage(e.getMessage) => - val clazz = manifest.runtimeClass - if (!clazz.isAssignableFrom(e.getClass)) - throw e - else return + try { + body + fail("Expression did not throw!") + } catch { + case e: Throwable if (manifest.runtimeClass isAssignableFrom e.getClass) && + checkMessage(e.getMessage) => } - fail("Expression did not throw!") } /** JUnit-style assertion for `IterableLike.sameElements`. |