Skip to content

Commit

Permalink
LSV6 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Sep 27, 2024
1 parent d738ac5 commit 1989d19
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions sc/shared/src/test/scala/sigma/LanguageSpecificationV6.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1523,4 +1523,94 @@ class LanguageSpecificationV6 extends LanguageSpecificationBase { suite =>
)
}

property("Coll.reverse") {
val f = newFeature[Coll[Int], Coll[Int]](
{ (xs: Coll[Int]) => xs.reverse },
"""{(xs: Coll[Int]) => xs.reverse }""".stripMargin,
sinceVersion = VersionContext.V6SoftForkVersion
)

verifyCases(
Seq(
Coll(1, 2) -> Expected(ExpectedResult(Success(Coll(2, 1)), None)),
Coll[Int]() -> Expected(ExpectedResult(Success(Coll[Int]()), None))
),
f
)
}

property("Coll.distinct") {
val f = newFeature[Coll[Int], Coll[Int]](
{ (xs: Coll[Int]) => xs.distinct },
"""{(xs: Coll[Int]) => xs.distinct }""".stripMargin,
sinceVersion = VersionContext.V6SoftForkVersion
)

verifyCases(
Seq(
Coll(1, 2) -> Expected(ExpectedResult(Success(Coll(1, 2)), None)),
Coll(1, 1, 2) -> Expected(ExpectedResult(Success(Coll(1, 2)), None)),
Coll(1, 2, 2) -> Expected(ExpectedResult(Success(Coll(1, 2)), None)),
Coll[Int]() -> Expected(ExpectedResult(Success(Coll[Int]()), None))
),
f
)
}

property("Coll.startsWith") {
val f = newFeature[(Coll[Int], Coll[Int]), Boolean](
{ (xs: (Coll[Int], Coll[Int])) => xs._1.startsWith(xs._2) },
"""{(xs: (Coll[Int], Coll[Int])) => xs._1.startsWith(xs._2) }""".stripMargin,
sinceVersion = VersionContext.V6SoftForkVersion
)

verifyCases(
Seq(
(Coll(1, 2, 3), Coll(1, 2)) -> Expected(ExpectedResult(Success(true), None)),
(Coll(1, 2, 3), Coll(1, 2, 3)) -> Expected(ExpectedResult(Success(true), None)),
(Coll(1, 2, 3), Coll(1, 2, 3, 4)) -> Expected(ExpectedResult(Success(false), None)),
(Coll[Int](), Coll[Int]()) -> Expected(ExpectedResult(Success(true), None))
),
f
)
}

property("Coll.endsWith") {
val f = newFeature[(Coll[Int], Coll[Int]), Boolean](
{ (xs: (Coll[Int], Coll[Int])) => xs._1.endsWith(xs._2) },
"""{(xs: (Coll[Int], Coll[Int])) => xs._1.endsWith(xs._2) }""".stripMargin,
sinceVersion = VersionContext.V6SoftForkVersion
)

verifyCases(
Seq(
(Coll(1, 2, 3), Coll(1, 2)) -> Expected(ExpectedResult(Success(false), None)),
(Coll(1, 2, 3), Coll(2, 3)) -> Expected(ExpectedResult(Success(true), None)),
(Coll(1, 2, 3), Coll(2, 3, 4)) -> Expected(ExpectedResult(Success(false), None)),
(Coll(1, 2, 3), Coll(1, 2, 3)) -> Expected(ExpectedResult(Success(true), None)),
(Coll[Int](), Coll[Int]()) -> Expected(ExpectedResult(Success(true), None))
),
f
)
}

property("Coll.get") {
val f = newFeature[(Coll[Int], Int), Option[Int]](
{ (xs: (Coll[Int], Int)) => xs._1.get(xs._2) },
"""{(xs: (Coll[Int], Int)) => xs._1.get(xs._2) }""".stripMargin,
sinceVersion = VersionContext.V6SoftForkVersion
)

verifyCases(
Seq(
(Coll(1, 2), 0) -> Expected(ExpectedResult(Success(Some(1)), None)),
(Coll(1, 2), 1) -> Expected(ExpectedResult(Success(Some(2)), None)),
(Coll(1, 2), -1) -> Expected(ExpectedResult(Success(None), None)),
(Coll(1, 2), 2) -> Expected(ExpectedResult(Success(None), None)),
(Coll[Int](), 0) -> Expected(ExpectedResult(Success(None), None))
),
f
)
}

}

0 comments on commit 1989d19

Please sign in to comment.