Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
1675b98e
Commit
1675b98e
authored
Nov 22, 2019
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/stress: Add test for maximum length limit of qstrs.
parent
bc129f1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
128 additions
and
0 deletions
+128
-0
tests/stress/qstr_limit.py
tests/stress/qstr_limit.py
+85
-0
tests/stress/qstr_limit.py.exp
tests/stress/qstr_limit.py.exp
+43
-0
No files found.
tests/stress/qstr_limit.py
0 → 100644
View file @
1675b98e
# Test interning qstrs that go over the limit of the maximum qstr length
# (which is 255 bytes for the default configuration)
def
make_id
(
n
,
base
=
'a'
):
return
''
.
join
(
chr
(
ord
(
base
)
+
i
%
26
)
for
i
in
range
(
n
))
# identifiers in parser
for
l
in
range
(
254
,
259
):
g
=
{}
var
=
make_id
(
l
)
try
:
exec
(
var
+
'=1'
,
g
)
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
continue
print
(
var
in
g
)
# calling a function with kwarg
def
f
(
**
k
):
print
(
k
)
for
l
in
range
(
254
,
259
):
try
:
exec
(
'f({}=1)'
.
format
(
make_id
(
l
)))
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
# type construction
for
l
in
range
(
254
,
259
):
id
=
make_id
(
l
)
try
:
print
(
type
(
id
,
(),
{}).
__name__
)
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
# hasattr, setattr, getattr
class
A
:
pass
for
l
in
range
(
254
,
259
):
id
=
make_id
(
l
)
a
=
A
()
try
:
setattr
(
a
,
id
,
123
)
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
try
:
print
(
hasattr
(
a
,
id
),
getattr
(
a
,
id
))
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
# format with keys
for
l
in
range
(
254
,
259
):
id
=
make_id
(
l
)
try
:
print
((
'{'
+
id
+
'}'
).
format
(
**
{
id
:
l
}))
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
# modulo format with keys
for
l
in
range
(
254
,
259
):
id
=
make_id
(
l
)
try
:
print
((
'%('
+
id
+
')d'
)
%
{
id
:
l
})
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
# import module
# (different OS's have different results so only print those that are consistent)
for
l
in
range
(
150
,
259
):
try
:
__import__
(
make_id
(
l
))
except
ImportError
:
if
l
<
152
:
print
(
'ok'
,
l
)
except
RuntimeError
:
if
l
>
255
:
print
(
'RuntimeError'
,
l
)
# import package
for
l
in
range
(
125
,
130
):
try
:
exec
(
'import '
+
make_id
(
l
)
+
'.'
+
make_id
(
l
,
'A'
))
except
ImportError
:
print
(
'ok'
,
l
)
except
RuntimeError
:
print
(
'RuntimeError'
,
l
)
tests/stress/qstr_limit.py.exp
0 → 100644
View file @
1675b98e
True
True
RuntimeError 256
RuntimeError 257
RuntimeError 258
{'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst': 1}
{'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu': 1}
RuntimeError 256
RuntimeError 257
RuntimeError 258
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu
RuntimeError 256
RuntimeError 257
RuntimeError 258
True 123
True 123
RuntimeError 256
RuntimeError 256
RuntimeError 257
RuntimeError 257
RuntimeError 258
RuntimeError 258
254
255
RuntimeError 256
RuntimeError 257
RuntimeError 258
254
255
RuntimeError 256
RuntimeError 257
RuntimeError 258
ok 150
ok 151
RuntimeError 256
RuntimeError 257
RuntimeError 258
ok 125
ok 126
ok 127
RuntimeError 128
RuntimeError 129
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