diff options
author | Anton Samokhvalov <[email protected]> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) |
Restoring authorship annotation for Anton Samokhvalov <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py')
-rw-r--r-- | contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py b/contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py index 15785f418d4..3792f26e994 100644 --- a/contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py +++ b/contrib/tools/cython/Cython/Compiler/Tests/TestMemView.py @@ -1,71 +1,71 @@ -from Cython.TestUtils import CythonTest -import Cython.Compiler.Errors as Errors -from Cython.Compiler.Nodes import * -from Cython.Compiler.ParseTreeTransforms import * -from Cython.Compiler.Buffer import * - - -class TestMemviewParsing(CythonTest): - - def parse(self, s): - return self.should_not_fail(lambda: self.fragment(s)).root - - def not_parseable(self, expected_error, s): - e = self.should_fail(lambda: self.fragment(s), Errors.CompileError) - self.assertEqual(expected_error, e.message_only) - - def test_default_1dim(self): - self.parse(u"cdef int[:] x") - self.parse(u"cdef short int[:] x") - - def test_default_ndim(self): - self.parse(u"cdef int[:,:,:,:,:] x") - self.parse(u"cdef unsigned long int[:,:,:,:,:] x") - self.parse(u"cdef unsigned int[:,:,:,:,:] x") - - def test_zero_offset(self): - self.parse(u"cdef long double[0:] x") - self.parse(u"cdef int[0:] x") - - def test_zero_offset_ndim(self): - self.parse(u"cdef int[0:,0:,0:,0:] x") - - def test_def_arg(self): - self.parse(u"def foo(int[:,:] x): pass") - - def test_cdef_arg(self): - self.parse(u"cdef foo(int[:,:] x): pass") - - def test_general_slice(self): - self.parse(u'cdef float[::ptr, ::direct & contig, 0::full & strided] x') - - def test_non_slice_memview(self): - self.not_parseable(u"An axis specification in memoryview declaration does not have a ':'.", - u"cdef double[:foo, bar] x") - self.not_parseable(u"An axis specification in memoryview declaration does not have a ':'.", - u"cdef double[0:foo, bar] x") - - def test_basic(self): - t = self.parse(u"cdef int[:] x") - memv_node = t.stats[0].base_type +from Cython.TestUtils import CythonTest +import Cython.Compiler.Errors as Errors +from Cython.Compiler.Nodes import * +from Cython.Compiler.ParseTreeTransforms import * +from Cython.Compiler.Buffer import * + + +class TestMemviewParsing(CythonTest): + + def parse(self, s): + return self.should_not_fail(lambda: self.fragment(s)).root + + def not_parseable(self, expected_error, s): + e = self.should_fail(lambda: self.fragment(s), Errors.CompileError) + self.assertEqual(expected_error, e.message_only) + + def test_default_1dim(self): + self.parse(u"cdef int[:] x") + self.parse(u"cdef short int[:] x") + + def test_default_ndim(self): + self.parse(u"cdef int[:,:,:,:,:] x") + self.parse(u"cdef unsigned long int[:,:,:,:,:] x") + self.parse(u"cdef unsigned int[:,:,:,:,:] x") + + def test_zero_offset(self): + self.parse(u"cdef long double[0:] x") + self.parse(u"cdef int[0:] x") + + def test_zero_offset_ndim(self): + self.parse(u"cdef int[0:,0:,0:,0:] x") + + def test_def_arg(self): + self.parse(u"def foo(int[:,:] x): pass") + + def test_cdef_arg(self): + self.parse(u"cdef foo(int[:,:] x): pass") + + def test_general_slice(self): + self.parse(u'cdef float[::ptr, ::direct & contig, 0::full & strided] x') + + def test_non_slice_memview(self): + self.not_parseable(u"An axis specification in memoryview declaration does not have a ':'.", + u"cdef double[:foo, bar] x") + self.not_parseable(u"An axis specification in memoryview declaration does not have a ':'.", + u"cdef double[0:foo, bar] x") + + def test_basic(self): + t = self.parse(u"cdef int[:] x") + memv_node = t.stats[0].base_type self.assertTrue(isinstance(memv_node, MemoryViewSliceTypeNode)) - - # we also test other similar declarations (buffers, anonymous C arrays) - # since the parsing has to distinguish between them. - - def disable_test_no_buf_arg(self): # TODO - self.not_parseable(u"Expected ']'", - u"cdef extern foo(object[int, ndim=2])") - - def disable_test_parse_sizeof(self): # TODO - self.parse(u"sizeof(int[NN])") - self.parse(u"sizeof(int[])") - self.parse(u"sizeof(int[][NN])") - self.not_parseable(u"Expected an identifier or literal", - u"sizeof(int[:NN])") - self.not_parseable(u"Expected ']'", - u"sizeof(foo[dtype=bar]") - -if __name__ == '__main__': - import unittest - unittest.main() + + # we also test other similar declarations (buffers, anonymous C arrays) + # since the parsing has to distinguish between them. + + def disable_test_no_buf_arg(self): # TODO + self.not_parseable(u"Expected ']'", + u"cdef extern foo(object[int, ndim=2])") + + def disable_test_parse_sizeof(self): # TODO + self.parse(u"sizeof(int[NN])") + self.parse(u"sizeof(int[])") + self.parse(u"sizeof(int[][NN])") + self.not_parseable(u"Expected an identifier or literal", + u"sizeof(int[:NN])") + self.not_parseable(u"Expected ']'", + u"sizeof(foo[dtype=bar]") + +if __name__ == '__main__': + import unittest + unittest.main() |