Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
e5c4362a
Commit
e5c4362a
authored
Apr 05, 2015
by
Damien George
Browse files
tests: Add some more tests to improve code coverage of corner cases.
parent
97abe229
Changes
6
Hide whitespace changes
Inline
Side-by-side
tests/basics/builtin_range.py
View file @
e5c4362a
...
...
@@ -3,6 +3,10 @@
# print
print
(
range
(
4
))
# bool
print
(
bool
(
range
(
0
)))
print
(
bool
(
range
(
10
)))
# len
print
(
len
(
range
(
0
)))
print
(
len
(
range
(
4
)))
...
...
@@ -29,3 +33,15 @@ print(range(4)[1:-2:2])
print
(
range
(
1
,
2
,
3
).
start
)
print
(
range
(
1
,
2
,
3
).
stop
)
print
(
range
(
1
,
2
,
3
).
step
)
# bad unary op
try
:
-
range
(
1
)
except
TypeError
:
print
(
"TypeError"
)
# bad subscription (can't store)
try
:
range
(
1
)[
0
]
=
1
except
TypeError
:
print
(
"TypeError"
)
tests/basics/fun_error.py
View file @
e5c4362a
...
...
@@ -29,3 +29,6 @@ test_exc("[].sort(noexist=1)", TypeError)
# function with keyword args not given a specific keyword arg
test_exc
(
"enumerate()"
,
TypeError
)
# kw given for positional, but a different positional is missing
test_exc
(
"def f(x, y): pass
\n
f(x=1)"
,
TypeError
)
tests/basics/getitem.py
View file @
e5c4362a
...
...
@@ -20,3 +20,13 @@ try:
next
(
it
)
except
StopIteration
:
pass
# this class raises a non-StopIteration exception on iteration
class
A
:
def
__getitem__
(
self
,
i
):
raise
TypeError
try
:
for
i
in
A
():
pass
except
TypeError
:
print
(
"TypeError"
)
tests/basics/namedtuple1.py
View file @
e5c4362a
...
...
@@ -49,10 +49,22 @@ try:
except
TypeError
:
print
(
"TypeError"
)
# enough args, but kw is wrong
try
:
t
=
T
(
1
,
baz
=
3
)
except
TypeError
:
print
(
"TypeError"
)
# bad argument for member spec
try
:
namedtuple
(
'T'
,
1
)
except
TypeError
:
print
(
"TypeError"
)
# Try single string
# Not implemented s
o
f
ar
#T3 = namedtuple("TupComma", "foo bar"
)
#t = T3(1, 2
)
T3
=
namedtuple
(
"TupComma"
,
"fo
o
b
ar
"
)
t
=
T3
(
1
,
2
)
print
(
t
.
foo
,
t
.
bar
)
# Try single string with comma field seperator
# Not implemented so far
...
...
tests/basics/struct1.py
View file @
e5c4362a
...
...
@@ -37,3 +37,6 @@ print(struct.pack("<I", 0xffffffff))
# check maximum unpack
print
(
struct
.
unpack
(
"<I"
,
b
"
\xff\xff\xff\xff
"
))
print
(
struct
.
unpack
(
"<Q"
,
b
"
\xff\xff\xff\xff\xff\xff\xff\xff
"
))
# network byte order
print
(
struct
.
pack
(
'!i'
,
123
))
tests/extmod/zlibd_decompress.py
View file @
e5c4362a
...
...
@@ -23,3 +23,9 @@ exp = b"hello"
out
=
zlib
.
decompress
(
v
,
-
15
)
assert
(
out
==
exp
)
print
(
exp
)
# this should error
try
:
zlib
.
decompress
(
b
'abc'
)
except
Exception
:
print
(
"Exception"
)
Write
Preview
Supports
Markdown
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