Skip to content

Commit

Permalink
Merge pull request #94 from scala-steward/update/scalafmt-core-3.8.1
Browse files Browse the repository at this point in the history
Update scalafmt-core to 3.8.1
  • Loading branch information
frawa authored Mar 30, 2024
2 parents bd92b3a + b7855df commit fc2a3ed
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 226 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ ee5b17e5bdcb9c053d5eb107445a342c1fd3778a

# Scala Steward: Reformat with scalafmt 3.7.5
21d9aa026e73c94347708197dfbe8dd911cf8c12

# Scala Steward: Reformat with scalafmt 3.8.1
d1681e4362ebcfca955c30b5ba934c3755cdcda8
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.8.0"
version = "3.8.1"
runner.dialect = scala3
project.git = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ class JawnOffsetParserTest extends FunSuite {
Right(
ArrayValue(
Offset(0, 11),
Seq(NumberValue(Offset(1, 3), 13), ArrayValue(Offset(4, 10), Seq(BoolValue(Offset(5, 9), value = true))))
Seq(
NumberValue(Offset(1, 3), 13),
ArrayValue(Offset(4, 10), Seq(BoolValue(Offset(5, 9), value = true)))
)
)
)
)
Expand Down Expand Up @@ -213,7 +216,11 @@ class JawnOffsetParserTest extends FunSuite {
Right(
ArrayValue(
Offset(0, 10),
Seq(NumberValue(Offset(1, 3), 13), NumberValue(Offset(4, 6), 14), NumberValue(Offset(7, 9), 15))
Seq(
NumberValue(Offset(1, 3), 13),
NumberValue(Offset(4, 6), 14),
NumberValue(Offset(7, 9), 15)
)
)
)
)
Expand Down Expand Up @@ -438,7 +445,9 @@ class JawnOffsetParserTest extends FunSuite {
// assertEquals(pointerAt(recovered)(4), (Pointer.empty / "toto"))
}

private def offsetAt(json: String)(at: Pointer): Either[OffsetParser.ParseError, Option[Offset]] = {
private def offsetAt(
json: String
)(at: Pointer): Either[OffsetParser.ParseError, Option[Offset]] = {
parser.parseWithOffset(json).map(OffsetParser.offsetAt(_)(at))
}

Expand Down Expand Up @@ -490,7 +499,10 @@ class JawnOffsetParserTest extends FunSuite {
assertEquals(offsetAt("""{"toto":13}""")(Pointer.empty / "toto"), Right(Some(Offset(8, 10))))
assertEquals(offsetAt("""{"toto":13}""")(Pointer.empty / "missing"), Right(None))
assertEquals(offsetAt("""{"toto":13}""")(Pointer.empty / 13), Right(None))
assertEquals(offsetAt("""{"foo": [13,14], "bar": {"gnu": 13}}""")(Pointer.empty), Right(Some(Offset(0, 36))))
assertEquals(
offsetAt("""{"foo": [13,14], "bar": {"gnu": 13}}""")(Pointer.empty),
Right(Some(Offset(0, 36)))
)
assertEquals(
offsetAt("""{"foo": [13,14], "bar": {"gnu": 13}}""")(Pointer.empty / "foo"),
Right(Some(Offset(8, 15)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class JawnParserTest extends FunSuite {
}

test("object") {
assertEquals(Parser("""{"toto":"titi"}"""), Right(ObjectValue(Map("toto" -> StringValue("titi")))))
assertEquals(
Parser("""{"toto":"titi"}"""),
Right(ObjectValue(Map("toto" -> StringValue("titi"))))
)
}

test("big number") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class ZioParserTest extends FunSuite:
}

test("object") {
assertEquals(Parser("""{"toto":"titi"}"""), Right(ObjectValue(Map("toto" -> StringValue("titi")))))
assertEquals(
Parser("""{"toto":"titi"}"""),
Right(ObjectValue(Map("toto" -> StringValue("titi"))))
)
}

test("big number") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class OffsetParserTest extends FunSuite:

test("contextAt around array") {
// [13,14]
val v = ArrayValue(Offset(0, 7), Seq(NumberValue(Offset(1, 3), 13), NumberValue(Offset(4, 6), 14)))
val v =
ArrayValue(Offset(0, 7), Seq(NumberValue(Offset(1, 3), 13), NumberValue(Offset(4, 6), 14)))
assertEquals(contextAt(v)(0), NewValue(Pointer.empty / 0, Offset(0, 0)))
assertEquals(contextAt(v)(1), InsideValue(Pointer.empty / 0, Offset(1, 3)))
assertEquals(contextAt(v)(2), InsideValue(Pointer.empty / 0, Offset(1, 3)))
Expand Down
60 changes: 48 additions & 12 deletions typed-json/src/test/scala/frawa/typedjson/eval/EvalCoreTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ class EvalCoreTest extends FunSuite:

test("false with errors") {
withCompiledSchema(falseSchema) { fun =>
assertEquals(doApply(fun, parseJsonValue("{}")), SimpleOutput(false, Seq(WithPointer(FalseSchemaReason()))))
assertEquals(
doApply(fun, parseJsonValue("{}")),
SimpleOutput(false, Seq(WithPointer(FalseSchemaReason())))
)
}
}

test("boolean") {
withCompiledSchema(boolSchema) { fun =>
assertEquals(doApply(fun, parseJsonValue("true")), SimpleOutput(true))
assertEquals(doApply(fun, parseJsonValue("13")), SimpleOutput(false, Seq(WithPointer(TypeMismatch("boolean")))))
assertEquals(
doApply(fun, parseJsonValue("13")),
SimpleOutput(false, Seq(WithPointer(TypeMismatch("boolean"))))
)
}
}

Expand All @@ -106,9 +112,18 @@ class EvalCoreTest extends FunSuite:

test("false schema") {
withCompiledSchema(falseSchema) { fun =>
assertEquals(doApply(fun, parseJsonValue("null")), SimpleOutput(false, Seq(WithPointer(FalseSchemaReason()))))
assertEquals(doApply(fun, parseJsonValue("13")), SimpleOutput(false, Seq(WithPointer(FalseSchemaReason()))))
assertEquals(doApply(fun, parseJsonValue("{}")), SimpleOutput(false, Seq(WithPointer(FalseSchemaReason()))))
assertEquals(
doApply(fun, parseJsonValue("null")),
SimpleOutput(false, Seq(WithPointer(FalseSchemaReason())))
)
assertEquals(
doApply(fun, parseJsonValue("13")),
SimpleOutput(false, Seq(WithPointer(FalseSchemaReason())))
)
assertEquals(
doApply(fun, parseJsonValue("{}")),
SimpleOutput(false, Seq(WithPointer(FalseSchemaReason())))
)
}
}

Expand All @@ -132,23 +147,38 @@ class EvalCoreTest extends FunSuite:

test("not empty schema") {
withCompiledSchema("""{"not": {}}""") { fun =>
assertEquals(doApply(fun, parseJsonValue("null")), SimpleOutput(false, Seq(WithPointer(NotInvalid()))))
assertEquals(doApply(fun, parseJsonValue("13")), SimpleOutput(false, Seq(WithPointer(NotInvalid()))))
assertEquals(doApply(fun, parseJsonValue("{}")), SimpleOutput(false, Seq(WithPointer(NotInvalid()))))
assertEquals(
doApply(fun, parseJsonValue("null")),
SimpleOutput(false, Seq(WithPointer(NotInvalid())))
)
assertEquals(
doApply(fun, parseJsonValue("13")),
SimpleOutput(false, Seq(WithPointer(NotInvalid())))
)
assertEquals(
doApply(fun, parseJsonValue("{}")),
SimpleOutput(false, Seq(WithPointer(NotInvalid())))
)
}
}

test("string") {
withCompiledSchema(stringSchema) { fun =>
assertEquals(doApply(fun, parseJsonValue(""""hello"""")), SimpleOutput(true))
assertEquals(doApply(fun, parseJsonValue("13")), SimpleOutput(false, Seq(WithPointer(TypeMismatch("string")))))
assertEquals(
doApply(fun, parseJsonValue("13")),
SimpleOutput(false, Seq(WithPointer(TypeMismatch("string"))))
)
}
}

test("number") {
withCompiledSchema(numberSchema) { fun =>
assertEquals(doApply(fun, parseJsonValue("13")), SimpleOutput(true))
assertEquals(doApply(fun, parseJsonValue("null")), SimpleOutput(false, Seq(WithPointer(TypeMismatch("number")))))
assertEquals(
doApply(fun, parseJsonValue("null")),
SimpleOutput(false, Seq(WithPointer(TypeMismatch("number"))))
)
}
}

Expand Down Expand Up @@ -308,7 +338,10 @@ class EvalCoreTest extends FunSuite:
|""".stripMargin) { fun =>
assertEquals(
doApply(fun, parseJsonValue("1313")),
SimpleOutput(false, Seq(WithPointer(TypeMismatch("string")), WithPointer(TypeMismatch("boolean"))))
SimpleOutput(
false,
Seq(WithPointer(TypeMismatch("string")), WithPointer(TypeMismatch("boolean")))
)
)
}
}
Expand Down Expand Up @@ -433,7 +466,10 @@ class EvalCoreTest extends FunSuite:
)
assertEquals(
doApply(fun, parseJsonValue("13")),
SimpleOutput(false, Seq(WithPointer(TypeMismatch("null")), WithPointer(TypeMismatch("string"))))
SimpleOutput(
false,
Seq(WithPointer(TypeMismatch("null")), WithPointer(TypeMismatch("string")))
)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,27 +619,30 @@ class EvalKeywordTest extends FunSuite:
}

test("unevaluatedItems with prefixItems") {
withCompiledSchema("""{ "prefixItems": [{ "type": "boolean" }], "unevaluatedItems": { "type": "string" } }""") {
fun =>
assertEquals(
doApplyBulk(
fun,
Seq(
parseJsonValue("""[true, "foo"]"""),
parseJsonValue("""[true, 13]""")
),
state => {}
),
withCompiledSchema(
"""{ "prefixItems": [{ "type": "boolean" }], "unevaluatedItems": { "type": "string" } }"""
) { fun =>
assertEquals(
doApplyBulk(
fun,
Seq(
SimpleOutput(true, annotations = Seq(EvaluatedIndices(Set(0, 1)))),
SimpleOutput(false, Seq(WithPointer(TypeMismatch("string"), Pointer.empty / 1)))
)
parseJsonValue("""[true, "foo"]"""),
parseJsonValue("""[true, 13]""")
),
state => {}
),
Seq(
SimpleOutput(true, annotations = Seq(EvaluatedIndices(Set(0, 1)))),
SimpleOutput(false, Seq(WithPointer(TypeMismatch("string"), Pointer.empty / 1)))
)
)
}
}

test("unevaluatedItems with contains") {
withCompiledSchema("""{ "unevaluatedItems": { "type": "string" }, "contains": {"type": "boolean"} }""") { fun =>
withCompiledSchema(
"""{ "unevaluatedItems": { "type": "string" }, "contains": {"type": "boolean"} }"""
) { fun =>
assertEquals(
doApplyBulk(
fun,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,10 @@ class EvalSpecDetailsTest extends FunSuite:
{ _ => }
),
Seq(
SimpleOutput(true, annotations = Seq(EvaluatedProperties(Set("alpha")), Ignored(Set("title")))),
SimpleOutput(
true,
annotations = Seq(EvaluatedProperties(Set("alpha")), Ignored(Set("title")))
),
SimpleOutput(
false,
errors = Seq(
Expand Down
11 changes: 8 additions & 3 deletions typed-json/src/test/scala/frawa/typedjson/eval/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ import scala.collection.immutable.Seq

object Util:
val vocabularyForTest: Option[Vocabulary] = dialect(
Seq(Vocabulary.coreId, Vocabulary.validationId, Vocabulary.applicatorId, Vocabulary.unevaluatedId)
Seq(
Vocabulary.coreId,
Vocabulary.validationId,
Vocabulary.applicatorId,
Vocabulary.unevaluatedId
)
)

def withKeywords(
Expand Down Expand Up @@ -80,8 +85,8 @@ object Util:
// println(s"counted ${s.count} binds")
o

def doApplyBulk[O: OutputOps](fun: Value => R[O], values: Seq[Value], fun2: CacheState => Unit)(using
resolver: SchemaResolver
def doApplyBulk[O: OutputOps](fun: Value => R[O], values: Seq[Value], fun2: CacheState => Unit)(
using resolver: SchemaResolver
): Seq[O] =
val emptyCache = empty(resolver, vocabularyForTest.get)
val (s, os) = values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class Draft202012OptionalTest extends JsonSchemaTestSuite:
)

override protected val ignoreByExpectation: Map[TestId, Seq[String]] = Map(
("format-assertion.json", "schema that uses custom metaschema with format-assertion: false") -> Seq(
(
"format-assertion.json",
"schema that uses custom metaschema with format-assertion: false"
) -> Seq(
"format-assertion: false: invalid string"
),
("dependencies-compatibility.json", "multiple dependents required") -> Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import munit.Compare
import munit.FunSuite

class KeywordsTest extends FunSuite:
private val vocabularyForTest = dialect(Seq(Vocabulary.coreId, Vocabulary.validationId, Vocabulary.applicatorId)).get
private val vocabularyForTest = dialect(
Seq(Vocabulary.coreId, Vocabulary.validationId, Vocabulary.applicatorId)
).get

private def assertKeywords(schema: SchemaValue, vocabulary: Vocabulary = vocabularyForTest)(
f: Keywords => Unit
Expand Down Expand Up @@ -102,7 +104,9 @@ class KeywordsTest extends FunSuite:
NotKeyword(
Keywords(
vocabularyForTest,
Set(WithLocation(TrivialKeyword(false), KeywordLocation(Pointer.parse("/not").get)))
Set(
WithLocation(TrivialKeyword(false), KeywordLocation(Pointer.parse("/not").get))
)
)
),
KeywordLocation(Pointer.parse("/not").get)
Expand All @@ -126,7 +130,9 @@ class KeywordsTest extends FunSuite:
assertSchemaProblems(schema) { problems =>
assertEquals(
problems,
SchemaProblems(Seq(WithPointer(InvalidSchemaValue(StringValue("gnu")), Pointer.empty / "not")))
SchemaProblems(
Seq(WithPointer(InvalidSchemaValue(StringValue("gnu")), Pointer.empty / "not"))
)
)
}
}
Expand Down Expand Up @@ -405,7 +411,10 @@ class KeywordsTest extends FunSuite:
Keywords(
vocabularyForTest,
Set(
WithLocation(NumberTypeKeyword, KeywordLocation(Pointer.empty / "if" / "type"))
WithLocation(
NumberTypeKeyword,
KeywordLocation(Pointer.empty / "if" / "type")
)
),
Seq()
)
Expand Down Expand Up @@ -537,7 +546,8 @@ class KeywordsTest extends FunSuite:
}

test("meta: title") {
val vocabularyWithMeta = vocabularyForTest.combine(Vocabulary.specVocabularies(Vocabulary.metaDataId))
val vocabularyWithMeta =
vocabularyForTest.combine(Vocabulary.specVocabularies(Vocabulary.metaDataId))
withSchema("""{
|"title": "My Title"
|}
Expand All @@ -557,7 +567,8 @@ class KeywordsTest extends FunSuite:
}

test("meta: title and description") {
val vocabularyWithMeta = vocabularyForTest.combine(Vocabulary.specVocabularies(Vocabulary.metaDataId))
val vocabularyWithMeta =
vocabularyForTest.combine(Vocabulary.specVocabularies(Vocabulary.metaDataId))
withSchema("""{
|"description": "Longer description.",
|"title": "My Title"
Expand All @@ -578,7 +589,8 @@ class KeywordsTest extends FunSuite:
}

test("meta: all") {
val vocabularyWithMeta = vocabularyForTest.combine(Vocabulary.specVocabularies(Vocabulary.metaDataId))
val vocabularyWithMeta =
vocabularyForTest.combine(Vocabulary.specVocabularies(Vocabulary.metaDataId))
withSchema("""{
|"description": "Longer description.",
|"title": "My Title",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ class LoadedSchemasResolverTest extends FunSuite:
val Some(SchemaResolution(schema, resolver2)) = resolver1.resolveRef("cache-me"): @unchecked
assertEquals(schema, SchemaValue.root(NullValue))
assertEquals(resolver2.isInstanceOf[LoadedSchemasResolver], true)
assertEquals(resolver2.asInstanceOf[LoadedSchemasResolver].schemas.keySet, Set(uri("cache-me")))
assertEquals(
resolver2.asInstanceOf[LoadedSchemasResolver].schemas.keySet,
Set(uri("cache-me"))
)
}
}

Expand Down Expand Up @@ -369,7 +372,8 @@ class LoadedSchemasResolverTest extends FunSuite:
withLoadedSchemas(Seq()) { resolver0 =>
val uriExample = uri(exampleUri)
val lazyResolver: LazyResolver = uri =>
if uri.toString == exampleUri then Some(RootSchemaValue(exampleSchema.value, Some(uriExample)))
if uri.toString == exampleUri then
Some(RootSchemaValue(exampleSchema.value, Some(uriExample)))
else None
val resolver = resolver0.withLazyResolver(lazyResolver)

Expand Down
Loading

0 comments on commit fc2a3ed

Please sign in to comment.