Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created July 28, 2012 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoelzro/3194797 to your computer and use it in GitHub Desktop.
Save hoelzro/3194797 to your computer and use it in GitHub Desktop.
use v6;
use Test;
plan 4;
class RETest {
has $.prefix;
method matches(Str $s) {
my $re = regex { ^ "$!prefix" };
return $s ~~ $re;
}
}
my $test = RETest.new(:prefix<foo>);
ok $test.matches('food');
ok $test.matches('foo');
nok $test.matches('fo');
nok $test.matches('bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment