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
11e3dcdc
Commit
11e3dcdc
authored
15 years ago
by
Mirco Dotta
Browse files
Options
Downloads
Patches
Plain Diff
- added Test.isPassed to transform a Test.Result object into a Boolean value.
parent
8f7facbf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/funcheck/scalacheck/ForAllTransformer.scala
+51
-48
51 additions, 48 deletions
src/funcheck/scalacheck/ForAllTransformer.scala
src/funcheck/scalacheck/ScalaCheck.scala
+2
-0
2 additions, 0 deletions
src/funcheck/scalacheck/ScalaCheck.scala
with
53 additions
and
48 deletions
src/funcheck/scalacheck/ForAllTransformer.scala
+
51
−
48
View file @
11e3dcdc
...
...
@@ -16,17 +16,18 @@ trait ForAllTransformer extends TypingTransformers
def
forAllTransform
(
unit
:
CompilationUnit
)
:
Unit
=
unit
.
body
=
new
ForAllTransformer
(
unit
).
transform
(
unit
.
body
)
class
ForAllTransformer
(
unit
:
CompilationUnit
)
extends
TypingTransformer
(
unit
)
{
override
def
transform
(
tree
:
Tree
)
:
Tree
=
{
curTree
=
tree
tree
match
{
tree
match
{
case
Apply
(
TypeApply
(
s
:
Select
,
_
),
rhs
@
List
(
f
@
Function
(
vparams
,
body
)))
if
isSelectOfSpecsMethod
(
s
.
symbol
,
"forAll"
)
=>
atOwner
(
currentOwner
)
{
assert
(
vparams
.
size
==
1
,
"funcheck.Specs.forAll properties are expected to take a single (tuple) parameter"
)
...
...
@@ -38,80 +39,82 @@ trait ForAllTransformer extends TypingTransformers
var
fun
:
Function
=
{
if
(
vtpes
.
size
<=
1
)
{
f
}
else
{
}
else
{
// create a fresh name for each parameter declared parametric type
val
freshNames
=
vtpes
.
map
(
i
=>
fresh
.
newName
(
"v"
))
val
funSym
=
tree
.
symbol
val
subst
=
for
{
i
<-
0
to
vtpes
.
size
-
1
}
yield
{
val
toSym
=
funSym
.
newValueParameter
(
funSym
.
pos
,
freshNames
(
i
)).
setInfo
(
vtpes
(
i
))
val
from
=
Select
(
v
,
v
.
symbol
.
tpe
.
decl
(
"_"
+(
i
+
1
)))
val
to
=
ValDef
(
toSym
,
EmptyTree
)
setPos
(
tree
.
pos
)
(
from
,
to
)
}
val
toSym
=
funSym
.
newValueParameter
(
funSym
.
pos
,
freshNames
(
i
)).
setInfo
(
vtpes
(
i
))
val
from
=
Select
(
v
,
v
.
symbol
.
tpe
.
decl
(
"_"
+(
i
+
1
)))
val
to
=
ValDef
(
toSym
,
EmptyTree
)
setPos
(
tree
.
pos
)
(
from
,
to
)
}
val
valdefs
=
subst
.
map
(
_
.
_2
).
toList
val
fun
=
localTyper
.
typed
{
val
newBody
=
new
MyTreeSubstituter
(
subst
.
map
(
p
=>
p
.
_1
.
symbol
).
toList
,
valdefs
.
map
(
v
=>
Ident
(
v
.
symbol
)).
toList
).
transform
(
resetAttrs
(
body
))
Function
(
valdefs
,
newBody
)
}.
asInstanceOf
[
Function
]
val
valdefs
=
subst
.
map
(
_
.
_2
).
toList
val
fun
=
localTyper
.
typed
{
val
newBody
=
new
MyTreeSubstituter
(
subst
.
map
(
p
=>
p
.
_1
.
symbol
).
toList
,
valdefs
.
map
(
v
=>
Ident
(
v
.
symbol
)).
toList
).
transform
(
resetAttrs
(
body
))
Function
(
valdefs
,
newBody
)
}.
asInstanceOf
[
Function
]
new
ChangeOwnerTraverser
(
funSym
,
fun
.
symbol
).
traverse
(
fun
);
new
ForeachTreeTraverser
({
t
:
Tree
=>
t
setPos
tree
.
pos
}).
traverse
(
fun
)
fun
new
ChangeOwnerTraverser
(
funSym
,
fun
.
symbol
).
traverse
(
fun
);
new
ForeachTreeTraverser
({
t
:
Tree
=>
t
setPos
tree
.
pos
}).
traverse
(
fun
)
fun
}
}
}
val
prop
=
Prop
.
forAll
(
List
(
fun
))
val
prop
=
Prop
.
forAll
(
List
(
transform
(
fun
))
)
var
buf
=
new
collection
.
mutable
.
ListBuffer
[
Tree
]()
var
buf
=
new
collection
.
mutable
.
ListBuffer
[
Tree
]()
val
blockValSym
=
newSyntheticValueParam
(
fun
.
symbol
,
definitions
.
BooleanClass
.
typeConstructor
)
val
blockValSym
=
newSyntheticValueParam
(
fun
.
symbol
,
definitions
.
BooleanClass
.
typeConstructor
)
val
fun2
=
localTyper
.
typed
{
val
body
=
Prop
.
propBoolean
(
resetAttrs
(
Ident
(
blockValSym
)))
Function
(
List
(
ValDef
(
blockValSym
,
EmptyTree
)),
body
)
}.
asInstanceOf
[
Function
]
val
fun2
=
localTyper
.
typed
{
val
body
=
Prop
.
propBoolean
(
resetAttrs
(
Ident
(
blockValSym
)))
Function
(
List
(
ValDef
(
blockValSym
,
EmptyTree
)),
body
)
}.
asInstanceOf
[
Function
]
new
ChangeOwnerTraverser
(
fun
.
symbol
,
fun2
.
symbol
).
traverse
(
fun2
);
new
ForeachTreeTraverser
({
t
:
Tree
=>
t
setPos
tree
.
pos
}).
traverse
(
fun2
)
new
ChangeOwnerTraverser
(
fun
.
symbol
,
fun2
.
symbol
).
traverse
(
fun2
);
new
ForeachTreeTraverser
({
t
:
Tree
=>
t
setPos
tree
.
pos
}).
traverse
(
fun2
)
buf
+=
Block
(
Nil
,
fun2
)
buf
+=
Block
(
Nil
,
fun2
)
if
(
vtpes
.
size
<=
1
)
{
buf
+=
resetAttrs
(
Arbitrary
.
arbitrary
(
tpe
))
buf
+=
resetAttrs
(
Shrink
.
shrinker
(
tpe
))
}
else
{
for
{
tpe
<-
vtpes
}
{
if
(
vtpes
.
size
<=
1
)
{
buf
+=
resetAttrs
(
Arbitrary
.
arbitrary
(
tpe
))
buf
+=
resetAttrs
(
Shrink
.
shrinker
(
tpe
))
}
else
{
for
{
tpe
<-
vtpes
}
{
buf
+=
resetAttrs
(
Arbitrary
.
arbitrary
(
tpe
))
buf
+=
resetAttrs
(
Shrink
.
shrinker
(
tpe
))
}
}
}
import
posAssigner.atPos
// for filling in tree positions
import
posAssigner.atPos
// for filling in tree positions
val
property
=
localTyper
.
typed
{
atPos
(
tree
.
pos
)
{
Apply
(
prop
,
buf
.
toList
)
val
property
=
localTyper
.
typed
{
atPos
(
tree
.
pos
)
{
Apply
(
prop
,
buf
.
toList
)
}
}
}
localTyper
.
typed
{
atPos
(
tree
.
pos
)
{
//ConsoleReporter.testStatsEx(Test.check(property))
Test
.
isPassed
(
Test
.
check
(
property
))
localTyper
.
typed
{
atPos
(
tree
.
pos
)
{
Test
.
isPassed
(
Test
.
check
(
property
))
}
}
}
case
t
=>
...
...
This diff is collapsed.
Click to expand it.
src/funcheck/scalacheck/ScalaCheck.scala
+
2
−
0
View file @
11e3dcdc
...
...
@@ -548,6 +548,7 @@ trait ScalaCheck extends FreshNameCreator {
/** Symbol for the <code>org.scalacheck.Prop</code> module definition. */
override
protected
lazy
val
moduleSym
=
definitions
.
getModule
(
"org.scalacheck.Prop"
)
def
forAll
(
props
:
List
[
Tree
])
:
Apply
=
moduleApply
(
"forAll"
,
props
)
...
...
@@ -556,6 +557,7 @@ trait ScalaCheck extends FreshNameCreator {
def
==>
(
ifz
:
Tree
,
then
:
Tree
)
:
Apply
=
moduleApply
(
"==>"
,
List
(
ifz
,
propBoolean
(
then
)))
def
propBoolean
(
prop
:
Tree
)
:
Apply
=
moduleApply
(
"propBoolean"
,
List
(
prop
))
}
...
...
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