From: James E. J. Jr. <mu...@us...> - 2003-08-02 06:17:32
|
Update of /cvsroot/psp/psp/lib/tools/t In directory sc8-pr-cvs1:/tmp/cvs-serv27844/psp/lib/tools/t Added Files: run_control.t run_error.t run_fieldspace.t run_form.t run_group.t run_message.t run_page.t run_tablespace.t Log Message: automated piler-to-driver page tests. --- NEW FILE --- #! perl -w use PSP::Test; use Test::More; my $n_iterations = 1; my $n_tests = 10; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. <psp:if test="1"> and more. </psp:if> PSP Content-length: 65 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. and more. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. <psp:if test="1">and more. </psp:if> PSP Content-length: 64 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. and more. OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $foo = "lala"; my $bar = "oodle"; %> [= (length($foo) > length($bar)) ? $foo : $bar =] [= sprintf("%0.7f",2*atan2(1,0)) =] PSP Content-length: 55 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> oodle 3.1415927 OUTPUT output_is(<<'PSP',<<'OUTPUT'); [= "foo" =] [= "bar" =] [= "foo" =][= "bar" =] PSP Content-length: 53 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> foo bar foobar OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my @data = qw(apple 0.41 banana 0.35 grape 0.02 celery 0.10); %> <table> <psp:while test="@data"> <% my $fruit = shift @data; my $price = shift @data; %> <tr><th>[+ $fruit +]</th><td>$[+ $price +]</td></tr> </psp:while> </table> PSP Content-length: 215 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <table> <tr><th>apple</th><td>$0.41</td></tr> <tr><th>banana</th><td>$0.35</td></tr> <tr><th>grape</th><td>$0.02</td></tr> <tr><th>celery</th><td>$0.10</td></tr> </table> OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT } # iterations 1; --- NEW FILE --- #! perl -w use PSP::Test; use Test::More; my $n_iterations = 1; my $n_tests = 2; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); output_is(<<'PSP',<<'OUTPUT'); <psp:errorreport/> PSP Content-length: 39 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> OUTPUT output_is(<<'PSP',<<'OUTPUT'); <psp:errorreport full="yes"/> PSP Content-length: 39 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> OUTPUT } # iterations 1; --- NEW FILE --- #! perl -w use PSP::Test; use Test::More; my $n_iterations = 1; my $n_tests = 5; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); my $test1_fs=<<'FIELDSPACE'; <psp:fieldspace name="transfer"> <psp:define name="acc_num" blankok="0"/> <psp:define name="acc_type" type="select" blankok="0">;; $field->set_display(1); $field->set_possible_hash ({''=>'None',DDA=>'Checking',SAV=>'Savings',LON=>'Loan'}, ['',qw(DDA SAV LON)]); </psp:define> </psp:fieldspace> FIELDSPACE my $_poss_changed = "PSP::FieldSpace::test::transfer::_poss_changed"; my $test1_send_form=<<'PSP'; <psp:script> my $title = "Send Account Type"; </psp:script> <html><head><title>Send</title></head> <body> <psp:form action="receive" fieldspace="transfer"> Sending:<br> Account Type: <psp:input name="acc_type"/><br> Account Number: <psp:input name="acc_num"/><br> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> <psp:submit name="cancel" goto="first"/> <psp:submit goto="receive" verify="instantiated"/> </psp:form> </body> </html> PSP my $test1_receive=<<'PSP'; <html><head><title>Receive</title></head> <psp:use_fieldspace name="transfer"> Received:<br> Account Type: <psp:display name="acc_type"/><br> Account Number: <psp:display name="acc_num"/><br> </psp:use_fieldspace> </body> </html> PSP my $test2_fs=<<'PSP'; <psp:fieldspace name="form4"> <psp:declare>use Benchmark;</psp:declare> <psp:define name="integer" data="integer"> $field->set_parameters({min_value => 10, max_value => 100}); $field->set_format({show_plus => 1}); </psp:define> <psp:define name="text" data="text"> $field->set_parameters({blank_ok => 0}); </psp:define> <psp:define name="date" data="date"> $field->set_parameters({blank_ok => 0}); $field->set_format({hyphens => 1}); </psp:define> </psp:fieldspace> PSP my $test2_display_chunk=<<'PSP'; <psp:if test="$cgi->param('go')"> Your form contents: <ul> <psp:list list="$cgi->param()" iterator="$param"> <psp:list list="$cgi->param($param)" iterator="$value"> <li><b>[+ $param +]</b> = [+ $value +]</li> </psp:list> </psp:list> </ul> </psp:if> PSP my $test2_form_chunk=<<'PSP'; <h1>PSP Form with fieldspace and submit:</h1> <psp:form fieldspace="form4"> <psp:errorreport full="yes"/> integer: <psp:input name="integer"><br> text: <psp:input name="text"><br> date: <psp:input name="date"><br> Verify integer and text: <psp:submit name="go1" value="Go!" html="true"> <psp:vfield name="integer"/> <psp:vfield name="text"/> </psp:submit><br> Verify integer only: <psp:submit name="go2" value="Go!" html="true"> <psp:vfield name="integer"/> </psp:submit><br> Verify date only: <psp:submit name="go3" value="Go!" html="true"> <psp:vfield name="date"/> </psp:submit><br> Verify instantiated: <psp:submit name="go4" value="Go!" html="true"> <psp:vinstantiated/> </psp:submit><br> Verify special: <psp:submit name="go5" value="Go!" html="true"> my $time = time(); if ($time % 2) { $fs->add_error("special","time ($time) was odd"); } else { $fs->add_error("special","time ($time) was even"); } </psp:submit><br> </psp:form> PSP ############################################################################## ############################################################################## output_is({"transfer.fs"=>$test1_fs, "default.psp"=>$test1_send_form},<<'OUTPUT'); Content-length: 801 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html><head><title>Send</title></head> <body> <form method="POST" action="receive"> Sending:<br> Account Type: <select name="acc_type"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select><br> Account Number: <input name="acc_num" type="text" value=""><br> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="acc_num~~acc_type"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </body> </html> OUTPUT output_is({"transfer.fs"=>$test1_fs, "receive.psp"=>$test1_receive, "default.psp"=>$test1_send_form}, { _form_id => "test:default:ABC123", $_poss_changed => "acc_num~~acc_type", submit => "Submit" }, <<'OUTPUT'); Content-length: 881 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html><head><title>Send</title></head> <body> <form method="POST" action="receive"> Sending:<br> Account Type: <font color="#ff0000" size="+3">*</font><select name="acc_type"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select><br> Account Number: <font color="#ff0000" size="+3">*</font><input name="acc_num" type="text" value=""><br> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="acc_num~~acc_type"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </body> </html> OUTPUT output_is({"transfer.fs"=>$test1_fs, "receive.psp"=>$test1_receive, "default.psp"=>$test1_send_form}, { _form_id => "test:default:ABC123", $_poss_changed => "acc_num~~acc_type", submit => "Submit" }, <<'OUTPUT'); Content-length: 881 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html><head><title>Send</title></head> <body> <form method="POST" action="receive"> Sending:<br> Account Type: <font color="#ff0000" size="+3">*</font><select name="acc_type"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select><br> Account Number: <font color="#ff0000" size="+3">*</font><input name="acc_num" type="text" value=""><br> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="acc_num~~acc_type"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </body> </html> OUTPUT output_is({"transfer.fs"=>$test1_fs, "receive.psp"=>$test1_receive, "default.psp"=>$test1_send_form}, { _form_id => "test:default:ABC123", acc_num => "12345678", acc_type => "SAV", $_poss_changed => "acc_num~~acc_type", submit => "Submit" }, <<'OUTPUT'); Content-length: 167 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__receive --> <html><head><title>Receive</title></head> Received:<br> Account Type: Savings<br> Account Number: 12345678<br> </body> </html> OUTPUT output_is(<<"PSP",<<'OUTPUT'); <html><head><title>Form Test 4</title></head><body> $test2_fs $test2_display_chunk $test2_form_chunk </body><html> PSP Content-length: 951 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html><head><title>Form Test 4</title></head><body> <h1>PSP Form with fieldspace and submit:</h1> <form method="POST"> integer: <input name="integer" type="text" value=""><br> text: <input name="text" type="text" value=""><br> date: <input name="date" type="text" value=""><br> Verify integer and text: <input type="submit" name="go1" value="Go!"><br> Verify integer only: <input type="submit" name="go2" value="Go!"><br> Verify date only: <input type="submit" name="go3" value="Go!"><br> Verify instantiated: <input type="submit" name="go4" value="Go!"><br> Verify special: <input type="submit" name="go5" value="Go!"><br> <input type="hidden" name="PSP::FieldSpace::test::form4::_poss_changed" value="date~~integer~~text"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </body><html> OUTPUT } # iterations 1; --- NEW FILE --- #! perl -w use PSP::Test; use Test::More; my $n_iterations = 1; my $n_tests = 10; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); my $test1_fs=<<'FIELDSPACE'; <psp:fieldspace name="transfer"> <psp:import vars="%pf_box,%acc_types"/> $pf_box{type_map} = \%acc_types; $pf_box{type_order} = [ sort { $a cmp $b } keys %{$pf_box{type_map}} ]; <psp:define name="acc_type" type="select" data="text">;; my %mapping = map { $_ => $pf_box{type_map}->{$_}->{desc} } @{$pf_box{type_order}}; my @order = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a->[2] cmp $b->[2] } map {[$_,$pf_box{type_map}->{$_}->{def},$pf_box{type_map}->{$_}->{def}]} keys %{$pf_box{type_map}}; $pf_box{no_None} and @order = grep {$_ ne ""} @order; $field->set_display(1); $field->set_possible_hash(\%mapping,\@order); $field->set_parameters({blank_ok => 0}); </psp:define> <psp:define name="acc_num" type="text" data="text"> ;; $field->set_parameters({blank_ok => 0}); </psp:define> </psp:fieldspace> FIELDSPACE my $test1_send_form=<<'PSP'; <psp:script> my $title = "Send Account Type"; </psp:script> <html> <head> <title>[= $title =]</title> </head> <body> <center> <psp:form action="receive" fieldspace="transfer"> <table border="1"> <tr align="center"> <th align="right"> Account type: </th><td> <psp:input name="acc_type"/><br> </td> </tr> <tr> <th align="right"> Account number: </th><td> <psp:input name="acc_num"/><br> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> </td> </tr> </table> <psp:submit name="cancel" goto="first"/> <psp:submit goto="receive"> <psp:vinstantiated> </psp:submit> </psp:form> </center> </body> </html> PSP my $test1_receive=<<'PSP'; <psp:script> my $title = "Send Account Type"; </psp:script> <html> <head> <title>[= $title =]</title> </head> <body> <center> <psp:use_fieldspace name="transfer"> Hello </psp:use_fieldspace> PSP output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is({"transfer.fs"=>$test1_fs, "default.psp"=>$test1_send_form},<<'OUTPUT'); Content-length: 940 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html> <head> <title>Send Account Type</title> </head> <body> <center> <form method="POST" action="receive"> <table border="1"> <tr align="center"> <th align="right"> Account type: </th><td> <select name="acc_type"> </select><br> </td> </tr> <tr> <th align="right"> Account number: </th><td> <input name="acc_num" type="text" value=""><br> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> </td> </tr> </table> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="acc_num~~acc_type"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </center> </body> </html> OUTPUT output_is({"transfer.fs"=>$test1_fs, "receive.psp"=>$test1_receive, "default.psp"=>$test1_send_form}, { _form_id => "test:default:ABC123", "PSP::FieldSpace::test::transfer::_poss_changed" => "acc_num~~acc_type", submit => "Submit" }, <<'OUTPUT'); Content-length: 1020 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html> <head> <title>Send Account Type</title> </head> <body> <center> <form method="POST" action="receive"> <table border="1"> <tr align="center"> <th align="right"> Account type: </th><td> <font color="#ff0000" size="+3">*</font><select name="acc_type"> </select><br> </td> </tr> <tr> <th align="right"> Account number: </th><td> <font color="#ff0000" size="+3">*</font><input name="acc_num" type="text" value=""><br> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> </td> </tr> </table> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="acc_num~~acc_type"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </center> </body> </html> OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $foo = "lala"; my $bar = "oodle"; %> [= (length($foo) > length($bar)) ? $foo : $bar =] [= sprintf("%0.7f",2*atan2(1,0)) =] PSP Content-length: 55 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> oodle 3.1415927 OUTPUT output_is(<<'PSP',<<'OUTPUT'); [= "foo" =] [= "bar" =] [= "foo" =][= "bar" =] PSP Content-length: 53 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> foo bar foobar OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my @data = qw(apple 0.41 banana 0.35 grape 0.02 celery 0.10); %> <table> <psp:while test="@data"> <% my $fruit = shift @data; my $price = shift @data; %> <tr><th>[+ $fruit +]</th><td>$[+ $price +]</td></tr> </psp:while> </table> PSP Content-length: 215 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <table> <tr><th>apple</th><td>$0.41</td></tr> <tr><th>banana</th><td>$0.35</td></tr> <tr><th>grape</th><td>$0.02</td></tr> <tr><th>celery</th><td>$0.10</td></tr> </table> OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT } # iterations 1; --- NEW FILE --- #! perl -w use PSP::Test; use Test::More; my $n_iterations = 1; my $n_tests = 3; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); my $test1_fs=<<'FIELDSPACE'; <psp:fieldspace name="transfer"> <psp:define name="desc"/> <psp:group name="accts" dummyok="1"> <psp:define name="acc_num" blankok="1"/> <psp:define name="acc_type" type="select" blankok="1">;; $field->set_display(1); $field->set_possible_hash ({''=>'None',DDA=>'Checking',SAV=>'Savings',LON=>'Loan'}, ['',qw(DDA SAV LON)]); </psp:define> </psp:group> </psp:fieldspace> FIELDSPACE my $_poss_changed = "PSP::FieldSpace::test::transfer::_poss_changed"; my $test1_send_form=<<'PSP'; <html><head><title>Send</title></head> <body> <psp:form action="receive" fieldspace="transfer"> Description: <psp:input name="desc"/><br> Sending:<br> <psp:dynamicdisplay name="accts" numvar="$i" numdisplay="5" dummyok="1"> Account [= $i =]: Type: <psp:input name="acc_type"/> Number: <psp:input name="acc_num"/><br> </psp:dynamicdisplay> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> <psp:submit name="cancel" goto="send"/> <psp:submit goto="receive" verify="current"/> </psp:form> </body> </html> PSP my $test1_receive=<<'PSP'; <html><head><title>Receive</title></head> <psp:use_fieldspace name="transfer"> Description: <psp:display name="desc"/><br> Received:<br> <psp:dynamicdisplay name="accts" numvar="$i"> Account [= $i =]: Type: <psp:display name="acc_type"/> Number: <psp:display name="acc_num"/><br> </psp:dynamicdisplay> </psp:use_fieldspace> </body> </html> PSP ############################################################################## ############################################################################## output_is({"transfer.fs"=>$test1_fs, "default.psp"=>$test1_send_form},<<'OUTPUT'); Content-length: 2217 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html><head><title>Send</title></head> <body> <form method="POST" action="receive"> Description: <input name="desc" type="text" value=""><br> Sending:<br> Account 1: Type: <select name="acc_type:1"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select> Number: <input name="acc_num:1" type="text" value=""><br> Account 2: Type: <select name="acc_type:2"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select> Number: <input name="acc_num:2" type="text" value=""><br> Account 3: Type: <select name="acc_type:3"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select> Number: <input name="acc_num:3" type="text" value=""><br> Account 4: Type: <select name="acc_type:4"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select> Number: <input name="acc_num:4" type="text" value=""><br> Account 5: Type: <select name="acc_type:5"> <option value="" selected>None</option> <option value="DDA">Checking</option> <option value="SAV">Savings</option> <option value="LON">Loan</option> </select> Number: <input name="acc_num:5" type="text" value=""><br> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> <input type="hidden" name="PSP::FieldSpace::Group::test::transfer::accts::_control" value="1~~5~~10"> <input type="hidden" name="PSP::FieldSpace::Group::test::transfer::accts::_control_names" value=""> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="desc~~acc_num:1~~acc_num:2~~acc_num:3~~acc_num:4~~acc_num:5~~acc_type:1~~acc_type:2~~acc_type:3~~acc_type:4~~acc_type:5"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </body> </html> OUTPUT output_is({"transfer.fs"=>$test1_fs, "receive.psp"=>$test1_receive, "default.psp"=>$test1_send_form}, { _form_id => "test:default:ABC123", $_poss_changed => "desc~~acc_num:1~~acc_num:2~~acc_num:3~~acc_num:4~~acc_num:5~~acc_type:1~~acc_type:2~~acc_type:3~~acc_type:4~~acc_type:5", submit => "Submit" }, <<'OUTPUT'); Content-length: 862 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__receive --> <html><head><title>Receive</title></head> Description: <br> Received:<br> Account 1: Type: None Number: <br> Account 2: Type: None Number: <br> Account 3: Type: None Number: <br> Account 4: Type: None Number: <br> Account 5: Type: None Number: <br> Account 6: Type: None Number: <br> Account 7: Type: None Number: <br> Account 8: Type: None Number: <br> Account 9: Type: None Number: <br> Account 10: Type: None Number: <br> Account 11: Type: None Number: <br> Account 12: Type: None Number: <br> Account 13: Type: None Number: <br> Account 14: Type: None Number: <br> Account 15: Type: None Number: <br> Account 16: Type: None Number: <br> Account 17: Type: None Number: <br> Account 18: Type: None Number: <br> Account 19: Type: None Number: <br> Account 20: Type: None Number: <br> </body> </html> OUTPUT output_is({"transfer.fs"=>$test1_fs, "receive.psp"=>$test1_receive, "default.psp"=>$test1_send_form}, { _form_id => "test:default:ABC123", $_poss_changed => "desc~~acc_num:1~~acc_num:2~~acc_num:3~~acc_num:4~~acc_num:5~~acc_type:1~~acc_type:2~~acc_type:3~~acc_type:4~~acc_type:5", submit => "Submit", 'desc' => "some accounts", 'acc_num:1' => '43218765', 'acc_type:1' => 'SAV' }, <<'OUTPUT'); Content-length: 886 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__receive --> <html><head><title>Receive</title></head> Description: some accounts<br> Received:<br> Account 1: Type: Savings Number: 43218765<br> Account 2: Type: None Number: <br> Account 3: Type: None Number: <br> Account 4: Type: None Number: <br> Account 5: Type: None Number: <br> Account 6: Type: None Number: <br> Account 7: Type: None Number: <br> Account 8: Type: None Number: <br> Account 9: Type: None Number: <br> Account 10: Type: None Number: <br> Account 11: Type: None Number: <br> Account 12: Type: None Number: <br> Account 13: Type: None Number: <br> Account 14: Type: None Number: <br> Account 15: Type: None Number: <br> Account 16: Type: None Number: <br> Account 17: Type: None Number: <br> Account 18: Type: None Number: <br> Account 19: Type: None Number: <br> Account 20: Type: None Number: <br> </body> </html> OUTPUT } # iterations 1; --- NEW FILE --- #! perl -w use PSP::Test; use Test::More; my $n_iterations = 1; my $n_tests = 10; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. <psp:if test="1"> and more. </psp:if> PSP Content-length: 65 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. and more. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. <psp:if test="1">and more. </psp:if> PSP Content-length: 64 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. and more. OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $foo = "lala"; my $bar = "oodle"; %> [= (length($foo) > length($bar)) ? $foo : $bar =] [= sprintf("%0.7f",2*atan2(1,0)) =] PSP Content-length: 55 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> oodle 3.1415927 OUTPUT output_is(<<'PSP',<<'OUTPUT'); [= "foo" =] [= "bar" =] [= "foo" =][= "bar" =] PSP Content-length: 53 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> foo bar foobar OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my @data = qw(apple 0.41 banana 0.35 grape 0.02 celery 0.10); %> <table> <psp:while test="@data"> <% my $fruit = shift @data; my $price = shift @data; %> <tr><th>[+ $fruit +]</th><td>$[+ $price +]</td></tr> </psp:while> </table> PSP Content-length: 215 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <table> <tr><th>apple</th><td>$0.41</td></tr> <tr><th>banana</th><td>$0.35</td></tr> <tr><th>grape</th><td>$0.02</td></tr> <tr><th>celery</th><td>$0.10</td></tr> </table> OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT } # iterations 1; --- NEW FILE --- #! perl -w use strict; use Test::More; use PSP::Test; my $n_iterations = 1; my $n_tests = 15; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); output_is(<<'PSP',<<'OUTPUT',"simple page"); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT',"empty page"); PSP Content-length: 38 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> OUTPUT output_is(<<'PSP',<<'OUTPUT',"blank line page"); PSP Content-length: 39 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $var = "value"; %> [= $var =] PSP Content-length: 45 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> value OUTPUT output_is(<<'PSP',<<'OUTPUT'); <psp:script> my $var = "value"; </psp:script> [= $var =] PSP Content-length: 45 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> value OUTPUT output_is(<<'PSP',<<'OUTPUT'); <psp:script> my $var = "value"; </psp:script> [= $var =] PSP Content-length: 45 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> value OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $var = "Hal & <Brothers>"; %> [= $var =] PSP Content-length: 56 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> Hal & <Brothers> OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $var = "Hal & <Brothers>"; %> [+ $var +] PSP Content-length: 66 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> Hal & <Brothers> OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $var = "Hal & <Brothers>"; %> [- $var -] PSP Content-length: 66 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> Hal%20%26%20%3CBrothers%3E OUTPUT output_is({"default.psp"=><<'PSP',"testinc.inc"=><<'INCLUDE'},<<'OUTPUT'); here is a page. <psp:include src="testinc.inc"> PSP here is an include. INCLUDE Content-length: 74 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. here is an include. OUTPUT output_is({"default.psp"=><<'PSP',"testinc.inc"=><<'INCLUDE'},<<'OUTPUT'); here is a page. <psp:include src="testinc.inc"> and more. PSP here is an include. INCLUDE Content-length: 85 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. here is an include. and more. OUTPUT output_is({"default.psp"=><<'PSP',"testinc.inc"=><<'INCLUDE'},<<'OUTPUT'); <psp:include src="testinc.inc"> and more. PSP here is an include. INCLUDE Content-length: 69 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is an include. and more. OUTPUT output_is({"default.psp"=><<'PSP',"testinc.inc"=><<'INCLUDE'},<<'OUTPUT'); <% my $testvar = "hello."; %> including.. <psp:include src="testinc.inc"> end of include. PSP here is an include with: [= $testvar =] INCLUDE Content-length: 100 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> including.. here is an include with: hello. end of include. OUTPUT output_is({"default.psp"=><<'PSP',"testinc.sub"=><<'SUB'},<<'OUTPUT'); <% my $testvar = "hello."; %> including.. <psp:call src="testinc.sub"> end of include. PSP <psp:sub proto="$testvar"/> here is an include with: [= $testvar =] SUB Content-length: 101 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> including.. here is an include with: hello. end of include. OUTPUT output_is({"default.psp"=><<'PSP1',"subdir"=>{"here.psp"=><<'PSP2'}},<<'OUTPUT'); erf. PSP1 hooyah! PSP2 Content-length: 43 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> erf. OUTPUT } # iterations 1; --- NEW FILE --- #! perl -w use PSP::Test; use Test::More; my $n_iterations = 1; my $n_tests = 10; my @option_set = ({},{AUTO_PILE => 1}); #my @option_set = ({}); PSP::Test->plan( tests => @option_set * $n_iterations * $n_tests ); for my $options ( (@option_set) x $n_iterations ) { set_test_options( %$options ); my $test1_fs=<<'FIELDSPACE'; <psp:fieldspace name="transfer"> <psp:import vars="%pf_box,%acc_types"/> $pf_box{type_map} = \%acc_types; $pf_box{type_order} = [ sort { $a cmp $b } keys %{$pf_box{type_map}} ]; <psp:define name="acc_type" type="select" data="text">;; my %mapping = map { $_ => $pf_box{type_map}->{$_}->{desc} } @{$pf_box{type_order}}; my @order = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a->[2] cmp $b->[2] } map {[$_,$pf_box{type_map}->{$_}->{def},$pf_box{type_map}->{$_}->{def}]} keys %{$pf_box{type_map}}; $pf_box{no_None} and @order = grep {$_ ne ""} @order; $field->set_display(1); $field->set_possible_hash(\%mapping,\@order); $field->set_parameters({blank_ok => 0}); </psp:define> <psp:define name="acc_num" type="text" data="text"> ;; $field->set_parameters({blank_ok => 0}); </psp:define> </psp:fieldspace> FIELDSPACE my $test1_send_form=<<'PSP'; <psp:script> my $title = "Send Account Type"; </psp:script> <html> <head> <title>[= $title =]</title> </head> <body> <center> <psp:form action="receive" fieldspace="transfer"> <table border="1"> <tr align="center"> <th align="right"> Account type: </th><td> <psp:input name="acc_type"/><br> </td> </tr> <tr> <th align="right"> Account number: </th><td> <psp:input name="acc_num"/><br> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> </td> </tr> </table> <psp:submit name="cancel" goto="first"/> <psp:submit goto="receive"> <psp:vinstantiated> </psp:submit> </psp:form> </center> </body> </html> PSP my $test1_receive=<<'PSP'; <psp:script> my $title = "Send Account Type"; </psp:script> <html> <head> <title>[= $title =]</title> </head> <body> <center> <psp:use_fieldspace name="transfer"> Hello </psp:use_fieldspace> PSP output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is({"transfer.fs"=>$test1_fs, "default.psp"=>$test1_send_form},<<'OUTPUT'); Content-length: 940 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html> <head> <title>Send Account Type</title> </head> <body> <center> <form method="POST" action="receive"> <table border="1"> <tr align="center"> <th align="right"> Account type: </th><td> <select name="acc_type"> </select><br> </td> </tr> <tr> <th align="right"> Account number: </th><td> <input name="acc_num" type="text" value=""><br> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> </td> </tr> </table> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="acc_num~~acc_type"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </center> </body> </html> OUTPUT output_is({"transfer.fs"=>$test1_fs, "receive.psp"=>$test1_receive, "default.psp"=>$test1_send_form}, { _form_id => "test:default:ABC123", "PSP::FieldSpace::test::transfer::_poss_changed" => "acc_num~~acc_type", submit => "Submit" }, <<'OUTPUT'); Content-length: 1020 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <html> <head> <title>Send Account Type</title> </head> <body> <center> <form method="POST" action="receive"> <table border="1"> <tr align="center"> <th align="right"> Account type: </th><td> <font color="#ff0000" size="+3">*</font><select name="acc_type"> </select><br> </td> </tr> <tr> <th align="right"> Account number: </th><td> <font color="#ff0000" size="+3">*</font><input name="acc_num" type="text" value=""><br> </td> </tr> <tr> <td colspan="2"> <input type="submit" name="submit" value="Submit"> <input type="submit" name="cancel" value="Cancel"> <input type="reset" value="Reset"> </td> </tr> </table> <input type="hidden" name="PSP::FieldSpace::test::transfer::_poss_changed" value="acc_num~~acc_type"> <input type="hidden" name="_form_submitter" value="page__default"> <input type="hidden" name="_form_id" value="test:default:ABC123"></form> </center> </body> </html> OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my $foo = "lala"; my $bar = "oodle"; %> [= (length($foo) > length($bar)) ? $foo : $bar =] [= sprintf("%0.7f",2*atan2(1,0)) =] PSP Content-length: 55 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> oodle 3.1415927 OUTPUT output_is(<<'PSP',<<'OUTPUT'); [= "foo" =] [= "bar" =] [= "foo" =][= "bar" =] PSP Content-length: 53 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> foo bar foobar OUTPUT output_is(<<'PSP',<<'OUTPUT'); <% my @data = qw(apple 0.41 banana 0.35 grape 0.02 celery 0.10); %> <table> <psp:while test="@data"> <% my $fruit = shift @data; my $price = shift @data; %> <tr><th>[+ $fruit +]</th><td>$[+ $price +]</td></tr> </psp:while> </table> PSP Content-length: 215 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> <table> <tr><th>apple</th><td>$0.41</td></tr> <tr><th>banana</th><td>$0.35</td></tr> <tr><th>grape</th><td>$0.02</td></tr> <tr><th>celery</th><td>$0.10</td></tr> </table> OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT output_is(<<'PSP',<<'OUTPUT'); here is a page. PSP Content-length: 54 Content-Type: text/html; charset=ISO-8859-1 <!-- pile:test page:page__default --> here is a page. OUTPUT } # iterations 1; |