Skip to content

Commit

Permalink
prepare Scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Jan 1, 2021
1 parent 4cff5d4 commit 668f9d6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion jvm/src/test/scala/msgpack4z/Java06Spec.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package msgpack4z

trait Java06Spec { _: SpecBase =>
trait Java06Spec { self: SpecBase =>
override protected[this] def packer() = Msgpack06.defaultPacker()
override protected[this] def unpacker(bytes: Array[Byte]) = Msgpack06.defaultUnpacker(bytes)
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/msgpack4z/IntSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scalaprops.Property.forAll
abstract class IntSpec extends SpecBase {
override def param = super.param.copy(minSuccessful = 200)

val int8 = forAll { x: Byte =>
val int8 = forAll { (x: Byte) =>
def u = unpacker(Array[Byte](msgpack4z.Code.INT8, x))
assert(u.unpackByte() == x)
assert(u.unpackShort() == x)
Expand All @@ -16,7 +16,7 @@ abstract class IntSpec extends SpecBase {
true
}

val int16 = forAll { x: Short =>
val int16 = forAll { (x: Short) =>
def u = {
val buf = MsgOutBuffer.create()
buf.writeByteAndShort(Code.INT16, x)
Expand All @@ -37,7 +37,7 @@ abstract class IntSpec extends SpecBase {
true
}

val int32 = forAll { x: Int =>
val int32 = forAll { (x: Int) =>
def u = {
val buf = MsgOutBuffer.create()
buf.writeByteAndInt(Code.INT32, x)
Expand All @@ -64,7 +64,7 @@ abstract class IntSpec extends SpecBase {
true
}

val int64 = forAll { x: Long =>
val int64 = forAll { (x: Long) =>
def u = {
val buf = MsgOutBuffer.create()
buf.writeByteAndLong(Code.INT64, x)
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/msgpack4z/Spec.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package msgpack4z

trait NativeSpec { _: SpecBase =>
trait NativeSpec { self: SpecBase =>
override protected[this] def packer() = MsgOutBuffer.create()
override protected[this] def unpacker(bytes: Array[Byte]) = MsgInBuffer(bytes)
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/msgpack4z/SpecBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class SpecBase extends Scalaprops {
Gen.alphaNumString

final def checkRoundTripBytes[A](checkHashCode: Boolean)(implicit A: MsgpackCodec[A], G: Gen[A], E: Equal[A]): Property =
Property.forAll { a: A =>
Property.forAll { (a: A) =>
try {
A.roundtripz(a, packer(), unpacker _) match {
case None =>
Expand Down
12 changes: 6 additions & 6 deletions src/test/scala/msgpack4z/UnionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import scalaprops._
import scalaz._

abstract class UnionSpec(unionGen0: Gen[MsgpackUnion] = UnionGen.unionGen) extends SpecBase {
private implicit def unionGen = unionGen0
private implicit def unionGen: Gen[MsgpackUnion] = unionGen0

private def supportExtType: Boolean = unionGen == UnionGen.unionGen

val union = checkLaw(MsgpackUnion.codecInstance, unionGen)

val `equals hashCode` = Property.forAll { a: MsgpackUnion =>
val `equals hashCode` = Property.forAll { (a: MsgpackUnion) =>
val M = MsgpackCodec[MsgpackUnion]
val bytes = M.toBytes(a, packer())
M.unpackAndClose(unpacker(bytes)) match {
Expand All @@ -23,13 +23,13 @@ abstract class UnionSpec(unionGen0: Gen[MsgpackUnion] = UnionGen.unionGen) exten
}
}.toProperties((), Param.minSuccessful(10000))

val `MsgpackLong and MsgpackULong` = Property.forAll { a: Long =>
val `MsgpackLong and MsgpackULong` = Property.forAll { (a: Long) =>
val x = MsgpackLong(a)
val y = MsgpackULong(java.math.BigInteger.valueOf(a))
(y == x) && (x == y) && (x.hashCode == y.hashCode)
}

val `MsgpackLong pack/unpack MsgpackLong` = Property.forAll { a: Long =>
val `MsgpackLong pack/unpack MsgpackLong` = Property.forAll { (a: Long) =>
val M = MsgpackCodec[MsgpackUnion]
val b = MsgpackLong(a)
val c = M.toBytes(b, packer())
Expand All @@ -41,7 +41,7 @@ abstract class UnionSpec(unionGen0: Gen[MsgpackUnion] = UnionGen.unionGen) exten
}
}

val extEqualsHashcode = Property.forAllG(UnionGen.extGen) { e1: MsgpackExt =>
val extEqualsHashcode = Property.forAllG(UnionGen.extGen) { (e1: MsgpackExt) =>
val e2 = e1.copy()
(e1 ne e2) && (e1 == e2) && (e1.## == e2.##)
}
Expand Down Expand Up @@ -106,7 +106,7 @@ abstract class UnionSpec(unionGen0: Gen[MsgpackUnion] = UnionGen.unionGen) exten
} else true
}

val `map imap` = Property.forAll { a: Map[MsgpackUnion, MsgpackUnion] =>
val `map imap` = Property.forAll { (a: Map[MsgpackUnion, MsgpackUnion]) =>
val b = MsgpackUnion.map(a)
val c = IMap.fromList(a.toList)
val d = MsgpackUnion.imap(c)
Expand Down

0 comments on commit 668f9d6

Please sign in to comment.