summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-19 12:34:20 +0200
committerNicholas Clark <nick@ccl4.org>2010-10-19 12:34:20 +0200
commit228f83bf2f4cc0f605478d266ed3a2dd48cb7041 (patch)
tree3f42bb4f81cf41f6bec31649bcbd05ccc2b74a49
parent80a649c810fab9a1510e35c012adc454dd4a0a4e (diff)
downloadperl-228f83bf2f4cc0f605478d266ed3a2dd48cb7041.tar.gz
Make Fcntl::AUTOLOAD's error messages consistent with croak() using modules.
Fcntl avoids using Carp::croak(), but its code was adding a full stop at the end of all error messages. Other modules are using croak(), which has no full stop between the line number and the newline. Add a test for the error messages from Fcntl::AUTOLOAD.
-rw-r--r--MANIFEST1
-rw-r--r--ext/Fcntl/Fcntl.pm2
-rw-r--r--ext/Fcntl/t/autoload.t32
3 files changed, 34 insertions, 1 deletions
diff --git a/MANIFEST b/MANIFEST
index 15298fa1c2..9c866a421e 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3162,6 +3162,7 @@ ext/Errno/t/Errno.t See if Errno works
ext/Fcntl/Fcntl.pm Fcntl extension Perl module
ext/Fcntl/Fcntl.xs Fcntl extension external subroutines
ext/Fcntl/Makefile.PL Fcntl extension makefile writer
+ext/Fcntl/t/autoload.t See if Fcntl AUTOLOAD error messages work
ext/Fcntl/t/fcntl.t See if Fcntl works
ext/Fcntl/t/mode.t See if S_ISREG() and S_ISDIR() work
ext/Fcntl/t/syslfs.t See if large files work for sysio
diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm
index 4aede8c222..970735cd4e 100644
--- a/ext/Fcntl/Fcntl.pm
+++ b/ext/Fcntl/Fcntl.pm
@@ -189,7 +189,7 @@ sub AUTOLOAD {
my ($error, $val) = constant($constname);
if ($error) {
my (undef,$file,$line) = caller;
- die "$error at $file line $line.\n";
+ die "$error at $file line $line\n";
}
no strict 'refs';
*$AUTOLOAD = sub { $val };
diff --git a/ext/Fcntl/t/autoload.t b/ext/Fcntl/t/autoload.t
new file mode 100644
index 0000000000..09d089c8ae
--- /dev/null
+++ b/ext/Fcntl/t/autoload.t
@@ -0,0 +1,32 @@
+#!./perl -w
+
+use strict;
+use Test::More;
+
+require Fcntl;
+
+# SEEK_SET intentionally included to test the skip functionality.
+foreach my $symbol (qw(SEEK_SET O_BINARY S_ENFMT)) {
+ my $full_name = "Fcntl::$symbol";
+ if (defined eval $full_name) {
+ foreach my $code ($full_name, "$full_name()") {
+ my $value = eval $code;
+ like ($value, qr/^[0-9]+$/, "$code is defined on this system");
+ }
+ } else {
+ foreach my $code ($full_name, "$full_name()") {
+ my $value = eval $code;
+ like ($@,
+ qr/^Your vendor has not defined Fcntl macro $symbol, used at \(eval [0-9]+\) line 1\n\z/,
+ "Expected error message for $symbol, not defined on this system");
+ }
+ }
+}
+
+my $value = eval 'Fcntl::S_ISPIE()';
+is($value, undef, "Fcntl::S_ISPIE isn't valid");
+like ($@,
+ qr/^S_ISPIE is not a valid Fcntl macro at \(eval [0-9]+\) line 1\n\z/,
+ "Expected error message for S_ISPIE");
+
+done_testing();