Skip to content

Instantly share code, notes, and snippets.

@cotto
Created March 23, 2010 06:18
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 cotto/340885 to your computer and use it in GitHub Desktop.
Save cotto/340885 to your computer and use it in GitHub Desktop.
#Note: none of the classes are implemented. This is just to figure out what kind of interface will be reasonable.
my $pir_code :=
'.sub main
say "what"
.end';
my $prof := ProfTest;PirProfile.new($pir);
#Does the profile have a version string?
my $matcher := ProfTest::Matcher.new();
$matcher.push( ProfTest::Want::Version() ); #use count=1 by default
ok( $matcher.matches($prof), "profile has a version number");
#Does the profile have a CLI invocation?
$matcher := ProfTest::Matcher.new();
$matcher.push( ProfTest::Want::CLI() );
ok( $matcher.matches($prof), "profile contains a CLI string");
#Does the profile have a 'say' op somewhere?
$matcher := ProfTest::Matcher.new();
$matcher.push( ProfTest::Want::Op( 'say' ));
ok( $matcher.matches($prof), "profile has a say op");
#Does the profile show a 'say' op inside the 'main' sub?
$matcher := ProfTest::Matcher.new(
ProfTest::Want::CS.new( :ns('main')),
ProfTest::Want.new( :count('*'), :type_isnt('CS')),
ProfTest::Want::Op.new( :op('say')),
);
ok( $matcher.matches($prof), "profile shows 'say' inside main sub");
#Does the profile show a 'say' op on line 2?
$match := ProfTest::Matcher.new();
$matcher.push (ProfTest::Want::Op.new( :count(1), :op('say'), :line('2')));
ok( $matcher.matches($prof), "profile shows say on the correct line");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment