7 skip_all_without_dynamic_extension('B');
12 my $bd = new B::Deparse '-p';
14 my %unsupported = map +($_=>1), qw (CORE and cmp dump eq ge gt le
15 getprotobynumber lt ne not or x xor);
17 dbmopen => '%1,$2,$3',
21 use File::Spec::Functions;
22 my $keywords_file = catfile(updir,'regen','keywords.pl');
23 open my $kh, $keywords_file
24 or die "$0 cannot open $keywords_file: $!";
26 if (m?__END__?..${\0} and /^[+-]/) {
28 if($& eq '+' || $unsupported{$word}) {
30 ok !defined &{\&{"CORE::$word"}}, "no CORE::$word";
35 my $proto = prototype "CORE::$word";
36 *{"my$word"} = \&{"CORE::$word"};
37 is prototype \&{"my$word"}, $proto, "prototype of &CORE::$word";
39 CORE::state $protochar = qr/([^\\]|\\(?:[^[]|\[[^]]+\]))/;
41 () = $proto =~ s/;.*//r =~ /\G$protochar/g;
43 "#line 1 This-line-makes-__FILE__-easier-to-test.
45 . ($args_for{$word} || join ",", map "\$$_", 1..$numargs)
47 my $core = $bd->coderef2text(eval $code =~ s/my/CORE::/r or die);
48 my $my = $bd->coderef2text(eval $code or die);
49 is $my, $core, "inlinability of CORE::$word with parens";
52 "#line 1 This-line-makes-__FILE__-easier-to-test.
54 . ($args_for{$word} || join ",", map "\$$_", 1..$numargs)
56 $core = $bd->coderef2text(eval $code =~ s/my/CORE::/r or die);
57 $my = $bd->coderef2text(eval $code or die);
58 is $my, $core, "inlinability of CORE::$word without parens";
60 # High-precedence tests
62 if (!$proto && defined $proto) { # nullary
63 $hpcode = "sub { () = my$word + 1 }";
65 elsif ($proto =~ /^;?$protochar\z/) { # unary
66 $hpcode = "sub { () = my$word "
67 . ($args_for{$word}||'$a') . ' > $b'
72 $core = $bd->coderef2text(eval $hpcode =~ s/my/CORE::/r or die);
73 $my = $bd->coderef2text(eval $hpcode or die);
74 is $my, $core, "precedence of CORE::$word without parens";
77 next if ($proto =~ /\@/);
78 # These ops currently accept any number of args, despite their
79 # prototypes, if they have any:
80 next if $word =~ /^(?:chom?p|exec|keys|each|read(?:lin|pip)e|reset
81 |system|values|l?stat)/x;
85 "sub { () = (my$word("
88 ? $args_for{$word}.',$7'
89 : join ",", map "\$$_", 1..$numargs+5+(
91 ? () = $' =~ /\G$protochar/g
97 like $@, qr/^Too many arguments for $word/,
98 "inlined CORE::$word with too many args"
105 is curr_test, $tests+1, 'right number of tests';