1#!./perl -T 2 3BEGIN { 4 chdir 't' if -d 't'; 5 require './test.pl'; 6 set_up_inc('../lib'); 7} 8 9use v5.36; 10no warnings 'experimental::builtin'; 11 12package FetchStoreCounter { 13 sub TIESCALAR($class, @args) { bless \@args, $class } 14 15 sub FETCH($self) { $self->[0]->$*++ } 16 sub STORE($self, $) { $self->[1]->$*++ } 17} 18 19# is_tainted 20{ 21 use builtin qw( is_tainted ); 22 23 is(is_tainted($0), !!${^TAINT}, "\$0 is tainted (if tainting is supported)"); 24 ok(!is_tainted($1), "\$1 isn't tainted"); 25 26 # Invokes magic 27 tie my $tied, FetchStoreCounter => (\my $fetchcount, \my $storecount); 28 29 my $_dummy = is_tainted($tied); 30 is($fetchcount, 1, 'is_tainted() invokes FETCH magic'); 31 32 $tied = is_tainted($0); 33 is($storecount, 1, 'is_tainted() invokes STORE magic'); 34 35 is(prototype(\&builtin::is_tainted), '$', 'is_tainted prototype'); 36} 37 38# vim: tabstop=4 shiftwidth=4 expandtab autoindent softtabstop=4 39 40done_testing(); 41