fix try-finally usage in STL vector test
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 11 Aug 2012 19:40:46 +0000 (21:40 +0200)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 11 Aug 2012 19:40:46 +0000 (21:40 +0200)
tests/run/cpp_stl_vector.pyx

index 979c40d..0d80093 100644 (file)
@@ -10,8 +10,8 @@ def simple_test(double x):
     >>> simple_test(55)
     3
     """
+    v = new vector[double]()
     try:
-        v = new vector[double]()
         v.push_back(1.0)
         v.push_back(x)
         from math import pi
@@ -29,8 +29,8 @@ def list_test(L):
     >>> list_test([-1] * 1000)
     (1000, 1000)
     """
+    v = new vector[int]()
     try:
-        v = new vector[int]()
         for a in L:
             v.push_back(a)
         return len(L), v.size()
@@ -44,8 +44,8 @@ def index_test(L):
     >>> index_test([1.25])
     (1.25, 1.25)
     """
+    v = new vector[double]()
     try:
-        v = new vector[double]()
         for a in L:
             v.push_back(a)
         return v[0][0], v[0][len(L)-1]
@@ -60,8 +60,8 @@ def index_set_test(L):
     >>> index_set_test([1.25])
     (-1.25, -1.25)
     """
+    v = new vector[double]()
     try:
-        v = new vector[double]()
         for a in L:
             v.push_back(a)
         for i in range(v.size()):
@@ -78,8 +78,8 @@ def iteration_test(L):
     4
     8
     """
+    v = new vector[int]()
     try:
-        v = new vector[int]()
         for a in L:
             v.push_back(a)
         it = v.begin()
@@ -98,8 +98,8 @@ def reverse_iteration_test(L):
     2
     1
     """
+    v = new vector[int]()
     try:
-        v = new vector[int]()
         for a in L:
             v.push_back(a)
         it = v.rbegin()