Skip to content
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 .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.9.4
version = 3.9.8
project.layout = StandardConvention
runner.dialect = scala3
maxColumn = 100
Expand Down
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MessagePack-Java is a binary serialization library that provides a fast and comp
### Build and Compile
```bash
./sbt compile # Compile source code
./sbt test:compile # Compile source and test code
./sbt "Test / compile" # Compile source and test code
./sbt package # Create JAR files
```

Expand All @@ -31,7 +31,7 @@ MessagePack-Java is a binary serialization library that provides a fast and comp
### Code Quality
```bash
./sbt jcheckStyle # Run checkstyle (Facebook Presto style)
./sbt scalafmtAll # Format Scala test code
./sbt scalafmtAll # Format all Scala and sbt code
```

### Publishing
Expand Down Expand Up @@ -66,7 +66,7 @@ The msgpack-jackson module provides:
- Extension type support including timestamps

### Testing Structure
- **msgpack-core tests**: Written in Scala using AirSpec framework
- **msgpack-core tests**: Written in Scala (always use the latest Scala 3 version) using AirSpec framework
- Location: `msgpack-core/src/test/scala/`
- **msgpack-jackson tests**: Written in Java using JUnit
- Location: `msgpack-jackson/src/test/java/`
Expand All @@ -81,7 +81,7 @@ For JDK 17+ compatibility, these options are automatically added:

## Code Style Requirements
- Java code follows Facebook Presto style (enforced by checkstyle)
- Scala test code uses Scalafmt with 180 character line limit
- Scala test code uses Scalafmt with Scala 3 dialect and 100 character line limit
- Checkstyle runs automatically during compilation
- No external dependencies allowed in msgpack-core

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ msgpack-java uses [sbt](http://www.scala-sbt.org/) for building the projects. Fo
Coding style
* msgpack-java uses [the same coding style](https://github.com/airlift/codestyle) with Facebook Presto
* [IntelliJ setting file](https://raw.githubusercontent.com/airlift/codestyle/master/IntelliJIdea14/Airlift.xml)
* Scala test code uses Scalafmt with Scala 3 dialect (always use the latest Scala 3 version)

### Basic sbt commands
Enter the sbt console:
Expand All @@ -76,14 +77,14 @@ $ ./sbt
Here is a list of sbt commands for daily development:
```
> ~compile # Compile source codes
> ~test:compile # Compile both source and test codes
> ~"Test / compile" # Compile both source and test codes
> ~test # Run tests upon source code change
> ~testOnly *MessagePackTest # Run tests in the specified class
> ~testOnly *MessagePackTest -- (pattern) # Run tests matching the pattern
> project msgpack-core # Focus on a specific project
> package # Create a jar file in the target folder of each project
> jcheckStyle # Run check style
> scalafmtAll # Reformat code
> scalafmtAll # Format all Scala and sbt code
```

### Publishing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class MessagePackTest extends AirSpec with PropertyCheck with Benchmark:
test("report errors when packing/unpacking malformed strings") {
pending("We need to produce malformed utf-8 strings in Java 8")
// Create 100 malformed UTF8 Strings
val r = new Random(0)
val r = new Random(0)
val malformedStrings = Iterator
.continually {
val b = new Array[Byte](10)
Expand Down Expand Up @@ -580,12 +580,12 @@ class MessagePackTest extends AirSpec with PropertyCheck with Benchmark:

kvs
.grouped(2)
.map((kvp: Array[Value]) =>
.map { (kvp: Array[Value]) =>
val k = kvp(0)
val v = kvp(1)

(k.asStringValue().asString, v.asStringValue().asString)
)
}
.toMap
}
.toList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class MessagePackerTest extends AirSpec with Benchmark:
}

test("compute totalWrittenBytes") {
val out = new ByteArrayOutputStream
val out = new ByteArrayOutputStream
val packerTotalWrittenBytes =
withResource(MessagePack.newDefaultPacker(out)) { packer =>
packer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import scala.util.Random

object MessageUnpackerTest:
class SplitMessageBufferInput(array: Array[Array[Byte]]) extends MessageBufferInput:
var cursor = 0
var cursor = 0
override def next(): MessageBuffer =
if cursor < array.length then
val a = array(cursor)
Expand All @@ -45,7 +45,7 @@ import org.msgpack.core.MessageUnpackerTest.*

class MessageUnpackerTest extends AirSpec with Benchmark:

private val universal = MessageBuffer.allocate(0).isInstanceOf[MessageBufferU]
private val universal = MessageBuffer.allocate(0).isInstanceOf[MessageBufferU]
private def testData: Array[Byte] =
val out = new ByteArrayOutputStream()
val packer = MessagePack.newDefaultPacker(out)
Expand Down Expand Up @@ -435,7 +435,7 @@ class MessageUnpackerTest extends AirSpec with Benchmark:
val t =
time("skip performance", repeat = N) {
block("v6") {
val v6 = new org.msgpack.MessagePack()
val v6 = new org.msgpack.MessagePack()
val unpacker =
new org.msgpack.unpacker.MessagePackUnpacker(v6, new ByteArrayInputStream(data))
var count = 0
Expand Down Expand Up @@ -567,7 +567,7 @@ class MessageUnpackerTest extends AirSpec with Benchmark:
val t =
time("unpack performance", repeat = N) {
block("v6") {
val v6 = new org.msgpack.MessagePack()
val v6 = new org.msgpack.MessagePack()
val unpacker =
new org.msgpack.unpacker.MessagePackUnpacker(v6, new ByteArrayInputStream(data))
var count = 0
Expand Down Expand Up @@ -655,7 +655,7 @@ class MessageUnpackerTest extends AirSpec with Benchmark:

time("unpackBinary", repeat = 100) {
block("v6") {
val v6 = new org.msgpack.MessagePack()
val v6 = new org.msgpack.MessagePack()
val unpacker =
new org.msgpack.unpacker.MessagePackUnpacker(v6, new ByteArrayInputStream(b))
var i = 0
Expand Down
80 changes: 40 additions & 40 deletions msgpack-core/src/test/scala/org/msgpack/value/VariableTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,39 +181,39 @@ class VariableTest extends AirSpec with PropertyCheck:

test("read integers") {
forAll { (i: Int) =>
check(
_.packInt(i),
checker =
v =>
val iv = validateValue(v.asIntegerValue(), asInteger = true)
iv.asInt() shouldBe i
iv.asLong() shouldBe i.toLong
)
check(
_.packInt(i),
checker =
v =>
val iv = validateValue(v.asIntegerValue(), asInteger = true)
iv.asInt() shouldBe i
iv.asLong() shouldBe i.toLong
)
}
}

test("read double") {
forAll { (x: Double) =>
check(
_.packDouble(x),
checker =
v =>
val iv = validateValue(v.asFloatValue(), asFloat = true)
// iv.toDouble shouldBe v
// iv.toFloat shouldBe x.toFloat
)
check(
_.packDouble(x),
checker =
v =>
val iv = validateValue(v.asFloatValue(), asFloat = true)
// iv.toDouble shouldBe v
// iv.toFloat shouldBe x.toFloat
)
}
}

test("read boolean") {
forAll { (x: Boolean) =>
check(
_.packBoolean(x),
checker =
v =>
val iv = validateValue(v.asBooleanValue(), asBoolean = true)
iv.getBoolean shouldBe x
)
check(
_.packBoolean(x),
checker =
v =>
val iv = validateValue(v.asBooleanValue(), asBoolean = true)
iv.getBoolean shouldBe x
)
}
}

Expand All @@ -234,13 +234,13 @@ class VariableTest extends AirSpec with PropertyCheck:

test("read string") {
forAll { (x: String) =>
check(
_.packString(x),
checker =
v =>
val iv = validateValue(v.asStringValue(), asString = true)
iv.asString() shouldBe x
)
check(
_.packString(x),
checker =
v =>
val iv = validateValue(v.asStringValue(), asString = true)
iv.asString() shouldBe x
)
}
}

Expand Down Expand Up @@ -280,7 +280,7 @@ class VariableTest extends AirSpec with PropertyCheck:
},
checker =
v =>
val iv = validateValue(v.asMapValue(), asMap = true)
val iv = validateValue(v.asMapValue(), asMap = true)
val lst =
iv.map()
.asScala
Expand All @@ -293,15 +293,15 @@ class VariableTest extends AirSpec with PropertyCheck:

test("read timestamps") {
forAll { (millis: Long) =>
val i = Instant.ofEpochMilli(millis)
check(
_.packTimestamp(i),
checker =
v =>
val ts = validateValue(v.asTimestampValue(), asTimestamp = true)
ts.isTimestampValue shouldBe true
ts.toInstant shouldBe i
)
val i = Instant.ofEpochMilli(millis)
check(
_.packTimestamp(i),
checker =
v =>
val ts = validateValue(v.asTimestampValue(), asTimestamp = true)
ts.isTimestampValue shouldBe true
ts.toInstant shouldBe i
)
}
}
}
Expand Down
Loading