File: arrayrefs.t

package info (click to toggle)
libmoosex-types-stringlike-perl 0.003-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 200; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 748 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
use 5.006;
use strict;
use warnings;
use Test::More 0.96;

use MooseX::Types::Stringlike qw/Stringable Stringlike ArrayRefOfStringable ArrayRefOfStringlike/;

{
  package BlessedPath;
  use overload q{""} => sub { "${$_[0]}" };
  sub new { my ($class, $path) = @_; return bless \$path, $class; }
}

my $stringable = [ map { BlessedPath->new($_) } ('./t', './xt') ];

ok(is_ArrayRefOfStringable($stringable), 'arrayref of stringable things is a ArrayRefOfStringable');

my $stringlike = to_ArrayRefOfStringlike($stringable);
ok(is_ArrayRefOfStringlike($stringlike), 'can coerce ArrayRefOfStringable to ArrayRefOfStringlike');
is_deeply($stringlike, [ './t', './xt' ], 'ArrayRefOfStringable properly coerced to ArrayRefOfStringlike');

done_testing;