File: path-segments.t

package info (click to toggle)
liburi-perl 5.30-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 948 kB
  • sloc: perl: 3,936; makefile: 4
file content (33 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (5)
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
use strict;
use warnings;

use Test::More 'no_plan';

use URI ();

{
    my $u = URI->new("http://www.example.org/a/b/c");

    is_deeply [$u->path_segments], ['', qw(a b c)], 'path_segments in list context';
    is $u->path_segments, '/a/b/c', 'path_segments in scalar context';

    is_deeply [$u->path_segments('', qw(z y x))], ['', qw(a b c)], 'set path_segments in list context';
    is $u->path_segments('/i/j/k'), '/z/y/x', 'set path_segments in scalar context';

    $u->path_segments('', qw(q r s));
    is $u->path_segments, '/q/r/s', 'set path_segments in void context';
}

{
    my $u = URI->new("http://www.example.org/abc");
    $u->path_segments('', '%', ';', '/');
    is $u->path_segments, '/%25/%3B/%2F', 'escaping special characters';
}

{
    my $u = URI->new("http://www.example.org/abc;param1;param2");
    my @ps = $u->path_segments;
    isa_ok $ps[1], 'URI::_segment';
    $u->path_segments(@ps);
    is $u->path_segments, '/abc;param1;param2', 'dealing with URI segments';
}