Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
f3320e46
Commit
f3320e46
authored
9 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Add tests to make sure solvers can handle global variables.
parent
95d75773
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/scala/leon/integration/solvers/GlobalVariablesSuite.scala
+74
-0
74 additions, 0 deletions
...scala/leon/integration/solvers/GlobalVariablesSuite.scala
with
74 additions
and
0 deletions
src/test/scala/leon/integration/solvers/GlobalVariablesSuite.scala
0 → 100644
+
74
−
0
View file @
f3320e46
/* Copyright 2009-2015 EPFL, Lausanne */
package
leon.integration.solvers
import
leon.test._
import
leon.test.helpers._
import
leon.purescala.Common._
import
leon.purescala.Definitions._
import
leon.purescala.ExprOps._
import
leon.purescala.Constructors._
import
leon.purescala.Expressions._
import
leon.purescala.Types._
import
leon.LeonContext
import
leon.solvers._
import
leon.solvers.smtlib._
import
leon.solvers.combinators._
import
leon.solvers.z3._
class
GlobalVariablesSuite
extends
LeonTestSuiteWithProgram
with
ExpressionsDSL
{
val
sources
=
List
(
"""|import leon.lang._
|import leon.annotation._
|
|object GlobalVariables {
|
| def test(i: BigInt): BigInt = {
| 0 // will be replaced
| }
|} """
.
stripMargin
)
val
getFactories
:
Seq
[(
String
,
(
LeonContext
,
Program
)
=>
Solver
)]
=
{
(
if
(
SolverFactory
.
hasNativeZ3
)
Seq
(
(
"fairz3"
,
(
ctx
:
LeonContext
,
pgm
:
Program
)
=>
new
FairZ3Solver
(
ctx
,
pgm
))
)
else
Nil
)
++
(
if
(
SolverFactory
.
hasZ3
)
Seq
(
(
"smt-z3"
,
(
ctx
:
LeonContext
,
pgm
:
Program
)
=>
new
UnrollingSolver
(
ctx
,
pgm
,
new
SMTLIBZ3Solver
(
ctx
,
pgm
)))
)
else
Nil
)
++
(
if
(
SolverFactory
.
hasCVC4
)
Seq
(
(
"smt-cvc4"
,
(
ctx
:
LeonContext
,
pgm
:
Program
)
=>
new
UnrollingSolver
(
ctx
,
pgm
,
new
SMTLIBCVC4Solver
(
ctx
,
pgm
)))
)
else
Nil
)
}
// Check that we correctly extract several types from solver models
for
((
sname
,
sf
)
<-
getFactories
)
{
test
(
s
"Global Variables in $sname"
)
{
implicit
fix
=>
val
ctx
=
fix
.
_1
val
pgm
=
fix
.
_2
pgm
.
lookup
(
"GlobalVariables.test"
)
match
{
case
Some
(
fd
:
FunDef
)
=>
val
b0
=
FreshIdentifier
(
"B"
,
BooleanType
);
fd
.
body
=
Some
(
IfExpr
(
b0
.
toVariable
,
bi
(
1
),
bi
(-
1
)))
val
cnstr
=
LessThan
(
FunctionInvocation
(
fd
.
typed
,
Seq
(
bi
(
42
))),
bi
(
0
))
val
solver
=
sf
(
ctx
,
pgm
)
solver
.
assertCnstr
(
And
(
b0
.
toVariable
,
cnstr
))
try
{
if
(
solver
.
check
!=
Some
(
false
))
{
fail
(
"Global variables not correctly handled."
)
}
}
finally
{
solver
.
free
()
}
case
_
=>
fail
(
"Function with global body not found"
)
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment