pad stuffing by source injection
[p5sagit/Devel-Declare.git] / t / simple.t
index 266bb8b..9b022d0 100644 (file)
@@ -1,7 +1,6 @@
 use strict;
 use warnings;
-
-print "1..1\n";
+use Test::More 'no_plan';
 
 sub method {
   my ($pack, $name, $sub) = @_;
@@ -9,15 +8,29 @@ sub method {
   *{"${pack}::${name}"} = $sub;
 }
 
-use Devel::Declare 'method';
+sub handle_method {
+  my ($pack, $use, $name) = @_;
+  return sub (&) { ($pack, $name, $_[0]); };
+}
+
+use Devel::Declare 'method' => \&handle_method;
+
+my ($args1, $args2);
 
 method bar {
-  my $str = join(', ', @_);
-  if ($str eq 'main, baz, quux') {
-    print "ok 1\n";
-  } else {
-    print "not ok 1\n";
-  }
+  $args1 = join(', ', @_);
 };
 
-__PACKAGE__->bar(qw(baz quux));
+method # blather
+  baz
+  # whee
+{ # fweet
+  $args2 = join(', ', @_);
+};
+
+__PACKAGE__->bar(qw(1 2));
+__PACKAGE__->baz(qw(3 4));
+
+is($args1, 'main, 1, 2', 'Method bar args ok');
+is($args2, 'main, 3, 4', 'Method baz args ok');
+