summaryrefslogtreecommitdiff
path: root/tests/micropython/viper_error.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-03-14 22:52:50 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-14 23:05:41 +1100
commite29f704b6776ac9f7b95bb35d53d65948e995b38 (patch)
tree32eb0243d580ac4c1232bba04515e80322554dd9 /tests/micropython/viper_error.py
parenta5a84e1f85e795338d462a32632709d7b297d05c (diff)
tests/micropython/viper_error: Add more tests to improve coverage.
Diffstat (limited to 'tests/micropython/viper_error.py')
-rw-r--r--tests/micropython/viper_error.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/micropython/viper_error.py b/tests/micropython/viper_error.py
index 116bd4ea0..847257285 100644
--- a/tests/micropython/viper_error.py
+++ b/tests/micropython/viper_error.py
@@ -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\ndef f(a:1): pass")
test("@micropython.viper\ndef f() -> 1: pass")
+# unknown type
+test("@micropython.viper\ndef f(x:unknown_type): pass")
+
+# too many arguments
+test("@micropython.viper\ndef 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\ndef f(): 1[0] = 1")
test("@micropython.viper\ndef f(): 1[x] = 1")
+test("@micropython.viper\ndef f(x:int): x[0] = x")
+test("@micropython.viper\ndef f(x:ptr32): x[0] = None")
+test("@micropython.viper\ndef f(x:ptr32): x[x] = None")
# must raise an object
test("@micropython.viper\ndef f(): raise 1")
@@ -57,3 +66,16 @@ test("@micropython.viper\ndef f(): raise 1")
test("@micropython.viper\ndef f(x:int): +x")
test("@micropython.viper\ndef f(x:int): -x")
test("@micropython.viper\ndef f(x:int): ~x")
+
+# binary op not implemented
+test("@micropython.viper\ndef f(x:int): res = x in x")
+
+# yield (from) not implemented
+test("@micropython.viper\ndef f(): yield")
+test("@micropython.viper\ndef f(): yield from f")
+
+# passing a ptr to a Python function not implemented
+test("@micropython.viper\ndef f(): print(ptr(1))")
+
+# cast of a casting identifier not implemented
+test("@micropython.viper\ndef f(): int(int)")