test kit as separate project (#178)

This commit is contained in:
Dima 2021-06-18 17:01:31 +03:00 committed by GitHub
parent 896cf7a228
commit f71de81cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 81 deletions

View File

@ -93,6 +93,10 @@ lazy val model = project
)
.dependsOn(types)
lazy val `test-kit` = project
.settings(commons: _*)
.dependsOn(model)
lazy val semantics = project
.settings(commons: _*)
.settings(
@ -101,7 +105,7 @@ lazy val semantics = project
"com.github.julien-truffaut" %% "monocle-macro" % monocleV
)
)
.dependsOn(model, parser)
.dependsOn(model, `test-kit` % Test, parser)
lazy val `backend-air` = project
.in(file("backend/air"))

View File

@ -1,75 +1,51 @@
package aqua.semantics
//import aqua.AquaSpec
//import aqua.model.transform._
//import aqua.model.{AquaContext, Node, VarModel}
//import aqua.parser.Ast
//import aqua.parser.lift.{LiftParser, Span}
//import aqua.types.ScalarType
//import cats.data.Chain
//import org.scalatest.flatspec.AnyFlatSpec
//import org.scalatest.matchers.should.Matchers
//
//class SemanticsSpec extends AnyFlatSpec with Matchers with AquaSpec {
//
// // use it to fix https://github.com/fluencelabs/aqua/issues/90
// "sem" should "create right model" in {
// implicit val fileLift: LiftParser[Span.F] = Span.spanLiftParser
//
// val script =
// """service CustomId("cid"):
// | id(s: string) -> string
// | ids() -> string
// |
// |func viaArr(node_id: string, viaAr: []string) -> string:
// | on node_id via viaAr:
// | p <- CustomId.ids()
// | <- p""".stripMargin
//
// val ast = Ast.fromString(script).toList.head
//
// val ctx = AquaContext.blank
// val bc = BodyConfig()
// import bc.aquaContextMonoid
//
// val func = Semantics.process(ast, ctx).toList.head.funcs("viaArr")
//
// val initCallable: InitPeerCallable = InitViaRelayCallable(
// Chain.fromOption(bc.relayVarName).map(VarModel(_, ScalarType.string))
// )
//
// val argsProvider: ArgsProvider =
// ArgsFromService(
// bc.dataSrvId,
// bc.relayVarName.map(_ -> ScalarType.string).toList ::: func.args.dataArgs.toList.map(add =>
// add.name -> add.dataType
// )
// )
//
// val transform =
// initCallable.transform _ compose argsProvider.transform
//
// val callback = initCallable.service(bc.callbackSrvId)
//
// val wrapFunc = ResolveFunc(
// transform,
// callback,
// bc.respFuncName
// )
//
// val tree =
// wrapFunc.resolve(func).value.tree
//
// println(Node.cofToNode(tree))
//
// // SO
//// Topology.resolve(
//// Node.cofToNode(tree)
//// )
//
// // or
//// val expected =
//// seq(par(on(LiteralModel("\"other-peer\"", LiteralType.string), Nil, callL(1)), callL(1)))
//
// }
//}
import aqua.Node
import aqua.Node._
import aqua.model.transform._
import aqua.model.{AquaContext, LiteralModel}
import aqua.parser.Ast
import aqua.parser.lift.{LiftParser, Span}
import aqua.types.LiteralType
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class SemanticsSpec extends AnyFlatSpec with Matchers {
// use it to fix https://github.com/fluencelabs/aqua/issues/90
ignore should "create right model" in {
implicit val fileLift: LiftParser[Span.F] = Span.spanLiftParser
val script =
"""service A("srv1"):
| fn1: -> string
|
|func parFunc():
| on "other-peer":
| A.fn1()
| par A.fn1()""".stripMargin
val ast = Ast.fromString(script).toList.head
val ctx = AquaContext.blank
val bc = BodyConfig()
import bc.aquaContextMonoid
val p = Semantics.process(ast, ctx)
val func = p.toList.head.funcs("parFunc")
val proc = Node.cofToNode(func.body.tree)
val expected =
seq(
par(
on(LiteralModel("\"other-peer\"", LiteralType.string), Nil, callLiteral(1)),
callLiteral(1)
)
)
// proc.equalsOrPrintDiff(expected) should be(true)
}
}

View File

@ -1,8 +1,9 @@
package aqua.model
package aqua
import aqua.model.func.Call
import aqua.model.func.body._
import aqua.model.transform.{BodyConfig, ErrorsCatcher}
import aqua.model.{LiteralModel, ValueModel, VarModel}
import aqua.types.{ArrayType, LiteralType, ScalarType}
import cats.Eval
import cats.data.Chain

View File

@ -1,13 +1,13 @@
package aqua.model.topology
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import Location.Matchers._
import ChainZipper.Matchers._
import aqua.model.func.body.SeqTag
import aqua.model.topology.ChainZipper.Matchers.`head`
import aqua.model.topology.Location.Matchers._
import cats.Eval
import cats.data.Chain
import cats.free.Cofree
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
class LocationSpec extends AnyFlatSpec with Matchers {

View File

@ -1,6 +1,6 @@
package aqua.model.topology
import aqua.model.Node
import aqua.Node
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

View File

@ -1,8 +1,9 @@
package aqua.model.transform
import aqua.Node
import aqua.model.func.body.{CallArrowTag, CallServiceTag, FuncOp}
import aqua.model.func.{ArgsDef, Call, FuncCallable}
import aqua.model.{LiteralModel, Node, VarModel}
import aqua.model.{LiteralModel, VarModel}
import aqua.types.ScalarType
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers