CSS-Tiny
view release on metacpan or search on metacpan
t/02_main.t view on Meta::CPAN
my $rv = $trivial->write( 'test2.css' );
ok( $rv, '->write returned true' );
ok( -e 'test2.css', '->write actually created a file' );
# Clean up on unload
END {
unlink 'test2.css';
}
# Try to read the config back in
$read = CSS::Tiny->read( 'test2.css' );
isa_ok( $read, 'CSS::Tiny' );
# Check the structure of what we read back in
is_deeply( $trivial, $read, 'We get back what we wrote out' );
#####################################################################
# Check that two identical named styles overwrite-by-property, rather than
# replace-by-style, so that styles are relatively correctly merged.
my $mergable = <<'END_CSS';
FOO { test1: 1; }
FOO { test2: 2; }
END_CSS
my $merged = CSS::Tiny->read_string( $mergable );
ok( $merged, "CSS::Tiny reads mergable CSS ok" );
is_deeply( $merged, { FOO => { test1 => 1, test2 => 2 } }, "Mergable CSS merges ok" );
#####################################################################
# Check the HTML generation
my $html = CSS::Tiny->new();
isa_ok( $html, 'CSS::Tiny' );
is( $html->html, '', '->html returns empty string for empty stylesheet' );
$html->{'.foo'}->{bar} = 1;
is( $html->html . "\n", <<'END_HTML', '->html returns correct looking HTML' );
<style type="text/css">
<!--
.foo {
bar: 1;
}
-->
</style>
END_HTML
#####################################################################
# Check the XHTML generation
my $xhtml = CSS::Tiny->new;
isa_ok( $xhtml, 'CSS::Tiny' );
is( $xhtml->xhtml, '', '->xhtml returns empty string for empty stylesheet' );
$xhtml->{'.foo'}->{bar} = 1;
is( $html->xhtml . "\n", <<'END_XHTML', '->xhtml returns correct looking HTML' );
<style type="text/css">
/* <![CDATA[ */
.foo {
bar: 1;
}
/* ]]> */
</style>
END_XHTML
( run in 1.532 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )