"Fossies" - the Fresh Open Source Software Archive 
Member "perl-5.32.1/cpan/HTTP-Tiny/t/003_agent.t" (18 Dec 2020, 1266 Bytes) of package /linux/misc/perl-5.32.1.tar.xz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 8;
7 use HTTP::Tiny;
8
9 # a couple tests to ensure that we get the default agent expected, the coorect
10 # agent when specified, and the correct agent when specifified with a space at
11 # the end of the string (as LWP::UserAgent does)
12
13
14 my $default = 'HTTP-Tiny/' . (HTTP::Tiny->VERSION || 0);
15
16 {
17 my $ua = HTTP::Tiny->new();
18 is $ua->agent, $default, 'default agent string is as expected';
19 }
20
21 {
22 my $ua = HTTP::Tiny->new(agent => 'something else');
23 is $ua->agent, 'something else', 'agent string is as expected';
24 }
25
26 {
27 my $ua = HTTP::Tiny->new(agent => 'something else ');
28 is
29 $ua->agent,
30 "something else $default",
31 'agent string is as properly appended to',
32 ;
33 }
34
35 {
36 my $ua = HTTP::Tiny->new();
37
38 is( HTTP::Tiny->_agent(), $default, 'check _agent on class' );
39 is $ua->_agent(), $default, 'check _agent on object';
40
41 $ua->agent(undef);
42 is $ua->agent, undef, 'agent string is empty';
43
44 $ua->agent('something else');
45 is $ua->agent, 'something else', 'agent string is as expected';
46
47 $ua->agent('something else ');
48 is
49 $ua->agent,
50 "something else $default",
51 'agent string is as properly appended to',
52 ;
53 }