use v6-alpha; use Test; plan 5; =pod L =cut # String-like things... my $fh = open($?FILE); rule monster { dr\wgon }; # contrived pattern which does not match itself; we're going to look for it in this file rule cheese { camembert | cheddar }; my $stream; eval '$stream is from($fh)'; ok(eval('$stream ~~ //'), 'rules on streams, positive', :todo); # should match ok(eval('! ($stream ~~ //)'), 'rules on streams, negative'); # shouldn't match # And arrays... my Dog $a; my Cat $b; my Fish $c; my @array = ($a, $b, $c); ok(eval('rule canine { <.isa(Dog)> }; @array ~~ //'), 'rules on an array - positive', :todo); ok(eval('rule herbivore { <.isa(Antelope)> }; ! @array ~~ //'), 'rules on an array - negative', :todo); # These seem to be failing for some sort of scoping error rather than a problem with the # rule matching itself. # And matching against each element of an array... a different topic really, but it's still in # that bit of the synopsis. my @names = ('zaphod', 'ford', 'arthur', 'slartibartfast'); my $arrr = rule { ar }; is(eval('@names>>.match($arrr)'), 2, 'matching with hyper-operator', :todo);