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
4c6544d8
Commit
4c6544d8
authored
15 years ago
by
Mirco Dotta
Browse files
Options
Downloads
Patches
Plain Diff
Simple tests for understanding how @generator annotation works.
parent
af889d72
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Test1.scala
+27
-0
27 additions, 0 deletions
Test1.scala
Test2.scala
+31
-0
31 additions, 0 deletions
Test2.scala
Test3.scala
+20
-0
20 additions, 0 deletions
Test3.scala
with
78 additions
and
0 deletions
Test1.scala
0 → 100644
+
27
−
0
View file @
4c6544d8
import
funcheck.lib.Specs._
import
org.scalacheck.
{
Gen
,
Arbitrary
}
object
HeapTest
{
sealed
abstract
class
Middle
extends
Top
case
class
E
()
extends
Middle
@generator
sealed
abstract
class
Top
case
class
Elem
(
i
:
Int
,
j
:
Int
)
@generator
def
create
()
:
E
=
E
()
//@generator def create2(i: Int): Elem = Elem(i)
def
genE
=
Gen
.
value
(
E
())
def
genE2
=
Gen
.
value
(
E
())
@generator
def
genElemSynthetic
(
a
:
Int
,
b
:
Int
)
=
Elem
(
a
,
b
)
def
genElem
=
for
{
v2
<-
Arbitrary
.
arbitrary
[
Int
]
v1
<-
Arbitrary
.
arbitrary
[
Int
]
}
yield
Elem
(
v2
,
v2
)
implicit
def
arbE
:
Arbitrary
[
E
]
=
Arbitrary
(
Gen
.
oneOf
(
genE
,
genE2
))
forAll
[(
Elem
,
Elem
,
Int
)](
p
=>
1
+
1
==
2
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Test2.scala
0 → 100644
+
31
−
0
View file @
4c6544d8
import
funcheck.lib.Specs._
import
org.scalacheck.
{
Gen
,
Arbitrary
}
object
HeapTest
{
@generator
sealed
abstract
class
Tree
case
class
Leaf
()
extends
Tree
case
class
Node
(
left
:
Tree
,
right
:
Tree
,
v
:
Int
)
extends
Tree
@generator
def
create
(
left
:
Tree
,
right
:
Tree
,
v
:
Int
)
:
Node
=
Node
(
left
,
right
,
v
)
case
class
Elem
(
i
:
Int
,
j
:
Int
,
k
:
Int
)
def
genElem
:
Gen
[
Elem
]
=
for
{
i
<-
Arbitrary
.
arbitrary
[
Int
]
j
<-
Arbitrary
.
arbitrary
[
Int
]
k
<-
Arbitrary
.
arbitrary
[
Int
]
}
yield
Elem
(
i
,
j
,
k
)
def
genLeaf
=
Gen
.
value
(
Leaf
())
def
genTree
:
Gen
[
Tree
]
=
Gen
.
oneOf
(
genLeaf
,
genNode
)
def
genNode
=
for
{
v1
<-
Arbitrary
.
arbitrary
[
Tree
]
v2
<-
Arbitrary
.
arbitrary
[
Tree
]
v3
<-
Arbitrary
.
arbitrary
[
Int
]
}
yield
Node
(
v1
,
v2
,
v3
)
implicit
def
arbTree
:
Arbitrary
[
Tree
]
=
Arbitrary
(
genTree
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Test3.scala
0 → 100644
+
20
−
0
View file @
4c6544d8
import
funcheck.lib.Specs._
import
org.scalacheck.
{
Gen
,
Arbitrary
}
object
HeapTest
{
@generator
sealed
abstract
class
Tree
case
class
Node
(
left
:
Tree
,
right
:
Tree
)
extends
Tree
case
class
Leaf
()
extends
Tree
def
genLeaf
:
Gen
[
Leaf
]
=
Gen
.
value
[
Leaf
](
Leaf
())
def
genNode
:
Gen
[
Node
]
=
for
{
v1
<-
Arbitrary
.
arbitrary
[
Tree
]
v2
<-
Arbitrary
.
arbitrary
[
Tree
]
}
yield
Node
(
v1
,
v2
)
implicit
def
arbTree
:
Arbitrary
[
Tree
]
=
Arbitrary
(
genTree
)
def
genTree
:
Gen
[
Tree
]
=
Gen
.
oneOf
(
genLeaf
,
genNode
)
}
\ No newline at end of file
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