Commit 3218a24e authored by Stefan Behnel's avatar Stefan Behnel

fix try-finally usage in STL vector test

parent 2812f9b2
...@@ -10,8 +10,8 @@ def simple_test(double x): ...@@ -10,8 +10,8 @@ def simple_test(double x):
>>> simple_test(55) >>> simple_test(55)
3 3
""" """
v = new vector[double]()
try: try:
v = new vector[double]()
v.push_back(1.0) v.push_back(1.0)
v.push_back(x) v.push_back(x)
from math import pi from math import pi
...@@ -29,8 +29,8 @@ def list_test(L): ...@@ -29,8 +29,8 @@ def list_test(L):
>>> list_test([-1] * 1000) >>> list_test([-1] * 1000)
(1000, 1000) (1000, 1000)
""" """
v = new vector[int]()
try: try:
v = new vector[int]()
for a in L: for a in L:
v.push_back(a) v.push_back(a)
return len(L), v.size() return len(L), v.size()
...@@ -44,8 +44,8 @@ def index_test(L): ...@@ -44,8 +44,8 @@ def index_test(L):
>>> index_test([1.25]) >>> index_test([1.25])
(1.25, 1.25) (1.25, 1.25)
""" """
v = new vector[double]()
try: try:
v = new vector[double]()
for a in L: for a in L:
v.push_back(a) v.push_back(a)
return v[0][0], v[0][len(L)-1] return v[0][0], v[0][len(L)-1]
...@@ -60,8 +60,8 @@ def index_set_test(L): ...@@ -60,8 +60,8 @@ def index_set_test(L):
>>> index_set_test([1.25]) >>> index_set_test([1.25])
(-1.25, -1.25) (-1.25, -1.25)
""" """
v = new vector[double]()
try: try:
v = new vector[double]()
for a in L: for a in L:
v.push_back(a) v.push_back(a)
for i in range(v.size()): for i in range(v.size()):
...@@ -78,8 +78,8 @@ def iteration_test(L): ...@@ -78,8 +78,8 @@ def iteration_test(L):
4 4
8 8
""" """
v = new vector[int]()
try: try:
v = new vector[int]()
for a in L: for a in L:
v.push_back(a) v.push_back(a)
it = v.begin() it = v.begin()
...@@ -98,8 +98,8 @@ def reverse_iteration_test(L): ...@@ -98,8 +98,8 @@ def reverse_iteration_test(L):
2 2
1 1
""" """
v = new vector[int]()
try: try:
v = new vector[int]()
for a in L: for a in L:
v.push_back(a) v.push_back(a)
it = v.rbegin() it = v.rbegin()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment