ó
¦V]c           @   s•   d  d l  m Z d  d l j j Z d  d l Td  d l Td  d l Td e f d „  ƒ  YZ d e f d „  ƒ  YZ	 e
 d k r‘ d  d l Z e j ƒ  n  d S(	   iÿÿÿÿ(   t
   CythonTestN(   t   *t   TestBufferParsingc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c            s   ˆ j  ‡  ‡ f d †  ƒ j S(   Nc              s   ˆ j  ˆ  ƒ S(   N(   t   fragment(    (   t   st   self(    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   <lambda>   t    (   t   should_not_failt   root(   R   R   (    (   R   R   s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   parse   s    c            s8   ˆ j  ‡  ‡ f d †  t j ƒ } ˆ j | | j ƒ d  S(   Nc              s   ˆ j  ˆ  ƒ S(   N(   R   (    (   R   R   (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyR      R   (   t   should_failt   Errorst   CompileErrort   assertEqualt   message_only(   R   t   expected_errorR   t   e(    (   R   R   s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   not_parseable   s    !c         C   sR   |  j  d ƒ } | j d j } |  j t | t ƒ ƒ |  j d t | j ƒ ƒ d  S(   Nu(   cdef object[float, 4, ndim=2, foo=foo] xi    i   (	   R
   t   statst	   base_typet   assert_t
   isinstancet   TemplatedTypeNodeR   t   lent   positional_args(   R   t   tt   bufnode(    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt
   test_basic   s    c         C   s   |  j  d ƒ d  S(   Nu$   cdef object[short unsigned int, 3] x(   R
   (   R   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   test_type_pos   s    c         C   s   |  j  d ƒ d  S(   Nu0   cdef object[foo=foo, dtype=short unsigned int] x(   R
   (   R   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   test_type_keyword    s    c         C   s   |  j  d d ƒ d  S(   Ns%   Non-keyword arg following keyword argu   cdef object[foo=1, 2] x(   R   (   R   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   test_pos_after_key#   s    	(   t   __name__t
   __module__R
   R   R   R   R   R   (    (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyR      s   					t   TestBufferOptionsc           B   sJ   e  Z d  „  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   s   | |  _  |  j |  j ƒ d  S(   N(   t   errorR   t   expect_error(   R   R#   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   nonfatal_error.   s    	c         C   sý   | d k s t  ‚ d | } | |  _ |  j | d t |  ƒ t |  ƒ g ƒj } | sÓ | j d j j d } t | t	 ƒ s t  ‚ | j
 } |  j t | t ƒ ƒ |  j t | j t ƒ ƒ |  j d | j j ƒ | S|  j t | j d j j ƒ d k ƒ d  S(   NR   u   def f():
  cdef object[%s] xt   pipelinei    u   object(   t   AssertionErrorR$   R   t   NormalizeTreet	   PostParseR	   R   t   bodyR   t   CVarDefNodeR   R   R   t   base_type_nodet   CSimpleBaseTypeNodeR   t   nameR   (   R   t   optsR$   R   R	   t   vardeft   buftype(    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt
   parse_opts3   s    
	*	c         C   s-   |  j  | d t ƒ|  j | |  j j ƒ d  S(   NR$   (   R2   t   TrueR   R#   R   (   R   t   expected_errR/   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt	   non_parseC   s    c         C   sj   |  j  d ƒ } |  j t | j t ƒ ƒ |  j | j j d k oO | j j d k ƒ |  j d | j ƒ d  S(   Nu   unsigned short int, 3i    iÿÿÿÿi   (	   R2   R   R   t
   dtype_nodeR-   t   signedt   longnessR   t   ndim(   R   t   buf(    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   __test_basicH   s    +c         C   sj   |  j  d ƒ } |  j t | j t ƒ ƒ |  j | j j d k oO | j j d k ƒ |  j d | j ƒ d  S(   Nu    ndim=3, dtype=unsigned short inti    iÿÿÿÿi   (	   R2   R   R   R6   R-   R7   R8   R   R9   (   R   R:   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   __test_dictN   s    +c         C   s1   |  j  d ƒ |  j t d ƒ |  j t d ƒ d  S(   Nu   int, 2u   int, 'a'u   int, -34(   R2   R5   t   ERR_BUF_NDIM(   R   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   __test_ndimT   s    c         C   s{   |  j  d d t |  ƒ t |  ƒ g ƒj } | j d j j } |  j | d j j d k ƒ |  j | d j j d k ƒ d  S(   Nu„   
        DEF ndim = 3
        def f():
            cdef object[int, ndim] x
            cdef object[ndim=ndim, dtype=int] y
        R&   i    i   i   (	   R   R(   R)   R	   R   R*   R   R   R9   (   R   R   R   (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   __test_use_DEFY   s
    $(
   R    R!   R%   t   FalseR2   R5   t   _TestBufferOptions__test_basict   _TestBufferOptions__test_dictt   _TestBufferOptions__test_ndimt    _TestBufferOptions__test_use_DEF(    (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyR"   +   s   					t   __main__(   t   Cython.TestUtilsR    t   Cython.Compiler.Errorst   CompilerR   t   Cython.Compiler.Nodest#   Cython.Compiler.ParseTreeTransformst   Cython.Compiler.BufferR   R"   R    t   unittestt   main(    (    (    s?   lib/python2.7/site-packages/Cython/Compiler/Tests/TestBuffer.pyt   <module>   s   


#;