Changeset 187

Show
Ignore:
Timestamp:
12/30/06 23:43:14 (2 years ago)
Author:
akhavr
Message:

ticket:370:

  • implemented Repr, Num and Str
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pybeast/trunk/dtest/py2py.py

    r186 r187  
    361361        'Call with keyword and star and kw args' 
    362362        self.reformat_and_test('func(a, b = b, c = c, *args, **kw)') 
     363 
     364 
     365class Repr(Expr): 
     366    'Test repr' 
     367 
     368    def test_simple(self): 
     369        'Simple repr' 
     370        self.reformat_and_test('`obj`') 
     371 
     372 
     373class Constants(Expr): 
     374    'Test Num and Str nodes' 
     375 
     376    def test_long(self): 
     377        'Simple long' 
     378        self.reformat_and_test('1L') 
     379 
     380    def test_e(self): 
     381        '9.9999999999999993e+74 test' 
     382        self.reformat_and_test('9.9999999999999993e+74') 
     383 
     384    def test_simple_string(self): 
     385        'Test simple string' 
     386        self.reformat_and_test('a = \'string\'') 
     387 
     388    def test_unicode_string(self): 
     389        'Test unicode string' 
     390        self.reformat_and_test('a = u\'string\'') 
    363391         
    364392     
  • pybeast/trunk/src/py2py.py

    r186 r187  
    5757            return self.space_after_parens 
    5858 
    59         if len(code) and code[-1] in ('[', '(', ' ',): 
     59        if len(code) and code[-1] in ('[', '(', ' ', '`',): 
    6060            return False 
    6161         
     
    144144        self.code = self.code[:-1] 
    145145 
     146    def visit_backquote(self, node, walker): 
     147        'visit Backquote node' 
     148        self.code += '`' 
     149        walker.dispatch(node.expr) 
     150        self.code += '`' 
     151 
    146152    def visit_callfunc(self, node, walker): 
    147153        'visit CallFunc node' 
     
    188194        if self.style.need_space(self.expr_ops_stack, self.code): 
    189195            self.code += ' ' 
    190         self.code += str(node.value) 
     196        self.code += repr(node.value) 
    191197 
    192198    def visit_dict(self, node, walker):