Skip to content

Commit

Permalink
Run all possible test for all Scala 3 (zio#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
987Nabil committed Aug 5, 2024
1 parent 5a276f7 commit 7e2749f
Show file tree
Hide file tree
Showing 40 changed files with 291 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import zio.test.Gen

object PlatformSpecificGen {

val platformSpecificStandardTypes: Gen[Any, StandardType[_]] = Gen.fromIterable(
val platformSpecificStandardTypes: Gen[Any, StandardType[Any]] = Gen.fromIterable(
List.empty
)

def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[_]): StandardTypeAndGen[_] =
def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[Any]): StandardTypeAndGen[Any] =
standardTypeGen match {
case _ => StandardType.UnitType -> Gen.unit: StandardTypeAndGen[_]
case _ => StandardType.UnitType.asInstanceOf[StandardType[Any]] -> Gen.unit
}

val platformSpecificSchemasAndGens: List[SchemaTest[_]] = List.empty
val platformSpecificSchemasAndGens: List[SchemaTest[Any]] = List.empty
}
24 changes: 0 additions & 24 deletions tests/jvm/src/test/scala-2/zio/schema/PlatformSpecificGen.scala

This file was deleted.

24 changes: 24 additions & 0 deletions tests/jvm/src/test/scala/zio/schema/PlatformSpecificGen.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package zio.schema

import zio.schema.SchemaGen.SchemaTest
import zio.schema.StandardTypeGen.StandardTypeAndGen
import zio.test.Gen

object PlatformSpecificGen {

val platformSpecificStandardTypes: Gen[Any, StandardType[Any]] = Gen.fromIterable(
List(
StandardType.CurrencyType
).map(_.asInstanceOf[StandardType[Any]])
)

def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[Any]): StandardTypeAndGen[Any] =
standardTypeGen match {
case typ if typ.isInstanceOf[StandardType.CurrencyType.type] => typ -> Gen.currency
case _ => StandardType.UnitType.asInstanceOf[StandardType[Any]] -> Gen.unit
}

val platformSpecificSchemasAndGens: List[SchemaTest[Any]] = List(
SchemaTest("Currency", StandardType.CurrencyType.asInstanceOf[StandardType[Any]], Gen.currency)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import zio.test.Gen

object PlatformSpecificGen {

val platformSpecificStandardTypes: Gen[Any, StandardType[_]] = Gen.fromIterable(
val platformSpecificStandardTypes: Gen[Any, StandardType[Any]] = Gen.fromIterable(
List.empty
)

def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[_]): StandardTypeAndGen[_] =
def platformSpecificStandardTypeAndGen(standardTypeGen: StandardType[Any]): StandardTypeAndGen[Any] =
standardTypeGen match {
case _ => StandardType.UnitType -> Gen.unit: StandardTypeAndGen[_]
case _ => StandardType.UnitType.asInstanceOf[StandardType[Any]] -> Gen.unit
}

val platformSpecificSchemasAndGens: List[SchemaTest[_]] = List.empty
val platformSpecificSchemasAndGens: List[SchemaTest[Any]] = List.empty
}
87 changes: 0 additions & 87 deletions tests/shared/src/test/scala-2/zio/schema/StandardTypeGen.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import zio.schema.SchemaGen.Json.schema
import zio.test._

object AccessorBuilderSpec extends ZIOSpecDefault {
import TestAccessorBuilder._
import Assertion._
import TestAccessorBuilder._

private val builder: TestAccessorBuilder = new TestAccessorBuilder

Expand Down Expand Up @@ -70,15 +70,12 @@ object AccessorBuilderSpec extends ZIOSpecDefault {

val accessor = tupleSchema.makeAccessors(builder)

assert(
accessor match {
case (Lens(r1, f1), Lens(r2, f2)) =>
r1 == r2 && r2 == tupleSchema.toRecord &&
f1.name == "_1" && f1.schema == leftSchema &&
f2.name == "_2" && f2.schema == rightSchema
case _ => false
}
)(isTrue)
assertTrue(accessor match {
case (Lens(r1, f1), Lens(r2, f2)) =>
r1 == r2 && r2 == tupleSchema.toRecord &&
f1.name == "_1" && f1.schema == leftSchema &&
f2.name == "_2" && f2.schema == rightSchema
})
}
},
test("either") {
Expand Down Expand Up @@ -122,8 +119,6 @@ object AccessorBuilderSpec extends ZIOSpecDefault {
accessor match {
case (Lens(r1, f1), Lens(r2, f2), Lens(r3, f3)) =>
r1 == schema && r2 == schema && r3 == schema && f1 == schema.field1 && f2 == schema.field2 && f3 == schema.field3
case _ => false

}
)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package zio.schema

import scala.collection.immutable.ListMap

import zio.Chunk
import zio.test._

import scala.collection.immutable.ListMap

object DynamicValueGen {

def anyPrimitiveDynamicValue[A](standardType: StandardType[A]): Gen[Sized, DynamicValue.Primitive[A]] = {
Expand Down Expand Up @@ -81,7 +81,11 @@ object DynamicValueGen {
case Schema.Either(left, right, _) =>
Gen.oneOf(anyDynamicLeftValueOfSchema(left), anyDynamicRightValueOfSchema(right))
case Schema.Fallback(left, right, _, _) =>
Gen.oneOf(anyDynamicLeftValueOfSchema(left), anyDynamicRightValueOfSchema(right), anyDynamicBothValueOfSchema(left, right))
Gen.oneOf[Sized, DynamicValue](
anyDynamicLeftValueOfSchema(left.asInstanceOf[Schema[Any]]),
anyDynamicRightValueOfSchema(right.asInstanceOf[Schema[Any]]),
anyDynamicBothValueOfSchema(left.asInstanceOf[Schema[Any]], right.asInstanceOf[Schema[Any]])
)
case Schema.Transform(schema, _, _, _, _) => anyDynamicValueOfSchema(schema)
case Schema.Fail(message, _) => Gen.const(DynamicValue.Error(message))
case l @ Schema.Lazy(_) => anyDynamicValueOfSchema(l.schema)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package zio.schema

import scala.collection.immutable.ListMap

import zio._
import zio.constraintless.TypeList._
import zio.schema.CaseSet._
Expand All @@ -10,6 +8,8 @@ import zio.schema.meta.ExtensibleMetaSchema.Labelled
import zio.schema.meta.{ ExtensibleMetaSchema, MetaSchema, NodePath }
import zio.test._

import scala.collection.immutable.ListMap

object MetaSchemaSpec extends ZIOSpecDefault {

def spec: Spec[Environment, Any] = suite("MetaSchema")(
Expand Down
Loading

0 comments on commit 7e2749f

Please sign in to comment.