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
e29f704b
Commit
e29f704b
authored
Mar 14, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/micropython/viper_error: Add more tests to improve coverage.
parent
a5a84e1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
tests/micropython/viper_error.py
tests/micropython/viper_error.py
+23
-1
tests/micropython/viper_error.py.exp
tests/micropython/viper_error.py.exp
+10
-0
No files found.
tests/micropython/viper_error.py
View file @
e29f704b
...
...
@@ -3,13 +3,19 @@
def
test
(
code
):
try
:
exec
(
code
)
except
(
SyntaxError
,
ViperTypeError
)
as
e
:
except
(
SyntaxError
,
ViperTypeError
,
NotImplementedError
)
as
e
:
print
(
repr
(
e
))
# viper: annotations must be identifiers
test
(
"@micropython.viper
\n
def f(a:1): pass"
)
test
(
"@micropython.viper
\n
def f() -> 1: pass"
)
# unknown type
test
(
"@micropython.viper
\n
def f(x:unknown_type): pass"
)
# too many arguments
test
(
"@micropython.viper
\n
def f(a, b, c, d, e): pass"
)
# local used before type known
test
(
"""
@micropython.viper
...
...
@@ -49,6 +55,9 @@ test("@micropython.viper\ndef f(): 1[x]")
# can't store
test
(
"@micropython.viper
\n
def f(): 1[0] = 1"
)
test
(
"@micropython.viper
\n
def f(): 1[x] = 1"
)
test
(
"@micropython.viper
\n
def f(x:int): x[0] = x"
)
test
(
"@micropython.viper
\n
def f(x:ptr32): x[0] = None"
)
test
(
"@micropython.viper
\n
def f(x:ptr32): x[x] = None"
)
# must raise an object
test
(
"@micropython.viper
\n
def f(): raise 1"
)
...
...
@@ -57,3 +66,16 @@ test("@micropython.viper\ndef f(): raise 1")
test
(
"@micropython.viper
\n
def f(x:int): +x"
)
test
(
"@micropython.viper
\n
def f(x:int): -x"
)
test
(
"@micropython.viper
\n
def f(x:int): ~x"
)
# binary op not implemented
test
(
"@micropython.viper
\n
def f(x:int): res = x in x"
)
# yield (from) not implemented
test
(
"@micropython.viper
\n
def f(): yield"
)
test
(
"@micropython.viper
\n
def f(): yield from f"
)
# passing a ptr to a Python function not implemented
test
(
"@micropython.viper
\n
def f(): print(ptr(1))"
)
# cast of a casting identifier not implemented
test
(
"@micropython.viper
\n
def f(): int(int)"
)
tests/micropython/viper_error.py.exp
View file @
e29f704b
SyntaxError('parameter annotation must be an identifier',)
SyntaxError('return annotation must be an identifier',)
ViperTypeError("unknown type 'unknown_type'",)
ViperTypeError("Viper functions don't currently support more than 4 arguments",)
ViperTypeError("local 'x' used before type known",)
ViperTypeError("local 'x' has type 'int' but source is 'object'",)
ViperTypeError("can't implicitly convert 'ptr' to 'bool'",)
...
...
@@ -9,7 +11,15 @@ ViperTypeError("can't load from 'int'",)
ViperTypeError("can't load from 'int'",)
ViperTypeError("can't store to 'int'",)
ViperTypeError("can't store to 'int'",)
ViperTypeError("can't store to 'int'",)
ViperTypeError("can't store 'None'",)
ViperTypeError("can't store 'None'",)
ViperTypeError('must raise an object',)
ViperTypeError('unary op __pos__ not implemented',)
ViperTypeError('unary op __neg__ not implemented',)
ViperTypeError('unary op __invert__ not implemented',)
ViperTypeError('binary op __contains__ not implemented',)
NotImplementedError('native yield',)
NotImplementedError('native yield from',)
NotImplementedError('conversion to object',)
NotImplementedError('casting',)
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