diff options
author | 2019-02-13 21:15:00 +0000 | |
---|---|---|
committer | 2019-02-13 21:15:00 +0000 | |
commit | 9f11ffb7133c203312a01e4b986886bc88c7d74b (patch) | |
tree | 6618511204c614b20256e4ef9dea39a7b311d638 /gnu/usr.bin/perl/t/opbasic | |
parent | Import perl-5.28.1 (diff) | |
download | wireguard-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/opbasic')
-rw-r--r-- | gnu/usr.bin/perl/t/opbasic/arith.t | 16 | ||||
-rw-r--r-- | gnu/usr.bin/perl/t/opbasic/cmp.t | 5 | ||||
-rw-r--r-- | gnu/usr.bin/perl/t/opbasic/concat.t | 718 | ||||
-rw-r--r-- | gnu/usr.bin/perl/t/opbasic/qq.t | 7 |
4 files changed, 712 insertions, 34 deletions
diff --git a/gnu/usr.bin/perl/t/opbasic/arith.t b/gnu/usr.bin/perl/t/opbasic/arith.t index 79922605df9..625f4c0e16f 100644 --- a/gnu/usr.bin/perl/t/opbasic/arith.t +++ b/gnu/usr.bin/perl/t/opbasic/arith.t @@ -2,7 +2,8 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; + require './test.pl'; + set_up_inc('../lib'); } # This file has been placed in t/opbasic to indicate that it should not use @@ -422,16 +423,15 @@ print "not "x($a ne $b), "ok ", $T++, qq ' - something % \$1 vs "\$1"\n'; my $vms_no_ieee; if ($^O eq 'VMS') { - use vars '%Config'; - eval {require Config; import Config}; - $vms_no_ieee = 1 unless defined($Config{useieee}); + eval { require Config }; + $vms_no_ieee = 1 unless defined($Config::Config{useieee}); } if ($^O eq 'vos') { print "not ok ", $T++, " # TODO VOS raises SIGFPE instead of producing infinity.\n"; } -elsif ($vms_no_ieee) { - print $T++, " # SKIP -- the IEEE infinity model is unavailable in this configuration.\n" +elsif ($vms_no_ieee || !$Config{d_double_has_inf}) { + print "ok ", $T++, " # SKIP -- the IEEE infinity model is unavailable in this configuration.\n" } elsif ($^O eq 'ultrix') { print "not ok ", $T++, " # TODO Ultrix enters deep nirvana instead of producing infinity.\n"; @@ -460,6 +460,9 @@ else { # [perl #120426] # small numbers shouldn't round to zero if they have extra floating digits +unless ($Config{d_double_style_ieee}) { +for (1..8) { print "ok ", $T++, " # SKIP -- not IEEE\n" } +} else { try $T++, 0.153e-305 != 0.0, '0.153e-305'; try $T++, 0.1530e-305 != 0.0, '0.1530e-305'; try $T++, 0.15300e-305 != 0.0, '0.15300e-305'; @@ -469,6 +472,7 @@ try $T++, 0.1530001e-305 != 0.0, '0.1530001e-305'; try $T++, 1.17549435100e-38 != 0.0, 'min single'; # For flush-to-zero systems this may flush-to-zero, see PERL_SYS_FPU_INIT try $T++, 2.2250738585072014e-308 != 0.0, 'min double'; +} # string-to-nv should equal float literals try $T++, "1.23" + 0 == 1.23, '1.23'; diff --git a/gnu/usr.bin/perl/t/opbasic/cmp.t b/gnu/usr.bin/perl/t/opbasic/cmp.t index 241eb491a69..5a88d21d0bf 100644 --- a/gnu/usr.bin/perl/t/opbasic/cmp.t +++ b/gnu/usr.bin/perl/t/opbasic/cmp.t @@ -1,10 +1,5 @@ #!./perl -BEGIN { - chdir 't' if -d 't'; - @INC = '../lib'; -} - # This file has been placed in t/opbasic to indicate that it should not use # functions imported from t/test.pl or Test::More, as those programs/libraries # use operators which are what is being tested in this file. diff --git a/gnu/usr.bin/perl/t/opbasic/concat.t b/gnu/usr.bin/perl/t/opbasic/concat.t index 9c4cbe20e22..9ce9722f5c8 100644 --- a/gnu/usr.bin/perl/t/opbasic/concat.t +++ b/gnu/usr.bin/perl/t/opbasic/concat.t @@ -5,12 +5,13 @@ BEGIN { @INC = '../lib'; } -# ok() functions from other sources (e.g., t/test.pl) may use concatenation, -# but that is what is being tested in this file. Hence, we place this file -# in the directory where do not use t/test.pl, and we write an ok() function -# specially written to avoid any concatenation. +# ok()/is() functions from other sources (e.g., t/test.pl) may use +# concatenation, but that is what is being tested in this file. Hence, we +# place this file in the directory where do not use t/test.pl, and we +# write functions specially written to avoid any concatenation. my $test = 1; + sub ok { my($ok, $name) = @_; @@ -22,7 +23,23 @@ sub ok { return $ok; } -print "1..31\n"; +sub is { + my($got, $expected, $name) = @_; + + my $ok = $got eq $expected; + + printf "%sok %d - %s\n", ($ok ? "" : "not "), $test, $name; + + if (!$ok) { + printf "# Failed test at line %d\n", (caller)[2]; + printf "# got: %s\n#expected: %s\n", $got, $expected; + } + + $test++; + return $ok; +} + +print "1..253\n"; ($a, $b, $c) = qw(foo bar); @@ -33,63 +50,63 @@ ok("$c$a$c" eq "foo", "concatenate undef, fore and aft"); # Okay, so that wasn't very challenging. Let's go Unicode. { - # bug id 20000819.004 + # bug id 20000819.004 (#3761) $_ = $dx = "\x{10f2}"; s/($dx)/$dx$1/; { - ok($_ eq "$dx$dx","bug id 20000819.004, back"); + ok($_ eq "$dx$dx","bug id 20000819.004 (#3761), back"); } $_ = $dx = "\x{10f2}"; s/($dx)/$1$dx/; { - ok($_ eq "$dx$dx","bug id 20000819.004, front"); + ok($_ eq "$dx$dx","bug id 20000819.004 (#3761), front"); } $dx = "\x{10f2}"; $_ = "\x{10f2}\x{10f2}"; s/($dx)($dx)/$1$2/; { - ok($_ eq "$dx$dx","bug id 20000819.004, front and back"); + ok($_ eq "$dx$dx","bug id 20000819.004 (#3761), front and back"); } } { - # bug id 20000901.092 + # bug id 20000901.092 (#4184) # test that undef left and right of utf8 results in a valid string my $a; $a .= "\x{1ff}"; - ok($a eq "\x{1ff}", "bug id 20000901.092, undef left"); + ok($a eq "\x{1ff}", "bug id 20000901.092 (#4184), undef left"); $a .= undef; - ok($a eq "\x{1ff}", "bug id 20000901.092, undef right"); + ok($a eq "\x{1ff}", "bug id 20000901.092 (#4184), undef right"); } { - # ID 20001020.006 + # ID 20001020.006 (#4484) "x" =~ /(.)/; # unset $2 # Without the fix this 5.7.0 would croak: # Modification of a read-only value attempted at ... eval {"$2\x{1234}"}; - ok(!$@, "bug id 20001020.006, left"); + ok(!$@, "bug id 20001020.006 (#4484), left"); # For symmetry with the above. eval {"\x{1234}$2"}; - ok(!$@, "bug id 20001020.006, right"); + ok(!$@, "bug id 20001020.006 (#4484), right"); *pi = \undef; # This bug existed earlier than the $2 bug, but is fixed with the same # patch. Without the fix this 5.7.0 would also croak: # Modification of a read-only value attempted at ... eval{"$pi\x{1234}"}; - ok(!$@, "bug id 20001020.006, constant left"); + ok(!$@, "bug id 20001020.006 (#4484), constant left"); # For symmetry with the above. eval{"\x{1234}$pi"}; - ok(!$@, "bug id 20001020.006, constant right"); + ok(!$@, "bug id 20001020.006 (#4484), constant right"); } sub beq { use bytes; $_[0] eq $_[1]; } @@ -132,6 +149,7 @@ sub beq { use bytes; $_[0] eq $_[1]; } my $up = "\x{100}\xB6"; my $x1 = $p; my $y1 = $u; + my ($x2, $x3, $x4, $y2); use bytes; ok(beq($p.$u, $p.$b), "perl #26905, left eq bytes"); @@ -144,11 +162,15 @@ sub beq { use bytes; $_[0] eq $_[1]; } $y1 .= $p; $y2 = $u . $p; + $x3 = $p; $x3 .= $u . $u; + $x4 = $p . $u . $u; + no bytes; ok(beq($x1, $x2), "perl #26905, left, .= vs = . in bytes"); ok(beq($y1, $y2), "perl #26905, right, .= vs = . in bytes"); ok(($x1 eq $x2), "perl #26905, left, .= vs = . in chars"); ok(($y1 eq $y2), "perl #26905, right, .= vs = . in chars"); + ok(($x3 eq $x4), "perl #26905, twin, .= vs = . in chars"); } { @@ -164,8 +186,670 @@ sub beq { use bytes; $_[0] eq $_[1]; } ok($x eq "ab-append-", "Appending to something initialized using constant folding"); } +# non-POK consts + +{ + my $a = "a"; + my $b; + $b = $a . $a . 1; + ok($b eq "aa1", "aa1"); + $b = 2 . $a . $a; + ok($b eq "2aa", "2aa"); +} + # [perl #124160] package o { use overload "." => sub { $_[0] }, fallback => 1 } $o = bless [], "o"; ok(ref(CORE::state $y = "a $o b") eq 'o', 'state $y = "foo $bar baz" does not stringify; only concats'); + + +# multiconcat: utf8 dest with non-utf8 args should grow dest sufficiently. +# This is mainly for valgrind or ASAN to detect problems with. + +{ + my $s = "\x{100}"; + my $t = "\x80" x 1024; + $s .= "-$t-"; + ok length($s) == 1027, "utf8 dest with non-utf8 args"; +} + +# target on RHS + +{ + my $a = "abc"; + $a .= $a; + ok($a eq 'abcabc', 'append self'); + + $a = "abc"; + $a = $a . $a; + ok($a eq 'abcabc', 'double self'); + + $a = "abc"; + $a .= $a . $a; + ok($a eq 'abcabcabc', 'append double self'); + + $a = "abc"; + $a = "$a-$a"; + ok($a eq 'abc-abc', 'double self with const'); + + $a = "abc"; + $a .= "$a-$a"; + ok($a eq 'abcabc-abc', 'append double self with const'); + + $a = "abc"; + $a .= $a . $a . $a; + ok($a eq 'abcabcabcabc', 'append triple self'); + + $a = "abc"; + $a = "$a-$a=$a"; + ok($a eq 'abc-abc=abc', 'triple self with const'); + + $a = "abc"; + $a .= "$a-$a=$a"; + ok($a eq 'abcabc-abc=abc', 'append triple self with const'); +} + +# test the sorts of optree which may (or may not) get optimised into +# a single MULTICONCAT op. It's based on a loop in t/perf/opcount.t, +# but here the loop is unwound as we would need to use concat to +# generate the expected results to compare with the actual results, +# which would rather defeat the object. + +{ + my ($a1, $a2, $a3) = qw(1 2 3); + our $pkg; + my $lex; + + is("-", '-', '"-"'); + is("-", '-', '"-"'); + is("-", '-', '"-"'); + is("-", '-', '"-"'); + is($a1, '1', '$a1'); + is("-".$a1, '-1', '"-".$a1'); + is($a1."-", '1-', '$a1."-"'); + is("-".$a1."-", '-1-', '"-".$a1."-"'); + is("$a1", '1', '"$a1"'); + is("-$a1", '-1', '"-$a1"'); + is("$a1-", '1-', '"$a1-"'); + is("-$a1-", '-1-', '"-$a1-"'); + is($a1.$a2, '12', '$a1.$a2'); + is($a1."-".$a2, '1-2', '$a1."-".$a2'); + is("-".$a1."-".$a2, '-1-2', '"-".$a1."-".$a2'); + is($a1."-".$a2."-", '1-2-', '$a1."-".$a2."-"'); + is("-".$a1."-".$a2."-", '-1-2-', '"-".$a1."-".$a2."-"'); + is("$a1$a2", '12', '"$a1$a2"'); + is("$a1-$a2", '1-2', '"$a1-$a2"'); + is("-$a1-$a2", '-1-2', '"-$a1-$a2"'); + is("$a1-$a2-", '1-2-', '"$a1-$a2-"'); + is("-$a1-$a2-", '-1-2-', '"-$a1-$a2-"'); + is($a1.$a2.$a3, '123', '$a1.$a2.$a3'); + is($a1."-".$a2."-".$a3, '1-2-3', '$a1."-".$a2."-".$a3'); + is("-".$a1."-".$a2."-".$a3, '-1-2-3', '"-".$a1."-".$a2."-".$a3'); + is($a1."-".$a2."-".$a3."-", '1-2-3-', '$a1."-".$a2."-".$a3."-"'); + is("-".$a1."-".$a2."-".$a3."-", '-1-2-3-', '"-".$a1."-".$a2."-".$a3."-"'); + is("$a1$a2$a3", '123', '"$a1$a2$a3"'); + is("$a1-$a2-$a3", '1-2-3', '"$a1-$a2-$a3"'); + is("-$a1-$a2-$a3", '-1-2-3', '"-$a1-$a2-$a3"'); + is("$a1-$a2-$a3-", '1-2-3-', '"$a1-$a2-$a3-"'); + is("-$a1-$a2-$a3-", '-1-2-3-', '"-$a1-$a2-$a3-"'); + $pkg = "-"; + is($pkg, '-', '$pkg = "-"'); + $pkg = "-"; + is($pkg, '-', '$pkg = "-"'); + $pkg = "-"; + is($pkg, '-', '$pkg = "-"'); + $pkg = "-"; + is($pkg, '-', '$pkg = "-"'); + $pkg = $a1; + is($pkg, '1', '$pkg = $a1'); + $pkg = "-".$a1; + is($pkg, '-1', '$pkg = "-".$a1'); + $pkg = $a1."-"; + is($pkg, '1-', '$pkg = $a1."-"'); + $pkg = "-".$a1."-"; + is($pkg, '-1-', '$pkg = "-".$a1."-"'); + $pkg = "$a1"; + is($pkg, '1', '$pkg = "$a1"'); + $pkg = "-$a1"; + is($pkg, '-1', '$pkg = "-$a1"'); + $pkg = "$a1-"; + is($pkg, '1-', '$pkg = "$a1-"'); + $pkg = "-$a1-"; + is($pkg, '-1-', '$pkg = "-$a1-"'); + $pkg = $a1.$a2; + is($pkg, '12', '$pkg = $a1.$a2'); + $pkg = $a1."-".$a2; + is($pkg, '1-2', '$pkg = $a1."-".$a2'); + $pkg = "-".$a1."-".$a2; + is($pkg, '-1-2', '$pkg = "-".$a1."-".$a2'); + $pkg = $a1."-".$a2."-"; + is($pkg, '1-2-', '$pkg = $a1."-".$a2."-"'); + $pkg = "-".$a1."-".$a2."-"; + is($pkg, '-1-2-', '$pkg = "-".$a1."-".$a2."-"'); + $pkg = "$a1$a2"; + is($pkg, '12', '$pkg = "$a1$a2"'); + $pkg = "$a1-$a2"; + is($pkg, '1-2', '$pkg = "$a1-$a2"'); + $pkg = "-$a1-$a2"; + is($pkg, '-1-2', '$pkg = "-$a1-$a2"'); + $pkg = "$a1-$a2-"; + is($pkg, '1-2-', '$pkg = "$a1-$a2-"'); + $pkg = "-$a1-$a2-"; + is($pkg, '-1-2-', '$pkg = "-$a1-$a2-"'); + $pkg = $a1.$a2.$a3; + is($pkg, '123', '$pkg = $a1.$a2.$a3'); + $pkg = $a1."-".$a2."-".$a3; + is($pkg, '1-2-3', '$pkg = $a1."-".$a2."-".$a3'); + $pkg = "-".$a1."-".$a2."-".$a3; + is($pkg, '-1-2-3', '$pkg = "-".$a1."-".$a2."-".$a3'); + $pkg = $a1."-".$a2."-".$a3."-"; + is($pkg, '1-2-3-', '$pkg = $a1."-".$a2."-".$a3."-"'); + $pkg = "-".$a1."-".$a2."-".$a3."-"; + is($pkg, '-1-2-3-', '$pkg = "-".$a1."-".$a2."-".$a3."-"'); + $pkg = "$a1$a2$a3"; + is($pkg, '123', '$pkg = "$a1$a2$a3"'); + $pkg = "$a1-$a2-$a3"; + is($pkg, '1-2-3', '$pkg = "$a1-$a2-$a3"'); + $pkg = "-$a1-$a2-$a3"; + is($pkg, '-1-2-3', '$pkg = "-$a1-$a2-$a3"'); + $pkg = "$a1-$a2-$a3-"; + is($pkg, '1-2-3-', '$pkg = "$a1-$a2-$a3-"'); + $pkg = "-$a1-$a2-$a3-"; + is($pkg, '-1-2-3-', '$pkg = "-$a1-$a2-$a3-"'); + $pkg = 'P'; + $pkg .= "-"; + is($pkg, 'P-', '$pkg .= "-"'); + $pkg = 'P'; + $pkg .= "-"; + is($pkg, 'P-', '$pkg .= "-"'); + $pkg = 'P'; + $pkg .= "-"; + is($pkg, 'P-', '$pkg .= "-"'); + $pkg = 'P'; + $pkg .= "-"; + is($pkg, 'P-', '$pkg .= "-"'); + $pkg = 'P'; + $pkg .= $a1; + is($pkg, 'P1', '$pkg .= $a1'); + $pkg = 'P'; + $pkg .= "-".$a1; + is($pkg, 'P-1', '$pkg .= "-".$a1'); + $pkg = 'P'; + $pkg .= $a1."-"; + is($pkg, 'P1-', '$pkg .= $a1."-"'); + $pkg = 'P'; + $pkg .= "-".$a1."-"; + is($pkg, 'P-1-', '$pkg .= "-".$a1."-"'); + $pkg = 'P'; + $pkg .= "$a1"; + is($pkg, 'P1', '$pkg .= "$a1"'); + $pkg = 'P'; + $pkg .= "-$a1"; + is($pkg, 'P-1', '$pkg .= "-$a1"'); + $pkg = 'P'; + $pkg .= "$a1-"; + is($pkg, 'P1-', '$pkg .= "$a1-"'); + $pkg = 'P'; + $pkg .= "-$a1-"; + is($pkg, 'P-1-', '$pkg .= "-$a1-"'); + $pkg = 'P'; + $pkg .= $a1.$a2; + is($pkg, 'P12', '$pkg .= $a1.$a2'); + $pkg = 'P'; + $pkg .= $a1."-".$a2; + is($pkg, 'P1-2', '$pkg .= $a1."-".$a2'); + $pkg = 'P'; + $pkg .= "-".$a1."-".$a2; + is($pkg, 'P-1-2', '$pkg .= "-".$a1."-".$a2'); + $pkg = 'P'; + $pkg .= $a1."-".$a2."-"; + is($pkg, 'P1-2-', '$pkg .= $a1."-".$a2."-"'); + $pkg = 'P'; + $pkg .= "-".$a1."-".$a2."-"; + is($pkg, 'P-1-2-', '$pkg .= "-".$a1."-".$a2."-"'); + $pkg = 'P'; + $pkg .= "$a1$a2"; + is($pkg, 'P12', '$pkg .= "$a1$a2"'); + $pkg = 'P'; + $pkg .= "$a1-$a2"; + is($pkg, 'P1-2', '$pkg .= "$a1-$a2"'); + $pkg = 'P'; + $pkg .= "-$a1-$a2"; + is($pkg, 'P-1-2', '$pkg .= "-$a1-$a2"'); + $pkg = 'P'; + $pkg .= "$a1-$a2-"; + is($pkg, 'P1-2-', '$pkg .= "$a1-$a2-"'); + $pkg = 'P'; + $pkg .= "-$a1-$a2-"; + is($pkg, 'P-1-2-', '$pkg .= "-$a1-$a2-"'); + $pkg = 'P'; + $pkg .= $a1.$a2.$a3; + is($pkg, 'P123', '$pkg .= $a1.$a2.$a3'); + $pkg = 'P'; + $pkg .= $a1."-".$a2."-".$a3; + is($pkg, 'P1-2-3', '$pkg .= $a1."-".$a2."-".$a3'); + $pkg = 'P'; + $pkg .= "-".$a1."-".$a2."-".$a3; + is($pkg, 'P-1-2-3', '$pkg .= "-".$a1."-".$a2."-".$a3'); + $pkg = 'P'; + $pkg .= $a1."-".$a2."-".$a3."-"; + is($pkg, 'P1-2-3-', '$pkg .= $a1."-".$a2."-".$a3."-"'); + $pkg = 'P'; + $pkg .= "-".$a1."-".$a2."-".$a3."-"; + is($pkg, 'P-1-2-3-', '$pkg .= "-".$a1."-".$a2."-".$a3."-"'); + $pkg = 'P'; + $pkg .= "$a1$a2$a3"; + is($pkg, 'P123', '$pkg .= "$a1$a2$a3"'); + $pkg = 'P'; + $pkg .= "$a1-$a2-$a3"; + is($pkg, 'P1-2-3', '$pkg .= "$a1-$a2-$a3"'); + $pkg = 'P'; + $pkg .= "-$a1-$a2-$a3"; + is($pkg, 'P-1-2-3', '$pkg .= "-$a1-$a2-$a3"'); + $pkg = 'P'; + $pkg .= "$a1-$a2-$a3-"; + is($pkg, 'P1-2-3-', '$pkg .= "$a1-$a2-$a3-"'); + $pkg = 'P'; + $pkg .= "-$a1-$a2-$a3-"; + is($pkg, 'P-1-2-3-', '$pkg .= "-$a1-$a2-$a3-"'); + $lex = "-"; + is($lex, '-', '$lex = "-"'); + $lex = "-"; + is($lex, '-', '$lex = "-"'); + $lex = "-"; + is($lex, '-', '$lex = "-"'); + $lex = "-"; + is($lex, '-', '$lex = "-"'); + $lex = $a1; + is($lex, '1', '$lex = $a1'); + $lex = "-".$a1; + is($lex, '-1', '$lex = "-".$a1'); + $lex = $a1."-"; + is($lex, '1-', '$lex = $a1."-"'); + $lex = "-".$a1."-"; + is($lex, '-1-', '$lex = "-".$a1."-"'); + $lex = "$a1"; + is($lex, '1', '$lex = "$a1"'); + $lex = "-$a1"; + is($lex, '-1', '$lex = "-$a1"'); + $lex = "$a1-"; + is($lex, '1-', '$lex = "$a1-"'); + $lex = "-$a1-"; + is($lex, '-1-', '$lex = "-$a1-"'); + $lex = $a1.$a2; + is($lex, '12', '$lex = $a1.$a2'); + $lex = $a1."-".$a2; + is($lex, '1-2', '$lex = $a1."-".$a2'); + $lex = "-".$a1."-".$a2; + is($lex, '-1-2', '$lex = "-".$a1."-".$a2'); + $lex = $a1."-".$a2."-"; + is($lex, '1-2-', '$lex = $a1."-".$a2."-"'); + $lex = "-".$a1."-".$a2."-"; + is($lex, '-1-2-', '$lex = "-".$a1."-".$a2."-"'); + $lex = "$a1$a2"; + is($lex, '12', '$lex = "$a1$a2"'); + $lex = "$a1-$a2"; + is($lex, '1-2', '$lex = "$a1-$a2"'); + $lex = "-$a1-$a2"; + is($lex, '-1-2', '$lex = "-$a1-$a2"'); + $lex = "$a1-$a2-"; + is($lex, '1-2-', '$lex = "$a1-$a2-"'); + $lex = "-$a1-$a2-"; + is($lex, '-1-2-', '$lex = "-$a1-$a2-"'); + $lex = $a1.$a2.$a3; + is($lex, '123', '$lex = $a1.$a2.$a3'); + $lex = $a1."-".$a2."-".$a3; + is($lex, '1-2-3', '$lex = $a1."-".$a2."-".$a3'); + $lex = "-".$a1."-".$a2."-".$a3; + is($lex, '-1-2-3', '$lex = "-".$a1."-".$a2."-".$a3'); + $lex = $a1."-".$a2."-".$a3."-"; + is($lex, '1-2-3-', '$lex = $a1."-".$a2."-".$a3."-"'); + $lex = "-".$a1."-".$a2."-".$a3."-"; + is($lex, '-1-2-3-', '$lex = "-".$a1."-".$a2."-".$a3."-"'); + $lex = "$a1$a2$a3"; + is($lex, '123', '$lex = "$a1$a2$a3"'); + $lex = "$a1-$a2-$a3"; + is($lex, '1-2-3', '$lex = "$a1-$a2-$a3"'); + $lex = "-$a1-$a2-$a3"; + is($lex, '-1-2-3', '$lex = "-$a1-$a2-$a3"'); + $lex = "$a1-$a2-$a3-"; + is($lex, '1-2-3-', '$lex = "$a1-$a2-$a3-"'); + $lex = "-$a1-$a2-$a3-"; + is($lex, '-1-2-3-', '$lex = "-$a1-$a2-$a3-"'); + $lex = 'L'; + $lex .= "-"; + is($lex, 'L-', '$lex .= "-"'); + $lex = 'L'; + $lex .= "-"; + is($lex, 'L-', '$lex .= "-"'); + $lex = 'L'; + $lex .= "-"; + is($lex, 'L-', '$lex .= "-"'); + $lex = 'L'; + $lex .= "-"; + is($lex, 'L-', '$lex .= "-"'); + $lex = 'L'; + $lex .= $a1; + is($lex, 'L1', '$lex .= $a1'); + $lex = 'L'; + $lex .= "-".$a1; + is($lex, 'L-1', '$lex .= "-".$a1'); + $lex = 'L'; + $lex .= $a1."-"; + is($lex, 'L1-', '$lex .= $a1."-"'); + $lex = 'L'; + $lex .= "-".$a1."-"; + is($lex, 'L-1-', '$lex .= "-".$a1."-"'); + $lex = 'L'; + $lex .= "$a1"; + is($lex, 'L1', '$lex .= "$a1"'); + $lex = 'L'; + $lex .= "-$a1"; + is($lex, 'L-1', '$lex .= "-$a1"'); + $lex = 'L'; + $lex .= "$a1-"; + is($lex, 'L1-', '$lex .= "$a1-"'); + $lex = 'L'; + $lex .= "-$a1-"; + is($lex, 'L-1-', '$lex .= "-$a1-"'); + $lex = 'L'; + $lex .= $a1.$a2; + is($lex, 'L12', '$lex .= $a1.$a2'); + $lex = 'L'; + $lex .= $a1."-".$a2; + is($lex, 'L1-2', '$lex .= $a1."-".$a2'); + $lex = 'L'; + $lex .= "-".$a1."-".$a2; + is($lex, 'L-1-2', '$lex .= "-".$a1."-".$a2'); + $lex = 'L'; + $lex .= $a1."-".$a2."-"; + is($lex, 'L1-2-', '$lex .= $a1."-".$a2."-"'); + $lex = 'L'; + $lex .= "-".$a1."-".$a2."-"; + is($lex, 'L-1-2-', '$lex .= "-".$a1."-".$a2."-"'); + $lex = 'L'; + $lex .= "$a1$a2"; + is($lex, 'L12', '$lex .= "$a1$a2"'); + $lex = 'L'; + $lex .= "$a1-$a2"; + is($lex, 'L1-2', '$lex .= "$a1-$a2"'); + $lex = 'L'; + $lex .= "-$a1-$a2"; + is($lex, 'L-1-2', '$lex .= "-$a1-$a2"'); + $lex = 'L'; + $lex .= "$a1-$a2-"; + is($lex, 'L1-2-', '$lex .= "$a1-$a2-"'); + $lex = 'L'; + $lex .= "-$a1-$a2-"; + is($lex, 'L-1-2-', '$lex .= "-$a1-$a2-"'); + $lex = 'L'; + $lex .= $a1.$a2.$a3; + is($lex, 'L123', '$lex .= $a1.$a2.$a3'); + $lex = 'L'; + $lex .= $a1."-".$a2."-".$a3; + is($lex, 'L1-2-3', '$lex .= $a1."-".$a2."-".$a3'); + $lex = 'L'; + $lex .= "-".$a1."-".$a2."-".$a3; + is($lex, 'L-1-2-3', '$lex .= "-".$a1."-".$a2."-".$a3'); + $lex = 'L'; + $lex .= $a1."-".$a2."-".$a3."-"; + is($lex, 'L1-2-3-', '$lex .= $a1."-".$a2."-".$a3."-"'); + $lex = 'L'; + $lex .= "-".$a1."-".$a2."-".$a3."-"; + is($lex, 'L-1-2-3-', '$lex .= "-".$a1."-".$a2."-".$a3."-"'); + $lex = 'L'; + $lex .= "$a1$a2$a3"; + is($lex, 'L123', '$lex .= "$a1$a2$a3"'); + $lex = 'L'; + $lex .= "$a1-$a2-$a3"; + is($lex, 'L1-2-3', '$lex .= "$a1-$a2-$a3"'); + $lex = 'L'; + $lex .= "-$a1-$a2-$a3"; + is($lex, 'L-1-2-3', '$lex .= "-$a1-$a2-$a3"'); + $lex = 'L'; + $lex .= "$a1-$a2-$a3-"; + is($lex, 'L1-2-3-', '$lex .= "$a1-$a2-$a3-"'); + $lex = 'L'; + $lex .= "-$a1-$a2-$a3-"; + is($lex, 'L-1-2-3-', '$lex .= "-$a1-$a2-$a3-"'); + { + my $l = "-"; + is($l, '-', 'my $l = "-"'); + } + { + my $l = "-"; + is($l, '-', 'my $l = "-"'); + } + { + my $l = "-"; + is($l, '-', 'my $l = "-"'); + } + { + my $l = "-"; + is($l, '-', 'my $l = "-"'); + } + { + my $l = $a1; + is($l, '1', 'my $l = $a1'); + } + { + my $l = "-".$a1; + is($l, '-1', 'my $l = "-".$a1'); + } + { + my $l = $a1."-"; + is($l, '1-', 'my $l = $a1."-"'); + } + { + my $l = "-".$a1."-"; + is($l, '-1-', 'my $l = "-".$a1."-"'); + } + { + my $l = "$a1"; + is($l, '1', 'my $l = "$a1"'); + } + { + my $l = "-$a1"; + is($l, '-1', 'my $l = "-$a1"'); + } + { + my $l = "$a1-"; + is($l, '1-', 'my $l = "$a1-"'); + } + { + my $l = "-$a1-"; + is($l, '-1-', 'my $l = "-$a1-"'); + } + { + my $l = $a1.$a2; + is($l, '12', 'my $l = $a1.$a2'); + } + { + my $l = $a1."-".$a2; + is($l, '1-2', 'my $l = $a1."-".$a2'); + } + { + my $l = "-".$a1."-".$a2; + is($l, '-1-2', 'my $l = "-".$a1."-".$a2'); + } + { + my $l = $a1."-".$a2."-"; + is($l, '1-2-', 'my $l = $a1."-".$a2."-"'); + } + { + my $l = "-".$a1."-".$a2."-"; + is($l, '-1-2-', 'my $l = "-".$a1."-".$a2."-"'); + } + { + my $l = "$a1$a2"; + is($l, '12', 'my $l = "$a1$a2"'); + } + { + my $l = "$a1-$a2"; + is($l, '1-2', 'my $l = "$a1-$a2"'); + } + { + my $l = "-$a1-$a2"; + is($l, '-1-2', 'my $l = "-$a1-$a2"'); + } + { + my $l = "$a1-$a2-"; + is($l, '1-2-', 'my $l = "$a1-$a2-"'); + } + { + my $l = "-$a1-$a2-"; + is($l, '-1-2-', 'my $l = "-$a1-$a2-"'); + } + { + my $l = $a1.$a2.$a3; + is($l, '123', 'my $l = $a1.$a2.$a3'); + } + { + my $l = $a1."-".$a2."-".$a3; + is($l, '1-2-3', 'my $l = $a1."-".$a2."-".$a3'); + } + { + my $l = "-".$a1."-".$a2."-".$a3; + is($l, '-1-2-3', 'my $l = "-".$a1."-".$a2."-".$a3'); + } + { + my $l = $a1."-".$a2."-".$a3."-"; + is($l, '1-2-3-', 'my $l = $a1."-".$a2."-".$a3."-"'); + } + { + my $l = "-".$a1."-".$a2."-".$a3."-"; + is($l, '-1-2-3-', 'my $l = "-".$a1."-".$a2."-".$a3."-"'); + } + { + my $l = "$a1$a2$a3"; + is($l, '123', 'my $l = "$a1$a2$a3"'); + } + { + my $l = "$a1-$a2-$a3"; + is($l, '1-2-3', 'my $l = "$a1-$a2-$a3"'); + } + { + my $l = "-$a1-$a2-$a3"; + is($l, '-1-2-3', 'my $l = "-$a1-$a2-$a3"'); + } + { + my $l = "$a1-$a2-$a3-"; + is($l, '1-2-3-', 'my $l = "$a1-$a2-$a3-"'); + } + { + my $l = "-$a1-$a2-$a3-"; + is($l, '-1-2-3-', 'my $l = "-$a1-$a2-$a3-"'); + } +} + +# multiconcat optimises away scalar assign, and is responsible +# for handling the assign itself. If the LHS is something weird, +# make sure it's handled ok + +{ + my $a = 'a'; + my $b = 'b'; + my $o = 'o'; + + my $re = qr/abc/; + $$re = $a . $b; + is($$re, "ab", '$$re = $a . $b'); + + #passing a hash elem to a sub creates a PVLV + my $s = sub { $_[0] = $a . $b; }; + my %h; + $s->($h{foo}); + is($h{foo}, "ab", "PVLV"); + + # assigning a string to a typeglob creates an alias + $Foo = 'myfoo'; + *Bar = ("F" . $o . $o); + is($Bar, "myfoo", '*Bar = "Foo"'); + + # while that same typeglob also appearing on the RHS returns + # a stringified value + + package QPR { + ${'*QPR::Bar*QPR::BarBaz'} = 'myfoobarbaz'; + *Bar = (*Bar . *Bar . "Baz"); + ::is($Bar, "myfoobarbaz", '*Bar = (*Bar . *Bar . "Baz")'); + } +} + +# distinguish between '=' and '.=' where the LHS has the OPf_MOD flag + +{ + my $foo = "foo"; + my $a . $foo; # weird but legal + is($a, '', 'my $a . $foo'); + my $b; $b .= $foo; + is($b, 'foo', 'my $b; $b .= $foo'); +} + +# distinguish between nested appends and concats; the former is +# affected by the change of value of the target on each concat. +# This is why multiconcat shouldn't be used in that case + +{ + my $a = "a"; + (($a .= $a) .= $a) .= $a; + is($a, "aaaaaaaa", '(($a .= $a) .= $a) .= $a;'); +} + +# check everything works ok near the max arg size of a multiconcat + +{ + my @a = map "<$_>", 0..99; + for my $i (60..68) { # check each side of 64 threshold + my $c = join '.', map "\$a[$_]", 0..$i; + my $got = eval $c or die $@; + my $empty = ''; # don't use a const string in case join'' ever + # gets optimised into a multiconcat + my $expected = join $empty, @a[0..$i]; + is($got, $expected, "long concat chain $i"); + } +} + +# RT #132646 +# with adjacent consts, the second const is treated as an arg rather than a +# consts. Make sure this doesn't exceeed the maximum allowed number of +# args +{ + my $x = 'X'; + my $got = + 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + . 'A' . $x . 'B' . 'C' . $x . 'D' + ; + is ($got, + "AXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXDAXBCXD", + "RT #132646"); +} + +# RT #132595 +# multiconcat shouldn't affect the order of arg evaluation +package RT132595 { + my $a = "a"; + my $i = 0; + sub TIESCALAR { bless({}, $_[0]) } + sub FETCH { ++$i; $a = "b".$i; "c".$i } + my $t; + tie $t, "RT132595"; + my $res = $a.$t.$a.$t; + ::is($res, "b1c1b1c2", "RT #132595"); +} diff --git a/gnu/usr.bin/perl/t/opbasic/qq.t b/gnu/usr.bin/perl/t/opbasic/qq.t index 5d6908cef1f..e633783df22 100644 --- a/gnu/usr.bin/perl/t/opbasic/qq.t +++ b/gnu/usr.bin/perl/t/opbasic/qq.t @@ -8,7 +8,7 @@ BEGIN { # This file uses a specially crafted is() function rather than that found in # t/test.pl or Test::More. Hence, we place this file in directory t/opbasic. -print q(1..29 +print q(1..28 ); # This is() function is written to avoid "" @@ -71,11 +71,6 @@ is ("a\o{120}b", "a" . chr(0x50) . "b"); is ("a\o{400}b", "a" . chr(0x100) . "b"); is ("a\o{1000}b", "a" . chr(0x200) . "b"); -# This caused a memory fault -no warnings "utf8"; -no warnings 'deprecated'; # This is above IV_MAX on 32 bit machines -is ("abc", eval qq[qq\x{8000_0000}abc\x{8000_0000}]); - # Maybe \x{} should be an error, but if not it should certainly mean \x{0} # rather than anything else. is ("\x{}", chr(0)); |