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
a3b1cf6f
Commit
a3b1cf6f
authored
Apr 03, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly test simple (and optimised) string concatenation in f-strings.
parent
7e004e0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
tests/run/fstring.pyx
tests/run/fstring.pyx
+59
-0
No files found.
tests/run/fstring.pyx
View file @
a3b1cf6f
...
...
@@ -17,6 +17,65 @@ max_long = LONG_MAX
min_long
=
LONG_MIN
@
cython
.
test_fail_if_path_exists
(
"//JoinedStrNode"
,
)
@
cython
.
test_assert_path_exists
(
"//AddNode"
,
)
def
concat_strings
(
a
,
b
):
"""
>>> concat_strings("", "")
x
<BLANKLINE>
x
x
x
xx
>>> concat_strings("a", "")
ax
a
x
ax
ax
axx
>>> concat_strings("", "b")
x
b
xb
xb
xb
xxb
>>> concat_strings("a", "b")
ax
ab
xb
axb
axb
axxb
>>> concat_strings("".join(["a", "b"]), "") # fresh temp string left
abx
ab
x
abx
abx
abxx
>>> concat_strings("", "".join(["a", "b"])) # fresh temp string right
x
ab
xab
xab
xab
xxab
"""
print
(
f"
{
a
}
x"
)
print
(
f"
{
a
}{
b
}
"
)
print
(
f"x
{
b
}
"
)
print
(
f"
{
a
+
'x'
}{
b
}
"
)
# fresh temp string left
print
(
f"
{
a
}{
'x'
+
b
}
"
)
# fresh temp string right
print
(
f"
{
a
+
'x'
}{
'x'
+
b
}
"
)
# fresh temp strings right and left
@
cython
.
test_fail_if_path_exists
(
"//FormattedValueNode"
,
"//JoinedStrNode"
,
...
...
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