Skip to content

Commit

Permalink
Add support for redefining data section markers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Jul 11, 2010
1 parent ab1b5b1 commit 7340c1b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions lib/TestML/Parser.pm
Expand Up @@ -18,6 +18,8 @@ method parse($testml) {
if (not $rc1) {
die "Parse TestML failed";
}
$TestML::Parser::Grammar::DataSection::block_marker = $doc.meta.data<BlockMarker>;
$TestML::Parser::Grammar::DataSection::point_marker = $doc.meta.data<PointMarker>;
my $rc2 = TestML::Parser::Grammar::DataSection.parse(
$data, :actions(TestML::Parser::Actions)
);
Expand Down
7 changes: 5 additions & 2 deletions lib/TestML/Parser/Grammar.pm
Expand Up @@ -207,6 +207,9 @@ token data_section {
#------------------------------------------------------------------------------#
grammar TestML::Parser::Grammar::DataSection is TestML::Parser::Grammar::Base;

our $block_marker = '===';
our $point_marker = '---';

token TOP { ^ <data_section> $ }

token data_section {
Expand All @@ -222,7 +225,7 @@ token block_header {
}

token block_marker {
'==='
$block_marker
}

token block_label {
Expand Down Expand Up @@ -251,7 +254,7 @@ token phrase_point {
}

token point_marker {
'---'
$point_marker
}

token point_name {
Expand Down
4 changes: 3 additions & 1 deletion lib/TestML/Runner.pm
Expand Up @@ -117,9 +117,11 @@ method parse_document () {

method _transform_modules() {
my @modules = (
$.bridge,
'TestML::Standard',
);
if $.bridge {
@modules.push($.bridge);
}
for @modules -> $module_name {
eval "use $module_name";
my $module = eval($module_name);
Expand Down
5 changes: 5 additions & 0 deletions t/markers.t
@@ -0,0 +1,5 @@
use TestML::Runner::TAP;

TestML::Runner::TAP.new(
document => 'testml-tml/markers.tml',
).run();
9 changes: 5 additions & 4 deletions t/parse-testml-document.t
@@ -1,14 +1,14 @@
use v6;
use Test;
plan 22;
plan 23;

use TestML::Parser;

my $testml = '
%TestML: 1.0
# A comment
%TestML: 1.0 #A line comment
%Plan: 2
%Title: O HAI TEST
%PointMarker: +++ #A line comment
*input.uppercase() == *output;
Expand All @@ -27,7 +27,8 @@ try {
is $match.meta.data<TestML>, '1.0', 'Version parses';
is $match.meta.data<Plan>, '2', 'Plan parses';
is $match.meta.data<Title>, 'O HAI TEST', 'Title parses';
is $match.meta.data<PointMarker>, '+++', 'PointMarker parses';
is $match.meta.data<BlockMarker>, '===', 'BlockMarker defaults';
is $match.meta.data<PointMarker>, '---', 'PointMarker defaults';

is $match.test.statements.elems, 1, 'One test statement';
my $statement = $match.test.statements[0];
Expand Down

0 comments on commit 7340c1b

Please sign in to comment.