Changeset 6375


Ignore:
Timestamp:
02/16/10 20:14:58 (2 years ago)
Author:
MichaelTempest
Message:

Item8422: Update the unit tests to correspond to the change in how newlines before here-document values are handled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UnitTestContrib/test/unit/ExpandMacrosTests.pm

    r6315 r6375  
    153153HERE 
    154154        {_RAW=>$dontCare, cheese=>'blue', say=>'bye!' }); 
    155     $this->assert_str_equals("1$macroWasHere Not part of the macro\nNor this either\n", $result); 
     155    $this->assert_str_equals("1$macroWasHere Not part of the macroNor this either\n", $result); 
    156156} 
    157157 
     
    166166                                    . " Nor this either\n", 
    167167                                    {_RAW=>$dontCare, cheese=>'blue', say=>' bye! ' }); 
    168     $this->assert_str_equals("1$macroWasHere Not part of the macro \n Nor this either\n", $result); 
     168    $this->assert_str_equals("1$macroWasHere Not part of the macro Nor this either\n", $result); 
    169169} 
    170170 
     
    175175before macro %MACRO{value=<<_10}% after macro 
    176176_10%_ 
     177 _10 
     178_10 more 
     179less _10 
    177180_10 
     181 
    178182after end marker 
    179183HERE 
    180         {_RAW=>$dontCare, value=>'_10%_' }); 
     184        {_RAW=>$dontCare, value=>"_10%_\n _10\n_10 more\nless _10" }); 
    181185    $this->assert_str_equals("before macro 1$macroWasHere after macro\nafter end marker\n", $result); 
    182186} 
     
    190194ping 
    191195HERE 
    192 baz 
     196bar 
    193197END 
    194198        {_RAW=>$dontCare, _DEFAULT=>"ping" }); 
    195     $this->assert_str_equals("wurble1${macroWasHere}blegh $expandedWikiName foo\nbaz\n", $result); 
     199    $this->assert_str_equals("wurble1${macroWasHere}blegh $expandedWikiName foobar\n", $result); 
    196200} 
    197201 
     
    217221HERE 
    218222END 
    219     $this->assert_str_equals("One Hump,Two Eyes,Three Teeth\n", $result); 
     223    $this->assert_str_equals("One Hump,Two Eyes,Three Teeth", $result); 
    220224} 
    221225 
     
    230234ENCODE 
    231235END 
    232     $this->assert_str_equals("%25topic,%25topic,%25topic\n", $result); 
     236    $this->assert_str_equals("%25topic,%25topic,%25topic", $result); 
    233237} 
    234238 
     
    249253        {_RAW=>$dontCare, _DEFAULT=>'orange', which=>'three'} 
    250254    ); 
     255    $this->assert_str_equals("1$macroWasHere\\,2$macroWasHere\\,3$macroWasHere\\", $result); 
     256} 
     257 
     258sub test_nestedHereDocOrderOfEvaluationOuterFirstWithNewline { 
     259    my $this = shift; 
     260 
     261    # Tests the case where inner macros are expanded after outer macro 
     262    my $result = $this->_testExpand(<<'END',  
     263%FOREACH{"one,two,three" format=<<HERE separator=","}% 
     264%MACRO{<<PURPLE which="$topic"}%\ 
     265orange 
     266PURPLE 
     267 
     268 
     269HERE 
     270 
     271END 
     272        {_RAW=>$dontCare, _DEFAULT=>'orange', which=>'one'}, 
     273        {_RAW=>$dontCare, _DEFAULT=>'orange', which=>'two'}, 
     274        {_RAW=>$dontCare, _DEFAULT=>'orange', which=>'three'} 
     275    ); 
    251276    $this->assert_str_equals("1$macroWasHere\\\n,2$macroWasHere\\\n,3$macroWasHere\\\n\n", $result); 
    252277} 
     
    263288HERE 
    264289END 
    265     $this->assert_str_equals("1$macroWasHere,1$macroWasHere,1$macroWasHere\n", $result); 
     290    $this->assert_str_equals("1$macroWasHere,1$macroWasHere,1$macroWasHere", $result); 
    266291} 
    267292 
     
    281306 
    282307    $result = $this->_expand("%BAR{ foo=<<HERE }%twibble\nignored\nHERE\nspoon"); 
    283     $this->assert_str_equals("bartwibble\nspoon", $result); 
     308    $this->assert_str_equals("bartwibblespoon", $result); 
    284309 
    285310} 
     
    291316    my $result = $this->_expand('%MACRO{"bar"}%'); 
    292317    $this->assert_str_equals('foo', $result); 
     318 
     319} 
     320 
     321sub test_newlines { 
     322    my $this = shift; 
     323    my $result = $this->_testExpand('a%MACRO%b', 
     324        {_RAW=>$dontCare} 
     325    ); 
     326    $this->assert_str_equals("a1${macroWasHere}b", $result); 
     327 
     328    $result = $this->_testExpand("a%MACRO%b\n", 
     329        {_RAW=>$dontCare} 
     330    ); 
     331    $this->assert_str_equals("a1${macroWasHere}b\n", $result); 
     332 
     333    $result = $this->_testExpand("a%MACRO{<<HERE}%b\nHERE", 
     334        {_RAW=>$dontCare, _DEFAULT=>""} 
     335    ); 
     336    $this->assert_str_equals("a1${macroWasHere}b", $result); 
     337 
     338    $result = $this->_testExpand("a%MACRO{<<HERE}%b\nHERE\n", 
     339        {_RAW=>$dontCare, _DEFAULT=>""} 
     340    ); 
     341    $this->assert_str_equals("a1${macroWasHere}b", $result); 
     342 
     343    $result = $this->_testExpand("a%MACRO{<<HERE}%b\nHERE\n\n", 
     344        {_RAW=>$dontCare, _DEFAULT=>""} 
     345    ); 
     346    $this->assert_str_equals("a1${macroWasHere}b\n", $result); 
     347 
     348    $result = $this->_testExpand("a%MACRO{<<HERE}%b\n\nHERE", 
     349        {_RAW=>$dontCare, _DEFAULT=>""} 
     350    ); 
     351    $this->assert_str_equals("a1${macroWasHere}b", $result); 
     352 
     353    $result = $this->_testExpand("a%MACRO{<<HERE}%b\n\nHERE\n", 
     354        {_RAW=>$dontCare, _DEFAULT=>""} 
     355    ); 
     356    $this->assert_str_equals("a1${macroWasHere}b", $result); 
     357 
     358    $result = $this->_testExpand("a%MACRO{<<HERE}%b\n\nHERE\n\n", 
     359        {_RAW=>$dontCare, _DEFAULT=>""} 
     360    ); 
     361    $this->assert_str_equals("a1${macroWasHere}b\n", $result); 
     362 
     363    $result = $this->_testExpand("a%MACRO{<<HERE}%b\n\n\nHERE", 
     364        {_RAW=>$dontCare, _DEFAULT=>"\n"} 
     365    ); 
     366    $this->assert_str_equals("a1${macroWasHere}b", $result); 
     367 
     368    $result = $this->_testExpand("a%MACRO{<<HERE}%b\n\n\nHERE\n", 
     369        {_RAW=>$dontCare, _DEFAULT=>"\n"} 
     370    ); 
     371    $this->assert_str_equals("a1${macroWasHere}b", $result); 
     372 
     373    $result = $this->_testExpand("a%MACRO{<<HERE}%b\n\n\nHERE\n\n", 
     374        {_RAW=>$dontCare, _DEFAULT=>"\n"} 
     375    ); 
     376    $this->assert_str_equals("a1${macroWasHere}b\n", $result); 
    293377 
    294378} 
Note: See TracChangeset for help on using the changeset viewer.