Skip to content

Commit

Permalink
passing test (compilation fixed)
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Jul 8, 2024
1 parent a731962 commit f577fd3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ trait TreeBuilding extends Base { IR: IRContext =>
.asInstanceOf[ConstantNode[SType]]
s.put(constant)(builder)
case None =>
mkConstant[tpe.type](x.asInstanceOf[tpe.WrappedType], tpe)
if(x.isInstanceOf[CollConst[_, _]]) { // hack used to process NumericToBigEndianBytes only
mkConstant[tpe.type](x.asInstanceOf[CollConst[_, _]].constValue.asInstanceOf[tpe.WrappedType], tpe)
} else {
mkConstant[tpe.type](x.asInstanceOf[tpe.WrappedType], tpe)
}
}
case Def(IR.ConstantPlaceholder(id, elem)) =>
val tpe = elemToSType(elem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ trait NumericOps extends Base { self: IRContext =>
/** Descriptor of unary `ToBigEndianBytes` conversion operation. */
case class NumericToBigEndianBytes[T](n: ExactNumeric[T])
extends UnOp[T, Coll[Byte]]("ToBigEndianBytes")(element[Coll[Byte]]) {
override def applySeq(x: T): Coll[Byte] =
n.toBigEndianBytes(x).asInstanceOf[Coll[Byte]]
override def applySeq(x: T): Coll[Byte] = {
liftableColl(Liftables.ByteIsLiftable).lift(n.toBigEndianBytes(x))
}
}

/** Descriptor of binary `/` operation (integral division). */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sigmastate.utxo
import org.ergoplatform.ErgoBox.{AdditionalRegisters, R6, R8}
import org.ergoplatform._
import sigma.Extensions.ArrayOps
import sigma.VersionContext
import sigma.ast.SCollection.SByteArray
import sigma.ast.SType.AnyOps
import sigma.data.{AvlTreeData, CAnyValue, CSigmaDslBuilder}
Expand Down Expand Up @@ -157,6 +158,22 @@ class BasicOpsSpecification extends CompilerTestingCommons
)
}

property("Long.toBytes") {
def toBytesTest() = test("Long.toBytes", env, ext,
"""{
| val l = 1L
| l.toBytes.size > 0
| }""".stripMargin,
null
)

if (VersionContext.current.isV6SoftForkActivated) {
toBytesTest()
} else {
an[Exception] shouldBe thrownBy(toBytesTest())
}
}

property("Relation operations") {
test("R1", env, ext,
"{ allOf(Coll(getVar[Boolean](trueVar).get, true, true)) }",
Expand Down

0 comments on commit f577fd3

Please sign in to comment.