Skip to content
Snippets Groups Projects
Commit 54e1f4ae authored by Régis Blanc's avatar Régis Blanc
Browse files

add regression to the top level and adapt run-tests script

parent 1bcf168b
No related branches found
No related tags found
No related merge requests found
Showing
with 231 additions and 0 deletions
object Array1 {
def foo(): Int = {
(Array.fill(5)(5))(2) = 3
0
}
}
object Array10 {
def foo(): Int = {
val a = Array.fill(5)(0)
def rec(): Array[Int] = {
a
}
val b = rec()
b(0)
}
}
object Array2 {
def foo(): Int = {
val a = Array.fill(5)(5)
val b = a
b(3)
}
}
object Array3 {
def foo(): Int = {
val a = Array.fill(5)(5)
if(a.length > 2)
a(1) = 2
else
0
0
}
}
object Array4 {
def foo(a: Array[Int]): Int = {
val b = a
b(3)
}
}
object Array5 {
def foo(a: Array[Int]): Int = {
a(2) = 4
a(2)
}
}
// vim: set ts=4 sw=4 et:
object Array6 {
def foo(): Int = {
val a = Array.fill(5)(5)
var b = a
b(0)
}
}
object Array7 {
def foo(): Int = {
val a = Array.fill(5)(5)
var b = a
b(0)
}
}
object Array8 {
def foo(a: Array[Int]): Array[Int] = {
a
}
}
object Array9 {
def foo(a: Array[Int]): Int = {
def rec(): Array[Int] = {
a
}
val b = rec()
b(0)
}
}
object InstanceOf1 {
abstract class A
case class B(i: Int) extends A
case class C(i: Int) extends A
abstract class Z
case class Y(i: Int) extends Z
def foo(): Int = {
//require(3.isInstanceOf[Int])
val b: A = B(2)
if(b.isInstanceOf[Y])
0
else
-1
} ensuring(_ == 0)
def bar(): Int = foo()
}
// vim: set ts=4 sw=4 et:
object Array1 {
def foo(): Int = {
val a = Array.fill(5)(0)
a(2) = 3
a(2)
} ensuring(_ == 0)
}
object Array2 {
def foo(): Int = {
val a = Array.fill(5)(0)
a(2) = 3
a.length
} ensuring(_ == 4)
}
import leon.Utils._
object Array3 {
def foo(): Int = {
val a = Array.fill(5)(3)
var i = 0
var sum = 0
(while(i <= a.length) {
sum = sum + a(i)
i = i + 1
}) invariant(i >= 0)
sum
} ensuring(_ == 15)
}
import leon.Utils._
object Array4 {
def foo(a: Array[Int]): Int = {
a(2)
}
}
import leon.Utils._
object Array4 {
def foo(a: Array[Int]): Int = {
require(a.length > 2)
a(2)
} ensuring(_ == 0)
}
import leon.Utils._
object Epsilon1 {
def rand2(x: Int): Int = epsilon((y: Int) => true)
//this should not hold
def property2(x: Int): Boolean = {
rand2(x) == rand2(x+1)
} holds
}
import leon.Utils._
object Epsilon1 {
def rand3(x: Int): Int = epsilon((y: Int) => x == x)
//this should not hold
def property3(x: Int): Boolean = {
rand3(x) == rand3(x+1)
} holds
}
import leon.Utils._
object Epsilon3 {
def posWrong(): Int = {
epsilon((y: Int) => y >= 0)
} ensuring(_ > 0)
}
import leon.Utils._
object Epsilon4 {
sealed abstract class MyList
case class MyCons(head: Int, tail: MyList) extends MyList
case class MyNil() extends MyList
def size(lst: MyList): Int = (lst match {
case MyNil() => 0
case MyCons(_, xs) => 1 + size(xs)
})
def toSet(lst: MyList): Set[Int] = lst match {
case MyCons(x, xs) => toSet(xs) ++ Set(x)
case MyNil() => Set[Int]()
}
def toList(set: Set[Int]): MyList = if(set == Set.empty[Int]) MyNil() else {
val elem = epsilon((x : Int) => set contains x)
MyCons(elem, toList(set -- Set[Int](elem)))
}
def wrongProperty0(lst: MyList): Boolean = (size(toList(toSet(lst))) == size(lst)) holds
//def wrongProperty1(lst: MyList): Boolean = (toList(toSet(lst)) == lst) holds
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment