Skip to content

Commit

Permalink
provide a JSON writer for PositionName
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed Oct 12, 2024
1 parent 097e786 commit 41205b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package instances
import cats.syntax.all.*

import at.ac.oeaw.imba.gerlich.gerlib.SimpleShow
import at.ac.oeaw.imba.gerlich.gerlib.json.JsonValueWriter
import at.ac.oeaw.imba.gerlich.gerlib.numeric.NonnegativeInt
import at.ac.oeaw.imba.gerlich.gerlib.numeric.instances.nonnegativeInt.given
import at.ac.oeaw.imba.gerlich.gerlib.syntax.all.*
Expand All @@ -12,6 +13,10 @@ import at.ac.oeaw.imba.gerlich.gerlib.syntax.all.*
* view
*/
trait FieldOfViewLikeInstances:
given JsonValueWriter[PositionName, ujson.Str] with
override def apply(posName: PositionName): ujson.Str =
ujson.Str(posName.get)

/** Simply show a field of view by the text representation of the underlying
* integer value.
*/
Expand Down
4 changes: 2 additions & 2 deletions modules/testing/src/test/scala/TestSyntaxExtensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class TestSyntaxExtensions
val sd = scala.math.sqrt(n * p * p)
val exp = n * p
(-zStar * sd + exp, zStar * sd + exp)

// the instance under test
given Arbitrary[Boolean | Int] = Arbitrary.oneOf[Boolean, Int]

// Use the instance under test to generate the values, then count by type.
forAll(Gen.listOfN(n, arbitrary[Boolean | Int])) { values =>
val (bools, ints): (List[Boolean], List[Int]) =
Expand Down

0 comments on commit 41205b4

Please sign in to comment.