File: 01-smart-uris.t

package info (click to toggle)
liburi-smarturi-perl 0.032-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 2,301; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!perl

use strict;
use warnings;
use Test::More tests => 10 + 1;
use Test::NoWarnings;
use Test::Fatal 'exception';

use URI::SmartURI;
use URI;

my $uri = URI::SmartURI->new('http://www.catalystframework.org/calendar',
    { reference => 'http://www.catalystframework.org/' }
);

is($uri, 'http://www.catalystframework.org/calendar', 'stringification');

is($uri->hostless, '/calendar', '$uri->hostless');

ok($uri->hostless->eq('/calendar'), '$uri->eq 1');
ok($uri->hostless->eq(URI::SmartURI->new('/calendar', 'http')), '$uri->eq 2');
ok($uri->hostless->eq(URI->new('/calendar', 'http')), '$uri->eq 3');

is($uri->relative, 'calendar', '$uri->relative');

is($uri->absolute, 'http://www.catalystframework.org/calendar', '$uri->absolute');

is(
    $uri->relative->absolute->hostless->relative->absolute,
    'http://www.catalystframework.org/calendar',
    'sticky reference URI'
);

my $exception = exception {
    is $uri->can('can'), \&URI::SmartURI::can,
        '->can resolves itself';
};

is $exception, undef, '->can resolves itself without dying';

# vim: expandtab shiftwidth=4 ts=4 tw=80: