Update of /cvsroot/http-webtest/HTTP-WebTest/t
In directory sc8-pr-cvs1:/tmp/cvs-serv4370/t
Modified Files:
06-parser.t 01-api.t
Log Message:
Tests for new parser API
Index: 06-parser.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/06-parser.t,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** 06-parser.t 3 Jan 2003 22:32:32 -0000 1.19
--- 06-parser.t 25 Jan 2003 17:48:05 -0000 1.20
***************
*** 10,14 ****
use HTTP::WebTest::SelfTest;
! use Test::More tests => 68;
# 1-60: check parsed wt script (which contains all variants of
--- 10,14 ----
use HTTP::WebTest::SelfTest;
! use Test::More tests => 69;
# 1-60: check parsed wt script (which contains all variants of
***************
*** 95,99 ****
}
! # 61-68: check error handling for borked wtscript files
parse_error_check(wtscript => 't/borked1.wt',
check_file => 't/test.out/borked1.err');
--- 95,99 ----
}
! # 61-68: test error handling for borked wtscript files
parse_error_check(wtscript => 't/borked1.wt',
check_file => 't/test.out/borked1.err');
***************
*** 121,124 ****
--- 121,135 ----
parse_error_check(wtscript => 't/borked8.wt',
check_file => 't/test.out/borked8.err');
+
+ # 69: test writing wtscript for single test
+ {
+ my @params = ( xxx => 'yyy',
+ zzz => [ 1 => 2 ],
+ abc => [ 1 => [ 2 => 3 ] ],
+ bad => [ qw|( ) ' \' " => { }| ]);
+ my $output = HTTP::WebTest::Parser->write_test(\@params);
+ compare_output(check_file => 't/test.out/write_params',
+ output_ref => \$output);
+ }
sub parse_error_check {
Index: 01-api.t
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest/t/01-api.t,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** 01-api.t 22 Dec 2002 21:25:50 -0000 1.14
--- 01-api.t 25 Jan 2003 17:48:05 -0000 1.15
***************
*** 12,16 ****
use HTTP::WebTest::Utils qw(start_webserver stop_webserver);
! use Test::More tests => 15;
# init test
--- 12,16 ----
use HTTP::WebTest::Utils qw(start_webserver stop_webserver);
! use Test::More tests => 19;
# init test
***************
*** 27,31 ****
my $user_agent = new LWP::UserAgent;
$WEBTEST->user_agent($user_agent);
! ok($WEBTEST->user_agent eq $user_agent);
}
--- 27,31 ----
my $user_agent = new LWP::UserAgent;
$WEBTEST->user_agent($user_agent);
! is($WEBTEST->user_agent, $user_agent);
}
***************
*** 39,43 ****
{
my $aref = $WEBTEST->tests;
! ok(@$aref == 0);
}
--- 39,43 ----
{
my $aref = $WEBTEST->tests;
! is(@$aref, 0);
}
***************
*** 49,53 ****
my $request = $WEBTEST->current_request;
my $response = $WEBTEST->current_response;
! ok($request->uri eq $url);
ok($response->is_success);
}
--- 49,53 ----
my $request = $WEBTEST->current_request;
my $response = $WEBTEST->current_response;
! is($request->uri->as_string, $url->as_string);
ok($response->is_success);
}
***************
*** 68,72 ****
{
my $aref = $WEBTEST->tests;
! ok(@$aref == 3);
}
--- 68,72 ----
{
my $aref = $WEBTEST->tests;
! is(@$aref, 3);
}
***************
*** 76,81 ****
my ($tests, $opts) = $WEBTEST->parse($data);
! ok($tests->[0]{test_name} eq 'Some name here');
! ok($opts->{text_require}[0] eq 'Require some');
}
--- 76,81 ----
my ($tests, $opts) = $WEBTEST->parse($data);
! is($tests->[0]{test_name}, 'Some name here');
! is($opts->{text_require}[0], 'Require some');
}
***************
*** 124,129 ****
$WEBTEST->run_tests($tests, { output_ref => \$output });
! ok($WEBTEST->num_fail == 2);
! ok($WEBTEST->num_succeed == 1);
}
--- 124,129 ----
$WEBTEST->run_tests($tests, { output_ref => \$output });
! is($WEBTEST->num_fail, 2);
! is($WEBTEST->num_succeed, 1);
}
***************
*** 136,140 ****
$WEBTEST->run_tests($tests, { output_ref => \$output });
! ok($WEBTEST->current_test->request->uri eq abs_url($URL, '/doesnt-exist'));
}
--- 136,160 ----
$WEBTEST->run_tests($tests, { output_ref => \$output });
! is($WEBTEST->current_test->request->uri->as_string,
! abs_url($URL, '/doesnt-exist')->as_string);
! }
!
! # 16-19: test $WEBTEST->parser_package
! {
! is($WEBTEST->parser_package, 'HTTP::WebTest::Parser');
! {
! package TestParser;
!
! sub parse { [ x => 'z' ], { 1 => 2 } };
! };
! # set non default parser
! $WEBTEST->parser_package('TestParser');
! is($WEBTEST->parser_package, 'TestParser');
! is_deeply([ [ x => 'z' ], { 1 => 2 } ],
! [ $WEBTEST->parse('a = b') ]);
! # reset to default
! $WEBTEST->parser_package(undef);
! is_deeply([ [ ], { a => 'b' } ],
! [ $WEBTEST->parse('a = b') ]);
}
|