1#!perl -Tw
2
3package Foo;
4
5sub new { my $class = shift; return bless [@_], $class; }
6
7package main;
8
9use warnings;
10use strict;
11
12use Test::More tests => 7;
13
14use Carp::Assert::More;
15
16use Test::Exception;
17
18my $FAILED = qr/Assertion failed/;
19
20# {} is not an arrayref.
21throws_ok( sub { assert_arrayref( {} ) }, $FAILED );
22
23# A ref to a hash with stuff in it is not an arrayref.
24my $ref = { foo => 'foo', bar => 'bar' };
25throws_ok( sub { assert_arrayref( $ref ) }, $FAILED );
26
27# 3 is not an arrayref.
28throws_ok( sub { assert_arrayref( 3 ) }, $FAILED );
29
30# [] is an arrayref.
31lives_ok( sub { [] } );
32
33# A ref to a list with stuff in it is an arrayref.
34my @ary = ('foo', 'bar', 'baaz');
35lives_ok( sub { assert_arrayref( \@ary ) } );
36
37# A coderef is not an arrayref.
38my $coderef = sub {};
39throws_ok( sub { assert_arrayref( $coderef ) }, $FAILED );
40
41# Foo->new->isa("ARRAY") returns true, so do we
42lives_ok( sub { assert_arrayref( Foo->new ) } );
43
44exit 0;
45