summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/t/comp
diff options
context:
space:
mode:
authorafresh1 <afresh1@openbsd.org>2019-02-13 21:15:00 +0000
committerafresh1 <afresh1@openbsd.org>2019-02-13 21:15:00 +0000
commit9f11ffb7133c203312a01e4b986886bc88c7d74b (patch)
tree6618511204c614b20256e4ef9dea39a7b311d638 /gnu/usr.bin/perl/t/comp
parentImport perl-5.28.1 (diff)
downloadwireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.tar.xz
wireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.zip
Fix merge issues, remove excess files - match perl-5.28.1 dist
looking good sthen@, Great! bluhm@
Diffstat (limited to 'gnu/usr.bin/perl/t/comp')
-rw-r--r--gnu/usr.bin/perl/t/comp/fold.t14
-rw-r--r--gnu/usr.bin/perl/t/comp/parser.t75
-rw-r--r--gnu/usr.bin/perl/t/comp/require.t8
-rw-r--r--gnu/usr.bin/perl/t/comp/utf.t6
4 files changed, 90 insertions, 13 deletions
diff --git a/gnu/usr.bin/perl/t/comp/fold.t b/gnu/usr.bin/perl/t/comp/fold.t
index 4fa0734bee8..a72394e8cf4 100644
--- a/gnu/usr.bin/perl/t/comp/fold.t
+++ b/gnu/usr.bin/perl/t/comp/fold.t
@@ -4,7 +4,7 @@
# we've not yet verified that use works.
# use strict;
-print "1..30\n";
+print "1..35\n";
my $test = 0;
# Historically constant folding was performed by evaluating the ops, and if
@@ -180,3 +180,15 @@ is "@values", "4 4",
is $w, 1, '1+undef_constant is not folded outside warninsg scope';
BEGIN { $^W = 1 }
}
+
+$a = eval 'my @z; @z = 0..~0 if 0; 3';
+is ($a, 3, "list constant folding doesn't signal compile-time error");
+is ($@, '', 'no error');
+
+$b = 0;
+$a = eval 'my @z; @z = 0..~0 if $b; 3';
+is ($a, 3, "list constant folding doesn't signal compile-time error");
+is ($@, '', 'no error');
+
+$a = eval 'local $SIG{__WARN__} = sub {}; join("", ":".."~", "z")';
+is ($a, ":z", "aborted list constant folding still executable");
diff --git a/gnu/usr.bin/perl/t/comp/parser.t b/gnu/usr.bin/perl/t/comp/parser.t
index 50f601cf45d..79b930ecb83 100644
--- a/gnu/usr.bin/perl/t/comp/parser.t
+++ b/gnu/usr.bin/perl/t/comp/parser.t
@@ -8,7 +8,7 @@ BEGIN {
chdir 't' if -d 't';
}
-print "1..173\n";
+print "1..188\n";
sub failed {
my ($got, $expected, $name) = @_;
@@ -58,11 +58,11 @@ sub is {
eval '%@x=0;';
like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' );
-# Bug 20010422.005
+# Bug 20010422.005 (#6874)
eval q{{s//${}/; //}};
like( $@, qr/syntax error/, 'syntax error, used to dump core' );
-# Bug 20010528.007
+# Bug 20010528.007 (#7052)
eval q/"\x{"/;
like( $@, qr/^Missing right brace on \\x/,
'syntax error in string, used to dump core' );
@@ -85,7 +85,7 @@ eval "a.b.c.d.e.f;sub";
like( $@, qr/^Illegal declaration of anonymous subroutine/,
'found by Markov chain stress testing' );
-# Bug 20010831.001
+# Bug 20010831.001 (#7605)
eval '($a, b) = (1, 2);';
like( $@, qr/^Can't modify constant item in list assignment/,
'bareword in list assignment' );
@@ -96,11 +96,11 @@ like( $@, qr/^Can't modify constant item in tie /,
eval 'undef foo';
like( $@, qr/^Can't modify constant item in undef operator /,
- 'undefing constant causes a segfault in 5.6.1 [ID 20010906.019]' );
+ 'undefing constant causes a segfault in 5.6.1 [ID 20010906.019 (#7642)]' );
eval 'read($bla, FILE, 1);';
like( $@, qr/^Can't modify constant item in read /,
- 'read($var, FILE, 1) segfaults on 5.6.1 [ID 20011025.054]' );
+ 'read($var, FILE, 1) segfaults on 5.6.1 [ID 20011025.054 (#7847)]' );
# This used to dump core (bug #17920)
eval q{ sub { sub { f1(f2();); my($a,$b,$c) } } };
@@ -444,7 +444,7 @@ is prototype "Hello::_he_said", '_', 'initial tick in sub declaration';
'literal -> after an array subscript within ""');
@x = ['string'];
# this used to give "string"
- like("$x[0]-> [0]", qr/^ARRAY\([^)]*\)-> \[0]\z/,
+ like("$x[0]-> [0]", qr/^ARRAY\([^)]*\)-> \[0\]\z/,
'literal -> [0] after an array subscript within ""');
}
@@ -540,12 +540,73 @@ eval "grep+grep";
eval 'my $_; m// ~~ 0';
}
+# Used to crash [perl #125679]
+eval 'BEGIN {$^H=-1} \eval=time';
+
+# Used to fail an assertion [perl #129073]
+{
+ local $SIG{__WARN__} = sub{};
+ eval '${p{};sub p}()';
+}
+
# RT #124207 syntax error during stringify can leave stringify op
# with multiple children and assertion failures
eval 'qq{@{0]}${}},{})';
is(1, 1, "RT #124207");
+# RT #127993 version control conflict markers
+" this should keep working
+<<<<<<<
+" =~ /
+>>>>>>>
+/;
+for my $marker (qw(
+<<<<<<<
+=======
+>>>>>>>
+)) {
+ eval "$marker";
+ like $@, qr/^Version control conflict marker at \(eval \d+\) line 1, near "$marker"/, "VCS marker '$marker' at beginning";
+ eval "\$_\n$marker";
+ like $@, qr/^Version control conflict marker at \(eval \d+\) line 2, near "$marker"/, "VCS marker '$marker' after value";
+ eval "\n\$_ =\n$marker";
+ like $@, qr/^Version control conflict marker at \(eval \d+\) line 3, near "$marker"/, "VCS marker '$marker' after operator";
+}
+
+# keys assignments in weird contexts (mentioned in perl #128260)
+eval 'keys(%h) .= "00"';
+is $@, "", 'keys .=';
+eval 'sub { read $fh, keys %h, 0 }';
+is $@, "", 'read into keys';
+eval 'substr keys(%h),0,=3';
+is $@, "", 'substr keys assignment';
+
+{ # very large utf8 char in error message was overflowing buffer
+ if (length sprintf("%x", ~0) <= 8) {
+ is 1, 1, "skip because overflows on 32-bit machine";
+ }
+ else {
+ no warnings;
+ eval "q" . chr(100000000064);
+ like $@, qr/Can't find string terminator "." anywhere before EOF/,
+ 'RT 128952';
+ }
+}
+
+# RT #130311: many parser shifts before a reduce
+
+{
+ eval '[' . ('{' x 300);
+ like $@, qr/Missing right curly or square bracket/, 'RT #130311';
+}
+
+# RT #130815: crash in ck_return for malformed code
+{
+ eval 'm(@{if(0){sub d{]]])}return';
+ like $@, qr/^syntax error at \(eval \d+\) line 1, near "\{\]"/,
+ 'RT #130815: null pointer deref';
+}
# Add new tests HERE (above this line)
diff --git a/gnu/usr.bin/perl/t/comp/require.t b/gnu/usr.bin/perl/t/comp/require.t
index b3e49954e68..c4889bba51f 100644
--- a/gnu/usr.bin/perl/t/comp/require.t
+++ b/gnu/usr.bin/perl/t/comp/require.t
@@ -34,7 +34,7 @@ if (grep -e, @files_to_delete) {
my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0;
my $Is_UTF8 = (${^OPEN} || "") =~ /:utf8/;
-my $total_tests = 57;
+my $total_tests = 58;
if ($Is_EBCDIC || $Is_UTF8) { $total_tests -= 3; }
print "1..$total_tests\n";
@@ -203,7 +203,11 @@ $foo = eval q{require bleah}; delete $INC{"bleah.pm"}; ++$::i;
eval q{return require bleah}; delete $INC{"bleah.pm"}; ++$::i;
$foo = eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
@foo = eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
- eval {require bleah};
+ eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
+
+eval 'require ::bleah;';
+print "# $@\nnot " unless $@ =~ /^Bareword in require must not start with a double-colon:/;
+print "ok ", $i," - require ::bleah is banned\n";
# Test for fix of RT #24404 : "require $scalar" may load a directory
my $r = "threads";
diff --git a/gnu/usr.bin/perl/t/comp/utf.t b/gnu/usr.bin/perl/t/comp/utf.t
index 4e747c4a98f..95c23651b9c 100644
--- a/gnu/usr.bin/perl/t/comp/utf.t
+++ b/gnu/usr.bin/perl/t/comp/utf.t
@@ -34,11 +34,11 @@ sub bytes_to_utf {
sub test {
my ($enc, $write, $expect, $bom, $nl, $name) = @_;
- open my $fh, ">", "utf$$.pl" or die "utf.pl: $!";
+ open my $fh, ">", "tmputf$$.pl" or die "tmputf$$.pl: $!";
binmode $fh;
print $fh bytes_to_utf($enc, $write . ($nl ? "\n" : ''), $bom);
close $fh or die $!;
- my $got = do "./utf$$.pl";
+ my $got = do "./tmputf$$.pl";
$test = $test + 1;
if (!defined $got) {
if ($@ =~ /^(Unsupported script encoding \Q$enc\E)/) {
@@ -100,5 +100,5 @@ for my $bom (0, 1) {
}
END {
- 1 while unlink "utf$$.pl";
+ 1 while unlink "tmputf$$.pl";
}