Commit 1e7ba6aa authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Testcase cleanup

parent fde67796
...@@ -17,13 +17,6 @@ cimport cython ...@@ -17,13 +17,6 @@ cimport cython
from python_ref cimport PyObject from python_ref cimport PyObject
__test__ = {} __test__ = {}
setup_string = u"""
>>> A = IntMockBuffer("A", range(6))
>>> B = IntMockBuffer("B", range(6))
>>> C = IntMockBuffer("C", range(6), (2,3))
>>> E = ErrorBuffer("E")
"""
import re import re
exclude = []#re.compile('object').search] exclude = []#re.compile('object').search]
...@@ -32,7 +25,7 @@ def testcase(func): ...@@ -32,7 +25,7 @@ def testcase(func):
for e in exclude: for e in exclude:
if e(func.__name__): if e(func.__name__):
return func return func
__test__[func.__name__] = setup_string + func.__doc__ __test__[func.__name__] = func.__doc__
return func return func
def testcas(a): def testcas(a):
...@@ -59,6 +52,8 @@ def printbuf(): ...@@ -59,6 +52,8 @@ def printbuf():
@testcase @testcase
def acquire_release(o1, o2): def acquire_release(o1, o2):
""" """
>>> A = IntMockBuffer("A", range(6))
>>> B = IntMockBuffer("B", range(6))
>>> acquire_release(A, B) >>> acquire_release(A, B)
acquired A acquired A
released A released A
...@@ -79,6 +74,7 @@ def acquire_raise(o): ...@@ -79,6 +74,7 @@ def acquire_raise(o):
Apparently, doctest won't handle mixed exceptions and print Apparently, doctest won't handle mixed exceptions and print
stats, so need to circumvent this. stats, so need to circumvent this.
>>> A = IntMockBuffer("A", range(6))
>>> A.resetlog() >>> A.resetlog()
>>> acquire_raise(A) >>> acquire_raise(A)
Traceback (most recent call last): Traceback (most recent call last):
...@@ -224,6 +220,7 @@ def acquire_nonbuffer2(): ...@@ -224,6 +220,7 @@ def acquire_nonbuffer2():
@testcase @testcase
def as_argument(object[int] bufarg, int n): def as_argument(object[int] bufarg, int n):
""" """
>>> A = IntMockBuffer("A", range(6))
>>> as_argument(A, 6) >>> as_argument(A, 6)
acquired A acquired A
0 1 2 3 4 5 END 0 1 2 3 4 5 END
...@@ -241,6 +238,7 @@ def as_argument_defval(object[int] bufarg=IntMockBuffer('default', range(6)), in ...@@ -241,6 +238,7 @@ def as_argument_defval(object[int] bufarg=IntMockBuffer('default', range(6)), in
acquired default acquired default
0 1 2 3 4 5 END 0 1 2 3 4 5 END
released default released default
>>> A = IntMockBuffer("A", range(6))
>>> as_argument_defval(A, 6) >>> as_argument_defval(A, 6)
acquired A acquired A
0 1 2 3 4 5 END 0 1 2 3 4 5 END
...@@ -254,6 +252,7 @@ def as_argument_defval(object[int] bufarg=IntMockBuffer('default', range(6)), in ...@@ -254,6 +252,7 @@ def as_argument_defval(object[int] bufarg=IntMockBuffer('default', range(6)), in
@testcase @testcase
def cdef_assignment(obj, n): def cdef_assignment(obj, n):
""" """
>>> A = IntMockBuffer("A", range(6))
>>> cdef_assignment(A, 6) >>> cdef_assignment(A, 6)
acquired A acquired A
0 1 2 3 4 5 END 0 1 2 3 4 5 END
...@@ -269,6 +268,8 @@ def cdef_assignment(obj, n): ...@@ -269,6 +268,8 @@ def cdef_assignment(obj, n):
@testcase @testcase
def forin_assignment(objs, int pick): def forin_assignment(objs, int pick):
""" """
>>> A = IntMockBuffer("A", range(6))
>>> B = IntMockBuffer("B", range(6))
>>> forin_assignment([A, B, A, A], 2) >>> forin_assignment([A, B, A, A], 2)
acquired A acquired A
2 2
...@@ -290,6 +291,7 @@ def forin_assignment(objs, int pick): ...@@ -290,6 +291,7 @@ def forin_assignment(objs, int pick):
@testcase @testcase
def cascaded_buffer_assignment(obj): def cascaded_buffer_assignment(obj):
""" """
>>> A = IntMockBuffer("A", range(6))
>>> cascaded_buffer_assignment(A) >>> cascaded_buffer_assignment(A)
acquired A acquired A
acquired A acquired A
...@@ -302,6 +304,8 @@ def cascaded_buffer_assignment(obj): ...@@ -302,6 +304,8 @@ def cascaded_buffer_assignment(obj):
@testcase @testcase
def tuple_buffer_assignment1(a, b): def tuple_buffer_assignment1(a, b):
""" """
>>> A = IntMockBuffer("A", range(6))
>>> B = IntMockBuffer("B", range(6))
>>> tuple_buffer_assignment1(A, B) >>> tuple_buffer_assignment1(A, B)
acquired A acquired A
acquired B acquired B
...@@ -314,6 +318,8 @@ def tuple_buffer_assignment1(a, b): ...@@ -314,6 +318,8 @@ def tuple_buffer_assignment1(a, b):
@testcase @testcase
def tuple_buffer_assignment2(tup): def tuple_buffer_assignment2(tup):
""" """
>>> A = IntMockBuffer("A", range(6))
>>> B = IntMockBuffer("B", range(6))
>>> tuple_buffer_assignment2((A, B)) >>> tuple_buffer_assignment2((A, B))
acquired A acquired A
acquired B acquired B
...@@ -384,6 +390,7 @@ def wrong_string(object[int] buf): ...@@ -384,6 +390,7 @@ def wrong_string(object[int] buf):
@testcase @testcase
def get_int_2d(object[int, ndim=2] buf, int i, int j): def get_int_2d(object[int, ndim=2] buf, int i, int j):
""" """
>>> C = IntMockBuffer("C", range(6), (2,3))
>>> get_int_2d(C, 1, 1) >>> get_int_2d(C, 1, 1)
acquired C acquired C
released C released C
...@@ -419,6 +426,7 @@ def get_int_2d(object[int, ndim=2] buf, int i, int j): ...@@ -419,6 +426,7 @@ def get_int_2d(object[int, ndim=2] buf, int i, int j):
def get_int_2d_uintindex(object[int, ndim=2] buf, unsigned int i, unsigned int j): def get_int_2d_uintindex(object[int, ndim=2] buf, unsigned int i, unsigned int j):
""" """
Unsigned indexing: Unsigned indexing:
>>> C = IntMockBuffer("C", range(6), (2,3))
>>> get_int_2d_uintindex(C, 0, 0) >>> get_int_2d_uintindex(C, 0, 0)
acquired C acquired C
released C released C
...@@ -438,6 +446,7 @@ def set_int_2d(object[int, ndim=2] buf, int i, int j, int value): ...@@ -438,6 +446,7 @@ def set_int_2d(object[int, ndim=2] buf, int i, int j, int value):
Uses get_int_2d to read back the value afterwards. For pure Uses get_int_2d to read back the value afterwards. For pure
unit test, one should support reading in MockBuffer instead. unit test, one should support reading in MockBuffer instead.
>>> C = IntMockBuffer("C", range(6), (2,3))
>>> set_int_2d(C, 1, 1, 10) >>> set_int_2d(C, 1, 1, 10)
acquired C acquired C
released C released C
......
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