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 42 43 44 45 46 47 48 49
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 10;
use Test::Exception;
BEGIN {
use_ok('Forest::Tree');
};
my $t = Forest::Tree->new();
isa_ok($t, 'Forest::Tree');
# test some errors
throws_ok {
$t->add_child(undef);
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
throws_ok {
$t->add_child([]);
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
throws_ok {
$t->add_child({});
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
throws_ok {
$t->add_child(bless {} => 'Foo');
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
throws_ok {
$t->insert_child_at(undef);
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
throws_ok {
$t->insert_child_at([]);
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
throws_ok {
$t->insert_child_at({});
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
throws_ok {
$t->insert_child_at(bless {} => 'Foo');
} qr/Child parameter must be a Forest\:\:Tree not/, '... throws exception';
|