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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
use strict;
use warnings;
use Test::More tests => 9;
use SVG;
my $svg = SVG->new( width => 100, height => 100 );
my $pi = $svg->pi( "Hello world", "I am a PI" );
ok( $pi, "PI: add 2 arbitrary processing instructions" );
ok(
$svg->rect(
x => 0,
y => 0,
width => 10,
height => 10,
fill => 'red',
stroke => 'brick'
),
"add a drawing element"
);
$svg->rect(
x => 0,
y => 0,
width => 10,
height => 10,
fill => 'red',
stroke => 'brick'
);
$svg->rect(
x => 0,
y => 0,
width => 10,
height => 10,
fill => 'red',
stroke => 'brick'
);
$svg->rect(
x => 0,
y => 0,
width => 10,
height => 10,
fill => 'red',
stroke => 'brick'
);
$svg->rect(
x => 0,
y => 0,
width => 10,
height => 10,
fill => 'red',
stroke => 'brick'
);
$svg->rect(
x => 0,
y => 0,
width => 10,
height => 10,
fill => 'red',
stroke => 'brick'
);
$svg->rect(
x => 0,
y => 0,
width => 10,
height => 10,
fill => 'red',
stroke => 'brick'
);
my $xml = $svg->xmlify();
ok( $xml, "serialize the svg" );
like( $xml, qr/<\?Hello\sworld\?>/,
"serialize arbitrary processing instruction 1" );
like( $xml, qr/<\?I\sam\sa\sPI\?>/,
"serialize arbitrary processing instruction 2" );
like( $xml, qr/rect/, "PI 2: add non-PI elements" );
is( scalar @{ $svg->pi }, 2, "PI 3 - fetch PI array" );
$svg->pi("Third PI entry");
$xml = $svg->xmlify();
like( $xml, qr/<\?Third\sPI\sentry\?>/, "pi 2" );
is( scalar @{ $svg->pi }, 3, "PI 3" );
|