beginning of wrapper code for meta-tests
Arthur Axel 'fREW' Schmidt [Sat, 5 Sep 2009 05:02:37 +0000 (00:02 -0500)]
t/lib/MetaTest.pm [new file with mode: 0644]

diff --git a/t/lib/MetaTest.pm b/t/lib/MetaTest.pm
new file mode 100644 (file)
index 0000000..06db4da
--- /dev/null
@@ -0,0 +1,30 @@
+package MetaTest;
+
+use Exporter 'import';
+use Test::More;
+our @EXPORT = qw{skip_meta meta_can_ok};
+
+sub skip_meta (&$) {
+   my $fn = shift;
+   my $amount = shift;
+   local $Test::Builder::Level = $Test::Builder::Level + 1;
+   SKIP: {
+      local $Test::Builder::Level = $Test::Builder::Level + 1;
+      skip 'meta-tests disabled', $amount if $ENV{SKIP_META_TESTS};
+      $fn->();
+   };
+}
+
+sub meta_can_ok {
+   my $class = shift;
+   my $method = shift;
+   my $message = shift;
+   local $Test::Builder::Level = $Test::Builder::Level + 1;
+   skip_meta {
+      local $Test::Builder::Level = $Test::Builder::Level + 1;
+      ok($class->meta->has_method($method), $message);
+      ok($class->can($method), $message);
+   } 1;
+}
+
+1;