summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/t/comp
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/perl/t/comp')
-rw-r--r--gnu/usr.bin/perl/t/comp/hints.t20
-rw-r--r--gnu/usr.bin/perl/t/comp/parser.t23
-rw-r--r--gnu/usr.bin/perl/t/comp/utf.t57
3 files changed, 98 insertions, 2 deletions
diff --git a/gnu/usr.bin/perl/t/comp/hints.t b/gnu/usr.bin/perl/t/comp/hints.t
index 117096860f4..f00bb6a893e 100644
--- a/gnu/usr.bin/perl/t/comp/hints.t
+++ b/gnu/usr.bin/perl/t/comp/hints.t
@@ -2,7 +2,13 @@
# Tests the scoping of $^H and %^H
-BEGIN { print "1..14\n"; }
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = qw(. ../lib);
+}
+
+
+BEGIN { print "1..15\n"; }
BEGIN {
print "not " if exists $^H{foo};
print "ok 1 - \$^H{foo} doesn't exist initially\n";
@@ -55,3 +61,15 @@ BEGIN {
print "not " if $^H & 0x00020000;
print "ok 8 - \$^H doesn't contain HINT_LOCALIZE_HH while finishing compilation\n";
}
+
+require 'test.pl';
+
+# bug #27040: hints hash was being double-freed
+my $result = runperl(
+ prog => '$^H |= 0x20000; eval q{BEGIN { $^H |= 0x20000 }}',
+ stderr => 1
+);
+print "not " if length $result;
+print "ok 15 - double-freeing hints hash\n";
+print "# got: $result\n" if length $result;
+
diff --git a/gnu/usr.bin/perl/t/comp/parser.t b/gnu/usr.bin/perl/t/comp/parser.t
index 730f187cec8..cd00b749c50 100644
--- a/gnu/usr.bin/perl/t/comp/parser.t
+++ b/gnu/usr.bin/perl/t/comp/parser.t
@@ -9,7 +9,7 @@ BEGIN {
}
require "./test.pl";
-plan( tests => 42 );
+plan( tests => 46 );
eval '%@x=0;';
like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' );
@@ -141,3 +141,24 @@ EOF
eval q{ *foo{CODE} ? 1 : 0 };
is( $@, '', "glob subscript in conditional" );
}
+
+# Bug #27024
+{
+ # this used to segfault (because $[=1 is optimized away to a null block)
+ my $x;
+ $[ = 1 while $x;
+ pass();
+ $[ = 0; # restore the original value for less side-effects
+}
+
+# [perl #2738] perl segfautls on input
+{
+ eval q{ sub _ <> {} };
+ like($@, qr/Illegal declaration of subroutine main::_/, "readline operator as prototype");
+
+ eval q{ $s = sub <> {} };
+ like($@, qr/Illegal declaration of anonymous subroutine/, "readline operator as prototype");
+
+ eval q{ sub _ __FILE__ {} };
+ like($@, qr/Illegal declaration of subroutine main::_/, "__FILE__ as prototype");
+}
diff --git a/gnu/usr.bin/perl/t/comp/utf.t b/gnu/usr.bin/perl/t/comp/utf.t
new file mode 100644
index 00000000000..90a9e5e11bb
--- /dev/null
+++ b/gnu/usr.bin/perl/t/comp/utf.t
@@ -0,0 +1,57 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ unless (find PerlIO::Layer 'perlio') {
+ print "1..0 # Skip: not perlio\n";
+ exit 0;
+ }
+ if ($ENV{PERL_CORE_MINITEST}) {
+ print "1..0 # Skip: no dynamic loading on miniperl, no threads\n";
+ exit 0;
+ }
+ require Config; import Config;
+ if ($Config{'extensions'} !~ /\bEncode\b/) {
+ print "1..0 # Skip: Encode was not built\n";
+ exit 0;
+ }
+}
+
+require "./test.pl";
+
+plan(tests => 15);
+
+my $BOM = chr(0xFEFF);
+
+sub test {
+ my ($enc, $tag, $bom) = @_;
+ open(UTF_PL, ">:raw:encoding($enc)", "utf.pl")
+ or die "utf.pl($enc,$tag,$bom): $!";
+ print UTF_PL $BOM if $bom;
+ print UTF_PL "$tag\n";
+ close(UTF_PL);
+ my $got = do "./utf.pl";
+ is($got, $tag);
+}
+
+test("utf16le", 123, 1);
+test("utf16le", 1234, 1);
+test("utf16le", 12345, 1);
+test("utf16be", 123, 1);
+test("utf16be", 1234, 1);
+test("utf16be", 12345, 1);
+test("utf8", 123, 1);
+test("utf8", 1234, 1);
+test("utf8", 12345, 1);
+
+test("utf16le", 123, 0);
+test("utf16le", 1234, 0);
+test("utf16le", 12345, 0);
+test("utf16be", 123, 0);
+test("utf16be", 1234, 0);
+test("utf16be", 12345, 0);
+
+END {
+ 1 while unlink "utf.pl";
+}