Skip to content
Snippets Groups Projects
Commit 4eb403c8 authored by Viktor Kuncak's avatar Viktor Kuncak
Browse files

ground property in ExprComp

parent 37a24609
No related branches found
No related tags found
No related merge requests found
object ExprComp { object ExprComp {
// Values // Values
case class Value(v : Int) sealed abstract class Whatever
case class Value(v : Int) extends Whatever
// Operations // Operations
sealed abstract class BinOp sealed abstract class BinOp
...@@ -76,6 +77,13 @@ object ExprComp { ...@@ -76,6 +77,13 @@ object ExprComp {
def property(e : Expr, acc : Program, vs : ValueStack) : Boolean = { def property(e : Expr, acc : Program, vs : ValueStack) : Boolean = {
run(compile(e, acc), vs) == Ok(NStack(eval(e), vs)) run(compile(e, acc), vs) == Ok(NStack(eval(e), vs))
} // ensuring (res => res)
def property0() : Boolean = {
val e = Binary(Constant(Value(3)), Plus(), Constant(Value(5)))
val vs = EStack()
val acc = EProgram()
run(compile(e, acc), vs) == Ok(NStack(eval(e), vs))
} ensuring (res => res) } ensuring (res => res)
def main(args : Array[String]) = { def main(args : Array[String]) = {
...@@ -84,6 +92,6 @@ object ExprComp { ...@@ -84,6 +92,6 @@ object ExprComp {
val acc = EProgram() val acc = EProgram()
println(run(compile(e, acc), vs)) println(run(compile(e, acc), vs))
println(Ok(NStack(eval(e), vs))) println(Ok(NStack(eval(e), vs)))
println(property(e,acc,vs)) assert(property(e,acc,vs))
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment