]> git.vpit.fr Git - perl/modules/indirect.git/commitdiff
Allow specifying a prefix and skipping individual tests
authorVincent Pit <vince@profvince.com>
Fri, 5 Dec 2008 17:13:49 +0000 (18:13 +0100)
committerVincent Pit <vince@profvince.com>
Fri, 5 Dec 2008 17:13:49 +0000 (18:13 +0100)
t/10-good.t
t/20-bad.t
t/22-bad-mixed.t

index 715136127bda47187d806208427188c3cdb95239..da9b2d734fd6dd7b903691758ddbafceb20fb292 100644 (file)
@@ -19,30 +19,41 @@ state $z;
 sub meh;
 
 {
 sub meh;
 
 {
- local $/ = "####\n";
+ local $/ = "####";
  while (<DATA>) {
   chomp;
   s/\s*$//;
  while (<DATA>) {
   chomp;
   s/\s*$//;
+  s/(.*?)$//m;
+  my ($skip, $prefix) = split /#+/, $1;
+  $skip   = 0  unless defined $skip;
+  $prefix = '' unless defined $prefix;
+  s/\s*//;
 
 
-  local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
+SKIP:
+  {
+   skip "$_: $skip" => 4 if eval $skip;
+
+   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
 
 
-  eval "die qq{ok\\n}; use indirect; $_";
-  is($@, "ok\n", "use indirect: $_");
+   eval "die qq{ok\\n}; $prefix; use indirect; $_";
+   is($@, "ok\n", "use indirect: $_");
 
 
-  eval "die qq{ok\n}; no indirect; $_";
-  is($@, "ok\n", "no indirect: $_");
+   eval "die qq{ok\n}; $prefix; no indirect; $_";
+   is($@, "ok\n", "no indirect: $_");
 
 
-  s/Hlagh/Dongs/g;
+   s/Hlagh/Dongs/g;
 
 
-  eval "die qq{ok\\n}; use indirect; $_";
-  is($@, "ok\n", "use indirect, defined: $_");
+   eval "die qq{ok\\n}; $prefix; use indirect; $_";
+   is($@, "ok\n", "use indirect, defined: $_");
 
 
-  eval "die qq{ok\\n}; no indirect; $_";
-  is($@, "ok\n", "no indirect, defined: $_");
+   eval "die qq{ok\\n}; $prefix; no indirect; $_";
+   is($@, "ok\n", "no indirect, defined: $_");
+  }
  }
 }
 
 __DATA__
  }
 }
 
 __DATA__
+
 $obj = Hlagh->new;
 ####
 $obj = Hlagh->new();
 $obj = Hlagh->new;
 ####
 $obj = Hlagh->new();
index 35c8723ff752ebb26573ee24ca5e2ab323a2ddb4..65511fd09a06f68cf1d1281179113a78c6b13e82 100644 (file)
@@ -23,35 +23,45 @@ sub expect {
 }
 
 {
 }
 
 {
- local $/ = "####\n";
+ local $/ = "####";
  while (<DATA>) {
   chomp;
   s/\s*$//;
  while (<DATA>) {
   chomp;
   s/\s*$//;
+  s/(.*?)$//m;
+  my ($skip, $prefix) = split /#+/, $1;
+  $skip   = 0  unless defined $skip;
+  $prefix = '' unless defined $prefix;
+  s/\s*//;
 
 
-  local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
+SKIP:
+  {
+   skip "$_: $skip" => 6 if eval $skip;
 
 
-  eval "die qq{ok\\n}; use indirect; $_";
-  is($@, "ok\n", "use indirect: $_");
+   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
 
 
-  eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
-  like($@, expect('Hlagh'), "no indirect: $_");
+   eval "die qq{ok\\n}; $prefix; use indirect; $_";
+   is($@, "ok\n", "use indirect: $_");
 
 
-  s/Hlagh/Dongs/g;
+   eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_";
+   like($@, expect('Hlagh'), "no indirect: $_");
 
 
-  eval "die qq{ok\\n}; use indirect; $_";
-  is($@, "ok\n", "use indirect, defined: $_");
+   s/Hlagh/Dongs/g;
 
 
-  eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
-  like($@, expect('Dongs'), "no indirect, defined: $_");
+   eval "die qq{ok\\n}; $prefix; use indirect; $_";
+   is($@, "ok\n", "use indirect, defined: $_");
 
 
-  s/\$/\$ \n\t /g;
-  s/Dongs/Hlagh/g;
+   eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_";
+   like($@, expect('Dongs'), "no indirect, defined: $_");
 
 
-  eval "die qq{ok\\n}; use indirect; $_";
-  is($@, "ok\n", "use indirect, spaces: $_");
+   s/\$/\$ \n\t /g;
+   s/Dongs/Hlagh/g;
 
 
-  eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
-  like($@, expect('Hlagh'), "no indirect, spaces: $_");
+   eval "die qq{ok\\n}; $prefix; use indirect; $_";
+   is($@, "ok\n", "use indirect, spaces: $_");
+
+   eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_";
+   like($@, expect('Hlagh'), "no indirect, spaces: $_");
+  }
  }
 }
 
  }
 }
 
@@ -64,6 +74,7 @@ eval {
 }
 
 __DATA__
 }
 
 __DATA__
+
 $obj = new Hlagh;
 ####
 $obj = new Hlagh();
 $obj = new Hlagh;
 ####
 $obj = new Hlagh();
index 3a01f463bbe19124219dac69a05ba0f09e37ad39..8cc0931aa9c28fd53f25a01ad702d05d49de7e5c 100644 (file)
@@ -14,30 +14,41 @@ use Test::More tests => 3 * 4;
 sub meh;
 
 {
 sub meh;
 
 {
- local $/ = "####\n";
+ local $/ = "####";
  while (<DATA>) {
   chomp;
   s/\s*$//;
  while (<DATA>) {
   chomp;
   s/\s*$//;
+  s/(.*?)$//m;
+  my ($skip, $prefix) = split /#+/, $1;
+  $skip   = 0  unless defined $skip;
+  $prefix = '' unless defined $prefix;
+  s/\s*//;
 
 
-  local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
+SKIP:
+  {
+   skip "$_: $skip" => 4 if eval $skip;
 
 
-  eval "die qq{ok\\n}; use indirect; $_";
-  is($@, "ok\n", "use indirect: $_");
+   local $SIG{__WARN__} = sub { die 'warn:' . join(' ', @_) };
 
 
-  eval "die qq{ok\n}; no indirect; $_";
-  is($@, "ok\n", "no indirect: $_");
+   eval "die qq{ok\\n}; $prefix; use indirect; $_";
+   is($@, "ok\n", "use indirect: $_");
 
 
-  s/Hlagh/Dongs/g;
+   eval "die qq{ok\n}; $prefix; no indirect; $_";
+   is($@, "ok\n", "no indirect: $_");
 
 
-  eval "die qq{ok\\n}; use indirect; $_";
-  is($@, "ok\n", "use indirect, defined: $_");
+   s/Hlagh/Dongs/g;
 
 
-  eval "die qq{the code compiled but it shouldn't have\n}; no indirect; $_";
-  like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_");
+   eval "die qq{ok\\n}; $prefix; use indirect; $_";
+   is($@, "ok\n", "use indirect, defined: $_");
+
+   eval "die qq{the code compiled but it shouldn't have\n}; $prefix; no indirect; $_";
+   like($@, qr/^warn:Indirect\s+call\s+of\s+method\s+"meh"\s+on\s+object\s+"Dongs"/, "no indirect, defined: $_");
+  }
  }
 }
 
 __DATA__
  }
 }
 
 __DATA__
+
 meh Hlagh->new;
 ####
 meh Hlagh->new();
 meh Hlagh->new;
 ####
 meh Hlagh->new();