aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/exception1.py6
-rw-r--r--tests/basics/exceptpoly.py208
-rw-r--r--tests/basics/string_rfind.py23
-rw-r--r--tests/basics/try-as-var.py10
-rw-r--r--tests/basics/types1.py5
5 files changed, 148 insertions, 104 deletions
diff --git a/tests/basics/exception1.py b/tests/basics/exception1.py
index 71d5ad304..739dd3275 100644
--- a/tests/basics/exception1.py
+++ b/tests/basics/exception1.py
@@ -7,3 +7,9 @@ print(str(IndexError("foo")))
a = IndexError(1, "test", [100, 200])
print(repr(a))
print(str(a))
+print(a.args)
+
+s = StopIteration()
+print(s.value)
+s = StopIteration(1, 2, 3)
+print(s.value)
diff --git a/tests/basics/exceptpoly.py b/tests/basics/exceptpoly.py
index 0e5ac2d1a..b2fc11afb 100644
--- a/tests/basics/exceptpoly.py
+++ b/tests/basics/exceptpoly.py
@@ -38,25 +38,25 @@ try:
except BufferError:
print("Caught BufferError")
-try:
- raise BytesWarning
-except Warning:
- print("Caught BytesWarning via Warning")
+#try:
+# raise BytesWarning
+#except Warning:
+# print("Caught BytesWarning via Warning")
-try:
- raise BytesWarning
-except BytesWarning:
- print("Caught BytesWarning")
+#try:
+# raise BytesWarning
+#except BytesWarning:
+# print("Caught BytesWarning")
-try:
- raise DeprecationWarning
-except Warning:
- print("Caught DeprecationWarning via Warning")
+#try:
+# raise DeprecationWarning
+#except Warning:
+# print("Caught DeprecationWarning via Warning")
-try:
- raise DeprecationWarning
-except DeprecationWarning:
- print("Caught DeprecationWarning")
+#try:
+# raise DeprecationWarning
+#except DeprecationWarning:
+# print("Caught DeprecationWarning")
try:
raise EOFError
@@ -68,15 +68,15 @@ try:
except EOFError:
print("Caught EOFError")
-try:
- raise EnvironmentError
-except Exception:
- print("Caught EnvironmentError via Exception")
+#try:
+# raise EnvironmentError
+#except Exception:
+# print("Caught EnvironmentError via Exception")
-try:
- raise EnvironmentError
-except EnvironmentError:
- print("Caught EnvironmentError")
+#try:
+# raise EnvironmentError
+#except EnvironmentError:
+# print("Caught EnvironmentError")
try:
raise Exception
@@ -98,15 +98,15 @@ try:
except FloatingPointError:
print("Caught FloatingPointError")
-try:
- raise FutureWarning
-except Warning:
- print("Caught FutureWarning via Warning")
+#try:
+# raise FutureWarning
+#except Warning:
+# print("Caught FutureWarning via Warning")
-try:
- raise FutureWarning
-except FutureWarning:
- print("Caught FutureWarning")
+#try:
+# raise FutureWarning
+#except FutureWarning:
+# print("Caught FutureWarning")
try:
raise IOError
@@ -128,15 +128,15 @@ try:
except ImportError:
print("Caught ImportError")
-try:
- raise ImportWarning
-except Warning:
- print("Caught ImportWarning via Warning")
+#try:
+# raise ImportWarning
+#except Warning:
+# print("Caught ImportWarning via Warning")
-try:
- raise ImportWarning
-except ImportWarning:
- print("Caught ImportWarning")
+#try:
+# raise ImportWarning
+#except ImportWarning:
+# print("Caught ImportWarning")
try:
raise IndentationError
@@ -228,35 +228,35 @@ try:
except OverflowError:
print("Caught OverflowError")
-try:
- raise PendingDeprecationWarning
-except Warning:
- print("Caught PendingDeprecationWarning via Warning")
+#try:
+# raise PendingDeprecationWarning
+#except Warning:
+# print("Caught PendingDeprecationWarning via Warning")
-try:
- raise PendingDeprecationWarning
-except PendingDeprecationWarning:
- print("Caught PendingDeprecationWarning")
+#try:
+# raise PendingDeprecationWarning
+#except PendingDeprecationWarning:
+# print("Caught PendingDeprecationWarning")
-try:
- raise ReferenceError
-except Exception:
- print("Caught ReferenceError via Exception")
+#try:
+# raise ReferenceError
+#except Exception:
+# print("Caught ReferenceError via Exception")
-try:
- raise ReferenceError
-except ReferenceError:
- print("Caught ReferenceError")
+#try:
+# raise ReferenceError
+#except ReferenceError:
+# print("Caught ReferenceError")
-try:
- raise ResourceWarning
-except Warning:
- print("Caught ResourceWarning via Warning")
+#try:
+# raise ResourceWarning
+#except Warning:
+# print("Caught ResourceWarning via Warning")
-try:
- raise ResourceWarning
-except ResourceWarning:
- print("Caught ResourceWarning")
+#try:
+# raise ResourceWarning
+#except ResourceWarning:
+# print("Caught ResourceWarning")
try:
raise RuntimeError
@@ -268,15 +268,15 @@ try:
except RuntimeError:
print("Caught RuntimeError")
-try:
- raise RuntimeWarning
-except Warning:
- print("Caught RuntimeWarning via Warning")
+#try:
+# raise RuntimeWarning
+#except Warning:
+# print("Caught RuntimeWarning via Warning")
-try:
- raise RuntimeWarning
-except RuntimeWarning:
- print("Caught RuntimeWarning")
+#try:
+# raise RuntimeWarning
+#except RuntimeWarning:
+# print("Caught RuntimeWarning")
try:
raise SyntaxError
@@ -288,15 +288,15 @@ try:
except SyntaxError:
print("Caught SyntaxError")
-try:
- raise SyntaxWarning
-except Warning:
- print("Caught SyntaxWarning via Warning")
+#try:
+# raise SyntaxWarning
+#except Warning:
+# print("Caught SyntaxWarning via Warning")
-try:
- raise SyntaxWarning
-except SyntaxWarning:
- print("Caught SyntaxWarning")
+#try:
+# raise SyntaxWarning
+#except SyntaxWarning:
+# print("Caught SyntaxWarning")
try:
raise SystemError
@@ -308,15 +308,15 @@ try:
except SystemError:
print("Caught SystemError")
-try:
- raise TabError
-except IndentationError:
- print("Caught TabError via IndentationError")
+#try:
+# raise TabError
+#except IndentationError:
+# print("Caught TabError via IndentationError")
-try:
- raise TabError
-except TabError:
- print("Caught TabError")
+#try:
+# raise TabError
+#except TabError:
+# print("Caught TabError")
try:
raise TypeError
@@ -338,15 +338,15 @@ try:
except UnboundLocalError:
print("Caught UnboundLocalError")
-try:
- raise UserWarning
-except Warning:
- print("Caught UserWarning via Warning")
+#try:
+# raise UserWarning
+#except Warning:
+# print("Caught UserWarning via Warning")
-try:
- raise UserWarning
-except UserWarning:
- print("Caught UserWarning")
+#try:
+# raise UserWarning
+#except UserWarning:
+# print("Caught UserWarning")
try:
raise ValueError
@@ -358,15 +358,15 @@ try:
except ValueError:
print("Caught ValueError")
-try:
- raise Warning
-except Exception:
- print("Caught Warning via Exception")
+#try:
+# raise Warning
+#except Exception:
+# print("Caught Warning via Exception")
-try:
- raise Warning
-except Warning:
- print("Caught Warning")
+#try:
+# raise Warning
+#except Warning:
+# print("Caught Warning")
try:
raise ZeroDivisionError
diff --git a/tests/basics/string_rfind.py b/tests/basics/string_rfind.py
new file mode 100644
index 000000000..4d0e84018
--- /dev/null
+++ b/tests/basics/string_rfind.py
@@ -0,0 +1,23 @@
+print("hello world".rfind("ll"))
+print("hello world".rfind("ll", None))
+print("hello world".rfind("ll", 1))
+print("hello world".rfind("ll", 1, None))
+print("hello world".rfind("ll", None, None))
+print("hello world".rfind("ll", 1, -1))
+print("hello world".rfind("ll", 1, 1))
+print("hello world".rfind("ll", 1, 2))
+print("hello world".rfind("ll", 1, 3))
+print("hello world".rfind("ll", 1, 4))
+print("hello world".rfind("ll", 1, 5))
+print("hello world".rfind("ll", -100))
+print("0000".rfind('0'))
+print("0000".rfind('0', 0))
+print("0000".rfind('0', 1))
+print("0000".rfind('0', 2))
+print("0000".rfind('0', 3))
+print("0000".rfind('0', 4))
+print("0000".rfind('0', 5))
+print("0000".rfind('-1', 3))
+print("0000".rfind('1', 3))
+print("0000".rfind('1', 4))
+print("0000".rfind('1', 5))
diff --git a/tests/basics/try-as-var.py b/tests/basics/try-as-var.py
new file mode 100644
index 000000000..0a92f1cae
--- /dev/null
+++ b/tests/basics/try-as-var.py
@@ -0,0 +1,10 @@
+try:
+ raise ValueError(534)
+except ValueError as e:
+ print(repr(e))
+
+# Var bound in except block is automatically deleted
+try:
+ e
+except NameError:
+ print("NameError")
diff --git a/tests/basics/types1.py b/tests/basics/types1.py
index 850b31b08..57b33b842 100644
--- a/tests/basics/types1.py
+++ b/tests/basics/types1.py
@@ -26,3 +26,8 @@ print(type(()) == tuple)
print(type([]) == list)
print(type({None}) == set)
print(type({}) == dict)
+
+try:
+ bool.foo
+except AttributeError:
+ print("AttributeError")