summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-12-18 14:43:58 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-12-18 14:43:58 +0000
commit7b5d8bbce1bc254559797266031a88531cfece6b (patch)
tree499aba7e439f41ed3c81560919508efb404ade41 /t
parentcddd4526476ba0ae3c81876684c5e7a648cb3265 (diff)
parent8218ea5d24f5de0a37393f19671aa5631c088be7 (diff)
downloadperl-7b5d8bbce1bc254559797266031a88531cfece6b.tar.gz
Integrate mainline
p4raw-id: //depot/perlio@13756
Diffstat (limited to 't')
-rw-r--r--t/lib/warnings/utf813
-rw-r--r--t/op/alarm.t47
-rwxr-xr-xt/op/glob.t12
-rwxr-xr-xt/op/gv.t12
-rwxr-xr-xt/op/ord.t11
-rw-r--r--t/run/runenv.t11
6 files changed, 85 insertions, 21 deletions
diff --git a/t/lib/warnings/utf8 b/t/lib/warnings/utf8
index 9a7dbafdee..fa7041b938 100644
--- a/t/lib/warnings/utf8
+++ b/t/lib/warnings/utf8
@@ -33,3 +33,16 @@ EXPECT
Malformed UTF-8 character (unexpected non-continuation byte 0x73 after start byte 0xf8) at - line 9.
Malformed UTF-8 character (unexpected non-continuation byte 0x73 after start byte 0xf8) at - line 14.
########
+use warnings 'utf8';
+my $surr = chr(0xD800);
+my $fff3 = chr(0xFFFE);
+my $ffff = chr(0xFFFF);
+no warnings 'utf8';
+$surr = chr(0xD800);
+$fffe = chr(0xFFFE);
+$ffff = chr(0xFFFF);
+EXPECT
+UTF-16 surrogate 0xd800 at - line 2.
+Unicode character 0xfffe is illegal at - line 3.
+Unicode character 0xffff is illegal at - line 4.
+########
diff --git a/t/op/alarm.t b/t/op/alarm.t
new file mode 100644
index 0000000000..12c8c264c4
--- /dev/null
+++ b/t/op/alarm.t
@@ -0,0 +1,47 @@
+#!./perl
+
+BEGIN {
+ chdir 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+BEGIN {
+ use Config;
+ if( !$Config{d_alarm} ) {
+ skip_all("alarm() not implemented on this platform");
+ }
+}
+
+plan tests => 4;
+my $Perl = which_perl();
+
+my $start_time = time;
+eval {
+ local $SIG{ALRM} = sub { die "ALARM!\n" };
+ alarm 3;
+
+ # perlfunc recommends against using sleep in combination with alarm.
+ 1 while (time - $start_time < 6);
+};
+alarm 0;
+my $diff = time - $start_time;
+
+# alarm time might be one second less than you said.
+is( $@, "ALARM!\n", 'alarm w/$SIG{ALRM} vs inf loop' );
+ok( $diff == 3 || $diff == 2, ' right time' );
+
+
+my $start_time = time;
+eval {
+ local $SIG{ALRM} = sub { die "ALARM!\n" };
+ alarm 3;
+ system(qq{$Perl -e "sleep 6"});
+};
+alarm 0;
+$diff = time - $start_time;
+
+# alarm time might be one second less than you said.
+is( $@, "ALARM!\n", 'alarm w/$SIG{ALRM} vs system()' );
+
+ok( $diff == 3 || $diff == 2, ' right time' );
diff --git a/t/op/glob.t b/t/op/glob.t
index 8bdf64f932..bc43323375 100755
--- a/t/op/glob.t
+++ b/t/op/glob.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..10\n";
+print "1..8\n";
@oops = @ops = <op/*>;
@@ -53,10 +53,8 @@ for (1..2) {
}
print $i == 2 ? "ok 7\n" : "not ok 7\n";
-# [ID 20010526.001] localized glob loses value when assigned to
+# ... while ($var = glob(...)) should test definedness not truth
-$j=1; %j=(a=>1); @j=(1); local *j=*j; *j = sub{};
-
-print $j == 1 ? "ok 8\n" : "not ok 8\n";
-print $j{a} == 1 ? "ok 9\n" : "not ok 9\n";
-print $j[0] == 1 ? "ok 10\n" : "not ok 10\n";
+my $ok = "not ok 8\n";
+$ok = "ok 8\n" while my $var = glob("0");
+print $ok;
diff --git a/t/op/gv.t b/t/op/gv.t
index a423cb49ed..9380735a1d 100755
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -11,7 +11,7 @@ BEGIN {
use warnings;
-print "1..41\n";
+print "1..44\n";
# type coersion on assignment
$foo = 'foo';
@@ -177,6 +177,14 @@ print {*x{IO}} "ok 23\n";
}
+# [ID 20010526.001] localized glob loses value when assigned to
+
+$j=1; %j=(a=>1); @j=(1); local *j=*j; *j = sub{};
+
+print $j == 1 ? "ok 41\n" : "not ok 41\n";
+print $j{a} == 1 ? "ok 42\n" : "not ok 42\n";
+print $j[0] == 1 ? "ok 43\n" : "not ok 43\n";
+
# does pp_readline() handle glob-ness correctly?
{
@@ -186,4 +194,4 @@ print {*x{IO}} "ok 23\n";
}
__END__
-ok 41
+ok 44
diff --git a/t/op/ord.t b/t/op/ord.t
index f7460553cc..ff51c18f8c 100755
--- a/t/op/ord.t
+++ b/t/op/ord.t
@@ -2,11 +2,11 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '.';
+ @INC = qw(.);
require "test.pl";
}
-print "1..8\n";
+plan tests => 7;
# compile time evaluation
@@ -33,10 +33,3 @@ is(ord("\x{1234}"), 0x1234, 'compile time ord \x{....}');
$x = "\x{1234}";
is(ord($x), 0x1234, 'runtime ord \x{....}');
-{
- eval 'my $surrogate = chr(0xD800)';
-
- like($@, qr/^UTF-16 surrogate 0xd800 /, "surrogates bad");
-}
-
-
diff --git a/t/run/runenv.t b/t/run/runenv.t
index 55c48f03b3..236f84eabb 100644
--- a/t/run/runenv.t
+++ b/t/run/runenv.t
@@ -16,7 +16,7 @@ BEGIN {
use Test;
-plan tests => 10;
+plan tests => 11;
my $STDOUT = './results-0';
my $STDERR = './results-1';
@@ -24,7 +24,7 @@ my $PERL = './perl';
my $FAILURE_CODE = 119;
# Run perl with specified environment and arguments returns a list.
-# First element is true iff Perl's stdout and stderr match the
+# First element is true if Perl's stdout and stderr match the
# supplied $stdout and $stderr argument strings exactly.
# second element is an explanation of the failure
sub runperl {
@@ -79,7 +79,7 @@ sub try {
# PERL5OPT Command-line options (switches). Switches in
# this variable are taken as if they were on
-# every Perl command line. Only the -[DIMUdmw]
+# every Perl command line. Only the -[DIMUdmtw]
# switches are allowed. When running taint
# checks (because the program was running setuid
# or setgid, or the -T switch was used), this
@@ -140,6 +140,11 @@ try({PERL5OPT => '-w -w'},
'-w -w',
'');
+try({PERL5OPT => '-t'},
+ ['-e', 'print ${^TAINT}'],
+ '1',
+ '');
+
END {
1 while unlink $STDOUT;
1 while unlink $STDERR;