Skip to content

Commit

Permalink
add tests to generated Scala3 code
Browse files Browse the repository at this point in the history
  • Loading branch information
lemastero committed May 6, 2024
1 parent 20dc473 commit fb8d09e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
15 changes: 0 additions & 15 deletions scala3/src/main/scala/examples/Main.scala

This file was deleted.

4 changes: 2 additions & 2 deletions scala3/src/main/scala/examples/adts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object adts:
case object False extends Bool

final case class RgbPair(snd: Bool, fst: Rgb)

def idRgb(theArg: Rgb): Rgb = theArg

def and0(rgbArg: Rgb, rgbPairArg: RgbPair): RgbPair = rgbPairArg
def constRgbPair(rgbArg: Rgb, rgbPairArg: RgbPair): RgbPair = rgbPairArg
13 changes: 0 additions & 13 deletions scala3/src/test/scala/examples/MainSpec.scala

This file was deleted.

24 changes: 24 additions & 0 deletions scala3/src/test/scala/examples/RgbSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package examples

import zio.test.Assertion.equalTo
import zio.test.junit.JUnitRunnableSpec
import zio.test.{ assert, suite, test }

import examples.adts.{ Rgb, Red, Green, Blue, idRgb }
import examples.adts.{ RgbPair, constRgbPair }
import examples.adts.{ Bool, True, False }

object RgbSpec extends JUnitRunnableSpec:

def spec = suite("Test Rgb")(
test("identity on Rgb") {
assert(idRgb(Red))(equalTo(Red))
assert(idRgb(Green))(equalTo(Green))
assert(idRgb(Blue))(equalTo(Blue))
},
test ("const on RgbPair") {
assert( constRgbPair(Red, RgbPair(True, Blue) ) )(equalTo( RgbPair(True, Blue) ))
assert( constRgbPair(Green, RgbPair(False, Red) ) )(equalTo( RgbPair(False, Red) ))
assert( constRgbPair(Blue, RgbPair(True, Blue) ) )(equalTo( RgbPair(True, Blue) ))
}
)

0 comments on commit fb8d09e

Please sign in to comment.