]> git.vpit.fr Git - perl/modules/with.git/blobdiff - t/12-keywords.t
Importing with-0.02.tar.gz
[perl/modules/with.git] / t / 12-keywords.t
index f2daaff4b3305c98e2903cdb193327825032b0b6..84b2c6f5d8aaff25d047324f95647013fdf3c601 100644 (file)
@@ -5,24 +5,20 @@ package main;
 use strict;
 use warnings;
 
-use Test::More 'no_plan';
-
-sub with::Mock::right { pass $_[1] }
-sub with::Mock::wrong { fail $_[1] }
-sub with::Mock::test  { is_deeply $_[1], $_[2], $_[3] }
+use Test::More tests => 10;
 
 use with \bless {}, 'with::Mock';
 
 my $c = 0;
 ++$c for 1 .. 10;
-test $c, 10, 'for';
+is $c, 10, 'for';
 
 $c = 0;
 while ($c < 5) { ++$c; }
-test $c, 5, 'while';
+is $c, 5, 'while';
 
 $c = undef;
-test !defined($c), 1, 'undef, defined';
+is !defined($c), 1, 'undef, defined';
 
 my @a = (1, 2);
 
@@ -30,24 +26,27 @@ my $x = pop @a;
 my $y = shift @a;
 push @a, $y;
 unshift @a, $x;
-test \@a, [ 2, 1 ], 'pop/shift/push/unshift';
+is_deeply \@a, [ 2, 1 ], 'pop/shift/push/unshift';
 
 @a = reverse @a;
-test \@a, [ 1, 2 ], 'reverse';
+is_deeply \@a, [ 1, 2 ], 'reverse';
 
 open my $fh, '<', $0 or die "$!";
 my $d = do { local $/; <$fh> };
 $d =~ s/^(\S+).*/$1/s;
-test $d, '#!perl', 'open/do/local';
+is $d, '#!perl', 'open/do/local';
 
 @a = map { $_ + 1 } 0 .. 5;
-test \@a, [ 1 .. 6 ], 'map';
+is_deeply \@a, [ 1 .. 6 ], 'map';
 
 @a = grep { $_ > 2 } 0 .. 5;
-test \@a, [ 3 .. 5 ], 'grep';
+is_deeply \@a, [ 3 .. 5 ], 'grep';
 
 my %h = (foo => 1, bar => 2);
 @a = sort { $h{$a} <=> $h{$b} } keys %h;
-test \@a, [ 'foo', 'bar' ], 'sort/keys';
+is_deeply \@a, [ 'foo', 'bar' ], 'sort/keys';
 
 print STDERR "# boo" if 0;
+$y = "foo\n";
+chomp $y;
+is $y, 'foo', 'chomp';