X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Fwith.git;a=blobdiff_plain;f=t%2F12-keywords.t;h=84b2c6f5d8aaff25d047324f95647013fdf3c601;hp=f2daaff4b3305c98e2903cdb193327825032b0b6;hb=9df381fa9059d0ceb298bbf49924a873b816e829;hpb=7d694e6f49e219b9c5f62d323666ca2854d51f50 diff --git a/t/12-keywords.t b/t/12-keywords.t index f2daaff..84b2c6f 100644 --- a/t/12-keywords.t +++ b/t/12-keywords.t @@ -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';