Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
e29f704b
Commit
e29f704b
authored
Mar 14, 2017
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
tests/micropython/viper_error: Add more tests to improve coverage.
parent
a5a84e1f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/micropython/viper_error.py
+23
-1
23 additions, 1 deletion
tests/micropython/viper_error.py
tests/micropython/viper_error.py.exp
+10
-0
10 additions, 0 deletions
tests/micropython/viper_error.py.exp
with
33 additions
and
1 deletion
tests/micropython/viper_error.py
+
23
−
1
View file @
e29f704b
...
@@ -3,13 +3,19 @@
...
@@ -3,13 +3,19 @@
def
test
(
code
):
def
test
(
code
):
try
:
try
:
exec
(
code
)
exec
(
code
)
except
(
SyntaxError
,
ViperTypeError
)
as
e
:
except
(
SyntaxError
,
ViperTypeError
,
NotImplementedError
)
as
e
:
print
(
repr
(
e
))
print
(
repr
(
e
))
# viper: annotations must be identifiers
# viper: annotations must be identifiers
test
(
"
@micropython.viper
\n
def f(a:1): pass
"
)
test
(
"
@micropython.viper
\n
def f(a:1): pass
"
)
test
(
"
@micropython.viper
\n
def f() -> 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
# local used before type known
test
(
"""
test
(
"""
@micropython.viper
@micropython.viper
...
@@ -49,6 +55,9 @@ test("@micropython.viper\ndef f(): 1[x]")
...
@@ -49,6 +55,9 @@ test("@micropython.viper\ndef f(): 1[x]")
# can't store
# can't store
test
(
"
@micropython.viper
\n
def f(): 1[0] = 1
"
)
test
(
"
@micropython.viper
\n
def f(): 1[0] = 1
"
)
test
(
"
@micropython.viper
\n
def f(): 1[x] = 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
# must raise an object
test
(
"
@micropython.viper
\n
def f(): raise 1
"
)
test
(
"
@micropython.viper
\n
def f(): raise 1
"
)
...
@@ -57,3 +66,16 @@ test("@micropython.viper\ndef 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
"
)
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)
"
)
This diff is collapsed.
Click to expand it.
tests/micropython/viper_error.py.exp
+
10
−
0
View file @
e29f704b
SyntaxError('parameter annotation must be an identifier',)
SyntaxError('parameter annotation must be an identifier',)
SyntaxError('return 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' used before type known",)
ViperTypeError("local 'x' has type 'int' but source is 'object'",)
ViperTypeError("local 'x' has type 'int' but source is 'object'",)
ViperTypeError("can't implicitly convert 'ptr' to 'bool'",)
ViperTypeError("can't implicitly convert 'ptr' to 'bool'",)
...
@@ -9,7 +11,15 @@ ViperTypeError("can't load from 'int'",)
...
@@ -9,7 +11,15 @@ ViperTypeError("can't load from 'int'",)
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 to 'int'",)
ViperTypeError("can't store to 'int'",)
ViperTypeError("can't store 'None'",)
ViperTypeError("can't store 'None'",)
ViperTypeError('must raise an object',)
ViperTypeError('must raise an object',)
ViperTypeError('unary op __pos__ not implemented',)
ViperTypeError('unary op __pos__ not implemented',)
ViperTypeError('unary op __neg__ not implemented',)
ViperTypeError('unary op __neg__ not implemented',)
ViperTypeError('unary op __invert__ 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',)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment