Help language development. Donate to The Perl Foundation

CSS::Properties zef:dwarring last updated on 2022-09-29

use v6;
use Test;
plan 16;

use CSS::Properties::PropertyInfo;
use CSS::Properties;
use CSS::Units :pt, :px;

my CSS::Properties::PropertyInfo $sample-prop .= new( :name<background-image> );

is-deeply $, 'background-image', '$';
is-deeply $, False, '$';
is-deeply $sample-prop.inherit, False, '$prop.inherit';
is-deeply $sample-prop.synopsis, '<uri> | none', '$prop.synopsis';
is-deeply $sample-prop.default, "none", '$prop.default';

my CSS::Properties::PropertyInfo %edges = <top right bottom left>.map: {
    $_ => :name('margin-' ~ $_);
dies-ok { :name<margin> )}, 'missing edges detected';
$sample-prop = :name<margin>, :%edges );

is-deeply $, 'margin', '$';
is-deeply $, True, '$';
is-deeply $sample-prop.inherit, False, '$prop.inherit';
is-deeply $sample-prop.synopsis, '<margin-width>{1,4}', '$prop.synopsis';
is-deeply $, 'margin-top', '$';

my $css = :margin(5pt), :width(4px);
is $css.width, 4px, 'declared property';
is $css.height, 'auto', 'defaulted property';
is $css.write, 'margin:5pt; width:4px;', 'write';
my $css2 = :style("margin:7pt; height:5px");
is $css2.write, 'height:5px; margin:7pt;', 'write';

is $css2.write, 'height:5px; margin:5pt; width:4px;', 'copy/write';