Skip to content

Commit ac1f8a4

Browse files
committed
Streamline tests, etc
1 parent dd7a27b commit ac1f8a4

File tree

7 files changed

+73
-73
lines changed

7 files changed

+73
-73
lines changed

lib/CSS/Specification/Compiler/RakuAST/Grammars.rakumod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,5 +285,5 @@ method build-grammar(@grammar-id) {
285285
:$name,
286286
:scope<unit>,
287287
:$body,
288-
).&expression.&statements;
288+
);
289289
}

lib/CSS/Specification/Compiler/Runtime/Actions.rakumod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ method any-function($/) {
4646

4747
multi method declaration($/ where $<any-declaration>) {
4848
with $<any-declaration>.ast -> $ast {
49-
my ($key, $value) = $ast.kv;
49+
my :($key, $value) := $ast.kv;
5050
if $.lax {
5151
make $key => $value;
5252
}

lib/CSS/Specification/Compiler/Runtime/Grammar.rakumod

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ token val( $*EXPR, $*USAGE='' ) {
66
<proforma> || <rx={$*EXPR}> || <usage>
77
}
88

9-
token seen($opt) {
10-
<?{@*SEEN[$opt]++}>
11-
}
12-
139
token usage {
1410
<any-args>
1511
}
@@ -27,8 +23,6 @@ token frequency:sym<zero> {<number> <?{ +$<number> == 0 }> }
2723
token integer {$<sign>=< + - >?<uint>}
2824
token number {<num><!before ['%'|\w]>}
2925
token uri {<url>}
30-
multi token keyw {<id=.Ident>} # keyword (case insensitive)
31-
# work-around for RT#117955 - conjunctive '&&' capture"
32-
multi token keyw($rx) {<id={$rx}>} # keyword (case insensitive)
26+
token keyw {<id=.Ident>} # keyword (case insensitive)
3327
token identifier {<name>} # identifier (case sensitive)
3428
rule identifiers {[ <identifier> ]+} # E.g. font name: Times New Roman

t/00compile.t

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,23 @@ for (
130130
''),
131131
},
132132
'property-spec' => {input => "'content'\tnormal | none | [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit\tnormal :before and :after pseudo-elements no",
133-
ast => {:props['content'],
134-
:default<normal>,
135-
:spec{:alt[
136-
{:keywords<normal none>},
137-
{:occurs["+",
138-
{:group(${:alt[{:rule<string>}, {:rule<uri>}, {:rule<counter>}, {:rule<attr>}, {:keywords<open-quote close-quote no-open-quote no-close-quote>}]})}]},
139-
{:keywords["inherit"]},
140-
]},
141-
:synopsis('normal | none | [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit'),
142-
:!inherit,
143-
},
133+
:ast{:props['content'],
134+
:default<normal>,
135+
:spec{
136+
:alt[
137+
{:keywords<normal none>},
138+
{:occurs["+",
139+
{:group{
140+
:alt[{:rule<string>}, {:rule<uri>}, {:rule<counter>}, {:rule<attr>}, {:keywords<open-quote close-quote no-open-quote no-close-quote>}]}
141+
},
142+
]
143+
},
144+
{:keywords["inherit"]},
145+
]
146+
},
147+
:synopsis('normal | none | [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit'),
148+
:!inherit,
149+
},
144150
rule-refs => [<attr counter identifier string uri>],
145151
deparse => join("\n",
146152
'#| content: normal | none | [ <string> | <uri> | <counter> | attr(<identifier>) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit',

t/build.t

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,36 @@ my $input-path = $*SPEC.catfile('examples', 'css21-aural.txt');
2626
my CSS::Specification::Compiler $compiler .= new;
2727
$compiler.load-defs($input-path);
2828

29+
sub name(RakuAST::Package $p, $j) {
30+
$p.name.parts>>.name.join: $j
31+
}
32+
2933
my @summary = CSS::Specification::Build::summary( :$input-path );
3034
is +@summary, 25, 'number of summary items';
31-
is-deeply [@summary.grep({ .<box> })], [{:box, :!inherit, :name<border-color>, :edges["border-top-color", "border-right-color", "border-bottom-color", "border-left-color"], :synopsis("[ <color> | transparent ]\{1,4}")},], 'summary item';
35+
is-deeply @summary.first(*.<box>), {:box, :!inherit, :name<border-color>, :edges["border-top-color", "border-right-color", "border-bottom-color", "border-left-color"], :synopsis("[ <color> | transparent ]\{1,4}")}, 'summary item';
3236

3337
{
3438
CSS::Specification::Build::generate( 'grammar', $grammar-name, :$input-path );
3539
}.&capture: 't/lib/Test/CSS/Aural/Spec/Grammar.rakumod';
3640
lives-ok {require ::($grammar-name)}, "$grammar-name compilation";
3741

38-
my RakuAST::StatementList $grammar = $compiler.build-grammar(@grammar-id);
39-
40-
't/lib/Test/CSS/Aural/Spec/GrammarAST.rakumod'.IO.spurt: $grammar.DEPARSE
41-
.subst(/";\n;"/, ';', :g) # work-around for https://github.com/rakudo/rakudo/issues/5991
42-
.subst(/'Grammar'/, 'GrammarAST')
43-
.subst(/' '/, ' ', :g);
42+
@grammar-id.tail ~= 'AST'; # parallel build for now
43+
my RakuAST::Package $grammar = $compiler.build-grammar(@grammar-id);
44+
"t/lib/{$grammar.&name('/')}.rakumod".IO.spurt: $grammar.DEPARSE
45+
.subst(/";\n;"/, ';', :g); # work-around for https://github.com/rakudo/rakudo/issues/5991
4446

4547
{
4648
CSS::Specification::Build::generate( 'actions', $actions-name, :$input-path );
4749
}.&capture: 't/lib/Test/CSS/Aural/Spec/Actions.rakumod';
4850
lives-ok {require ::($actions-name)}, "$actions-name compilation";
4951

52+
@actions-id.tail ~= 'AST'; # parallel build for now
5053
my RakuAST::Package $actions-pkg = $compiler.build-actions(@actions-id);
51-
52-
't/lib/Test/CSS/Aural/Spec/ActionsAST.rakumod'.IO.spurt: $actions-pkg.DEPARSE;
54+
"t/lib/{$actions-pkg.&name('/')}.rakumod".IO.spurt: $actions-pkg.DEPARSE;
5355

5456
my $role-name = @role-id.join: '::';
5557
my RakuAST::Package $interface-pkg = $compiler.build-role(@role-id);
56-
't/lib/Test/CSS/Aural/Spec/Interface.rakumod'.IO.spurt: $interface-pkg.DEPARSE;
58+
"t/lib/{$interface-pkg.&name('/')}.rakumod".IO.spurt: $interface-pkg.DEPARSE;
5759
lives-ok {require ::($role-name)}, "$role-name compilation";
5860

5961
dies-ok {require ::("Test::CSS::Aural::BadGrammar")}, 'grammar composition, unimplemented interface - dies';
@@ -67,29 +69,27 @@ lives-ok {$actions = (require ::("Test::CSS::Aural::Actions")).new}, 'class comp
6769
ok $actions.defined, '::("Test::CSS::Aural::Actions").new';
6870

6971
for ('.aural-test { stress: 42; speech-rate: fast; volume: inherit; voice-family: female; }' =>
70-
{ast => { :stylesheet[
71-
:ruleset{
72-
:selectors[ :selector[ :simple-selector[ :class<aural-test> ] ] ],
73-
:declarations[
74-
:property{ :ident<stress>, :expr[{ :num(42) }] },
75-
:property{ :ident<speech-rate>, :expr[{ :keyw<fast> }] },
76-
:property{ :ident<volume>, :expr[{ :keyw<inherit> }] },
77-
:property{ :ident<voice-family>, :expr[{ :keyw<female> }] },
78-
],
79-
}
80-
]}
81-
},
72+
ast => :stylesheet[
73+
:ruleset{
74+
:selectors[ :selector[ :simple-selector[ :class<aural-test> ] ] ],
75+
:declarations[
76+
:property{ :ident<stress>, :expr[ :num(42) ] },
77+
:property{ :ident<speech-rate>, :expr[ :keyw<fast> ] },
78+
:property{ :ident<volume>, :expr[ :keyw<inherit> ] },
79+
:property{ :ident<voice-family>, :expr[ :keyw<female> ] },
80+
],
81+
}
82+
],
8283
'.boxed-test { border-color: #aaa }' =>
83-
{ast => { :stylesheet[
84+
ast => :stylesheet[
8485
:ruleset{
85-
:selectors[ :selector[ :simple-selector[{:class<boxed-test>}] ]],
86+
:selectors[ :selector[ :simple-selector[ :class<boxed-test> ] ]],
8687
:declarations[ :property{
8788
:ident<border-color>,
88-
:expr[{ :rgb[ :num(170), :num(170), :num(170) ]}]}],
89+
:expr[ :rgb[ :num(170), :num(170), :num(170) ]]}],
8990
}
90-
]}
91-
},
92-
) {
91+
],
92+
) {
9393
my ($input, $expected) = .kv;
9494

9595
&CSS::Grammar::Test::parse-tests($aural-class, $input,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
unit class Test::CSS::Aural::Spec::Actions;
1+
unit class Test::CSS::Aural::Spec::ActionsAST;
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
unit grammar Test::CSS::Aural::Spec::GrammarAST;
22
#| azimuth: <angle> | [[ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards
33
rule decl:sym<azimuth> { :i (azimuth) ":" <val(/<expr=.expr-azimuth> /, &?ROUTINE.WHY)> }
4-
rule expr-azimuth { :i <angle> || [[:my @S; [["left-side" | "far-left" | left | "center-left" | center | "center-right" | right | "far-right" | "right-side" ]& <keyw>]<!{
5-
@S[0]++
4+
rule expr-azimuth { :i <angle> || [[:my @S; [["left-side" | "far-left" | left | "center-left" | center | "center-right" | right | "far-right" | "right-side" ]& <keyw>]<!{
5+
@S[0]++
66
}>| behind & <keyw><!{
7-
@S[1]++
8-
}>]+] || [leftwards | rightwards ]& <keyw> }
7+
@S[1]++
8+
}>]+] || [leftwards | rightwards ]& <keyw> }
99
#| cue-after: <uri> | none
1010
rule decl:sym<cue-after> { :i ("cue-after") ":" <val(/<expr=.expr-cue-after> /, &?ROUTINE.WHY)> }
11-
rule expr-cue-after { :i <uri> || none & <keyw> }
11+
rule expr-cue-after { :i <uri> || none & <keyw> }
1212
#| cue-before: <uri> | none
1313
rule decl:sym<cue-before> { :i ("cue-before") ":" <val(/<expr=.expr-cue-before> /, &?ROUTINE.WHY)> }
14-
rule expr-cue-before { :i <uri> || none & <keyw> }
14+
rule expr-cue-before { :i <uri> || none & <keyw> }
1515
#| cue: [ 'cue-before' || 'cue-after' ]
1616
rule decl:sym<cue> { :i (cue) ":" <val(/<expr=.expr-cue> /, &?ROUTINE.WHY)> }
17-
rule expr-cue { :i [[:my @S; <expr-cue-before><!{
18-
@S[0]++
17+
rule expr-cue { :i [[:my @S; <expr-cue-before><!{
18+
@S[0]++
1919
}>| <expr-cue-after><!{
20-
@S[1]++
20+
@S[1]++
2121
}>]+] }
2222
#| elevation: <angle> | below | level | above | higher | lower
2323
rule decl:sym<elevation> { :i (elevation) ":" <val(/<expr=.expr-elevation> /, &?ROUTINE.WHY)> }
24-
rule expr-elevation { :i <angle> || [below | level | above | higher | lower ]& <keyw> }
24+
rule expr-elevation { :i <angle> || [below | level | above | higher | lower ]& <keyw> }
2525
#| pause: [ [<time> | <percentage>]{1,2} ]
2626
rule decl:sym<pause> { :i (pause) ":" <val(/<expr=.expr-pause> /, &?ROUTINE.WHY)> }
2727
rule expr-pause { :i [[<time> || <percentage> ]** 1..2] }
2828
#| pause-after: <time> | <percentage>
2929
rule decl:sym<pause-after> { :i ("pause-after") ":" <val(/<expr=.expr-pause-after> /, &?ROUTINE.WHY)> }
30-
rule expr-pause-after { :i <time> || <percentage> }
30+
rule expr-pause-after { :i <time> || <percentage> }
3131
#| pause-before: <time> | <percentage>
3232
rule decl:sym<pause-before> { :i ("pause-before") ":" <val(/<expr=.expr-pause-before> /, &?ROUTINE.WHY)> }
33-
rule expr-pause-before { :i <time> || <percentage> }
33+
rule expr-pause-before { :i <time> || <percentage> }
3434
#| pitch-range: <number>
3535
rule decl:sym<pitch-range> { :i ("pitch-range") ":" <val(/<expr=.expr-pitch-range> /, &?ROUTINE.WHY)> }
3636
rule expr-pitch-range { :i <number> }
3737
#| pitch: <frequency> | x-low | low | medium | high | x-high
3838
rule decl:sym<pitch> { :i (pitch) ":" <val(/<expr=.expr-pitch> /, &?ROUTINE.WHY)> }
39-
rule expr-pitch { :i <frequency> || ["x-low" | low | medium | high | "x-high" ]& <keyw> }
39+
rule expr-pitch { :i <frequency> || ["x-low" | low | medium | high | "x-high" ]& <keyw> }
4040
#| play-during: <uri> [ mix || repeat ]? | auto | none
4141
rule decl:sym<play-during> { :i ("play-during") ":" <val(/<expr=.expr-play-during> /, &?ROUTINE.WHY)> }
42-
rule expr-play-during { :i <uri> [[:my @S; mix & <keyw><!{
43-
@S[0]++
42+
rule expr-play-during { :i <uri> [[:my @S; mix & <keyw><!{
43+
@S[0]++
4444
}>| repeat & <keyw><!{
45-
@S[1]++
46-
}>]+]? || [auto | none ]& <keyw> }
45+
@S[1]++
46+
}>]+]? || [auto | none ]& <keyw> }
4747
#| richness: <number>
4848
rule decl:sym<richness> { :i (richness) ":" <val(/<expr=.expr-richness> /, &?ROUTINE.WHY)> }
4949
rule expr-richness { :i <number> }
@@ -61,7 +61,7 @@ rule decl:sym<speak-punctuation> { :i ("speak-punctuation") ":" <val(/<expr=.exp
6161
rule expr-speak-punctuation { :i [code | none ]& <keyw> }
6262
#| speech-rate: <number> | x-slow | slow | medium | fast | x-fast | faster | slower
6363
rule decl:sym<speech-rate> { :i ("speech-rate") ":" <val(/<expr=.expr-speech-rate> /, &?ROUTINE.WHY)> }
64-
rule expr-speech-rate { :i <number> || ["x-slow" | slow | medium | fast | "x-fast" | faster | slower ]& <keyw> }
64+
rule expr-speech-rate { :i <number> || ["x-slow" | slow | medium | fast | "x-fast" | faster | slower ]& <keyw> }
6565
#| stress: <number>
6666
rule decl:sym<stress> { :i (stress) ":" <val(/<expr=.expr-stress> /, &?ROUTINE.WHY)> }
6767
rule expr-stress { :i <number> }
@@ -71,22 +71,22 @@ rule expr-voice-family { :i [<generic-voice> || <specific-voice> ]+% <op(",")> }
7171
#| male | female | child
7272
rule generic-voice { :i [male | female | child ]& <keyw> }
7373
#| <identifier> | <string>
74-
rule specific-voice { :i <identifier> || <string> }
74+
rule specific-voice { :i <identifier> || <string> }
7575
#| volume: <number> | <percentage> | silent | x-soft | soft | medium | loud | x-loud
7676
rule decl:sym<volume> { :i (volume) ":" <val(/<expr=.expr-volume> /, &?ROUTINE.WHY)> }
77-
rule expr-volume { :i <number> || <percentage> || [silent | "x-soft" | soft | medium | loud | "x-loud" ]& <keyw> }
77+
rule expr-volume { :i <number> || <percentage> || [silent | "x-soft" | soft | medium | loud | "x-loud" ]& <keyw> }
7878
#| border-color: [ <color> | transparent ]{1,4}
7979
rule decl:sym<border-color> { :i ("border-color") ":" <val(/<expr=.expr-border-color> /, &?ROUTINE.WHY)> }
8080
rule expr-border-color { :i [<color> || transparent & <keyw> ]** 1..4 }
8181
#| border-top-color: <color> | transparent
8282
rule decl:sym<border-top-color> { :i ("border-top-color") ":" <val(/<expr=.expr-border-top-color> /, &?ROUTINE.WHY)> }
83-
rule expr-border-top-color { :i <color> || transparent & <keyw> }
83+
rule expr-border-top-color { :i <color> || transparent & <keyw> }
8484
#| border-top-color: <color> | transparent
8585
rule decl:sym<border-right-color> { :i ("border-right-color") ":" <val(/<expr=.expr-border-right-color> /, &?ROUTINE.WHY)> }
86-
rule expr-border-right-color { :i <color> || transparent & <keyw> }
86+
rule expr-border-right-color { :i <color> || transparent & <keyw> }
8787
#| border-top-color: <color> | transparent
8888
rule decl:sym<border-bottom-color> { :i ("border-bottom-color") ":" <val(/<expr=.expr-border-bottom-color> /, &?ROUTINE.WHY)> }
89-
rule expr-border-bottom-color { :i <color> || transparent & <keyw> }
89+
rule expr-border-bottom-color { :i <color> || transparent & <keyw> }
9090
#| border-top-color: <color> | transparent
9191
rule decl:sym<border-left-color> { :i ("border-left-color") ":" <val(/<expr=.expr-border-left-color> /, &?ROUTINE.WHY)> }
92-
rule expr-border-left-color { :i <color> || transparent & <keyw> }
92+
rule expr-border-left-color { :i <color> || transparent & <keyw> }

0 commit comments

Comments
 (0)