Skip to content

Commit

Permalink
Fix to bug found by Andrew Rodland: t+
Browse files Browse the repository at this point in the history
  • Loading branch information
- committed Nov 13, 2012
1 parent 266b25b commit f310016
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions r2/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ t/randal.t
t/rewrite.t
t/sequence.t
t/sequence2.t
t/stuifzand.t
t/syn_engine.t
t/syn_stuifzand.t
t/thin_eq.t
Expand Down
2 changes: 1 addition & 1 deletion r2/lib/Marpa/R2/Stuifzand.pm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ sub do_empty_rule {
my ( undef, $lhs, undef, $adverb_list ) = @_;
my $action = $adverb_list->{action};
# mask not needed
return [ { lhs => $lhs, rhs => [], @{ $action || [] } } ];
return [ { lhs => $lhs, rhs => [], defined($action) ? (action => $action) : () } ];
}

sub do_quantified_rule {
Expand Down
50 changes: 50 additions & 0 deletions r2/t/stuifzand.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/perl
# Copyright 2012 Jeffrey Kegler
# This file is part of Marpa::R2. Marpa::R2 is free software: you can
# redistribute it and/or modify it under the terms of the GNU Lesser
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Marpa::R2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser
# General Public License along with Marpa::R2. If not, see
# http://www.gnu.org/licenses/.

# Regressions tests involving the Stuizand interface

use 5.010;
use strict;
use warnings;
use Test::More tests => 1;

use lib 'inc';
use Marpa::R2::Test;

## no critic (ErrorHandling::RequireCarping);

# Marpa::R2::Display
# name: Stuifzand Synopsis

use Marpa::R2;

# Regression test of bug found by Andrew Rodland

my $g = Marpa::R2::Grammar->new(
{ actions => "main",
start => "start",
rules => "start ::= action => act"
}
);
$g->precompute;
my $r = Marpa::R2::Recognizer->new( { grammar => $g } );
my $value_ref = $r->value;
my $value = defined $value_ref ? ${$value_ref} : 'No parse';
sub act {123};

Test::More::is( $value, '123', 'Rodland regression test' );

# vim: expandtab shiftwidth=4:

0 comments on commit f310016

Please sign in to comment.