Skip to content

Commit

Permalink
fix and enable special.sigma.BigInt negation SigmaDsl test;
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Feb 26, 2019
1 parent 772a030 commit 2a5524a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions sigma-api/src/main/scala/special/sigma/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package sigma {
case class WrapperType[Wrapper](cWrapper: ClassTag[Wrapper]) extends RType[Wrapper] {
override def classTag: ClassTag[Wrapper] = cWrapper
override def toString: String = cWrapper.toString
override def name: String = cWrapper.runtimeClass.getSimpleName
}

}
Expand Down
7 changes: 6 additions & 1 deletion src/test/scala/sigmastate/helpers/SigmaTestingCommons.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package sigmastate.helpers

import java.math.BigInteger

import org.ergoplatform.ErgoAddressEncoder.TestnetNetworkPrefix
import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, TokenId}
import org.ergoplatform.ErgoScriptPredef.TrueProp
Expand All @@ -18,7 +20,8 @@ import sigmastate.interpreter.Interpreter.{ScriptEnv, ScriptNameProp}
import sigmastate.interpreter.{CryptoConstants, Interpreter}
import sigmastate.lang.{SigmaCompiler, TransformingSigmaBuilder}
import sigmastate.serialization.{ErgoTreeSerializer, SigmaSerializer}
import sigmastate.{SGroupElement, SType, SBigInt}
import sigmastate.{SGroupElement, SType}
import special.sigma._
import spire.util.Opt

import scala.annotation.tailrec
Expand Down Expand Up @@ -120,6 +123,8 @@ trait SigmaTestingCommons extends PropSpec
case Opt(pv) => pv
case _ => x // cannot wrap, so just return as is
}
case wt: WrapperType[_] if wt.classTag == reflect.classTag[BigInt] =>
IR.sigmaDslBuilderValue.BigInt(x.asInstanceOf[BigInteger])
case _ => x // don't need to wrap
}
case _ => res
Expand Down
4 changes: 1 addition & 3 deletions src/test/scala/special/sigma/SigmaDslTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,9 @@ class SigmaDslTest extends PropSpec
forAll { x: Int => negInt(x) }
val negLong = checkEq(func[Long, Long]("{ (x: Long) => -x }")) { x => -x }
forAll { x: Long => negLong(x) }
// TODO add scala.BigInt test
}

ignore("special.sigma.BigInt Negation equivalence") {
// TODO fix return type (java.math.BigInteger)
property("special.sigma.BigInt Negation equivalence") {
// TODO make negate() into a prefix method
val negBigInteger = checkEq(func[BigInt, BigInt]("{ (x: BigInt) => -x }")) { x => x.negate() }
forAll { x: BigInt => negBigInteger(x) }
Expand Down

0 comments on commit 2a5524a

Please sign in to comment.