Changeset 33 for trunk/airspeed_test.py

Show
Ignore:
Timestamp:
16/09/04 15:07:05 (8 years ago)
Author:
steve
Message:

interpolated strings

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/airspeed_test.py

    r32 r33  
    179179        self.assertEquals("1296", template.merge(locals())) 
    180180 
    181     def test_can_call_function_with_one_parameter(self): 
     181    def test_can_call_function_with_two_parameters(self): 
    182182        def multiply(number1, number2): 
    183183            return number1 * number2 
     
    398398        self.assertEquals(" $user.name ", template.merge({'user':MyObject()})) 
    399399 
     400    def test_variables_expanded_in_double_quoted_strings(self): 
     401        template = airspeed.Template('#set($hello="hello, $name is my name")$hello') 
     402        self.assertEquals("hello, Steve is my name", template.merge({'name':'Steve'})) 
     403 
     404    def test_escaped_variable_references_not_expanded_in_double_quoted_strings(self): 
     405        template = airspeed.Template('#set($hello="hello, \\$name is my name")$hello') 
     406        self.assertEquals("hello, $name is my name", template.merge({'name':'Steve'})) 
     407 
     408    def test_macros_expanded_in_double_quoted_strings(self): 
     409        template = airspeed.Template('#macro(hi $person)$person says hello#end#set($hello="#hi($name)")$hello') 
     410        self.assertEquals("Steve says hello", template.merge({'name':'Steve'})) 
     411 
    400412# 
    401413# TODO: 
    402414# 
     415#  Report locations for template errors in strings 
    403416#  Math expressions 
    404417#  Gobbling up whitespace (tricky!) 
     
    406419#  Bind #macro calls at compile time? 
    407420#  #stop ? 
    408 #  Interpolated strings -- what about \$ etc? 
    409 #  Directives inside string literals 
    410421#  map literals 
    411422#  Sub-object assignment:  #set( $customer.Behavior = $primate )