#!/usr/bin/perl use strict; use warnings; use lib '.'; use Stream qw/node list_to_stream/; use Parser ':all'; use Test::More 'no_plan'; my @tokens = ( node( OP => '+' ), node( VAR => 'x' ), node( VAL => 3 ) ); my $stream = list_to_stream(@tokens); my $parser = concatenate( lookfor('OP'), lookfor('VAR'), ); my ( $parsed, $remainder ) = $parser->($stream); is_deeply $parsed, [qw/+ x/], 'concatenate should return the parsed values'; is_deeply $remainder, [ VAL => 3 ], '... and the rest of the stream'; # the next test fails ... $parser = concatenate( lookfor('OP'), lookfor('VAR'), lookfor('VAL'), ); ( $parsed, $remainder ) = $parser->($stream); is_deeply $parsed, [qw/+ x 3/], 'concatenate should return the parsed values'; ok !defined $remainder, '... and the remaining stream should be empty';