Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
fd3344bd
Commit
fd3344bd
authored
Jan 05, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for 'lock' and 'locked'
parent
34924021
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
0 deletions
+166
-0
tests/errors/cypclass_lock_errors.pyx
tests/errors/cypclass_lock_errors.pyx
+117
-0
tests/errors/cypclass_locked_errors.pyx
tests/errors/cypclass_locked_errors.pyx
+49
-0
No files found.
tests/errors/cypclass_lock_errors.pyx
0 → 100644
View file @
fd3344bd
# mode: error
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
A
activable
:
void
f
(
self
,
A
other
):
pass
void
f_iso
(
self
,
iso
A
other
):
pass
void
f_lock
(
self
,
lock
A
other
):
pass
void
f_active
(
self
,
active
A
other
):
pass
void
f_locked_self
(
locked
self
):
cdef
lock
A
l
=
self
def
test_aliasing
():
cdef
lock
A
lock_a
# Aliasing from lock
cdef
iso
A
iso_a
iso_a
=
lock_a
cdef
active
A
active_a
active_a
=
lock_a
cdef
locked
A
locked_a
locked_a
=
lock_a
cdef
A
ref_a
ref_a
=
lock_a
# Aliasing to lock
cdef
lock
A
lock_b
lock_b
=
A
()
cdef
lock
A
lock_c
lock_c
=
consume
A
()
cdef
lock
A
lock_d
lock_d
=
<
lock
A
>
consume
A
()
cdef
lock
A
lock_e
cdef
locked
A
locked_b
lock_e
=
locked_b
def
test_calling
():
cdef
lock
A
a
a
.
f
(
A
())
a
.
f
(
consume
A
())
a
.
f_locked_self
()
cdef
iso
A
iso_a
a
.
f_iso
(
consume
iso_a
)
cdef
lock
A
lock_a
a
.
f_lock
(
lock_a
)
cdef
active
A
active_a
a
.
f_active
(
active_a
)
def
test_typecast
():
cdef
lock
A
lock_a
# Casting from lock
cdef
iso
A
iso_a
iso_a
=
consume
<
iso
A
>
lock_a
cdef
active
A
active_a
active_a
=
<
active
A
>
lock_a
cdef
locked
A
locked_a
locked_a
=
<
locked
A
>
lock_a
cdef
A
ref_a
ref_a
=
<
A
>
lock_a
# Casting to lock
cdef
lock
A
lock_b
lock_b
=
<
lock
A
>
A
()
cdef
lock
A
lock_c
lock_c
=
<
lock
A
>
<
iso
A
>
consume
A
()
cdef
lock
A
lock_d
lock_d
=
<
lock
A
>
activate
(
consume
A
())
cdef
lock
A
lock_e
cdef
locked
A
locked_b
lock_e
=
<
lock
A
>
locked_b
_ERRORS
=
u'''
27:12: Cannot assign type 'lock A' to 'iso A'
30:15: Cannot assign type 'lock A' to 'active A'
33:15: Cannot assign type 'lock A' to 'locked A'
36:12: Cannot assign type 'lock A' to 'A'
40:14: Cannot assign type 'A' to 'lock A'
56:9: Cannot assign type 'A' to 'lock-> A'
77:20: Cannot cast 'lock A' to 'iso A'
80:15: Cannot cast 'lock A' to 'active A'
83:15: Cannot cast 'lock A' to 'locked A'
86:12: Cannot cast 'lock A' to 'A'
90:13: Cannot cast 'A' to 'lock A'
93:13: Cannot cast 'iso A' to 'lock A'
96:13: Cannot cast 'active A' to 'lock A'
'''
tests/errors/cypclass_locked_errors.pyx
0 → 100644
View file @
fd3344bd
# mode: error
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef
cypclass
Error
:
locked
Error
prohibited_field_type
locked
Error
forward_prohibited_return_type
(
self
)
locked
Error
prohibited_return_type
(
self
):
pass
cdef
locked
Error
prohibited_global_variable
cdef
cypclass
A
:
void
f
(
locked
self
):
pass
void
g
(
self
,
locked
A
other
):
pass
void
h
(
self
,
A
other
):
cdef
locked
A
a
def
test_aliasing
():
cdef
locked
A
locked_a
cdef
lock
A
lock_a
lock_a
=
locked_a
locked_a
=
lock_a
lock_a
.
f
()
A
().
g
(
locked_a
)
A
().
g
(
lock_a
)
_ERRORS
=
u'''
6:4: 'locked' variables are only allowed inside a function
8:47: Function cannot return a 'locked' cypclass instance
10:39: Function cannot return a 'locked' cypclass instance
13:5: 'locked' variables are only allowed inside a function
33:15: Cannot assign type 'lock A' to 'locked A'
39:10: Cannot assign type 'lock A' to 'locked A'
'''
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