Fix and test for #78

This commit is contained in:
Mark Harrah 2010-04-06 23:43:43 -04:00
parent 26bd11e50c
commit 81780d0cf7
2 changed files with 12 additions and 1 deletions

View File

@ -255,7 +255,7 @@ object FileUtilities
None
}
from.closeEntry()
entryErr orElse next()
entryErr match { case None => next(); case x => x }
}
}
val result = next()

View File

@ -17,6 +17,17 @@ object WriteContentSpecification extends Properties("Write content")
specify("Write bytes overwrites", overwriteAndCheckBytes _)
specify("Append string appends", appendAndCheckStrings _)
specify("Append bytes appends", appendAndCheckBytes _)
property("Unzip doesn't stack overflow") = largeUnzip() match { case Some(msg) => error(msg); case None => true }
private def largeUnzip() =
testUnzip[ScalaObject] orElse
testUnzip[scala.tools.nsc.Global]
private def testUnzip[T](implicit mf: scala.reflect.Manifest[T]) =
unzipFile(FileUtilities.classLocationFile(mf.erasure))
private def unzipFile(jar: File) =
FileUtilities.withTemporaryDirectory(log) { tmp =>
FileUtilities.unzip(jar, Path.fromFile(tmp), log).left.toOption
}
// make the test independent of underlying platform and allow any unicode character in Strings to be encoded
val charset = java.nio.charset.Charset.forName("UTF-8")