Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add some basic CSSGrammar tests. Fix @page rule
  • Loading branch information
dwarring committed Aug 16, 2016
1 parent 22ed552 commit 2300b77
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion categories/parsers/CSSGrammar.pm
Expand Up @@ -66,7 +66,7 @@ grammar CSSGrammar {
rule media_type { <cssident> }
rule media_rules { '{' ~ '}' <ruleset>* }

rule page {:i'@page' [':'<cssident>]? <declarations> }
rule page {:i'@page' [':'<cssident>]? '{' ~ '}' <declarations> }

# Comments and whitespace.
token comment {'<!--' .*? '-->' | '/*' .*? '*/'}
Expand Down
24 changes: 24 additions & 0 deletions t/categories/parsers/CSSGrammar.t
@@ -0,0 +1,24 @@
#!/usr/bin/env perl6

use v6;
use Test;

# A simple string parser is defined here:
use lib 'categories/parsers';
use CSSGrammar;

plan(8);

# Save these to variables just for brevity
my $grammar = CSSGrammar;

ok $grammar.parse(q<H1 { color: blue; }>), "ruleset, basic";
ok $grammar.parse(q<42 7% 12.5cm -1em 2 ex 45deg 10s 50Hz 'ZZ' counter(a,b) counters(p,'s') attr(data-foo)>, :rule<expr>), "expressions";
ok $grammar.parse(q<A:Visited + .some_class:link + H1[lang=fr]>, :rule<selector>), "selector";
ok $grammar.parse(q<@import url('file:///etc/passwd');>, :rule<import>), 'import url';
ok $grammar.parse(q<@import '/etc/passwd';>), 'import file';
ok $grammar.parse(q<body{margin: 1cm; color: red;}>, :rule<ruleset>), 'ruleset';
ok $grammar.parse(q<@media print {body{margin: 1cm}}>), '@media rule';
ok $grammar.parse(q<@Page :first { margin-right: 2cm }>), '@page rule';

# vim: sw=4 softtabstop=4 ai expandtab filetype=perl6

0 comments on commit 2300b77

Please sign in to comment.