<s> import parser <EOL> import unittest <EOL> import sys <EOL> import struct <EOL> from test import test_support as support <EOL> from test . script_helper import assert_python_failure <EOL> class RoundtripLegalSyntaxTestCase ( unittest . TestCase ) : <EOL> def roundtrip ( self , f , s ) : <EOL> st1 = f ( s ) <EOL> t = st1 . totuple ( ) <EOL> try : <EOL> st2 = parser . sequence2st ( t ) <EOL> except parser . ParserError , why : <EOL> self . fail ( "<STR_LIT>" % ( s , why ) ) <EOL> self . assertEqual ( t , st2 . totuple ( ) , <EOL> "<STR_LIT>" ) <EOL> def check_expr ( self , s ) : <EOL> self . roundtrip ( parser . expr , s ) <EOL> def test_flags_passed ( self ) : <EOL> suite = parser . suite ( "<STR_LIT>" ) <EOL> code = suite . compile ( ) <EOL> scope = { } <EOL> exec code in scope <EOL> self . assertIsInstance ( scope [ "<STR_LIT:x>" ] , unicode ) <EOL> def check_suite ( self , s ) : <EOL> self . roundtrip ( parser . suite , s ) <EOL> def test_yield_statement ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_expressions ( self ) : <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> self . check_expr ( "<STR_LIT>" ) <EOL> def test_print ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_simple_expression ( self ) : <EOL> self . check_suite ( "<STR_LIT:a>" ) <EOL> def test_simple_assignments ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_simple_augmented_assignments ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_function_defs ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_class_defs ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_import_from_statement ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_basic_import_statement ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_relative_imports ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_pep263 ( self ) : <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_assert ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_with ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_try_stmt ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_except_clause ( self ) : <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> self . check_suite ( "<STR_LIT>" ) <EOL> def test_position ( self ) : <EOL> code = "<STR_LIT>" <EOL> st1 = parser . suite ( code ) <EOL> st2 = st1 . totuple ( line_info = <NUM_LIT:1> , col_info = <NUM_LIT:1> ) <EOL> def walk ( tree ) : <EOL> node_type = tree [ <NUM_LIT:0> ] <EOL> next = tree [ <NUM_LIT:1> ] <EOL> if isinstance ( next , tuple ) : <EOL> for elt in tree [ <NUM_LIT:1> : ] : <EOL> for x in walk ( elt ) : <EOL> yield x <EOL> else : <EOL> yield tree <EOL> terminals = list ( walk ( st2 ) ) <EOL> self . assertEqual ( [ <EOL> ( <NUM_LIT:1> , '<STR_LIT>' , <NUM_LIT:1> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT:f>' , <NUM_LIT:1> , <NUM_LIT:4> ) , <EOL> ( <NUM_LIT:7> , '<STR_LIT:(>' , <NUM_LIT:1> , <NUM_LIT:5> ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT:x>' , <NUM_LIT:1> , <NUM_LIT:6> ) , <EOL> ( <NUM_LIT:8> , '<STR_LIT:)>' , <NUM_LIT:1> , <NUM_LIT:7> ) , <EOL> ( <NUM_LIT:11> , '<STR_LIT::>' , <NUM_LIT:1> , <NUM_LIT:8> ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' , <NUM_LIT:1> , <NUM_LIT:9> ) , <EOL> ( <NUM_LIT:5> , '<STR_LIT>' , <NUM_LIT:2> , - <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' , <NUM_LIT:2> , <NUM_LIT:4> ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT:x>' , <NUM_LIT:2> , <NUM_LIT:11> ) , <EOL> ( <NUM_LIT> , '<STR_LIT:+>' , <NUM_LIT:2> , <NUM_LIT> ) , <EOL> ( <NUM_LIT:2> , '<STR_LIT:1>' , <NUM_LIT:2> , <NUM_LIT:15> ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' , <NUM_LIT:2> , <NUM_LIT:16> ) , <EOL> ( <NUM_LIT:6> , '<STR_LIT>' , <NUM_LIT:2> , - <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' , <NUM_LIT:2> , - <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:0> , '<STR_LIT>' , <NUM_LIT:2> , - <NUM_LIT:1> ) ] , <EOL> terminals ) <EOL> class IllegalSyntaxTestCase ( unittest . TestCase ) : <EOL> def check_bad_tree ( self , tree , label ) : <EOL> try : <EOL> parser . sequence2st ( tree ) <EOL> except parser . ParserError : <EOL> pass <EOL> else : <EOL> self . fail ( "<STR_LIT>" % label ) <EOL> def test_junk ( self ) : <EOL> self . check_bad_tree ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , "<STR_LIT>" ) <EOL> def test_illegal_yield_1 ( self ) : <EOL> tree = ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT:f>' ) , <EOL> ( <NUM_LIT> , ( <NUM_LIT:7> , '<STR_LIT:(>' ) , ( <NUM_LIT:8> , '<STR_LIT:)>' ) ) , <EOL> ( <NUM_LIT:11> , '<STR_LIT::>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:5> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:2> , '<STR_LIT:1>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:2> , '<STR_LIT:1>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) ) ) , <EOL> ( <NUM_LIT:6> , '<STR_LIT>' ) ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:0> , '<STR_LIT>' ) ) ) ) <EOL> self . check_bad_tree ( tree , "<STR_LIT>" ) <EOL> def test_illegal_yield_2 ( self ) : <EOL> tree = ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT>' ) ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT>' ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) ) ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT:f>' ) , <EOL> ( <NUM_LIT> , ( <NUM_LIT:7> , '<STR_LIT:(>' ) , ( <NUM_LIT:8> , '<STR_LIT:)>' ) ) , <EOL> ( <NUM_LIT:11> , '<STR_LIT::>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:5> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:2> , '<STR_LIT:1>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:2> , '<STR_LIT:1>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) ) ) , <EOL> ( <NUM_LIT:6> , '<STR_LIT>' ) ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:0> , '<STR_LIT>' ) ) ) ) <EOL> self . check_bad_tree ( tree , "<STR_LIT>" ) <EOL> def test_print_chevron_comma ( self ) : <EOL> tree = ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT:12> , '<STR_LIT:U+002C>' ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) ) ) , <EOL> ( <NUM_LIT:0> , '<STR_LIT>' ) ) <EOL> self . check_bad_tree ( tree , "<STR_LIT>" ) <EOL> def test_a_comma_comma_c ( self ) : <EOL> tree = ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT:a>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT:12> , '<STR_LIT:U+002C>' ) , <EOL> ( <NUM_LIT:12> , '<STR_LIT:U+002C>' ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT:c>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:0> , '<STR_LIT>' ) ) <EOL> self . check_bad_tree ( tree , "<STR_LIT>" ) <EOL> def test_illegal_operator ( self ) : <EOL> tree = ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT:a>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , '<STR_LIT>' ) ) , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT:b>' ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) ) ) , <EOL> ( <NUM_LIT:0> , '<STR_LIT>' ) ) <EOL> self . check_bad_tree ( tree , "<STR_LIT>" ) <EOL> def test_malformed_global ( self ) : <EOL> tree = ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT:foo>' ) ) ) , ( <NUM_LIT:4> , '<STR_LIT>' ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:0> , '<STR_LIT>' ) ) <EOL> self . check_bad_tree ( tree , "<STR_LIT>" ) <EOL> def test_missing_import_source ( self ) : <EOL> tree = ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , <EOL> ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT>' ) , ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT> , ( <NUM_LIT> , ( <NUM_LIT:1> , '<STR_LIT>' ) ) ) ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) ) ) , <EOL> ( <NUM_LIT:4> , '<STR_LIT>' ) , ( <NUM_LIT:0> , '<STR_LIT>' ) ) <EOL> self . check_bad_tree ( tree , "<STR_LIT>" ) <EOL> class CompileTestCase ( unittest . TestCase ) : <EOL> def test_compile_expr ( self ) : <EOL> st = parser . expr ( '<STR_LIT>' ) <EOL> code = parser . compilest ( st ) <EOL> self . assertEqual ( eval ( code ) , <NUM_LIT:5> ) <EOL> def test_compile_suite ( self ) : <EOL> st = parser . suite ( '<STR_LIT>' ) <EOL> code = parser . compilest ( st ) <EOL> globs = { } <EOL> exec code in globs <EOL> self . assertEqual ( globs [ '<STR_LIT:y>' ] , <NUM_LIT:5> ) <EOL> def test_compile_error ( self ) : <EOL> st = parser . suite ( '<STR_LIT>' ) <EOL> self . assertRaises ( SyntaxError , parser . compilest , st ) <EOL> def test_compile_badunicode ( self ) : <EOL> st = parser . suite ( '<STR_LIT>' ) <EOL> self . assertRaises ( SyntaxError , parser . compilest , st ) <EOL> st = parser . suite ( '<STR_LIT>' ) <EOL> self . assertRaises ( SyntaxError , parser . compilest , st ) <EOL> def test_issue_9011 ( self ) : <EOL> st = parser . expr ( '<STR_LIT>' ) <EOL> code1 = parser . compilest ( st ) <EOL> self . assertEqual ( eval ( code1 ) , - <NUM_LIT:3> ) <EOL> code2 = parser . compilest ( st ) <EOL> self . assertEqual ( eval ( code2 ) , - <NUM_LIT:3> ) <EOL> class ParserStackLimitTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def _nested_expression ( self , level ) : <EOL> return "<STR_LIT:[>" * level + "<STR_LIT:]>" * level <EOL> def test_deeply_nested_list ( self ) : <EOL> e = self . _nested_expression ( <NUM_LIT> ) <EOL> st = parser . expr ( e ) <EOL> st . compile ( ) <EOL> def test_trigger_memory_error ( self ) : <EOL> e = self . _nested_expression ( <NUM_LIT:100> ) <EOL> rc , out , err = assert_python_failure ( '<STR_LIT:-c>' , e ) <EOL> self . assertIn ( b'<STR_LIT>' , err ) <EOL> self . assertIn ( b'<STR_LIT>' , err ) <EOL> class STObjectTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> check_sizeof = support . check_sizeof <EOL> @ support . cpython_only <EOL> def test_sizeof ( self ) : <EOL> def XXXROUNDUP ( n ) : <EOL> if n <= <NUM_LIT:1> : <EOL> return n <EOL> if n <= <NUM_LIT> : <EOL> return ( n + <NUM_LIT:3> ) & ~ <NUM_LIT:3> <EOL> return <NUM_LIT:1> << ( n - <NUM_LIT:1> ) . bit_length ( ) <EOL> basesize = support . calcobjsize ( '<STR_LIT>' ) <EOL> nodesize = struct . calcsize ( '<STR_LIT>' ) <EOL> def sizeofchildren ( node ) : <EOL> if node is None : <EOL> return <NUM_LIT:0> <EOL> res = <NUM_LIT:0> <EOL> hasstr = len ( node ) > <NUM_LIT:1> and isinstance ( node [ - <NUM_LIT:1> ] , str ) <EOL> if hasstr : <EOL> res += len ( node [ - <NUM_LIT:1> ] ) + <NUM_LIT:1> <EOL> children = node [ <NUM_LIT:1> : - <NUM_LIT:1> ] if hasstr else node [ <NUM_LIT:1> : ] <EOL> if children : <EOL> res += XXXROUNDUP ( len ( children ) ) * nodesize <EOL> for child in children : <EOL> res += sizeofchildren ( child ) <EOL> return res <EOL> def check_st_sizeof ( st ) : <EOL> self . check_sizeof ( st , basesize + nodesize + <EOL> sizeofchildren ( st . totuple ( ) ) ) <EOL> check_st_sizeof ( parser . expr ( '<STR_LIT>' ) ) <EOL> check_st_sizeof ( parser . expr ( '<STR_LIT>' ) ) <EOL> check_st_sizeof ( parser . suite ( '<STR_LIT>' ) ) <EOL> check_st_sizeof ( parser . suite ( '<STR_LIT>' ) ) <EOL> check_st_sizeof ( parser . suite ( '<STR_LIT>' ) ) <EOL> check_st_sizeof ( parser . expr ( '<STR_LIT:[>' + '<STR_LIT>' * <NUM_LIT:1000> + '<STR_LIT:]>' ) ) <EOL> def test_main ( ) : <EOL> support . run_unittest ( <EOL> RoundtripLegalSyntaxTestCase , <EOL> IllegalSyntaxTestCase , <EOL> CompileTestCase , <EOL> ParserStackLimitTestCase , <EOL> STObjectTestCase , <EOL> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
