diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-04-03 07:06:12 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-04-03 07:06:12 +0000 |
commit | 668079a2b440421ddf96ba71b4aa709ca57a1854 (patch) | |
tree | f74beb40afa9d7242d655be2d8d4a6e799c05c53 /t | |
parent | e336de0d01f30cc4061b6d6a00d11df30fc67cd3 (diff) | |
parent | a231274ce58dd8b3e2ca5659d8a951ddf06510d2 (diff) | |
download | perl-668079a2b440421ddf96ba71b4aa709ca57a1854.tar.gz |
[win32] integrate mainline
p4raw-id: //depot/win32/perl@865
Diffstat (limited to 't')
-rwxr-xr-x | t/lib/english.t | 2 | ||||
-rwxr-xr-x | t/op/hashwarn.t | 70 |
2 files changed, 71 insertions, 1 deletions
diff --git a/t/lib/english.t b/t/lib/english.t index 1a96c772fe..9691229be0 100755 --- a/t/lib/english.t +++ b/t/lib/english.t @@ -5,7 +5,7 @@ print "1..16\n"; BEGIN { @INC = '../lib' } use English; use Config; -my $threads = $Config{archname} =~ /-thread$/; +my $threads = $Config{'usethreads'} || 0; print $PID == $$ ? "ok 1\n" : "not ok 1\n"; diff --git a/t/op/hashwarn.t b/t/op/hashwarn.t new file mode 100755 index 0000000000..741982622b --- /dev/null +++ b/t/op/hashwarn.t @@ -0,0 +1,70 @@ +#!./perl + +use strict; + +BEGIN { + chdir 't' if -d 't'; +} + +use vars qw{ @warnings }; + +BEGIN { + $^W |= 1; # Insist upon warnings + # ...and save 'em as we go + $SIG{'__WARN__'} = sub { push @warnings, @_ }; + $| = 1; + print "1..7\n"; +} + +END { print "not ok\n# Uncaught warnings:\n@warnings\n" if @warnings } + +sub test ($$;$) { + my($num, $bool, $diag) = @_; + if ($bool) { + print "ok $num\n"; + return; + } + print "not ok $num\n"; + return unless defined $diag; + $diag =~ s/\Z\n?/\n/; # unchomp + print map "# $num : $_", split m/^/m, $diag; +} + +sub test_warning ($$$) { + my($num, $got, $expected) = @_; + my($pattern, $ok); + if (($pattern) = ($expected =~ m#^/(.+)/$#s) or + (undef, $pattern) = ($expected =~ m#^m([^\w\s])(.+)\1$#s)) { + # it's a regexp + $ok = ($got =~ /$pattern/); + test $num, $ok, "Expected pattern /$pattern/, got '$got'\n"; + } else { + $ok = ($got eq $expected); + test $num, $ok, "Expected string '$expected', got '$got'\n"; + } +# print "# $num: $got\n"; +} + +my $odd_msg = '/^Odd number of elements in hash/'; +my $ref_msg = '/^Reference found where even-sized list expected/'; + +{ + my %hash = (1..3); + test_warning 1, shift @warnings, $odd_msg; + + %hash = 1; + test_warning 2, shift @warnings, $odd_msg; + + %hash = { 1..3 }; + test_warning 3, shift @warnings, $odd_msg; + test_warning 4, shift @warnings, $ref_msg; + + %hash = [ 1..3 ]; + test_warning 5, shift @warnings, $ref_msg; + + %hash = sub { print "ok" }; + test_warning 6, shift @warnings, $odd_msg; + + $_ = { 1..10 }; + test 7, ! @warnings, "Unexpected warning"; +} |