Skip to content

Update scala 2.13.0-M5 to 2.13.0-RC2 #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jdk:
- oraclejdk8

scala:
- 2.13.0-M5
- 2.13.0-RC2
- 2.11.12
- 2.12.7
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ organization := "org.clapper"
licenses := Seq("BSD" -> url("http://software.clapper.org/grizzled-scala/license.html"))
homepage := Some(url("http://software.clapper.org/grizzled-scala/"))
description := "A general-purpose Scala utility library"
scalaVersion := "2.13.0-M5"
crossScalaVersions := Seq("2.11.12", "2.12.7", "2.13.0-M5")
scalaVersion := "2.13.0-RC2"
crossScalaVersions := Seq("2.11.12", "2.12.7", "2.13.0-RC2")


unmanagedSourceDirectories in Compile += {
Expand Down Expand Up @@ -59,8 +59,8 @@ wartremoverErrors in (Compile, compile) ++= Seq(
// Dependencies

libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "0.2.1",
"org.scalatest" %% "scalatest" % "3.0.6-SNAP5" % Test
"org.scala-lang.modules" %% "scala-collection-compat" % "2.0.0",
"org.scalatest" %% "scalatest" % "3.0.8-RC4" % Test
)

parallelExecution in Test := true
Expand Down
3 changes: 1 addition & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.3")

addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")

addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.3.7")

addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.2")
10 changes: 5 additions & 5 deletions src/main/scala/grizzled/binary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object binary {
*/
def bitCount(num: Int): Int = {
val numLong: Long = num.toLong
bitCount(numLong & 0xffffffffl)
bitCount(numLong & 0xffffffffL)
}

/** Count the number of bits in a numeric (integer or long) value. This
Expand All @@ -27,16 +27,16 @@ object binary {
*/
def bitCount(num: Long): Int = {
// Put count of each 2 bits into those 2 bits.
val res1: Long = num - ((num >> 1) & 0x5555555555555555l)
val res1: Long = num - ((num >> 1) & 0x5555555555555555L)

// Put count of each 4 bits into those 4 bits.
val allThrees = 0x3333333333333333l
val allThrees = 0x3333333333333333L
val res2 = (res1 & allThrees) + ((res1 >> 2) & allThrees)

// Put count of each 8 bits into those 8 bits.
val res3 = (res2 + (res2 >> 4)) & 0x0f0f0f0f0f0f0f0fl
val res3 = (res2 + (res2 >> 4)) & 0x0f0f0f0f0f0f0f0fL

// Left-most bits.
((res3 * 0x0101010101010101l) >> 56).toInt
((res3 * 0x0101010101010101L) >> 56).toInt
}
}
2 changes: 1 addition & 1 deletion src/main/scala/grizzled/config/config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1414,5 +1414,5 @@ object Configuration {
}

private[config] final case class Value(value: String, isRaw: Boolean = false) {
override val toString = s"Value<value=$value, isRaw=$isRaw>"
override val toString = s"Value<value=$value, isRaw=${isRaw.toString}>"
}
4 changes: 2 additions & 2 deletions src/main/scala/grizzled/file/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object Implicits {
if (file.exists)
Success(true)
else
Failure(new FileDoesNotExistException(s""""$file" does not exist."""))
Failure(new FileDoesNotExistException(s""""${file.toString}" does not exist."""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious about this and the other similar diffs, why is this necessary/desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The [wartremover:StringPlusAny] Implicit conversion to string is disabled-wart triggers on scala 2.13.0-RC1, which maybe it shouldn't? On scala 2.12.8 it does not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. hmmm....

I think I personally wouldn't expect or want the wart to trigger inside a string interpolator, but that's just a hunch, not sure what the wart's author's intentions might have been

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed an issue here: wartremover/wartremover#447

}

/** Get the directory name of the file.
Expand Down Expand Up @@ -155,7 +155,7 @@ object Implicits {
*
* @return `Success(true)` on success, `Failure(exception)` on error.
*/
def touch(time: Long = -1l): Try[Boolean] = {
def touch(time: Long = -1L): Try[Boolean] = {
util.touch(file.getPath, time)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/grizzled/file/Includer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ extends Iterator[String] {
case includeRegex(inc) =>
if (sourceStack.length >= maxNesting)
throw new IllegalStateException(
s"Max nesting level ($maxNesting) exceeded."
s"Max nesting level (${maxNesting.toString}) exceeded."
)

val curURI = sourceStack.head.uri
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/grizzled/file/util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ object util {
if (c1 == fileSep)
c2.toString
else
s"$c1$c2"
s"$c1${c2.toString}"
}

val absolute = path.startsWith(fileSep) || (prefix != "")
Expand Down Expand Up @@ -705,7 +705,7 @@ object util {

if (tries > maxTries) {
Failure(new IOException(
s"Failed to create temporary directory after $maxTries attempts."
s"Failed to create temporary directory after ${maxTries.toString} attempts."
))
}
else {
Expand Down Expand Up @@ -976,15 +976,15 @@ object util {
def deleteTree(dir: File): Try[Int] = {
def deleteOne(f: File): Try[Int] = {
if (! f.delete)
Failure(new IOException(s"Can't delete '$f'"))
Failure(new IOException(s"Can't delete '${f.toString}'"))
else
Success(1)
}

if (! dir.exists)
Success(0)
else if (! dir.isDirectory)
Failure(new IOException(s""""$dir" is not a directory."""))
Failure(new IOException(s""""${dir.toString}" is not a directory."""))
else {
@SuppressWarnings(Array("org.wartremover.warts.TryPartial"))
val treeResults = dir.listFiles.map { f =>
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/grizzled/net/URLUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ object URLUtil {
if (path.isDirectory) {
Future.failed(
new IOException(
s"""Output file "$pathOut" exists and is a directory."""
s"""Output file "${pathOut.toString}" exists and is a directory."""
)
)
}
else {
val dir = pathOut.dirname
if ((! dir.exists) && (! dir.mkdirs())) {
Future.failed(new IOException(
s"Can't create target directory '$dir' or one of its parents."
s"Can't create target directory '${dir.toString}' or one of its parents."
))
}
else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/grizzled/string/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ object Implicits {
case '\\' :: 'f' :: rest => doParse(rest, buf + "\f")
case '\\' :: '\\' :: rest => doParse(rest, buf + "\\")

case '\\' :: 'u' :: a :: b :: c :: d :: rest if isHexString(s"$a$b$c$d") =>
case '\\' :: 'u' :: a :: b :: c :: d :: rest if isHexString(s"${a.toString}${b.toString}${c.toString}${d.toString}") =>
val chars = Integer.parseInt(Array(a, b, c, d).mkString(""), 16)
doParse(rest.toList, buf + Character.toChars(chars).mkString(""))

case '\\' :: 'u' :: rest =>
doParse(rest, buf + "\\u")

case '\\' :: c :: rest =>
doParse(rest, buf + s"\\$c")
doParse(rest, buf + s"\\${c.toString}")

case '\\' :: Nil =>
buf + "\\"
Expand Down
18 changes: 9 additions & 9 deletions src/test/scala/grizzled/BinarySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class BinarySpec extends BaseSpec {
)

val longData = Map[Long, Int](
0l -> 0,
1l -> 1,
2l -> 1,
3l -> 2,
0x444444444l -> 9,
0xeeeeeeeeel -> 27,
0xffffffffl -> 32,
0x7fffffffl -> 31,
0xffffffffffffl -> 48
0L -> 0,
1L -> 1,
2L -> 1,
3L -> 2,
0x444444444L -> 9,
0xeeeeeeeeeL -> 27,
0xffffffffL -> 32,
0x7fffffffL -> 31,
0xffffffffffffL -> 48
)

for((n, expected) <- intData) {
Expand Down
10 changes: 5 additions & 5 deletions src/test/scala/grizzled/ConfigSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ConfigSpec extends BaseSpec {

it should "allow + to replace an option without mutating the original" in {
val eCfg = Configuration.read(Source.fromString(Fixture.TestConfig))
eCfg shouldBe 'success
eCfg shouldBe Symbol("success")

val cfg: Configuration = eCfg.get
val newCfg = cfg + ("section2", "o1", "bar")
Expand Down Expand Up @@ -227,7 +227,7 @@ class ConfigSpec extends BaseSpec {
val cfg = Fixture.cfg
val section1 = cfg.getSection("section1")

section1 shouldBe 'defined
section1 shouldBe Symbol("defined")
section1.get.options.get("o2") !== None
section1.get.options.get("o2") shouldBe Some("val2")
section1.get.options.get("o99") shouldBe None
Expand Down Expand Up @@ -350,22 +350,22 @@ class ConfigSpec extends BaseSpec {
val cfg = Configuration.read(Source.fromString(Fixture.TestConfig),
safe = false).get

cfg.tryGet("section2", "substError") shouldBe 'failure
cfg.tryGet("section2", "substError") shouldBe Symbol("failure")
cfg.asTry[Int]("section3", "intOpt") shouldBe Success(Some(10))
cfg.asTry[Int]("section1", "intOpt") shouldBe Success(Some(10))
}

it should "detect illegal characters in section names" in {
val cfg = Configuration.read(Source.fromString(Fixture.TestConfigWithExoticSection))
cfg shouldBe 'failure
cfg shouldBe Symbol("failure")
}

it should "honor given SectionNamePattern when loading data" in {
val cfg = Configuration.read(
Source.fromString(Fixture.TestConfigWithExoticSection),
sectionNamePattern = """([a-zA-Z0-9_\.]+)""".r
)
cfg shouldBe 'success
cfg shouldBe Symbol("success")
val loadedCfg = cfg.get
loadedCfg.get("section1.1", "bar") shouldBe Some("baz")
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/grizzled/file/FileUtilSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,16 @@ class FileUtilSpec extends BaseSpec {
}

"copy" should "fail if the directory doesn't exist" in {
copy(Seq("foo.c"), "/nonexistent/directory", createTarget=false) shouldBe 'failure
copy(Seq("foo.c"), "/nonexistent/directory", createTarget=false) shouldBe Symbol("failure")
}

it should "fail if the directory cannot be created" in {
copy(Seq("foo.c"), "/etc/foo/bar/baz") shouldBe 'failure
copy(Seq("foo.c"), "/etc/foo/bar/baz") shouldBe Symbol("failure")
}

it should "fail if the source path doesn't exist" in {
withTemporaryDirectory("copy") { d =>
copy(Seq("foo.c"), d.getPath) shouldBe 'failure
copy(Seq("foo.c"), d.getPath) shouldBe Symbol("failure")
}
}

Expand All @@ -285,7 +285,7 @@ class FileUtilSpec extends BaseSpec {
f.write("This is a test.\n")
}
val sourceSize = sourceFile.length
copy(sourceFile.getPath, d.getPath) shouldBe 'success
copy(sourceFile.getPath, d.getPath) shouldBe Symbol("success")
val targetPath = joinPath(d.getPath, basename(sourceFile.getPath))
new File(targetPath).length shouldBe sourceSize
}
Expand Down
18 changes: 9 additions & 9 deletions src/test/scala/grizzled/file/GrizzledFileSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GrizzledFileSpec extends BaseSpec {
withTemporaryDirectory("GrizzledFile") { dir =>
val path = new File(fileutil.joinPath(dir.getAbsolutePath, "foobar.txt"))
path should not (exist)
path.touch() shouldBe 'success
path.touch() shouldBe Symbol("success")
path should exist
}
}
Expand All @@ -40,22 +40,22 @@ class GrizzledFileSpec extends BaseSpec {
withTemporaryDirectory("GrizzledFile") { dir =>
val absDir = dir.getAbsolutePath
val f = new File(fileutil.joinPath(absDir, "foo", "bar", "baz.txt"))
f.touch() shouldBe 'failure
f.touch() shouldBe Symbol("failure")
}
}

"pathExists" should "return Success for an existing file" in {
withTemporaryDirectory("GrizzedFile") { dir =>
val path = new File(fileutil.joinPath(dir.getAbsolutePath, "foo.txt"))
path.touch() shouldBe 'success
path.pathExists shouldBe 'success
path.touch() shouldBe Symbol("success")
path.pathExists shouldBe Symbol("success")
}
}

it should "return Failure for a nonexistent file" in {
withTemporaryDirectory("GrizzedFile") { dir =>
val path = new File(fileutil.joinPath(dir.getAbsolutePath, "foo.txt"))
path.pathExists shouldBe 'failure
path.pathExists shouldBe Symbol("failure")
}
}

Expand All @@ -68,15 +68,15 @@ class GrizzledFileSpec extends BaseSpec {
it should "return false for a non-empty directory" in {
withTemporaryDirectory("GrizzledFile") { dir =>
val f = new File(fileutil.joinPath(dir.getAbsolutePath, "foo.txt"))
f.touch() shouldBe 'success
f.touch() shouldBe Symbol("success")
dir.isEmpty shouldBe false
}
}

it should "fail with an assertion error for a non-directory" in {
withTemporaryDirectory("GrizzledFile") { dir =>
val f = new File(fileutil.joinPath(dir.getAbsolutePath, "foo.txt"))
f.touch() shouldBe 'success
f.touch() shouldBe Symbol("success")

an [AssertionError] should be thrownBy {
f.isEmpty
Expand All @@ -93,10 +93,10 @@ class GrizzledFileSpec extends BaseSpec {

parentDir.mkdirs() should be (true)
parentDir should exist
file.touch() shouldBe 'success
file.touch() shouldBe Symbol("success")

val t = topDir.deleteRecursively()
t shouldBe 'success
t shouldBe Symbol("success")
t.get shouldEqual 1
topDir should not (exist)
new File(absDir) should exist
Expand Down
Loading