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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
702f1f4d
Commit
702f1f4d
authored
Jul 22, 2015
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for conditional expressions with refernces.
parent
f2c71d24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
tests/run/if_else_expr_cpp.pyx
tests/run/if_else_expr_cpp.pyx
+41
-0
tests/run/if_else_expr_cpp_helper.h
tests/run/if_else_expr_cpp_helper.h
+17
-0
No files found.
tests/run/if_else_expr_cpp.pyx
0 → 100644
View file @
702f1f4d
# mode: run
# tag: condexpr, cpp
cdef
extern
from
"if_else_expr_cpp_helper.h"
:
cdef
cppclass
Holder
:
int
value
Holder
()
Holder
(
int
value
)
cdef
Holder
v1
cdef
Holder
v2
cdef
Holder
&
get_v1
()
cdef
Holder
&
get_v2
()
cdef
reset
()
:
v1
.
value
=
1
v2
.
value
=
2
def
test_one_ref
(
bint
b
):
"""
>>> test_one_ref(False)
1
>>> test_one_ref(True)
100
"""
reset
()
return
(
Holder
(
100
)
if
b
else
get_v1
()).
value
def
test_both_ref
(
bint
b
):
"""
>>> test_both_ref(False)
(1, 100)
>>> test_both_ref(True)
(100, 2)
"""
reset
()
try
:
(
get_v1
()
if
b
else
get_v2
()).
value
=
100
return
v1
.
value
,
v2
.
value
finally
:
reset
()
tests/run/if_else_expr_cpp_helper.h
0 → 100644
View file @
702f1f4d
class
Holder
{
public:
int
value
;
Holder
()
:
value
(
-
1
)
{
}
Holder
(
int
value
)
:
value
(
value
)
{
}
};
Holder
v1
(
1
);
Holder
v2
(
2
);
Holder
&
get_v1
()
{
return
v1
;
}
Holder
&
get_v2
()
{
return
v2
;
}
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