";
}
sub token {
state $empty_line;
loop {
if @tokens {
if @tokens[0] ~~ '#' {
# skip comment
@tokens = ();
next;
$line_number++;
# print "# $line_number: $line\n";
@tokens = $line ~~ m:g:perl5 {(\w+|\s+|.+?)}; # \b doesn't work ???
@tokens = @tokens.map:{ ~$_ }; # force
}
}
sub optional_space {
my $word;
loop {
$word = token;
next if $word ~~ m:perl5/^\s/;
unshift @tokens, $word;
return;
}
}
sub sentence {
print ta
nsaction in progress" unless $self->transaction->count;
die "Mismatched transaction" unless $tran ~~ $self->transaction->last;
}
=head2 transaction_commit
Commit this transaction to storage - makes
nsaction in progress" unless $self->transaction->count;
die "Mismatched transaction" unless $tran ~~ $self->transaction->last;
}
=head2 transaction_end
Release the transaction on completion.
=cut
nsaction in progress" unless $self->transaction->count;
die "Mismatched transaction" unless $tran ~~ $self->transaction->last;
$self->transaction->pop;
return $self;
}
sub backend_ready { shift->{
logDebug("Check match: src " . scalar(@srcList) . ", dest " . scalar(@dstList));
return \@srcList ~~ \@dstList;
}
=head2 read_tables
Virtual method for reading table definitions.
=cut
sub read_ta
} $e->dependencies;
my @pendingNames = map { $_->name } @pending;
my @unsatisfied = grep { $_ ~~ @deps } @pendingNames;
my @existing = map { $_->name } $self->entity->list;
# Include current
y in list of available entries, so that we can allow self-reference
my @unresolved = grep { !($_ ~~ [@pendingNames, @existing, $e->name]) } @deps;
if(@unresolved) {
logError("%s unresolved (pen
a ~~ $b;
foreach (keys %$a) {
return if !match( $a->{$_}, $b->{$_} );
}
return 1;
}
# avoid smartmatch doing number matches on strings
# e.g. '5x' ~~
5 is true
return if looks_like_number($a) xor looks_like_number($b);
return $a ~~ $b;
}
1;
__END__
=pod
=encoding utf-8
=head1 NAME
Test::Magpie::Util - Internal utility functions for T
sub read_packet_chunk { #{{{
my ( $self, $first_bit ) = @_;
my ($packet_string);
given ($first_bit) {
when (/[\x70-\x7f]/) {
my $length = unpack "C*", $first_bit;
= keys %{$hessian_data};
my $datastructure = $hessian_data->{ $keys[0] };
given ( $keys[0] ) {
when (/call/) {
$hessian_message = $self->write_hessia
ed $data_hash->{'input_type_list'} and
not $data_hash->{'input_type_list'} ~~
$self->{'input_type_list'}) {
next;
id => $self->_request->get_cookie(name => 'session_id'));
if (!($self->_session->get_id() ~~
$self->_request->get_cookie(name => 'session_id'))) {
$self->_response->set_cook
r of elements). If C<$fields> is specified, the resulting document
will only include the fields given (and the C<_id> field) which can cut down on
wire traffic.
=head2 insert ($object, $options?)
y $i = 0; $i <= $#token; $i++ ) {
foreach ( $token[$i] ) {
if ( $preserve_caps ~~ q(1)
&& m{^\p{Lu}+(?:\N{APOSTROPHE})?$}msx )
{
next;
e given but it's too much typing.
=head1 SYNOPSIS
use Acme::Given::Hash;
my $result = $given ~~ gvn { $value1 => $scalar
, $value2 => do { ... }
} || $default ;
# is going to result in the same thing as:
my $result;
given($given) {
when ($value1) { $result = $scalar }
when ($value2) { $result = do{ ... }}
= $default }
};
# if you use an arrayref you can do more complex matching
$result = $given ~~ gvn [ 'scalar' => 'still works, just like the hash'
, qr{reg} => [qw{al
push @{$testrun{image}}, @{ $description ~~ dpath '/preconditions/*/mount[value eq "/"]/../image' };
push @{$testrun{image}}, @{ $description ~~ dpath '//root/precondition_type[value eq "a
];
}
my @testplan_elements;
foreach my $plan (@plans) {
given ($plan->{type})
{
when(['multitest', 'testrun']) { push
$isGap = $stock->is_gap (SEQNAME, $colNum)
Return true if a given (SEQNAME,column) co-ordinate is a gap.
=cut
# Return true if a given (rowname,column) co-ordinate is a gap
sub is_gap {
my ($se
'$lang'" unless exists $self->{languages}->{$lang}->{match}->{True};
return true if ($to_test ~~ $self->{languages}->{$lang}->{match}->{True});
return false;
}
sub _looks_false {
my $sel
'$lang'" unless exists $self->{languages}->{$lang}->{match}->{False};
return true if ($to_test ~~ $self->{languages}->{$lang}->{match}->{False});
return false;
}
1;
__END__
=pod
=encoding
um where { $^n % 2 == 0 }
my Str_not2b $hamlet;
$hamlet = 'isnt'; # Okay because 'isnt' ~~ /^[isnt|arent|amnot|aint]$/
$hamlet = 'amnt'; # Bzzzzzzzt! 'amnt' !~ /^[isnt|arent|amnot|a
use Rules::Common :profanity;
multi sub mesg (Str where /<profanity>/ $mesg is copy) {
$mesg ~~ s:g/<profanity>/[expletive deleted]/;
print $MESG_LOG: $mesg;
}
multi sub mesg (Str $mes
sures too. These means the same thing:
use Dog-{$^ver ~~ 1.2.1 | 1.3.4}-{$^auth ~~ /:i jrandom/};
use Dog-{$^ver ~~ Any}-{$^auth ~~ /^cpan\:/}
In any event, however you select the module, i
ector on
the right. Our example is roughly equivalent to this closure:
{ $_.does(Str) and $_ ~~ /^[isnt|arent|amnot|aint]$/; }
except that a subtype knows when to call itself.
A subtype is not
ot2b $hamlet;
$hamlet = 'isnt'; # Okay because 'isnt' ~~ /^[isnt|arent|amnot|aint]$/
$hamlet = 'amnt'; # Bzzzzzzzt! 'amnt' !~~ /^[isnt|arent|amnot|aint]$/
my EvenNum $n;
$n = 2;
:Common :profanity;
multi sub mesg ($mesg of Str where /<profanity>/ is copy) {
$mesg ~~ s:g/<profanity>/[expletive deleted]/;
print $MESG_LOG: $mesg;
}
multi sub mesg ($
}
grep_subfields { (tag) ~~ $sspec }
} grep_fields { (tag) ~~ $fspec }
# TODO: Benchmark: is it really faster ?
# map_fields {
# if ( (tag) ~~ $fspec ) {
# map_s
ubfields {
# if ( (tag) ~~ $sspec ) {
# with_value { $code->() }
# } else { () }
# }
# } else { () }
# } $rec
}
sub marawk (&$) {
my $code =
emplate::Element',
'BASE' => 'Excel::Template::Base',
);
my %isBuildable = map { $_ => ~~1 } qw(
WORKBOOK WORKSHEET
FORMAT BOLD HIDDEN ITALIC LOCKED OUTLINE SHADOW STRIKEOUT
IF
or '$class' ($filename) because $@\n";
}
$Loaded{$class} = ~~1;
}
return ~~1;
}
}
{
my @param_names = qw(name class isa);
sub register
{
rams{class} );
$Manifest{$name} = $params{class};
$isBuildable{$name} = ~~1;
return ~~1;
}
}
sub _create
{
my $self = shift;
my $name = uc shift;
return unl
data => 122,
}
],
}
);
$cucumber->Given(
qr/^(.+),.+entered (\d+)/ => sub {
my $c = shift;
my $subj
$num = $2;
$c->{$key} = $num;
$c->Log($subject);
}
)->Given(
qr/^(.+),.+entered number of/ => sub {
my $c = shift;
my $
}
]
)
->Given(...)
->Then(...)
->Test;
=head2 Scenarios
Create a cucumber with a plain array list of scenarios
Test::Cucumber::Tiny->Scenarios(
{ ... }
)
->Given(...)
->When(..
*remove_values = \&remove_value;
=head2 remove_pair(%pairs), remove_pairs(%pairs)
Remove all given (key, value) pairs from the multiset.
=cut
sub remove_pair {
my ($self, %pairs) = @_;
w
= $self;
$sub->($self, @_);
die "Fork within transaction is not recommended" unless $self->pid ~~ $$;
if($level) {
logDebug("Commit to level %d", $level);
$self->dbh->do("release tran_" .
to reuse existing handles.
=cut
sub _fork_guard {
my $self = shift;
return $self if $self->pid ~~ $$;
logError("Fork inside a transaction (level %d), old pid %d, new pid %d", $self->transactionLe