Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
visitors
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
visitors
Commits
b27d284e
Commit
b27d284e
authored
Mar 15, 2017
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New tests of [@name] and [@@name].
parent
8b55208a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
8 deletions
+74
-8
test/misc.mllib
test/misc.mllib
+1
-0
test/test06.ml
test/test06.ml
+24
-8
test/test07.ml
test/test07.ml
+49
-0
No files found.
test/misc.mllib
View file @
b27d284e
...
...
@@ -13,4 +13,5 @@ test03
test04
test05
test06
test07
testallprims
test/test06.ml
View file @
b27d284e
(* Testing @name attributes. *)
(* Testing @name attributes
on data constructors
. *)
type
foo
=
|
A
[
@
name
"transform_A"
]
|
B
of
int
[
@
name
"transform_B"
]
|
C
of
int
*
int
[
@
name
"transform_C"
]
[
@@
deriving
visitors
{
variety
=
"map"
;
concrete
=
true
}]
|
A
[
@
name
"TA"
]
|
B
of
int
[
@
name
"TB"
]
|
C
of
int
*
int
[
@
name
"TC"
]
[
@@
deriving
visitors
{
variety
=
"map"
;
concrete
=
true
}
,
visitors
{
variety
=
"fold"
;
ancestors
=
[
"VisitorsRuntime.map"
]
}]
let
f
(
x
:
foo
)
=
let
o
=
object
inherit
[
_
]
map
method
!
transform_
A
_env
=
B
0
method
!
transform_
B
_env
x
=
B
(
x
+
1
)
method
!
transform_
C
_env
x
y
=
C
(
x
,
x
+
y
)
method
!
visit_T
A
_env
=
B
0
method
!
visit_T
B
_env
x
=
B
(
x
+
1
)
method
!
visit_T
C
_env
x
y
=
C
(
x
,
x
+
y
)
end
in
o
#
visit_foo
()
x
...
...
@@ -20,3 +21,18 @@ let () =
assert
(
f
(
B
0
)
=
B
1
);
assert
(
f
(
C
(
1
,
1
))
=
C
(
1
,
2
));
()
let
g
(
x
:
foo
)
:
int
=
let
o
=
object
inherit
[
_
]
fold
method
build_TA
_env
=
42
method
build_TB
_env
x
=
x
method
build_TC
_env
x
y
=
x
+
y
end
in
o
#
visit_foo
()
x
let
()
=
assert
(
g
A
=
42
);
assert
(
g
(
B
12
)
=
12
);
assert
(
g
(
C
(
1
,
1
))
=
2
);
()
test/test07.ml
0 → 100644
View file @
b27d284e
(* Testing @name attributes on data types. *)
(* Testing local types decorated with [@@name]. *)
module
Point
=
struct
type
point
=
{
x
:
coordinate
;
y
:
coordinate
}
[
@@
name
"foo"
]
and
coordinate
=
float
[
@@
name
"coord"
]
[
@@
deriving
visitors
{
variety
=
"map"
;
concrete
=
true
}
,
visitors
{
variety
=
"fold"
;
ancestors
=
[
"VisitorsRuntime.map"
]}]
let
f
(
p
:
point
)
=
let
o
=
new
map
in
o
#
visit_foo
()
p
let
()
=
assert
(
f
{
x
=
0
.;
y
=
0
.
}
=
{
x
=
0
.;
y
=
0
.
});
()
let
g
(
p
:
point
)
:
float
=
let
o
=
object
inherit
[
_
]
fold
method
build_coord
_env
x
=
x
method
build_foo
_env
x
y
=
x
+.
y
end
in
o
#
visit_foo
()
p
let
()
=
assert
(
g
{
x
=
1
.;
y
=
2
.
}
=
3
.
);
()
end
type
boolean
=
Vrai
|
Faux
[
@@
name
"condition"
]
[
@@
deriving
visitors
{
variety
=
"iter2"
;
concrete
=
true
}]
let
()
=
try
new
iter2
#
fail_condition
()
Vrai
Faux
;
assert
false
with
VisitorsRuntime
.
StructuralMismatch
->
()
(* Testing nonlocal types decorated with [@name]. *)
type
segment
=
{
source
:
Point
.
point
[
@
name
"foo"
];
destination
:
Point
.
point
[
@
name
"foo"
]
}
[
@@
deriving
visitors
{
variety
=
"map"
;
concrete
=
true
;
nude
=
true
;
ancestors
=
[
"Point.map"
]
}]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment