Skip to content

Commit

Permalink
Split out the parts of lib/builtin.t that require -T into a separate …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
leonerd committed Jul 27, 2023
1 parent d6b55ee commit 51ae39f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 20 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -5065,6 +5065,7 @@ lib/blib.pm For "use blib"
lib/blib.t blib.pm test
lib/builtin.pm builtin function namespace
lib/builtin.t test builtin function namespace
lib/builtin-taint.t test builtin function namespace in taint mode
lib/bytes.pm Pragma to enable byte operations
lib/bytes.t bytes.pm test
lib/bytes_heavy.pl Support routines for byte pragma
Expand Down
1 change: 1 addition & 0 deletions Porting/Maintainers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,7 @@ package Maintainers;
lib/_charnames.pm
lib/blib.{pm,t}
lib/builtin.{pm,t}
lib/builtin-taint.t
lib/bytes.{pm,t}
lib/bytes_heavy.pl
lib/charnames.{pm,t}
Expand Down
40 changes: 40 additions & 0 deletions lib/builtin-taint.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!./perl -T

BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
}

use v5.36;
no warnings 'experimental::builtin';

package FetchStoreCounter {
sub TIESCALAR($class, @args) { bless \@args, $class }

sub FETCH($self) { $self->[0]->$*++ }
sub STORE($self, $) { $self->[1]->$*++ }
}

# is_tainted
{
use builtin qw( is_tainted );

is(is_tainted($0), !!${^TAINT}, "\$0 is tainted (if tainting is supported)");
ok(!is_tainted($1), "\$1 isn't tainted");

# Invokes magic
tie my $tied, FetchStoreCounter => (\my $fetchcount, \my $storecount);

my $_dummy = is_tainted($tied);
is($fetchcount, 1, 'is_tainted() invokes FETCH magic');

$tied = is_tainted($0);
is($storecount, 1, 'is_tainted() invokes STORE magic');

is(prototype(\&builtin::is_tainted), '$', 'is_tainted prototype');
}

# vim: tabstop=4 shiftwidth=4 expandtab autoindent softtabstop=4

done_testing();
21 changes: 1 addition & 20 deletions lib/builtin.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!./perl -T
#!./perl

BEGIN {
chdir 't' if -d 't';
Expand Down Expand Up @@ -366,25 +366,6 @@ TODO: {
is(trim($str2), "Hello world!", "trim on an our \$var");
}

# is_tainted
{
use builtin qw( is_tainted );

is(is_tainted($0), !!${^TAINT}, "\$0 is tainted (if tainting is supported)");
ok(!is_tainted($1), "\$1 isn't tainted");

# Invokes magic
tie my $tied, FetchStoreCounter => (\my $fetchcount, \my $storecount);

my $_dummy = is_tainted($tied);
is($fetchcount, 1, 'is_tainted() invokes FETCH magic');

$tied = is_tainted($0);
is($storecount, 1, 'is_tainted() invokes STORE magic');

is(prototype(\&builtin::is_tainted), '$', 'is_tainted prototype');
}

# Lexical export
{
my $name;
Expand Down

0 comments on commit 51ae39f

Please sign in to comment.