summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/comp/proto.t12
-rwxr-xr-xt/io/pipe.t1
-rw-r--r--t/lib/h2ph.h85
-rw-r--r--t/lib/h2ph.pht69
-rwxr-xr-xt/lib/h2ph.t34
-rwxr-xr-xt/op/die.t19
-rwxr-xr-xt/op/ipcmsg.t5
-rwxr-xr-xt/op/ipcsem.t5
-rwxr-xr-xt/pragma/locale.t3
9 files changed, 226 insertions, 7 deletions
diff --git a/t/comp/proto.t b/t/comp/proto.t
index 2a4c9ccce5..6a59107ce7 100755
--- a/t/comp/proto.t
+++ b/t/comp/proto.t
@@ -16,7 +16,7 @@ BEGIN {
use strict;
-print "1..80\n";
+print "1..82\n";
my $i = 1;
@@ -403,3 +403,13 @@ sub foo2 ($\%);
eval q{ foo2 "s" };
print "not " unless $@ =~ /^Not enough/;
print "ok ", $i++, "\n";
+
+sub X::foo3;
+*X::foo3 = sub {'ok'};
+print "# $@not " unless eval {X->foo3} eq 'ok';
+print "ok ", $i++, "\n";
+
+sub X::foo4 ($);
+*X::foo4 = sub ($) {'ok'};
+print "not " unless X->foo4 eq 'ok';
+print "ok ", $i++, "\n";
diff --git a/t/io/pipe.t b/t/io/pipe.t
index 4a7cb7a423..63614f5f4f 100755
--- a/t/io/pipe.t
+++ b/t/io/pipe.t
@@ -59,6 +59,7 @@ close READER;
$SIG{'PIPE'} = 'broken_pipe';
sub broken_pipe {
+ $SIG{'PIPE'} = 'IGNORE'; # loop preventer
print "ok 7\n";
}
diff --git a/t/lib/h2ph.h b/t/lib/h2ph.h
new file mode 100644
index 0000000000..cddf0a7d94
--- /dev/null
+++ b/t/lib/h2ph.h
@@ -0,0 +1,85 @@
+/*
+ * Test header file for h2ph
+ *
+ * Try to test as many constructs as possible
+ * For example, the multi-line comment :)
+ */
+
+/* And here's a single line comment :) */
+
+/* Test #define with no indenting, over multiple lines */
+#define SQUARE(x) \
+((x)*(x))
+
+/* Test #ifndef and parameter interpretation*/
+#ifndef ERROR
+#define ERROR(x) fprintf(stderr, "%s\n", x[2][3][0])
+#endif /* ERROR */
+
+#ifndef _H2PH_H_
+#define _H2PH_H_
+
+/* #ident - doesn't really do anything, but I think it always gets included anyway */
+#ident "$Revision h2ph.h,v 1.0 98/05/04 20:42:14 billy $"
+
+/* Test #undef */
+#undef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+/* Test #ifdef */
+#ifdef __SOME_UNIMPORTANT_PROPERTY
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif /* __SOME_UNIMPORTANT_PROPERTY */
+
+/*
+ * Test #if, #elif, #else, #endif, #warn and #error, and `!'
+ * Also test whitespace between the `#' and the command
+ */
+#if !(defined __SOMETHING_MORE_IMPORTANT)
+# warn Be careful...
+#elif !(defined __SOMETHING_REALLY_REALLY_IMPORTANT)
+# error Nup, can't go on /* ' /* stupid font-lock-mode */
+#else /* defined __SOMETHING_MORE_IMPORTANT && defined __SOMETHING_REALLY_REALLY_IMPORTANT */
+# define EVERYTHING_IS_OK
+#endif
+
+/* Test && and || */
+#undef WHATEVER
+#if (!((defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO)) \
+ || defined __SOMETHING_OVERPOWERING)
+# define WHATEVER 6
+#elif !(defined __SOMETHING_TRIVIAL) /* defined __SOMETHING_LESS_SO */
+# define WHATEVER 7
+#elif !(defined __SOMETHING_LESS_SO) /* defined __SOMETHING_TRIVIAL */
+# define WHATEVER 8
+#else /* defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO */
+# define WHATEVER 1000
+#endif
+
+/*
+ * Test #include, #import and #include_next
+ * #include_next is difficult to test, it really depends on the actual
+ * circumstances - for example, `#include_next <limits.h>' on a Linux system
+ * with `use lib qw(/opt/perl5/lib/site_perl/i586-linux/linux);' or whatever
+ * your equivalent is...
+ */
+#include <sys/socket.h>
+#import "sys/ioctl.h"
+#include_next <sys/fcntl.h>
+
+/* typedefs should be ignored */
+typedef struct a_struct {
+ int typedefs_should;
+ char be_ignored;
+ long as_well;
+} a_typedef;
+
+/*
+ * however, typedefs of enums and just plain enums should end up being treated
+ * like a bunch of #defines...
+ */
+
+typedef enum _days_of_week { sun, mon, tue, wed, thu, fri, sat, Sun=0, Mon,
+ Tue, Wed, Thu, Fri, Sat } days_of_week;
+
+#endif /* _H2PH_H_ */
diff --git a/t/lib/h2ph.pht b/t/lib/h2ph.pht
new file mode 100644
index 0000000000..80867a6113
--- /dev/null
+++ b/t/lib/h2ph.pht
@@ -0,0 +1,69 @@
+unless(defined(&SQUARE)) {
+ sub SQUARE {
+ local($x) = @_;
+ eval q((($x)*($x)));
+ }
+}
+unless(defined(&ERROR)) {
+ eval 'sub ERROR {
+ local($x) = @_;
+ eval q( &fprintf( &stderr, \\"%s\\\\n\\", $x->[2][3][0]));
+ }' unless defined(&ERROR);
+}
+unless(defined(&_H2PH_H_)) {
+ eval 'sub _H2PH_H_ () {1;}' unless defined(&_H2PH_H_);
+ # "$Revision h2ph.h,v 1.0 98/05/04 20:42:14 billy $"
+ undef(&MAX) if defined(&MAX);
+ eval 'sub MAX {
+ local($a,$b) = @_;
+ eval q((($a) > ($b) ? ($a) : ($b)));
+ }' unless defined(&MAX);
+ if(defined(&__SOME_UNIMPORTANT_PROPERTY)) {
+ eval 'sub MIN {
+ local($a,$b) = @_;
+ eval q((($a) < ($b) ? ($a) : ($b)));
+ }' unless defined(&MIN);
+ }
+ if(!(defined (defined(&__SOMETHING_MORE_IMPORTANT) ? &__SOMETHING_MORE_IMPORTANT : 0))) {
+ }
+ elsif(!(defined (defined(&__SOMETHING_REALLY_REALLY_IMPORTANT) ? &__SOMETHING_REALLY_REALLY_IMPORTANT : 0))) {
+ die("Nup, can't go on ");
+ } else {
+ eval 'sub EVERYTHING_IS_OK () {1;}' unless defined(&EVERYTHING_IS_OK);
+ }
+ undef(&WHATEVER) if defined(&WHATEVER);
+ if((!((defined (defined(&__SOMETHING_TRIVIAL) ? &__SOMETHING_TRIVIAL : 0) && defined (defined(&__SOMETHING_LESS_SO) ? &__SOMETHING_LESS_SO : 0))) || defined (defined(&__SOMETHING_OVERPOWERING) ? &__SOMETHING_OVERPOWERING : 0))) {
+ eval 'sub WHATEVER () {6;}' unless defined(&WHATEVER);
+ }
+ elsif(!(defined (defined(&__SOMETHING_TRIVIAL) ? &__SOMETHING_TRIVIAL : 0)) ) {
+ eval 'sub WHATEVER () {7;}' unless defined(&WHATEVER);
+ }
+ elsif(!(defined (defined(&__SOMETHING_LESS_SO) ? &__SOMETHING_LESS_SO : 0)) ) {
+ eval 'sub WHATEVER () {8;}' unless defined(&WHATEVER);
+ } else {
+ eval 'sub WHATEVER () {1000;}' unless defined(&WHATEVER);
+ }
+ require 'sys/socket.ph';
+ require 'sys/ioctl.ph';
+ eval {
+ my(%INCD) = map { $INC{$_} => 1 } (grep { $_ eq "sys/fcntl.ph" } keys(%INC));
+ my(@REM) = map { "$_/sys/fcntl.ph" } (grep { not exists($INCD{"$_/sys/fcntl.ph"})and -f "$_/sys/fcntl.ph" } @INC);
+ require "$REM[0]" if @REM;
+ };
+ warn($@) if $@;
+ eval("sub sun () { 0; }") unless defined(&sun);
+ eval("sub mon () { 1; }") unless defined(&mon);
+ eval("sub tue () { 2; }") unless defined(&tue);
+ eval("sub wed () { 3; }") unless defined(&wed);
+ eval("sub thu () { 4; }") unless defined(&thu);
+ eval("sub fri () { 5; }") unless defined(&fri);
+ eval("sub sat () { 6; }") unless defined(&sat);
+ eval("sub Sun () { 0; }") unless defined(&Sun);
+ eval("sub Mon () { 1; }") unless defined(&Mon);
+ eval("sub Tue () { 2; }") unless defined(&Tue);
+ eval("sub Wed () { 3; }") unless defined(&Wed);
+ eval("sub Thu () { 4; }") unless defined(&Thu);
+ eval("sub Fri () { 5; }") unless defined(&Fri);
+ eval("sub Sat () { 6; }") unless defined(&Sat);
+}
+1;
diff --git a/t/lib/h2ph.t b/t/lib/h2ph.t
new file mode 100755
index 0000000000..17d5509085
--- /dev/null
+++ b/t/lib/h2ph.t
@@ -0,0 +1,34 @@
+#!./perl
+
+# quickie tests to see if h2ph actually runs and does more or less what is
+# expected
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+print "1..2\n";
+
+# quickly compare two text files
+sub txt_compare {
+ local ($/, $A, $B);
+ for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ }
+ $A cmp $B;
+}
+
+unless(-e '../utils/h2ph') {
+ print("ok 1\nok 2\n");
+ # i'll probably get in trouble for this :)
+} else {
+ # does it run?
+ $ok = system("./perl -I../lib ../utils/h2ph -d. lib/h2ph.h");
+ print(($ok == 0 ? "" : "not "), "ok 1\n");
+
+ # does it work? well, does it do what we expect? :-)
+ $ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht");
+ print(($ok == 0 ? "" : "not "), "ok 2\n");
+
+ # cleanup - should this be in an END block?
+ unlink("lib/h2ph.ph");
+}
diff --git a/t/op/die.t b/t/op/die.t
index 795d856564..d473ed6b7f 100755
--- a/t/op/die.t
+++ b/t/op/die.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..6\n";
+print "1..10\n";
$SIG{__DIE__} = sub { print ref($_[0]) ? ("ok ",$_[0]->[0]++,"\n") : @_ } ;
@@ -24,3 +24,20 @@ eval {
};
die if $@;
};
+
+eval {
+ eval {
+ die bless [ 7 ], "Error";
+ };
+ die if $@;
+};
+
+print "not " unless ref($@) eq "Out";
+print "ok 10\n";
+
+package Error;
+
+sub PROPAGATE {
+ print "ok ",$_[0]->[0]++,"\n";
+ bless [$_[0]->[0]], "Out";
+}
diff --git a/t/op/ipcmsg.t b/t/op/ipcmsg.t
index ab2b0737e9..72e345c90a 100755
--- a/t/op/ipcmsg.t
+++ b/t/op/ipcmsg.t
@@ -110,8 +110,9 @@ use strict;
print "1..6\n";
-my $msg = msgget($IPC_PRIVATE, $S_IRWXU | $S_IRWXG | $S_IRWXO)
- || die "msgget failed: $!\n";
+my $msg = msgget($IPC_PRIVATE, $S_IRWXU | $S_IRWXG | $S_IRWXO);
+# Very first time called after machine is booted value may be 0
+die "msgget failed: $!\n" unless defined($msg) && $msg >= 0;
print "ok 1\n";
diff --git a/t/op/ipcsem.t b/t/op/ipcsem.t
index f71f810570..a1450ffd42 100755
--- a/t/op/ipcsem.t
+++ b/t/op/ipcsem.t
@@ -115,8 +115,9 @@ exit;
print "1..10\n";
-my $sem = semget($IPC_PRIVATE, 10, $S_IRWXU | $S_IRWXG | $S_IRWXO | $IPC_CREAT)
- || die "semget: $!\n";
+my $sem = semget($IPC_PRIVATE, 10, $S_IRWXU | $S_IRWXG | $S_IRWXO | $IPC_CREAT);
+# Very first time called after machine is booted value may be 0
+die "semget: $!\n" unless defined($sem) && $sem >= 0;
print "ok 1\n";
diff --git a/t/pragma/locale.t b/t/pragma/locale.t
index bd5267d720..00baa6645e 100755
--- a/t/pragma/locale.t
+++ b/t/pragma/locale.t
@@ -20,7 +20,8 @@ eval {
};
# Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1"
-$have_setlocale = 0 if $^O eq 'MSWin32' && $Config{cc} =~ /^cl/i;
+# and mingw32 uses said silly CRT
+$have_setlocale = 0 if $^O eq 'MSWin32' && $Config{cc} =~ /^(cl|gcc)/i;
print "1..", ($have_setlocale ? 102 : 98), "\n";