mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 14:40:17 +00:00
chore(compiler): Add PathFinder test (#872)
This commit is contained in:
parent
443e65e3d8
commit
c1fbea1a49
@ -7,6 +7,7 @@ import aqua.raw.value.{LiteralRaw, ValueRaw, VarRaw}
|
|||||||
import aqua.raw.ops.{Call, FuncOp, OnTag}
|
import aqua.raw.ops.{Call, FuncOp, OnTag}
|
||||||
import aqua.raw.value.{ValueRaw, VarRaw}
|
import aqua.raw.value.{ValueRaw, VarRaw}
|
||||||
import aqua.types.{ArrayType, ScalarType}
|
import aqua.types.{ArrayType, ScalarType}
|
||||||
|
|
||||||
import cats.data.{Chain, NonEmptyList}
|
import cats.data.{Chain, NonEmptyList}
|
||||||
import org.scalatest.flatspec.AnyFlatSpec
|
import org.scalatest.flatspec.AnyFlatSpec
|
||||||
import org.scalatest.matchers.should.Matchers
|
import org.scalatest.matchers.should.Matchers
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package aqua.model.transform.topology
|
||||||
|
|
||||||
|
import aqua.model.*
|
||||||
|
import aqua.model.transform.ModelBuilder
|
||||||
|
import aqua.types.ScalarType
|
||||||
|
|
||||||
|
import cats.data.Chain
|
||||||
|
import cats.syntax.show.*
|
||||||
|
import org.scalatest.flatspec.AnyFlatSpec
|
||||||
|
import org.scalatest.matchers.should.Matchers
|
||||||
|
|
||||||
|
class PathFinderSpec extends AnyFlatSpec with Matchers {
|
||||||
|
|
||||||
|
val relay = ValueModel.fromRaw(ModelBuilder.relayV)
|
||||||
|
val initPeer = ValueModel.fromRaw(ModelBuilder.initPeer)
|
||||||
|
|
||||||
|
val relayOn = OnModel(relay, Chain.empty)
|
||||||
|
val initPeerRelayOn = OnModel(initPeer, Chain.one(relay))
|
||||||
|
|
||||||
|
it should "find path from (op, or) -> r -> (i, r) to r -> (i, r)" in {
|
||||||
|
|
||||||
|
val otherPeer = VarModel("other-peer", ScalarType.string)
|
||||||
|
val otherRelay = VarModel("other-relay", ScalarType.string)
|
||||||
|
val otherPeerRelayOn = OnModel(otherPeer, Chain.one(otherRelay))
|
||||||
|
|
||||||
|
val from = TopologyPath(otherPeerRelayOn :: relayOn :: initPeerRelayOn :: Nil)
|
||||||
|
val to = TopologyPath(relayOn :: initPeerRelayOn :: Nil)
|
||||||
|
|
||||||
|
val path = PathFinder.findPath(from, to)
|
||||||
|
|
||||||
|
path shouldBe Chain.one(otherRelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user