Changeset 1345:b24305dd9edb


Ignore:
Timestamp:
09/09/09 11:01:08 (2 years ago)
Author:
niam
Branch:
default
Message:

updated tests

Location:
trunk/tests
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/cgi_test/index.tpl

    r1110 r1345  
    1 index.tpl 
    2  
    3 <(> 
     1<(if $main)> 
    42        <(include $main)> 
    5  
    6         <(print "a=", $a, " b=", $b)> 
    7  
    8         <(if $a!=$b)> 
    9                 a != b 
    10         <(else)> 
    11                 a == b 
    12         <(fi)> 
    13 <)> 
    14  
    15 <(include $main)> 
     3<(else)> 
     4        <(include "index.tpl")> 
     5<(fi)> 
    166 
    177<(print "a=", $a, " b=", $b)> 
  • trunk/tests/cgi_test/menu.tpl

    r1110 r1345  
    1 menu.tpl 
    2  
    3 test recursion includes 
    4 <(> 
    5         <(include index.tpl)> 
    6         <(include test.tpl)> 
    7 <)> 
     1<(* test recursion includes *)> 
    82 
    93<(include index.tpl)> 
  • trunk/tests/cgi_test/test.cc

    r1312 r1345  
    7575        d.HEADERS[cgi::RESPONSE_HEADER_CONTENTTYPE] = "text/html"; 
    7676 
    77         d.setCookie(cookie("test", "Ni@m")); 
     77        d.setCookie(cookie("test", "cookie")); 
    7878 
    7979        exchange *io = d; 
  • trunk/tests/cgi_test/test.tpl

    r1110 r1345  
    1212 
    1313<pre> 
    14  
    1514        <(* test template *)> 
    1615 
     
    1817        <(assign b = 2)> 
    1918 
    20         included menu.tpl: <(include "menu.tpl")> 
     19        <(include "menu.tpl")> 
    2120 
    2221        <(assign b = $a)> 
    2322 
    24         included $main <(include $main)> 
    25  
    26         ********** 
     23        <(include $main)> 
    2724 
    2825        <(> <( not )> parsed area <)> 
    2926 
    30         ********** 
     27        <(print "test=", $test)> 
    3128 
    32         simple 'if' statement 
    33  
    34         <(> 
    35                 <(print $test)> 
    36                 <(if $test!=test )> 
    37                         equal 
    38                 <(else)> 
    39                         not equal 
    40                 <(fi)> 
    41         <)> 
    42  
    43         <(print $test)> 
    4429        <(if $test!=test )> 
    45                 equal 
     30                $test != 'test' 
    4631        <(else)> 
    47                 not equal 
     32                $test == 'test' 
    4833        <(fi)> 
    49  
    50         ********** 
    51  
    52         nested 'if' statements 
    53  
    54         <(> 
    55                 <(if $test )> 
    56                         $test 
    57                         <(if $test==test )> 
    58                                 test 
    59                         <(fi)> 
    60                         <(if $test!=test )> 
    61                                 !test 
    62                         <(fi)>   
    63                          
    64                         <(if $test )> 
    65                                 test 
    66                                 <(if $test==test )> 
    67                                         <(print $test)> 
    68                                 <(else)> 
    69                                         NULL 
    70                                 <(fi)> 
    71                         <(else)>         
    72                                 <(if $test!=test )> 
    73                                         !test 
    74                                 <(fi)>   
    75                                 <(if false )> 
    76                                         WTF? 
    77                                 <(fi)> 
    78                         <(fi)>   
    79                          
    80                         <(if 3>2 )> 
    81                                 3>2 
    82                         <(fi)> 
    83  
    84                         <(if 3<2 )> 
    85                                 WTF? 
    86                         <(fi)> 
    87                          
    88                         <( 
    89                                 if 
    90                                 ! `false` 
    91                         )> 
    92                                 !false 
    93                         <(fi)> 
    94                          
    95                         <(if!false)>!false<(fi)> 
    96                          
    97                         <(if ! 'false' )> 
    98                                 !'false' 
    99                         <(fi)>           
    100                         <(if ! "false" )> 
    101                                 ! "false" 
    102                         <(fi)>   
    103                 <(fi)> 
    104         <)> 
    10534 
    10635        <(if $test )> 
    10736                $test 
    10837                <(if $test==test )> 
    109                         test 
     38                        $test == 'test' 
    11039                <(fi)> 
    11140                <(if $test!=test )> 
    112                         !test 
    113                 <(fi)>   
    114                  
     41                        $test != 'test' 
     42                <(fi)> 
     43 
    11544                <(if $test )> 
    11645                        test 
    11746                        <(if $test==test )> 
    118                                 <(print $test)> 
     47                                $test == 'test' 
    11948                        <(else)> 
    120                                 NULL 
     49                                $test != 'test' 
    12150                        <(fi)> 
    122                 <(else)>         
     51                <(else)> 
    12352                        <(if $test!=test )> 
    124                                 !test 
    125                         <(fi)>   
     53                                $test != 'test' 
     54                        <(fi)> 
    12655                        <(if false )> 
    12756                                WTF? 
    12857                        <(fi)> 
    129                 <(fi)>   
    130                  
     58                <(fi)> 
     59 
    13160                <(if 3>2 )> 
    13261                        3>2 
     
    13665                        WTF? 
    13766                <(fi)> 
    138                  
     67 
    13968                <( 
    14069                        if 
     
    14372                        !false 
    14473                <(fi)> 
    145                  
     74 
    14675                <(if!false)>!false<(fi)> 
    147                  
     76 
    14877                <(if ! 'false' )> 
    14978                        !'false' 
    150                 <(fi)>           
     79                <(fi)> 
    15180                <(if ! "false" )> 
    15281                        ! "false" 
    153                 <(fi)>   
     82                <(fi)> 
    15483        <(fi)> 
    155  
    156         ********** 
    157  
    158         simple 'for' statement 
    159          
    160         <(> 
    161                 <(for $i in $strarr)> 
    162                         <(for $j in $i)><(print $j)><(rof)> 
    163                 <(rof)> 
    164  
    165                 <(for $b in $strmaparr)> 
    166                         <(for $c in $b)> 
    167                                 |<(print $c)>|<(print $b.one)> 
    168                         <(rof)> 
    169                 <(rof)> 
    170  
    171                 <(for $c in $strmaparr.1)> 
    172                         |<(print $c)> 
    173                 <(rof)> 
    174         <)> 
    17584 
    17685        <(for $i in $strarr)> 
     
    18897        <(rof)> 
    18998 
    190         ********** 
    191  
    192         namespace 
    193  
    194         <(> 
    195                 <(for $i in $strmaparr)> 
    196                         <(for $i in $i)> <(* HERE : '$i in $i' is OK because of the namespace scope *)> 
    197                                 |<(print $i)> 
    198                                 <(print $dodo.iterator)> 
    199                         <(rof)> 
    200                         |<(print $i.one)> 
    201                         <(print $dodo.iterator)> 
    202                 <(rof)> 
    203          
    204                 <(assign a = test1)> 
    205  
    206                 <(if true )>     
    207                         <(assign a = test2)> 
    208  
    209                         <(for $i in $strmaparr)> 
    210                                 <(for $i => $j in $i)> 
    211                                         <(if $i == three)> 
    212                                                 <(break 3)> 
    213                                         <(fi)> 
    214                                         <(print $i)> - <(print $j)> 
    215                                          
    216                                         <(assign a = test3)> 
    217                                         <(print $a," must be test3")> 
    218                                 <(rof)> 
    219                                 ------- 
    220                         <(rof)>  
    221                         <(print $a," must be test2")> 
    222                 <(fi)> 
    223                 <(print $a," must be test1")> 
    224                  
    225                 <(ns)> 
    226                                 <(ns)> 
    227                                         <(assign a = in namespace)> 
    228                                         <(print $a," must be `in namespace`")> 
    229                                 <(sn)> 
    230                         <(print $a," must be test1")> 
    231                 <(sn)> 
    232         <)> 
    233  
    23499        <(for $i in $strmaparr)> 
    235100                <(for $i in $i)> <(* HERE : '$i in $i' is OK because of the namespace scope *)> 
     
    243108        <(assign a = test1)> 
    244109 
    245         <(if true )>     
     110        <(if true )> 
    246111                <(assign a = test2)> 
    247112 
     
    252117                                <(fi)> 
    253118                                <(print $i)> - <(print $j)> 
    254                                  
     119 
    255120                                <(assign a = test3)> 
    256                                 <(print $a," must be test3")> 
     121                                <(print "$a= '", $a,"' (must be equal to 'test3')")> 
    257122                        <(rof)> 
    258123                        ------- 
    259                 <(rof)>  
    260                 <(print $a," must be test2")> 
     124                <(rof)> 
     125                <(print "$a= '", $a,"' (must be equal to 'test2')")> 
    261126        <(fi)> 
    262         <(print $a," must be test1")> 
    263                  
     127        <(print "$a= '", $a,"' (must be equal to 'test1')")> 
     128 
    264129        <(ns)> 
    265130                        <(ns)> 
    266131                                <(assign a = in namespace)> 
    267                                 <(print $a," must be `in namespace`")> 
     132                                <(print "$a= '", $a,"' (must be equal to 'in namespace')")> 
    268133                        <(sn)> 
    269                 <(print $a," must be test1")> 
     134                <(print "$a= '", $a,"' (must be equal to 'test1')")> 
    270135        <(sn)> 
    271  
    272         ********** 
    273  
    274         print statement and variable resolution 
    275  
    276         <(> 
    277                 <(print string literal)> 
    278                 <(print {$strmaparr.{0}.{$one}} )> 
    279                 <(print $strmaparr.1.{$strmap.{$one}} )> 
    280                 <(print $strarr.0.0 )> 
    281                 <(print $strmap.one )> 
    282                 <(print $strmaparr.0.one )> 
    283                 <(print $strmaparr.1.one )> 
    284                 <(print $strmaparr.1.{$strmap.{$one}} , -- , {$strmaparr.{0}.{$one}})> 
    285                 <(print $dodo.version, " ", $dodo)> 
    286         <)> 
    287136 
    288137        <(print string literal)> 
     
    295144        <(print $strmaparr.1.{$strmap.{$one}} , -- , {$strmaparr.{0}.{$one}})> 
    296145        <(print $dodo.version, " ", $dodo)> 
    297  
    298146</pre> 
  • trunk/tests/cgifast_test/test.cc

    r1312 r1345  
    1919 
    2020void 
    21 cgif(exchange &fcgi) 
     21handler(exchange &ex) 
    2222{ 
    2323        using namespace cgi; 
    2424 
    25         dialogue cgit(fcgi, true); 
     25        dialogue d(ex, true); 
    2626 
    27         cgit.setCookie(cookie("test", "Ni@m")); 
     27        d.setCookie(cookie("test", "Ni@m")); 
    2828 
    2929        ///increment counter in shared memory 
     
    3131        sh.release(); 
    3232 
    33         exchange *io = cgit; 
     33        exchange *io = d; 
    3434        io->writeString("The headers thould be already printed successfully.<br>"); 
    3535 
     
    3838#endif 
    3939 
    40         fcgi.writeString("counter: " + tools::string::iToString(*inc) + "<br>"); 
     40        ex.writeString("counter: " + tools::string::iToString(*inc) + "<br>"); 
    4141 
    42         fcgi.writeString("GET[\"argument\"]: " + cgit.GET["argument"] + "<br>"); 
    43         fcgi.writeString("POST[\"hidden\"]: " + cgit.POST["hidden"] + "<br>"); 
    44         fcgi.writeString("POST[\"test\"]: " + cgit.POST["test"] + "<br>"); 
    45         fcgi.writeString("ENVIRONMENT[CGI_ENVIRONMENT_QUERYSTRING]: " + cgit.ENVIRONMENT[cgi::ENVIRONMENT_QUERYSTRING] + "<br>"); 
    46         fcgi.writeString("COOKIES[\"test\"]: " + cgit.COOKIES["test"] + "<br>"); 
    47         fcgi.writeString("FILES[\"file\"].size: " + tools::string::iToString(cgit.FILES["file"].size) + "<br>"); 
    48         fcgi.writeString("tpl::processor:<br>"); 
     42        ex.writeString("GET[\"argument\"]: " + d.GET["argument"] + "<br>"); 
     43        ex.writeString("POST[\"hidden\"]: " + d.POST["hidden"] + "<br>"); 
     44        ex.writeString("POST[\"test\"]: " + d.POST["test"] + "<br>"); 
     45        ex.writeString("ENVIRONMENT[CGI_ENVIRONMENT_QUERYSTRING]: " + d.ENVIRONMENT[cgi::ENVIRONMENT_QUERYSTRING] + "<br>"); 
     46        ex.writeString("COOKIES[\"test\"]: " + d.COOKIES["test"] + "<br>"); 
     47        ex.writeString("FILES[\"file\"].size: " + tools::string::iToString(d.FILES["file"].size) + "<br>"); 
     48        ex.writeString("tpl::processor:<br>"); 
    4949 
    5050        try 
    5151        { 
    52                 processor cgip; 
     52                processor p; 
    5353 
    54                 cgip.assign("test", "hoho"); 
    55                 cgip.assign("one", "one"); 
     54                p.assign("test", "test"); 
     55                p.assign("one", "one"); 
    5656 
    5757                dodoStringArray strarr; 
     
    5959                strarr.push_back("two"); 
    6060                strarr.push_back("three"); 
    61                 cgip.assign("strarr", strarr); 
     61                p.assign("strarr", strarr); 
    6262 
    6363                dodoStringMap strmap; 
     
    6565                strmap["two"] = "two"; 
    6666                strmap["three"] = "three"; 
    67                 cgip.assign("strmap", strmap); 
     67                p.assign("strmap", strmap); 
    6868 
    6969                dodoArray<dodoStringMap> strmaparr; 
     
    7171                strmap["one"] = "three"; 
    7272                strmaparr.push_back(strmap); 
    73                 cgip.assign("strmaparr", strmaparr); 
     73                p.assign("strmaparr", strmaparr); 
    7474 
    75                 cgip.processFile("test.tpl", *io); 
     75                p.processFile("test.tpl", *io); 
    7676        } 
    7777        catch (dodo::exception::basic ex) 
    7878        { 
    79                 fcgi.writeString(ex.errStr + " " + tools::string::lToString(ex.line)); 
     79                ex.writeString(ex.errStr + " " + tools::string::lToString(ex.line)); 
    8080        } 
    8181 
    82         fcgi.writeString("<br>"); 
     82        ex.writeString("<br>"); 
    8383 
    8484        inc = (int *)sh.acquire(); 
     
    108108                server c; 
    109109#endif 
    110 \ 
    111                 c.serve(&cgif); 
     110                c.serve(&handler); 
    112111 
    113112                delete shared; 
  • trunk/tests/cgifast_test/test.tpl

    r1110 r1345  
    1  
    21<form enctype="multipart/form-data" method="POST"> 
    32        <input type="file" name="file"> 
     3        <input type="hidden" name="hidden" value="post"> 
     4        <input type="text" name="text" value="text"> 
    45        <input type="submit" value="push file"> 
     6</form> 
     7<form method="POST"> 
     8        <input type="hidden" name="hidden" value="post"> 
     9        <input type="text" name="text" value="text"> 
     10        <input type="submit" value="push"> 
    511</form> 
    612 
    713<pre> 
     14        <(* test template *)> 
    815 
    9         <(* test template *)> 
     16        <(assign a = 1)> 
     17        <(assign b = 2)> 
     18 
     19        <(assign b = $a)> 
    1020 
    1121        <(> <( not )> parsed area <)> 
    1222 
    13         ********** 
     23        <(print "test=", $test)> 
    1424 
    15         simple 'if' statement 
    16  
    17         <(> 
    18                 <(print $test)> 
    19                 <(if $test!=test )> 
    20                         equal 
    21                 <(else)> 
    22                         not equal 
    23                 <(fi)> 
    24         <)> 
    25  
    26         <(print $test)> 
    2725        <(if $test!=test )> 
    28                 equal 
     26                $test != 'test' 
    2927        <(else)> 
    30                 not equal 
     28                $test == 'test' 
    3129        <(fi)> 
    32  
    33         ********** 
    34  
    35         nested 'if' statements 
    36  
    37         <(> 
    38                 <(if $test )> 
    39                         $test 
    40                         <(if $test==test )> 
    41                                 test 
    42                         <(fi)> 
    43                         <(if $test!=test )> 
    44                                 !test 
    45                         <(fi)>   
    46                          
    47                         <(if $test )> 
    48                                 test 
    49                                 <(if $test==test )> 
    50                                         <(print $test)> 
    51                                 <(else)> 
    52                                         NULL 
    53                                 <(fi)> 
    54                         <(else)>         
    55                                 <(if $test!=test )> 
    56                                         !test 
    57                                 <(fi)>   
    58                                 <(if false )> 
    59                                         WTF? 
    60                                 <(fi)> 
    61                         <(fi)>   
    62                          
    63                         <(if 3>2 )> 
    64                                 3>2 
    65                         <(fi)> 
    66  
    67                         <(if 3<2 )> 
    68                                 WTF? 
    69                         <(fi)> 
    70                          
    71                         <( 
    72                                 if 
    73                                 ! `false` 
    74                         )> 
    75                                 !false 
    76                         <(fi)> 
    77                          
    78                         <(if!false)>!false<(fi)> 
    79                          
    80                         <(if ! 'false' )> 
    81                                 !'false' 
    82                         <(fi)>           
    83                         <(if ! "false" )> 
    84                                 ! "false" 
    85                         <(fi)>   
    86                 <(fi)> 
    87         <)> 
    8830 
    8931        <(if $test )> 
    9032                $test 
    9133                <(if $test==test )> 
    92                         test 
     34                        $test == 'test' 
    9335                <(fi)> 
    9436                <(if $test!=test )> 
    95                         !test 
    96                 <(fi)>   
    97                  
     37                        $test != 'test' 
     38                <(fi)> 
     39 
    9840                <(if $test )> 
    9941                        test 
    10042                        <(if $test==test )> 
    101                                 <(print $test)> 
     43                                $test == 'test' 
    10244                        <(else)> 
    103                                 NULL 
     45                                $test != 'test' 
    10446                        <(fi)> 
    105                 <(else)>         
     47                <(else)> 
    10648                        <(if $test!=test )> 
    107                                 !test 
    108                         <(fi)>   
     49                                $test != 'test' 
     50                        <(fi)> 
    10951                        <(if false )> 
    11052                                WTF? 
    11153                        <(fi)> 
    112                 <(fi)>   
    113                  
     54                <(fi)> 
     55 
    11456                <(if 3>2 )> 
    11557                        3>2 
     
    11961                        WTF? 
    12062                <(fi)> 
    121                  
     63 
    12264                <( 
    12365                        if 
     
    12668                        !false 
    12769                <(fi)> 
    128                  
     70 
    12971                <(if!false)>!false<(fi)> 
    130                  
     72 
    13173                <(if ! 'false' )> 
    13274                        !'false' 
    133                 <(fi)>           
     75                <(fi)> 
    13476                <(if ! "false" )> 
    13577                        ! "false" 
    136                 <(fi)>   
     78                <(fi)> 
    13779        <(fi)> 
    138  
    139         ********** 
    140  
    141         simple 'for' statement 
    142          
    143         <(> 
    144                 <(for $i in $strarr)> 
    145                         <(for $j in $i)><(print $j)><(rof)> 
    146                 <(rof)> 
    147  
    148                 <(for $b in $strmaparr)> 
    149                         <(for $c in $b)> 
    150                                 |<(print $c)>|<(print $b.one)> 
    151                         <(rof)> 
    152                 <(rof)> 
    153  
    154                 <(for $c in $strmaparr.1)> 
    155                         |<(print $c)> 
    156                 <(rof)> 
    157         <)> 
    15880 
    15981        <(for $i in $strarr)> 
     
    17193        <(rof)> 
    17294 
    173         ********** 
    174  
    175         namespace 
    176  
    177         <(> 
    178                 <(for $i in $strmaparr)> 
    179                         <(for $i in $i)> <(* HERE : '$i in $i' is OK because of the namespace scope *)> 
    180                                 |<(print $i)> 
    181                                 <(print $dodo.iterator)> 
    182                         <(rof)> 
    183                         |<(print $i.one)> 
    184                         <(print $dodo.iterator)> 
    185                 <(rof)> 
    186          
    187                 <(assign a = test1)> 
    188  
    189                 <(if true )>     
    190                         <(assign a = test2)> 
    191  
    192                         <(for $i in $strmaparr)> 
    193                                 <(for $i => $j in $i)> 
    194                                         <(if $i == three)> 
    195                                                 <(break 3)> 
    196                                         <(fi)> 
    197                                         <(print $i)> - <(print $j)> 
    198                                          
    199                                         <(assign a = test3)> 
    200                                         <(print $a," must be test3")> 
    201                                 <(rof)> 
    202                                 ------- 
    203                         <(rof)>  
    204                         <(print $a," must be test2")> 
    205                 <(fi)> 
    206                 <(print $a," must be test1")> 
    207                  
    208                 <(ns)> 
    209                                 <(ns)> 
    210                                         <(assign a = in namespace)> 
    211                                         <(print $a," must be `in namespace`")> 
    212                                 <(sn)> 
    213                         <(print $a," must be test1")> 
    214                 <(sn)> 
    215         <)> 
    216  
    21795        <(for $i in $strmaparr)> 
    21896                <(for $i in $i)> <(* HERE : '$i in $i' is OK because of the namespace scope *)> 
     
    226104        <(assign a = test1)> 
    227105 
    228         <(if true )>     
     106        <(if true )> 
    229107                <(assign a = test2)> 
    230108 
     
    235113                                <(fi)> 
    236114                                <(print $i)> - <(print $j)> 
    237                                  
     115 
    238116                                <(assign a = test3)> 
    239                                 <(print $a," must be test3")> 
     117                                <(print "$a= '", $a,"' (must be equal to 'test3')")> 
    240118                        <(rof)> 
    241119                        ------- 
    242                 <(rof)>  
    243                 <(print $a," must be test2")> 
     120                <(rof)> 
     121                <(print "$a= '", $a,"' (must be equal to 'test2')")> 
    244122        <(fi)> 
    245         <(print $a," must be test1")> 
    246                  
     123        <(print "$a= '", $a,"' (must be equal to 'test1')")> 
     124 
    247125        <(ns)> 
    248126                        <(ns)> 
    249127                                <(assign a = in namespace)> 
    250                                 <(print $a," must be `in namespace`")> 
     128                                <(print "$a= '", $a,"' (must be equal to 'in namespace')")> 
    251129                        <(sn)> 
    252                 <(print $a," must be test1")> 
     130                <(print "$a= '", $a,"' (must be equal to 'test1')")> 
    253131        <(sn)> 
    254  
    255         ********** 
    256  
    257         print statement and variable resolution 
    258  
    259         <(> 
    260                 <(print string literal)> 
    261                 <(print {$strmaparr.{0}.{$one}} )> 
    262                 <(print $strmaparr.1.{$strmap.{$one}} )> 
    263                 <(print $strarr.0.0 )> 
    264                 <(print $strmap.one )> 
    265                 <(print $strmaparr.0.one )> 
    266                 <(print $strmaparr.1.one )> 
    267                 <(print $strmaparr.1.{$strmap.{$one}} , -- , {$strmaparr.{0}.{$one}})> 
    268                 <(print $dodo.version, " ", $dodo)> 
    269         <)> 
    270132 
    271133        <(print string literal)> 
     
    278140        <(print $strmaparr.1.{$strmap.{$one}} , -- , {$strmaparr.{0}.{$one}})> 
    279141        <(print $dodo.version, " ", $dodo)> 
    280  
    281142</pre> 
Note: See TracChangeset for help on using the changeset viewer.