7 skip_all_if_miniperl("no dynamic loading on miniperl, no Tie::Hash::NamedCapture");
10 # Do a basic test on all the tied methods of Tie::Hash::NamedCapture
14 # PL_curpm->paren_names can be a null pointer. See that this succeeds anyway.
17 pass( 'still alive' );
28 is($+{a}, "h", "FETCH");
29 is($+{b}, "l", "FETCH");
30 is($-{a}[0], "h", "FETCH");
31 is($-{a}[1], "a", "FETCH");
34 eval { $+{a} = "yon" };
35 like($@, qr/read-only/, "STORE");
38 eval { delete $+{a} };
39 like($@, qr/read-only/, "DELETE");
43 like($@, qr/read-only/, "CLEAR");
46 ok(exists $+{e}, "EXISTS");
47 ok(!exists $+{d}, "EXISTS");
50 is(join('|', sort keys %+), "a|b|e", "FIRSTKEY/NEXTKEY");
53 is(scalar(%+), 3, "SCALAR");
54 is(scalar(%-), 3, "SCALAR");
56 # Abuse all methods with undef as the first argument (RT #71828 and then some):
58 is(Tie::Hash::NamedCapture::FETCH(undef, undef), undef, 'FETCH with undef');
59 eval {Tie::Hash::NamedCapture::STORE(undef, undef, undef)};
60 like($@, qr/Modification of a read-only value attempted/, 'STORE with undef');
61 eval {Tie::Hash::NamedCapture::DELETE(undef, undef)};
62 like($@, , qr/Modification of a read-only value attempted/,
64 eval {Tie::Hash::NamedCapture::CLEAR(undef)};
65 like($@, qr/Modification of a read-only value attempted/, 'CLEAR with undef');
66 is(Tie::Hash::NamedCapture::EXISTS(undef, undef), undef, 'EXISTS with undef');
67 is(Tie::Hash::NamedCapture::FIRSTKEY(undef), undef, 'FIRSTKEY with undef');
68 is(Tie::Hash::NamedCapture::NEXTKEY(undef, undef), undef, 'NEXTKEY with undef');
69 is(Tie::Hash::NamedCapture::SCALAR(undef), undef, 'SCALAR with undef');
72 foreach ([FETCH => '$key'],
73 [STORE => '$key, $value'],
78 [NEXTKEY => '$lastkey'],
81 my ($method, $error) = @$_;
83 is(eval {$obj->$method(0..3); 1}, undef, "$method with undef");
84 like($@, qr/Usage: Tie::Hash::NamedCapture::$method\(\Q$error\E\)/,
85 "usage method for $method");