HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //root/.cpanm/latest-build/HTTP-Tiny-0.090/t/003_agent.t
#!perl

use strict;
use warnings;

use Test::More tests => 8;
use HTTP::Tiny;

# a couple tests to ensure that we get the default agent expected, the correct
# agent when specified, and the correct agent when specified with a space at
# the end of the string (as LWP::UserAgent does)


my $default = 'HTTP-Tiny/' . (HTTP::Tiny->VERSION || 0);

{
    my $ua = HTTP::Tiny->new();
    is $ua->agent, $default, 'default agent string is as expected';
}

{
    my $ua = HTTP::Tiny->new(agent => 'something else');
    is $ua->agent, 'something else', 'agent string is as expected';
}

{
    my $ua = HTTP::Tiny->new(agent => 'something else ');
    is
        $ua->agent,
        "something else $default",
        'agent string is as properly appended to',
        ;
}

{
    my $ua = HTTP::Tiny->new();

    is( HTTP::Tiny->_agent(), $default, 'check _agent on class' );
    is $ua->_agent(), $default, 'check _agent on object';

    $ua->agent(undef);
    is $ua->agent, undef, 'agent string is empty';

    $ua->agent('something else');
    is $ua->agent, 'something else', 'agent string is as expected';

    $ua->agent('something else ');
    is
        $ua->agent,
        "something else $default",
        'agent string is as properly appended to',
        ;
}