6 use Test::More tests=>23;
9 use_ok( 'WWW::Mechanize::Link' );
14 WWW::Mechanize::Link->new(
15 'url.html', 'text', 'name', 'frame', 'http://base.example.com/', { alt => 'alt text' } );
17 isa_ok( $link, 'WWW::Mechanize::Link' );
18 is( scalar @$link, 6, 'Should have five elements' );
20 # Test the new-style accessors
21 is( $link->url, 'url.html', 'url() works' );
22 is( $link->text, 'text', 'text() works' );
23 is( $link->name, 'name', 'name() works' );
24 is( $link->tag, 'frame', 'tag() works' );
25 is( $link->base, 'http://base.example.com/', 'base() works' );
26 is( $link->attrs->{alt}, 'alt text', 'attrs() works' );
28 # Order of the parms in the blessed array is important for backwards compatibility.
29 is( $link->[0], 'url.html', 'parm 0 is url' );
30 is( $link->[1], 'text', 'parm 1 is text' );
31 is( $link->[2], 'name', 'parm 2 is name' );
32 is( $link->[3], 'frame', 'parm 3 is tag' );
33 is( $link->[4], 'http://base.example.com/', 'parm 4 is base' );
36 isa_ok( $URI, 'URI::URL', 'URI is proper type' );
37 is( $URI->rel, 'url.html', 'Short form of the url' );
38 is( $link->url_abs, 'http://base.example.com/url.html', 'url_abs works' );
43 my $link = WWW::Mechanize::Link->new( {
48 base => 'http://base.example.com/',
49 attrs => { alt => 'alt text' },
52 is( $link->url, 'url.html', 'url() works' );
53 is( $link->text, 'text', 'text() works' );
54 is( $link->name, 'name', 'name() works' );
55 is( $link->tag, 'frame', 'tag() works' );
56 is( $link->base, 'http://base.example.com/', 'base() works' );
57 is( $link->attrs->{alt}, 'alt text', 'attrs() works' );