use v6-alpha; use Test; plan 5; =pod L =cut # String-like things... my $fh = open($?FILE); regex monster { dr\wgon }; # contrived pattern which does not match itself; we're going to look for it in this file regex cheese { camembert | cheddar }; my $stream; eval '$stream := cat =$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('regex canine { <.isa(Dog)> }; @array ~~ //'), 'rules on an array - positive', :todo); ok(eval('regex 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 # regex 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 = regex { ar }; is(eval('@names>>.match($arrr)'), 2, 'matching with hyper-operator', :todo);