summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/t/re
diff options
context:
space:
mode:
authorsthen <sthen@openbsd.org>2013-03-25 20:40:40 +0000
committersthen <sthen@openbsd.org>2013-03-25 20:40:40 +0000
commit48950c12d106c85f315112191a0228d7b83b9510 (patch)
tree54e43d54484c1bfe9bb06a10ede0ba3e2fa52c08 /gnu/usr.bin/perl/t/re
parentavoid null dereference affecting mod_perl, Perl RT bug 116441 (diff)
downloadwireguard-openbsd-48950c12d106c85f315112191a0228d7b83b9510.tar.xz
wireguard-openbsd-48950c12d106c85f315112191a0228d7b83b9510.zip
merge/resolve conflicts
(some more to do after this one)
Diffstat (limited to 'gnu/usr.bin/perl/t/re')
-rw-r--r--gnu/usr.bin/perl/t/re/ReTest.pl193
-rwxr-xr-xgnu/usr.bin/perl/t/re/pat.t8
-rwxr-xr-xgnu/usr.bin/perl/t/re/re.t64
-rwxr-xr-xgnu/usr.bin/perl/t/re/reg_unsafe.t19
-rwxr-xr-xgnu/usr.bin/perl/t/re/substr.t725
-rwxr-xr-xgnu/usr.bin/perl/t/re/substr_thr.t7
6 files changed, 7 insertions, 1009 deletions
diff --git a/gnu/usr.bin/perl/t/re/ReTest.pl b/gnu/usr.bin/perl/t/re/ReTest.pl
deleted file mode 100644
index 4e69145ea4d..00000000000
--- a/gnu/usr.bin/perl/t/re/ReTest.pl
+++ /dev/null
@@ -1,193 +0,0 @@
-#!./perl
-#
-# This is the test subs used for regex testing.
-# This used to be part of re/pat.t
-use warnings;
-use strict;
-use 5.010;
-use base qw/Exporter/;
-use Carp;
-use vars qw(
- $EXPECTED_TESTS
- $TODO
- $Message
- $Error
- $DiePattern
- $WarnPattern
- $BugId
- $PatchId
- $running_as_thread
- $IS_ASCII
- $IS_EBCDIC
- $ordA
-);
-
-$| = 1;
-
-$Message ||= "Noname test";
-
-our $ordA = ord ('A'); # This defines ASCII/UTF-8 vs EBCDIC/UTF-EBCDIC
-# This defined the platform.
-our $IS_ASCII = $ordA == 65;
-our $IS_EBCDIC = $ordA == 193;
-
-use vars '%Config';
-eval 'use Config'; # Defaults assumed if this fails
-
-my $test = 0;
-my $done_plan;
-sub plan {
- my (undef,$tests)= @_;
- if (defined $tests) {
- die "Number of tests already defined! ($EXPECTED_TESTS)"
- if $EXPECTED_TESTS;
- $EXPECTED_TESTS= $tests;
- }
- if ($EXPECTED_TESTS) {
- print "1..$EXPECTED_TESTS\n" if !$done_plan++;
- } else {
- print "Number of tests not declared!";
- }
-}
-
-sub pretty {
- my ($mess) = @_;
- $mess =~ s/\n/\\n/g;
- $mess =~ s/\r/\\r/g;
- $mess =~ s/\t/\\t/g;
- $mess =~ s/([\00-\37\177])/sprintf '\%03o', ord $1/eg;
- $mess =~ s/#/\\#/g;
- $mess;
-}
-
-sub safe_globals {
- defined($_) and s/#/\\#/g for $BugId, $PatchId, $TODO;
-}
-
-sub _ok {
- my ($ok, $mess, $error) = @_;
- plan();
- safe_globals();
- $mess = pretty ($mess // $Message);
- $mess .= "; Bug $BugId" if defined $BugId;
- $mess .= "; Patch $PatchId" if defined $PatchId;
- $mess .= " # TODO $TODO" if defined $TODO;
-
- my $line_nr = (caller(1)) [2];
-
- printf "%sok %d - %s\n",
- ($ok ? "" : "not "),
- ++ $test,
- "$mess\tLine $line_nr";
-
- unless ($ok) {
- print "# Failed test at line $line_nr\n" unless defined $TODO;
- if ($error //= $Error) {
- no warnings 'utf8';
- chomp $error;
- $error = join "\n#", map {pretty $_} split /\n\h*#/ => $error;
- $error = "# $error" unless $error =~ /^\h*#/;
- print $error, "\n";
- }
- }
-
- return $ok;
-}
-
-# Force scalar context on the pattern match
-sub ok ($;$$) {_ok $_ [0], $_ [1], $_ [2]}
-sub nok ($;$$) {_ok !$_ [0], "Failed: " . ($_ [1] // $Message), $_ [2]}
-
-
-sub skip {
- my $why = shift;
- safe_globals();
- $why =~ s/\n.*//s;
- $why .= "; Bug $BugId" if defined $BugId;
- # seems like the new harness code doesnt like todo and skip to be mixed.
- # which seems like a bug in the harness to me. -- dmq
- #$why .= " # TODO $TODO" if defined $TODO;
-
- my $n = shift // 1;
- my $line_nr = (caller(0)) [2];
- for (1 .. $n) {
- ++ $test;
- #print "not " if defined $TODO;
- print "ok $test # skip $why\tLine $line_nr\n";
- }
- no warnings "exiting";
- last SKIP;
-}
-
-sub iseq ($$;$) {
- my ($got, $expect, $name) = @_;
-
- $_ = defined ($_) ? "'$_'" : "undef" for $got, $expect;
-
- my $ok = $got eq $expect;
- my $error = "# expected: $expect\n" .
- "# result: $got";
-
- _ok $ok, $name, $error;
-}
-
-sub isneq ($$;$) {
- my ($got, $expect, $name) = @_;
- my $todo = $TODO ? " # TODO $TODO" : '';
-
- $_ = defined ($_) ? "'$_'" : "undef" for $got, $expect;
-
- my $ok = $got ne $expect;
- my $error = "# results are equal ($got)";
-
- _ok $ok, $name, $error;
-}
-
-
-sub eval_ok ($;$) {
- my ($code, $name) = @_;
- local $@;
- if (ref $code) {
- _ok eval {&$code} && !$@, $name;
- }
- else {
- _ok eval ($code) && !$@, $name;
- }
-}
-
-sub must_die {
- my ($code, $pattern, $name) = @_;
- $pattern //= $DiePattern
- or Carp::confess("Bad pattern");
- undef $@;
- ref $code ? &$code : eval $code;
- my $r = $@ && $@ =~ /$pattern/;
- _ok $r, $name // $Message // "\$\@ =~ /$pattern/";
-}
-
-sub must_warn {
- my ($code, $pattern, $name) = @_;
- $pattern //= $WarnPattern;
- my $w;
- local $SIG {__WARN__} = sub {$w .= join "" => @_};
- use warnings 'all';
- ref $code ? &$code : eval $code;
- my $r = $w && $w =~ /$pattern/;
- $w //= "UNDEF";
- _ok $r, $name // $Message // "Got warning /$pattern/",
- "# expected: /$pattern/\n" .
- "# result: $w";
-}
-
-sub may_not_warn {
- my ($code, $name) = @_;
- my $w;
- local $SIG {__WARN__} = sub {$w .= join "" => @_};
- use warnings 'all';
- ref $code ? &$code : eval $code;
- _ok !$w, $name // ($Message ? "$Message (did not warn)"
- : "Did not warn"),
- "Got warning '$w'";
-}
-
-1;
diff --git a/gnu/usr.bin/perl/t/re/pat.t b/gnu/usr.bin/perl/t/re/pat.t
index faddbc5aaa8..2d026b3114b 100755
--- a/gnu/usr.bin/perl/t/re/pat.t
+++ b/gnu/usr.bin/perl/t/re/pat.t
@@ -508,7 +508,13 @@ sub run_tests {
is(qr/\b\v$/, '(?^:\b\v$)', 'qr/\b\v$/');
}
- { # Test that charset modifier work, and are interpolated
+ SKIP: { # Test that charset modifier work, and are interpolated
+ if (
+ !$Config::Config{d_setlocale}
+ || $Config::Config{ccflags} =~ /\bD?NO_LOCALE(_|\b)/
+ ) {
+ skip "no locale support", 13
+ }
is(qr/\b\v$/, '(?^:\b\v$)', 'Verify no locale, no unicode_strings gives default modifier');
is(qr/(?l:\b\v$)/, '(?^:(?l:\b\v$))', 'Verify infix l modifier compiles');
is(qr/(?u:\b\v$)/, '(?^:(?u:\b\v$))', 'Verify infix u modifier compiles');
diff --git a/gnu/usr.bin/perl/t/re/re.t b/gnu/usr.bin/perl/t/re/re.t
deleted file mode 100755
index 249c6ddf229..00000000000
--- a/gnu/usr.bin/perl/t/re/re.t
+++ /dev/null
@@ -1,64 +0,0 @@
-#!./perl
-
-BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
- require './test.pl';
-}
-
-use strict;
-use warnings;
-
-use re qw(is_regexp regexp_pattern
- regname regnames regnames_count);
-{
- my $qr=qr/foo/pi;
- my $rx = $$qr;
-
- ok(is_regexp($qr),'is_regexp(REGEXP ref)');
- ok(is_regexp($rx),'is_regexp(REGEXP)');
- ok(!is_regexp(''),'is_regexp("")');
-
- is((regexp_pattern($qr))[0],'foo','regexp_pattern[0] (ref)');
- is((regexp_pattern($qr))[1],'ip','regexp_pattern[1] (ref)');
- is(regexp_pattern($qr),'(?pi-xsm:foo)','scalar regexp_pattern (ref)');
-
- is((regexp_pattern($rx))[0],'foo','regexp_pattern[0] (bare REGEXP)');
- is((regexp_pattern($rx))[1],'ip','regexp_pattern[1] (bare REGEXP)');
- is(regexp_pattern($rx),'(?pi-xsm:foo)',
- 'scalar regexp_pattern (bare REGEXP)');
-
- ok(!regexp_pattern(''),'!regexp_pattern("")');
-}
-
-if ('1234'=~/(?:(?<A>\d)|(?<C>!))(?<B>\d)(?<A>\d)(?<B>\d)/){
- my @names = sort +regnames();
- is("@names","A B","regnames");
- @names = sort +regnames(0);
- is("@names","A B","regnames");
- my $names = regnames();
- is($names, "B", "regnames in scalar context");
- @names = sort +regnames(1);
- is("@names","A B C","regnames");
- is(join("", @{regname("A",1)}),"13");
- is(join("", @{regname("B",1)}),"24");
- {
- if ('foobar'=~/(?<foo>foo)(?<bar>bar)/) {
- is(regnames_count(),2);
- } else {
- ok(0); ok(0);
- }
- }
- is(regnames_count(),3);
-}
-
- { # Keep this test last, as whole script will be interrupted if times out
- # Bug #72998; this can loop
- watchdog(2);
- eval '"\x{100}\x{FB00}" =~ /\x{100}\N{U+66}+/i';
- pass("Didn't loop");
- }
-
-# New tests above this line, don't forget to update the test count below!
-BEGIN { plan tests => 19 }
-# No tests here!
diff --git a/gnu/usr.bin/perl/t/re/reg_unsafe.t b/gnu/usr.bin/perl/t/re/reg_unsafe.t
deleted file mode 100755
index fe2c718e310..00000000000
--- a/gnu/usr.bin/perl/t/re/reg_unsafe.t
+++ /dev/null
@@ -1,19 +0,0 @@
-#!./perl
-
-BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
-
-}
-print "1..1\n";
-
-# there is an equivelent test in t/re/pat.t which does NOT fail
-# its not clear why it doesnt fail, so this todo gets its own test
-# file until we can work it out.
-
-my $x;
-($x='abc')=~/(abc)/g;
-$x='123';
-
-print "not " if $1 ne 'abc';
-print "ok 1 # TODO safe match vars make /g slow\n";
diff --git a/gnu/usr.bin/perl/t/re/substr.t b/gnu/usr.bin/perl/t/re/substr.t
deleted file mode 100755
index d0717ba8ff0..00000000000
--- a/gnu/usr.bin/perl/t/re/substr.t
+++ /dev/null
@@ -1,725 +0,0 @@
-#!./perl
-
-#P = start of string Q = start of substr R = end of substr S = end of string
-
-BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
-}
-use warnings ;
-no warnings 'deprecated';
-
-$a = 'abcdefxyz';
-$SIG{__WARN__} = sub {
- if ($_[0] =~ /^substr outside of string/) {
- $w++;
- } elsif ($_[0] =~ /^Attempt to use reference as lvalue in substr/) {
- $w += 2;
- } elsif ($_[0] =~ /^Use of uninitialized value/) {
- $w += 3;
- } else {
- warn $_[0];
- }
-};
-
-require './test.pl';
-
-plan(360);
-
-run_tests() unless caller;
-
-my $krunch = "a";
-
-sub run_tests {
-
-$FATAL_MSG = qr/^substr outside of string/;
-
-is(substr($a,0,3), 'abc'); # P=Q R S
-is(substr($a,3,3), 'def'); # P Q R S
-is(substr($a,6,999), 'xyz'); # P Q S R
-$b = substr($a,999,999) ; # warn # P R Q S
-is ($w--, 1);
-eval{substr($a,999,999) = "" ; };# P R Q S
-like ($@, $FATAL_MSG);
-is(substr($a,0,-6), 'abc'); # P=Q R S
-is(substr($a,-3,1), 'x'); # P Q R S
-
-$[ = 1;
-
-is(substr($a,1,3), 'abc' ); # P=Q R S
-is(substr($a,4,3), 'def' ); # P Q R S
-is(substr($a,7,999), 'xyz');# P Q S R
-$b = substr($a,999,999) ; # warn # P R Q S
-is($w--, 1);
-eval{substr($a,999,999) = "" ; } ; # P R Q S
-like ($@, $FATAL_MSG);
-is(substr($a,1,-6), 'abc' );# P=Q R S
-is(substr($a,-3,1), 'x' ); # P Q R S
-
-$[ = 0;
-
-substr($a,3,3) = 'XYZ';
-is($a, 'abcXYZxyz' );
-substr($a,0,2) = '';
-is($a, 'cXYZxyz' );
-substr($a,0,0) = 'ab';
-is($a, 'abcXYZxyz' );
-substr($a,0,0) = '12345678';
-is($a, '12345678abcXYZxyz' );
-substr($a,-3,3) = 'def';
-is($a, '12345678abcXYZdef');
-substr($a,-3,3) = '<';
-is($a, '12345678abcXYZ<' );
-substr($a,-1,1) = '12345678';
-is($a, '12345678abcXYZ12345678' );
-
-$a = 'abcdefxyz';
-
-is(substr($a,6), 'xyz' ); # P Q R=S
-is(substr($a,-3), 'xyz' ); # P Q R=S
-$b = substr($a,999,999) ; # warning # P R=S Q
-is($w--, 1);
-eval{substr($a,999,999) = "" ; } ; # P R=S Q
-like($@, $FATAL_MSG);
-is(substr($a,0), 'abcdefxyz'); # P=Q R=S
-is(substr($a,9), ''); # P Q=R=S
-is(substr($a,-11), 'abcdefxyz'); # Q P R=S
-is(substr($a,-9), 'abcdefxyz'); # P=Q R=S
-
-$a = '54321';
-
-$b = substr($a,-7, 1) ; # warn # Q R P S
-is($w--, 1);
-eval{substr($a,-7, 1) = "" ; }; # Q R P S
-like($@, $FATAL_MSG);
-$b = substr($a,-7,-6) ; # warn # Q R P S
-is($w--, 1);
-eval{substr($a,-7,-6) = "" ; }; # Q R P S
-like($@, $FATAL_MSG);
-is(substr($a,-5,-7), ''); # R P=Q S
-is(substr($a, 2,-7), ''); # R P Q S
-is(substr($a,-3,-7), ''); # R P Q S
-is(substr($a, 2,-5), ''); # P=R Q S
-is(substr($a,-3,-5), ''); # P=R Q S
-is(substr($a, 2,-4), ''); # P R Q S
-is(substr($a,-3,-4), ''); # P R Q S
-is(substr($a, 5,-6), ''); # R P Q=S
-is(substr($a, 5,-5), ''); # P=R Q S
-is(substr($a, 5,-3), ''); # P R Q=S
-$b = substr($a, 7,-7) ; # warn # R P S Q
-is($w--, 1);
-eval{substr($a, 7,-7) = "" ; }; # R P S Q
-like($@, $FATAL_MSG);
-$b = substr($a, 7,-5) ; # warn # P=R S Q
-is($w--, 1);
-eval{substr($a, 7,-5) = "" ; }; # P=R S Q
-like($@, $FATAL_MSG);
-$b = substr($a, 7,-3) ; # warn # P Q S Q
-is($w--, 1);
-eval{substr($a, 7,-3) = "" ; }; # P Q S Q
-like($@, $FATAL_MSG);
-$b = substr($a, 7, 0) ; # warn # P S Q=R
-is($w--, 1);
-eval{substr($a, 7, 0) = "" ; }; # P S Q=R
-like($@, $FATAL_MSG);
-
-is(substr($a,-7,2), ''); # Q P=R S
-is(substr($a,-7,4), '54'); # Q P R S
-is(substr($a,-7,7), '54321');# Q P R=S
-is(substr($a,-7,9), '54321');# Q P S R
-is(substr($a,-5,0), ''); # P=Q=R S
-is(substr($a,-5,3), '543');# P=Q R S
-is(substr($a,-5,5), '54321');# P=Q R=S
-is(substr($a,-5,7), '54321');# P=Q S R
-is(substr($a,-3,0), ''); # P Q=R S
-is(substr($a,-3,3), '321');# P Q R=S
-is(substr($a,-2,3), '21'); # P Q S R
-is(substr($a,0,-5), ''); # P=Q=R S
-is(substr($a,2,-3), ''); # P Q=R S
-is(substr($a,0,0), ''); # P=Q=R S
-is(substr($a,0,5), '54321');# P=Q R=S
-is(substr($a,0,7), '54321');# P=Q S R
-is(substr($a,2,0), ''); # P Q=R S
-is(substr($a,2,3), '321'); # P Q R=S
-is(substr($a,5,0), ''); # P Q=R=S
-is(substr($a,5,2), ''); # P Q=S R
-is(substr($a,-7,-5), ''); # Q P=R S
-is(substr($a,-7,-2), '543');# Q P R S
-is(substr($a,-5,-5), ''); # P=Q=R S
-is(substr($a,-5,-2), '543');# P=Q R S
-is(substr($a,-3,-3), ''); # P Q=R S
-is(substr($a,-3,-1), '32');# P Q R S
-
-$a = '';
-
-is(substr($a,-2,2), ''); # Q P=R=S
-is(substr($a,0,0), ''); # P=Q=R=S
-is(substr($a,0,1), ''); # P=Q=S R
-is(substr($a,-2,3), ''); # Q P=S R
-is(substr($a,-2), ''); # Q P=R=S
-is(substr($a,0), ''); # P=Q=R=S
-
-
-is(substr($a,0,-1), ''); # R P=Q=S
-$b = substr($a,-2, 0) ; # warn # Q=R P=S
-is($w--, 1);
-eval{substr($a,-2, 0) = "" ; }; # Q=R P=S
-like($@, $FATAL_MSG);
-
-$b = substr($a,-2, 1) ; # warn # Q R P=S
-is($w--, 1);
-eval{substr($a,-2, 1) = "" ; }; # Q R P=S
-like($@, $FATAL_MSG);
-
-$b = substr($a,-2,-1) ; # warn # Q R P=S
-is($w--, 1);
-eval{substr($a,-2,-1) = "" ; }; # Q R P=S
-like($@, $FATAL_MSG);
-
-$b = substr($a,-2,-2) ; # warn # Q=R P=S
-is($w--, 1);
-eval{substr($a,-2,-2) = "" ; }; # Q=R P=S
-like($@, $FATAL_MSG);
-
-$b = substr($a, 1,-2) ; # warn # R P=S Q
-is($w--, 1);
-eval{substr($a, 1,-2) = "" ; }; # R P=S Q
-like($@, $FATAL_MSG);
-
-$b = substr($a, 1, 1) ; # warn # P=S Q R
-is($w--, 1);
-eval{substr($a, 1, 1) = "" ; }; # P=S Q R
-like($@, $FATAL_MSG);
-
-$b = substr($a, 1, 0) ;# warn # P=S Q=R
-is($w--, 1);
-eval{substr($a, 1, 0) = "" ; }; # P=S Q=R
-like($@, $FATAL_MSG);
-
-$b = substr($a,1) ; # warning # P=R=S Q
-is($w--, 1);
-eval{substr($a,1) = "" ; }; # P=R=S Q
-like($@, $FATAL_MSG);
-
-$b = substr($a,-7,-6) ; # warn # Q R P S
-is($w--, 1);
-eval{substr($a,-7,-6) = "" ; }; # Q R P S
-like($@, $FATAL_MSG);
-
-my $a = 'zxcvbnm';
-substr($a,2,0) = '';
-is($a, 'zxcvbnm');
-substr($a,7,0) = '';
-is($a, 'zxcvbnm');
-substr($a,5,0) = '';
-is($a, 'zxcvbnm');
-substr($a,0,2) = 'pq';
-is($a, 'pqcvbnm');
-substr($a,2,0) = 'r';
-is($a, 'pqrcvbnm');
-substr($a,8,0) = 'asd';
-is($a, 'pqrcvbnmasd');
-substr($a,0,2) = 'iop';
-is($a, 'ioprcvbnmasd');
-substr($a,0,5) = 'fgh';
-is($a, 'fghvbnmasd');
-substr($a,3,5) = 'jkl';
-is($a, 'fghjklsd');
-substr($a,3,2) = '1234';
-is($a, 'fgh1234lsd');
-
-
-# with lexicals (and in re-entered scopes)
-for (0,1) {
- my $txt;
- unless ($_) {
- $txt = "Foo";
- substr($txt, -1) = "X";
- is($txt, "FoX");
- }
- else {
- substr($txt, 0, 1) = "X";
- is($txt, "X");
- }
-}
-
-$w = 0 ;
-# coercion of references
-{
- my $s = [];
- substr($s, 0, 1) = 'Foo';
- is (substr($s,0,7), "FooRRAY");
- is ($w,2);
- $w = 0;
-}
-
-# check no spurious warnings
-is($w, 0);
-
-# check new 4 arg replacement syntax
-$a = "abcxyz";
-$w = 0;
-is(substr($a, 0, 3, ""), "abc");
-is($a, "xyz");
-is(substr($a, 0, 0, "abc"), "");
-is($a, "abcxyz");
-is(substr($a, 3, -1, ""), "xy");
-is($a, "abcz");
-
-is(substr($a, 3, undef, "xy"), "");
-is($a, "abcxyz");
-is($w, 3);
-
-$w = 0;
-
-is(substr($a, 3, 9999999, ""), "xyz");
-is($a, "abc");
-eval{substr($a, -99, 0, "") };
-like($@, $FATAL_MSG);
-eval{substr($a, 99, 3, "") };
-like($@, $FATAL_MSG);
-
-substr($a, 0, length($a), "foo");
-is ($a, "foo");
-is ($w, 0);
-
-# using 4 arg substr as lvalue is a compile time error
-eval 'substr($a,0,0,"") = "abc"';
-like ($@, qr/Can't modify substr/);
-is ($a, "foo");
-
-$a = "abcdefgh";
-is(sub { shift }->(substr($a, 0, 4, "xxxx")), 'abcd');
-is($a, 'xxxxefgh');
-
-{
- my $y = 10;
- $y = "2" . $y;
- is ($y, 210);
-}
-
-# utf8 sanity
-{
- my $x = substr("a\x{263a}b",0);
- is(length($x), 3);
- $x = substr($x,1,1);
- is($x, "\x{263a}");
- $x = $x x 2;
- is(length($x), 2);
- substr($x,0,1) = "abcd";
- is($x, "abcd\x{263a}");
- is(length($x), 5);
- $x = reverse $x;
- is(length($x), 5);
- is($x, "\x{263a}dcba");
-
- my $z = 10;
- $z = "21\x{263a}" . $z;
- is(length($z), 5);
- is($z, "21\x{263a}10");
-}
-
-# replacement should work on magical values
-require Tie::Scalar;
-my %data;
-tie $data{'a'}, 'Tie::StdScalar'; # makes $data{'a'} magical
-$data{a} = "firstlast";
-is(substr($data{'a'}, 0, 5, ""), "first");
-is($data{'a'}, "last");
-
-# more utf8
-
-# The following two originally from Ignasi Roca.
-
-$x = "\xF1\xF2\xF3";
-substr($x, 0, 1) = "\x{100}"; # Ignasi had \x{FF}
-is(length($x), 3);
-is($x, "\x{100}\xF2\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 0, 1) = "\x{100}\x{FF}"; # Ignasi had \x{FF}
-is(length($x), 4);
-is($x, "\x{100}\x{FF}\xF2\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F2}");
-is(substr($x, 3, 1), "\x{F3}");
-
-# more utf8 lval exercise
-
-$x = "\xF1\xF2\xF3";
-substr($x, 0, 2) = "\x{100}\xFF";
-is(length($x), 3);
-is($x, "\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 1, 1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\xF1\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{F1}");
-is(substr($x, 1, 1), "\x{100}");
-is(substr($x, 2, 1), "\x{FF}");
-is(substr($x, 3, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 2, 1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\xF1\xF2\x{100}\xFF");
-is(substr($x, 0, 1), "\x{F1}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 3, 1) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\xF1\xF2\xF3\x{100}\xFF");
-is(substr($x, 0, 1), "\x{F1}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{F3}");
-is(substr($x, 3, 1), "\x{100}");
-is(substr($x, 4, 1), "\x{FF}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, -1, 1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\xF1\xF2\x{100}\xFF");
-is(substr($x, 0, 1), "\x{F1}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, -1, 0) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\xF1\xF2\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{F1}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-is(substr($x, 4, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 0, -1) = "\x{100}\xFF";
-is(length($x), 3);
-is($x, "\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 0, -2) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\x{100}\xFF\xF2\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F2}");
-is(substr($x, 3, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 0, -3) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\x{100}\xFF\xF1\xF2\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F1}");
-is(substr($x, 3, 1), "\x{F2}");
-is(substr($x, 4, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, 1, -1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\xF1\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{F1}");
-is(substr($x, 1, 1), "\x{100}");
-is(substr($x, 2, 1), "\x{FF}");
-is(substr($x, 3, 1), "\x{F3}");
-
-$x = "\xF1\xF2\xF3";
-substr($x, -1, -1) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\xF1\xF2\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{F1}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-is(substr($x, 4, 1), "\x{F3}");
-
-# And tests for already-UTF8 one
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 0, 1) = "\x{100}";
-is(length($x), 3);
-is($x, "\x{100}\xF2\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 0, 1) = "\x{100}\x{FF}";
-is(length($x), 4);
-is($x, "\x{100}\x{FF}\xF2\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F2}");
-is(substr($x, 3, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 0, 2) = "\x{100}\xFF";
-is(length($x), 3);
-is($x, "\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 1, 1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\x{101}\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{101}");
-is(substr($x, 1, 1), "\x{100}");
-is(substr($x, 2, 1), "\x{FF}");
-is(substr($x, 3, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 2, 1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\x{101}\xF2\x{100}\xFF");
-is(substr($x, 0, 1), "\x{101}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 3, 1) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\x{101}\x{F2}\x{F3}\x{100}\xFF");
-is(substr($x, 0, 1), "\x{101}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{F3}");
-is(substr($x, 3, 1), "\x{100}");
-is(substr($x, 4, 1), "\x{FF}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, -1, 1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\x{101}\xF2\x{100}\xFF");
-is(substr($x, 0, 1), "\x{101}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, -1, 0) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\x{101}\xF2\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{101}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-is(substr($x, 4, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 0, -1) = "\x{100}\xFF";
-is(length($x), 3);
-is($x, "\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 0, -2) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\x{100}\xFF\xF2\xF3");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{F2}");
-is(substr($x, 3, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 0, -3) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\x{100}\xFF\x{101}\x{F2}\x{F3}");
-is(substr($x, 0, 1), "\x{100}");
-is(substr($x, 1, 1), "\x{FF}");
-is(substr($x, 2, 1), "\x{101}");
-is(substr($x, 3, 1), "\x{F2}");
-is(substr($x, 4, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, 1, -1) = "\x{100}\xFF";
-is(length($x), 4);
-is($x, "\x{101}\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{101}");
-is(substr($x, 1, 1), "\x{100}");
-is(substr($x, 2, 1), "\x{FF}");
-is(substr($x, 3, 1), "\x{F3}");
-
-$x = "\x{101}\x{F2}\x{F3}";
-substr($x, -1, -1) = "\x{100}\xFF";
-is(length($x), 5);
-is($x, "\x{101}\xF2\x{100}\xFF\xF3");
-is(substr($x, 0, 1), "\x{101}");
-is(substr($x, 1, 1), "\x{F2}");
-is(substr($x, 2, 1), "\x{100}");
-is(substr($x, 3, 1), "\x{FF}");
-is(substr($x, 4, 1), "\x{F3}");
-
-substr($x = "ab", 0, 0, "\x{100}\x{200}");
-is($x, "\x{100}\x{200}ab");
-
-substr($x = "\x{100}\x{200}", 0, 0, "ab");
-is($x, "ab\x{100}\x{200}");
-
-substr($x = "ab", 1, 0, "\x{100}\x{200}");
-is($x, "a\x{100}\x{200}b");
-
-substr($x = "\x{100}\x{200}", 1, 0, "ab");
-is($x, "\x{100}ab\x{200}");
-
-substr($x = "ab", 2, 0, "\x{100}\x{200}");
-is($x, "ab\x{100}\x{200}");
-
-substr($x = "\x{100}\x{200}", 2, 0, "ab");
-is($x, "\x{100}\x{200}ab");
-
-substr($x = "\xFFb", 0, 0, "\x{100}\x{200}");
-is($x, "\x{100}\x{200}\xFFb");
-
-substr($x = "\x{100}\x{200}", 0, 0, "\xFFb");
-is($x, "\xFFb\x{100}\x{200}");
-
-substr($x = "\xFFb", 1, 0, "\x{100}\x{200}");
-is($x, "\xFF\x{100}\x{200}b");
-
-substr($x = "\x{100}\x{200}", 1, 0, "\xFFb");
-is($x, "\x{100}\xFFb\x{200}");
-
-substr($x = "\xFFb", 2, 0, "\x{100}\x{200}");
-is($x, "\xFFb\x{100}\x{200}");
-
-substr($x = "\x{100}\x{200}", 2, 0, "\xFFb");
-is($x, "\x{100}\x{200}\xFFb");
-
-# [perl #20933]
-{
- my $s = "ab";
- my @r;
- $r[$_] = \ substr $s, $_, 1 for (0, 1);
- is(join("", map { $$_ } @r), "ab");
-}
-
-# [perl #23207]
-{
- sub ss {
- substr($_[0],0,1) ^= substr($_[0],1,1) ^=
- substr($_[0],0,1) ^= substr($_[0],1,1);
- }
- my $x = my $y = 'AB'; ss $x; ss $y;
- is($x, $y);
-}
-
-# [perl #24605]
-{
- my $x = "0123456789\x{500}";
- my $y = substr $x, 4;
- is(substr($x, 7, 1), "7");
-}
-
-# multiple assignments to lvalue [perl #24346]
-{
- my $x = "abcdef";
- for (substr($x,1,3)) {
- is($_, 'bcd');
- $_ = 'XX';
- is($_, 'XX');
- is($x, 'aXXef');
- $_ = "\xFF";
- is($_, "\xFF");
- is($x, "a\xFFef");
- $_ = "\xF1\xF2\xF3\xF4\xF5\xF6";
- is($_, "\xF1\xF2\xF3\xF4\xF5\xF6");
- is($x, "a\xF1\xF2\xF3\xF4\xF5\xF6ef");
- $_ = 'YYYY';
- is($_, 'YYYY');
- is($x, 'aYYYYef');
- }
-}
-
-# [perl #24200] string corruption with lvalue sub
-
-{
- sub bar: lvalue { substr $krunch, 0 }
- bar = "XXX";
- is(bar, 'XXX');
- $krunch = '123456789';
- is(bar, '123456789');
-}
-
-# [perl #29149]
-{
- my $text = "0123456789\xED ";
- utf8::upgrade($text);
- my $pos = 5;
- pos($text) = $pos;
- my $a = substr($text, $pos, $pos);
- is(substr($text,$pos,1), $pos);
-
-}
-
-# [perl #23765]
-{
- my $a = pack("C", 0xbf);
- substr($a, -1) &= chr(0xfeff);
- is($a, "\xbf");
-}
-
-# [perl #34976] incorrect caching of utf8 substr length
-{
- my $a = "abcd\x{100}";
- is(substr($a,1,2), 'bc');
- is(substr($a,1,1), 'b');
-}
-
-# [perl #62646] offsets exceeding 32 bits on 64-bit system
-SKIP: {
- skip("32-bit system", 24) unless ~0 > 0xffffffff;
- my $a = "abc";
- my $s;
- my $r;
-
- utf8::downgrade($a);
- for (1..2) {
- $w = 0;
- $r = substr($a, 0xffffffff, 1);
- is($r, undef);
- is($w, 1);
-
- $w = 0;
- $r = substr($a, 0xffffffff+1, 1);
- is($r, undef);
- is($w, 1);
-
- $w = 0;
- ok( !eval { $r = substr($s=$a, 0xffffffff, 1, "_"); 1 } );
- is($r, undef);
- is($s, $a);
- is($w, 0);
-
- $w = 0;
- ok( !eval { $r = substr($s=$a, 0xffffffff+1, 1, "_"); 1 } );
- is($r, undef);
- is($s, $a);
- is($w, 0);
-
- utf8::upgrade($a);
- }
-}
-
-}
diff --git a/gnu/usr.bin/perl/t/re/substr_thr.t b/gnu/usr.bin/perl/t/re/substr_thr.t
deleted file mode 100755
index 295c61760ef..00000000000
--- a/gnu/usr.bin/perl/t/re/substr_thr.t
+++ /dev/null
@@ -1,7 +0,0 @@
-#!./perl
-
-chdir 't' if -d 't';
-@INC = ('../lib', '.');
-
-require 'thread_it.pl';
-thread_it(qw(re substr.t));