tests/basics: Split out literal tests that raise SyntaxWarning on CPy.
Fixes issue #7330. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
486fe71c6e
commit
025e4b6fbc
|
@ -1,14 +1,4 @@
|
||||||
print(1 is 1)
|
|
||||||
print(1 is 2)
|
|
||||||
print(1 is not 1)
|
|
||||||
print(1 is not 2)
|
|
||||||
|
|
||||||
|
|
||||||
print([1, 2] is [1, 2])
|
print([1, 2] is [1, 2])
|
||||||
a = [1, 2]
|
a = [1, 2]
|
||||||
b = a
|
b = a
|
||||||
print(b is a)
|
print(b is a)
|
||||||
|
|
||||||
# TODO: strings require special "is" handling, postponed
|
|
||||||
# until qstr refactor.
|
|
||||||
#print("a" is "a")
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# test "is" and "is not" with literal arguments
|
||||||
|
# these raise a SyntaxWarning in CPython because the results are
|
||||||
|
# implementation dependent; see https://bugs.python.org/issue34850
|
||||||
|
|
||||||
|
print(1 is 1)
|
||||||
|
print(1 is 2)
|
||||||
|
print(1 is not 1)
|
||||||
|
print(1 is not 2)
|
||||||
|
|
||||||
|
print("a" is "a")
|
||||||
|
print("a" is "b")
|
||||||
|
print("a" is not "a")
|
||||||
|
print("a" is not "b")
|
|
@ -0,0 +1,8 @@
|
||||||
|
True
|
||||||
|
False
|
||||||
|
False
|
||||||
|
True
|
||||||
|
True
|
||||||
|
False
|
||||||
|
False
|
||||||
|
True
|
|
@ -29,18 +29,10 @@ except TypeError:
|
||||||
print('TypeError')
|
print('TypeError')
|
||||||
|
|
||||||
# unsupported subscription
|
# unsupported subscription
|
||||||
try:
|
|
||||||
1[0]
|
|
||||||
except TypeError:
|
|
||||||
print('TypeError')
|
|
||||||
try:
|
try:
|
||||||
1[0] = 1
|
1[0] = 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print('TypeError')
|
print('TypeError')
|
||||||
try:
|
|
||||||
''['']
|
|
||||||
except TypeError:
|
|
||||||
print('TypeError')
|
|
||||||
try:
|
try:
|
||||||
'a'[0] = 1
|
'a'[0] = 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
@ -50,12 +42,6 @@ try:
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print('TypeError')
|
print('TypeError')
|
||||||
|
|
||||||
# not callable
|
|
||||||
try:
|
|
||||||
1()
|
|
||||||
except TypeError:
|
|
||||||
print('TypeError')
|
|
||||||
|
|
||||||
# not an iterator
|
# not an iterator
|
||||||
try:
|
try:
|
||||||
next(1)
|
next(1)
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# test errors from bad operations with literals
|
||||||
|
# these raise a SyntaxWarning in CPython; see https://bugs.python.org/issue15248
|
||||||
|
|
||||||
|
# unsupported subscription
|
||||||
|
try:
|
||||||
|
1[0]
|
||||||
|
except TypeError:
|
||||||
|
print("TypeError")
|
||||||
|
try:
|
||||||
|
""[""]
|
||||||
|
except TypeError:
|
||||||
|
print("TypeError")
|
||||||
|
|
||||||
|
# not callable
|
||||||
|
try:
|
||||||
|
1()
|
||||||
|
except TypeError:
|
||||||
|
print("TypeError")
|
|
@ -0,0 +1,3 @@
|
||||||
|
TypeError
|
||||||
|
TypeError
|
||||||
|
TypeError
|
Loading…
Reference in New Issue