summaryrefslogtreecommitdiff
path: root/t/10-sub.t
blob: b7530e69c3ca7bd9c6ecad8b5d3c8f5035f6a4aa (plain)
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
#!/usr/bin/perl

use strict;

use Test::More;

eval "use Tie::Sub";

plan skip_all => "Tie::Sub required" if $@;

plan tests => 4;

use_ok( 'Graphics::ColorNames', '2.10', qw( all_schemes ) );

tie my %colors, 'Graphics::ColorNames';

# Test handling of non-existent color names

ok( !defined $colors{NonExistentColorName} );
ok( !exists $colors{NonExistentColorName} );

# Test dynamic loading of scheme

my $colorobj = tied(%colors);
$colorobj->load_scheme(
    sub {
        return 0x123456;
    }
);
ok( $colors{NonExistentColorName} eq '123456' );