App-SimpleScan

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- contributed fix: allow non-http URLs to be tested
	  (from bbking@checkfree.com)
	- Clarified App::SimpleScan docs: this is not useful to
	  read if you want to run simple_scan; only useful if
	  you're subclassing this class (or writing your own app)
	- Addded PLUGINS section to simple_scan doc.

1.12  Wed Jul  5 12:40:18 PDT 2006
        - fixed pattern interpolation into the comment section of
	  the generated code so Perl wouldn't complain about bad
	  character escapes in the string.

1.11  Fri Jun 23 17:41:22 PDT 2006
	- expand_backticked was changed to a method to allow it
	  to more easily emit warnings for mismatched quotes.
	- mismatched quotes are now explicitly diagnosed. Formerly,
	  there'd be a !!THISISGARBAGE!! in the output. Not right.

1.10  Fri Jun 23 12:53:33 PDT 2006
	- Unicode works!
  	  - accented character tests gone. 

MANIFEST  view on Meta::CPAN

examples/cross_product.in
examples/expression.in
examples/renegade-percent.in
examples/ss.in
examples/ss_backtick1.in
examples/ss_backtick_env.in
examples/ss_blank.in
examples/ss_comment.in
examples/ss_country.in
examples/ss_dynamvar.in
examples/ss_escaped.in
examples/ss_extpattern.in
examples/ss_fail.in
examples/ss_garbage1.in
examples/ss_garbage2.in
examples/ss_garbage3.in
examples/ss_multisub.in
examples/ss_nested.in
examples/ss_nested2.in
examples/ss_newbracket.in
examples/ss_nodouble.in

lib/App/SimpleScan.pm  view on Meta::CPAN


  my ($self, $text) = @_;

  # The state machine was a really cool idea, except it didn't work. :-P
  # A little reading in Mastering Regular Expressions gave me the patterns
  # shown below for matching quoted strings.

  # For an explanation of why this works, see Friedl, p. 262 ff.
  # It's called "unrolling" the regex there.

  #  Pattern: quote (nonspecial)*(escape anything (nonspecial)*)* quote
  my $qregex  = qr/'[^'\\]*(?:\\.[^'\\]*)*'/;
  my $qqregex = qr/"[^"\\]*(?:\\.[^"\\]*)*"/;
  my $qxregex = qr/`[^`\\]*(?:\\.[^`\\]*)*`/;

  # Plus we need the cleanup tokenizer: match anything nonblank. This
  # picks up tokens that are not properly-balanced quoted strings.
  # We'll trap those later, or not. We'll see.
  my $cleanup = qr/\S+/;

  # An item is a quoted string of any flavor, or the cleanup item.

lib/App/SimpleScan/TestSpec.pm  view on Meta::CPAN

  if ($delim ne '/') {
    $regex = "m$delim$regex$delim";
  }
  else {
    $regex = "/$regex/";
  }
  if ($flags) {
    $regex .= $flags;
  }
  if ($regex =~ /\\/mx) {
    # Have to escape backslashes.
    $regex =~ s/\\/\\\\/mxg;
  }

  return $regex;
}

sub as_tests {
  my ($self) = @_;
  my @tests;
  my $current = 0;

t/40inputq.t  view on Meta::CPAN


my $ss = new App::SimpleScan;
ok $ss->can('plugins'), "plugins method available";
isa_ok [$ss->plugins()],"ARRAY", "plugin list";
is  1, ( grep { /TestNextLine/ } $ss->plugins() ), "test plugin there";

ok scalar @{ $ss->next_line_callbacks }, "plugin installed callback";

$ENV{HARNESS_PERL_SWITCHES} = "" unless defined $ENV{HARNESS_PERL_SWITCHES};

@output = `$^X $ENV{HARNESS_PERL_SWITCHES} -Mlib='t' -Iblib/lib bin/simple_scan -gen -test_nextline <examples/ss_escaped.in 2>&1`;
@expected = map {"$_\n"} split /\n/,<<EOF;
use Test::More tests=>1;
use Test::WWW::Simple;
use strict;

use Test::Demo;
mech->agent_alias('Windows IE 6');
# next line plugin called 1 time
page_like "http://yahoo.com",
          qr/\\d+/,

t/50quoteescbug.t  view on Meta::CPAN

use Test::More tests=>2;
use App::SimpleScan;
my $app = new App::SimpleScan;

my $text     = qq('I am quoted with an escape\\.');
my $dequoted = qq(I am quoted with an escape\\.);
my @match = $app->expand_backticked($text);
is @match, 1, 'Should only be one result';
is $match[0], $dequoted, 'matched it right';

xt/39backslash.t  view on Meta::CPAN

#!/usr/local/bin/perl
use Test::More tests=>2;
use Test::Differences;

$ENV{HARNESS_PERL_SWITCHES} = "" unless defined $ENV{HARNESS_PERL_SWITCHES};

@output = `$^X $ENV{HARNESS_PERL_SWITCHES} -Iblib/lib bin/simple_scan -run <examples/ss_escaped.in 2>&1`;
@expected = map {"$_\n"} split /\n/,<<EOF;
1..1
ok 1 - digits [http://yahoo.com] [/\\d+/ should match]

EOF
eq_or_diff(\@output, \@expected, "working output as expected");

@output = `$^X $ENV{HARNESS_PERL_SWITCHES} -Iblib/lib bin/simple_scan -gen <examples/ss_escaped.in 2>&1|$^X`;
@expected = map {"$_\n"} split /\n/,<<EOF;
1..1
ok 1 - digits [http://yahoo.com] [/\\d+/ should match]

EOF
eq_or_diff(\@output, \@expected, "working output as expected");



( run in 0.517 second using v1.01-cache-2.11-cpan-c21f80fb71c )