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
e9404e5f
Commit
e9404e5f
authored
Oct 17, 2016
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Improve coverage of array, range, dict, slice, exc, unicode.
parent
453c2e8f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
87 additions
and
2 deletions
+87
-2
tests/basics/array1.py
tests/basics/array1.py
+4
-0
tests/basics/builtin_range.py
tests/basics/builtin_range.py
+6
-0
tests/basics/dict1.py
tests/basics/dict1.py
+24
-0
tests/basics/dict_views.py
tests/basics/dict_views.py
+15
-0
tests/basics/int_constfolding.py
tests/basics/int_constfolding.py
+5
-0
tests/basics/slice_attrs.py
tests/basics/slice_attrs.py
+9
-0
tests/misc/non_compliant.py
tests/misc/non_compliant.py
+18
-0
tests/misc/non_compliant.py.exp
tests/misc/non_compliant.py.exp
+3
-0
tests/unicode/unicode.py
tests/unicode/unicode.py
+3
-2
No files found.
tests/basics/array1.py
View file @
e9404e5f
...
...
@@ -21,6 +21,10 @@ print(array.array('i'))
print
(
bool
(
array
.
array
(
'i'
)))
print
(
bool
(
array
.
array
(
'i'
,
[
1
])))
# containment, with incorrect type
print
(
'12'
in
array
.
array
(
'B'
,
b'12'
))
print
([]
in
array
.
array
(
'B'
,
b'12'
))
# bad typecode
try
:
array
.
array
(
'X'
)
...
...
tests/basics/builtin_range.py
View file @
e9404e5f
...
...
@@ -50,3 +50,9 @@ try:
range
(
1
)[
0
]
=
1
except
TypeError
:
print
(
"TypeError"
)
# bad attr (can't store)
try
:
range
(
4
).
start
=
0
except
AttributeError
:
print
(
'AttributeError'
)
tests/basics/dict1.py
View file @
e9404e5f
...
...
@@ -16,3 +16,27 @@ while x < 100:
d
[
x
]
=
x
x
+=
1
print
(
d
[
50
])
# equality operator on dicts of different size
print
({}
==
{
1
:
1
})
# equality operator on dicts of same size but with different keys
print
({
1
:
1
}
==
{
2
:
1
})
# value not found
try
:
{}[
0
]
except
KeyError
:
print
(
'KeyError'
)
# unsupported unary op
try
:
+
{}
except
TypeError
:
print
(
'TypeError'
)
# unsupported binary op
try
:
{}
+
{}
except
TypeError
:
print
(
'TypeError'
)
tests/basics/dict_views.py
View file @
e9404e5f
...
...
@@ -3,4 +3,19 @@ for m in d.items, d.values, d.keys:
print
(
m
())
print
(
list
(
m
()))
# print a view with more than one item
print
({
1
:
1
,
2
:
1
}.
values
())
# unsupported binary op on a dict values view
try
:
{
1
:
1
}.
values
()
+
1
except
TypeError
:
print
(
'TypeError'
)
# unsupported binary op on a dict keys view
try
:
{
1
:
1
}.
keys
()
+
1
except
TypeError
:
print
(
'TypeError'
)
# set operations still to come
tests/basics/int_constfolding.py
View file @
e9404e5f
...
...
@@ -38,3 +38,8 @@ print(-123 // 7, -123 % 7)
print
(
123
//
-
7
,
123
%
-
7
)
print
(
-
123
//
-
7
,
-
123
%
-
7
)
# zero big-num on rhs
print
(
1
+
((
1
<<
65
)
-
(
1
<<
65
)))
# negative big-num on rhs
print
(
1
+
(
-
(
1
<<
65
)))
tests/basics/slice_attrs.py
View file @
e9404e5f
...
...
@@ -14,3 +14,12 @@ except:
A
()[
1
:
2
:
3
]
# test storing to attr (shouldn't be allowed)
class
B
:
def
__getitem__
(
self
,
idx
):
try
:
idx
.
start
=
0
except
AttributeError
:
print
(
'AttributeError'
)
B
()[:]
tests/misc/non_compliant.py
View file @
e9404e5f
...
...
@@ -9,6 +9,12 @@ try:
except
SyntaxError
:
print
(
'SyntaxError'
)
# store to exception attribute is not allowed
try
:
ValueError
().
x
=
0
except
AttributeError
:
print
(
'AttributeError'
)
# array deletion not implemented
try
:
a
=
array
.
array
(
'b'
,
(
1
,
2
,
3
))
...
...
@@ -23,6 +29,12 @@ try:
except
NotImplementedError
:
print
(
'NotImplementedError'
)
# containment, looking for integer not implemented
try
:
print
(
1
in
array
.
array
(
'B'
,
b'12'
))
except
NotImplementedError
:
print
(
'NotImplementedError'
)
# should raise type error
try
:
print
(
set
(
'12'
)
>=
'1'
)
...
...
@@ -65,6 +77,12 @@ try:
except
NotImplementedError
:
print
(
'NotImplementedError'
)
# str subscr with step!=1 not implemented
try
:
print
(
'abc'
[
1
:
2
:
3
])
except
NotImplementedError
:
print
(
'NotImplementedError'
)
# bytes(...) with keywords not implemented
try
:
bytes
(
'abc'
,
encoding
=
'utf8'
)
...
...
tests/misc/non_compliant.py.exp
View file @
e9404e5f
SyntaxError
AttributeError
TypeError
NotImplementedError
NotImplementedError
True
True
TypeError, ValueError
...
...
@@ -13,5 +15,6 @@ NotImplementedError
NotImplementedError
NotImplementedError
NotImplementedError
NotImplementedError
b'\x01\x02'
b'\x01\x00'
tests/unicode/unicode.py
View file @
e9404e5f
...
...
@@ -18,8 +18,9 @@ enc = s.encode()
print
(
enc
,
enc
.
decode
()
==
s
)
# printing of unicode chars using repr
# TODO we don't do this correctly
#print(repr(s))
# NOTE: for some characters (eg \u10ff) we differ to CPython
print
(
repr
(
'a
\uffff
'
))
print
(
repr
(
'a
\U0001ffff
'
))
# test invalid escape code
try
:
...
...
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