ó
ŒwÛjc           @   sy   d  Z  d d l Z d d l Z d d l m Z d Z d „  Z d e j f d „  ƒ  YZ d „  Z	 e
 d	 k ru e	 ƒ  n  d S(
   s&   
Test the API of the symtable module.
iÿÿÿÿN(   t   test_supportsM  
import sys

glob = 42

class Mine:
    instance_var = 24
    def a_method(p1, p2):
        pass

def spam(a, b, *var, **kw):
    global bar
    bar = 47
    x = 23
    glob
    def internal():
        return x
    return internal

def foo():
    exec 'm'
    from sys import *

def namespace_test(): pass
def namespace_test(): pass
c         C   s1   x* |  j  ƒ  D] } | j ƒ  | k r | Sq Wd  S(   N(   t   get_childrent   get_name(   t   blockt   namet   ch(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt
   find_block&   s    t   SymtableTestc           B   s8  e  Z e j d  e f ƒ � e j e d d ƒ Z Wd QXe e d ƒ Z	 e e	 d ƒ Z
 e e d ƒ Z e e d ƒ Z e e d ƒ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! RS(   s&   import \* only allowed at module levelt   ?t   execNt   Minet   a_methodt   spamt   internalt   fooc         C   s�   |  j  |  j j ƒ  d ƒ |  j  |  j j ƒ  d ƒ |  j  |  j j ƒ  d ƒ |  j  |  j j ƒ  d ƒ |  j  |  j j ƒ  d ƒ d  S(   Nt   modulet   classt   function(   t   assertEqualt   topt   get_typeR
   R   R   R   (   t   self(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt	   test_type8   s
    c         C   sž   |  j  |  j j ƒ  ƒ |  j  |  j j ƒ  ƒ |  j  |  j j ƒ  ƒ |  j |  j j ƒ  ƒ |  j  |  j j ƒ  ƒ |  j |  j j ƒ  ƒ |  j |  j j ƒ  ƒ d  S(   N(   t   assertFalseR   t   is_optimizedt   has_exect   has_import_start
   assertTrueR   R   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_optimized?   s    c         C   s\   |  j  |  j j ƒ  ƒ |  j  |  j j ƒ  ƒ |  j  |  j j ƒ  ƒ |  j |  j j ƒ  ƒ d  S(   N(   R   R   t	   is_nestedR
   R   R   R   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_nestedJ   s    c         C   sF   |  j  |  j j ƒ  ƒ |  j  |  j j ƒ  ƒ |  j |  j j ƒ  ƒ d  S(   N(   R   R   t   has_childrenR
   R   R   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_childrenP   s    c         C   s6   |  j  |  j j ƒ  d ƒ |  j  |  j j ƒ  d ƒ d  S(   Ni    i   (   R   R   t
   get_linenoR   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_linenoU   s    c         C   s¤   |  j  } |  j t | j ƒ  ƒ d d d d g ƒ d d d d d d g } |  j t | j ƒ  ƒ | ƒ |  j t | j ƒ  ƒ d d g ƒ |  j |  j j ƒ  d	 ƒ d  S(
   Nt   at   bt   kwt   varR   t   xt   bart   glob(   R'   (   R   R   t   sortedt   get_parameterst
   get_localst   get_globalsR   t	   get_frees(   R   t   funct   expected(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_function_infoY   s    	("c         C   s¾   |  j  |  j j d ƒ j ƒ  ƒ |  j |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j |  j j d ƒ j ƒ  ƒ |  j |  j j d ƒ j ƒ  ƒ d  S(   NR)   R(   R'   t   instance_var(   R   R   t   lookupt	   is_globalR   t   is_declared_globalR   R
   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_globalsa   s    c         C   sB   |  j  |  j j d ƒ j ƒ  ƒ |  j |  j j d ƒ j ƒ  ƒ d  S(   NR'   (   R   R   R3   t   is_localR   R   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt
   test_locali   s    c         C   sa   |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j |  j j d ƒ j ƒ  ƒ d  S(   NR'   R   (   R   R   R3   t   is_referencedR   R   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_referencedm   s    c         C   sS   x- d D]% } |  j  |  j j | ƒ j ƒ  ƒ q W|  j |  j j d ƒ j ƒ  ƒ d  S(   NR#   R&   R%   R'   (   R#   R&   R%   (   R   R   R3   t   is_parameterR   (   R   t   sym(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_parametersr   s    #c         C   sK   |  j  t |  j j ƒ  ƒ t |  j j ƒ  ƒ ƒ |  j t |  j j d ƒ d  S(   Nt   not_here(   R   t   lenR   t   get_identifierst   get_symbolst   assertRaisest   KeyErrorR3   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_symbol_lookupw   s    c         C   s'  |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  |  j k ƒ |  j j d ƒ } |  j t	 | j
 ƒ  ƒ d ƒ |  j t | j ƒ d  S(   NR
   R   R   R   t   namespace_testR'   i   (   R   R   R3   t   is_namespaceR
   R   R   t   get_namespaceR   R?   t   get_namespacesRB   t
   ValueError(   R   t   ns_test(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_namespaces}   s    (c         C   sŸ   |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j  |  j j d ƒ j ƒ  ƒ |  j |  j j d ƒ j ƒ  ƒ d  S(   NR'   R(   R   R   (   R   R   R3   t   is_assignedR   R
   R   R   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_assignedŠ   s
    c         C   s#   |  j  |  j j d ƒ j ƒ  ƒ d  S(   Nt   sys(   R   R   R3   t   is_imported(   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_imported‘   s    c         C   sq   |  j  |  j j ƒ  d ƒ |  j  |  j j ƒ  d ƒ |  j  |  j j d ƒ j ƒ  d ƒ |  j  |  j j ƒ  d ƒ d  S(   NR   R   R'   R
   (   R   R   R   R   R3   R
   (   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt	   test_name”   s    "c         C   s   |  j  |  j j ƒ  d ƒ d  S(   NR   (   R   (   R   R
   t   get_methods(   R   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_class_infoš   s    c            s'   ‡  f d †  } | d ƒ | d ƒ d  S(   Nc            sX   y t  j  |  d d ƒ Wn& t k
 r? } ˆ  j | j d ƒ n Xˆ  j d |  f ƒ d  S(   NR   R	   s   no SyntaxError for %r(   t   symtablet   SyntaxErrorR   t   filenamet   fail(   t
   brokencodet   e(   R   (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   checkfilename    s
    s   def f(x): foo)(s   def f(x): global x(    (   R   RZ   (    (   R   sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_filename_correct�   s    
c         C   s   t  j  d d d ƒ } d  S(   Nt   42R   t   eval(   RT   (   R   t   symbols(    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt	   test_evalª   s    c         C   s   t  j  d d d ƒ } d  S(   NR\   R   t   single(   RT   (   R   R^   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   test_single­   s    c         C   s   t  j  d d d ƒ } d  S(   Ns   def f(x): return xR   R	   (   RT   (   R   R^   (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt	   test_exec°   s    ("   t   __name__t
   __module__R    t   check_warningst   SyntaxWarningRT   t	   TEST_CODER   R   R
   R   R   R   R   R   R   R   R    R"   R1   R6   R8   R:   R=   RD   RK   RM   RP   RQ   RS   R[   R_   Ra   Rb   (    (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyR   ,   s8   																			c           C   s   t  j t ƒ d  S(   N(   R    t   run_unittestR   (    (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt	   test_main´   s    t   __main__(   t   __doc__RT   t   unittestt   testR    Rg   R   t   TestCaseR   Ri   Rc   (    (    (    sˆ   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_symtable.pyt   <module>   s   	ˆ	