Commit | Line | Data |
---|---|---|
192b9cd1 AB |
1 | #!./perl |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
5 | @INC = '../lib'; | |
6 | require './test.pl'; | |
7 | } | |
8 | ||
9 | # Do a basic test on all the tied methods of Tie::Hash::NamedCapture | |
10 | ||
1e1d4b91 JJ |
11 | print "1..13\n"; |
12 | ||
13 | # PL_curpm->paren_names can be a null pointer. See that this succeeds anyway. | |
14 | 'x' =~ /(.)/; | |
15 | () = %+; | |
16 | pass( 'still alive' ); | |
192b9cd1 AB |
17 | |
18 | "hlagh" =~ / | |
19 | (?<a>.) | |
20 | (?<b>.) | |
21 | (?<a>.) | |
22 | .* | |
23 | (?<e>$) | |
24 | /x; | |
25 | ||
26 | # FETCH | |
27 | is($+{a}, "h", "FETCH"); | |
28 | is($+{b}, "l", "FETCH"); | |
29 | is($-{a}[0], "h", "FETCH"); | |
30 | is($-{a}[1], "a", "FETCH"); | |
31 | ||
32 | # STORE | |
33 | eval { $+{a} = "yon" }; | |
34 | ok(index($@, "read-only") != -1, "STORE"); | |
35 | ||
36 | # DELETE | |
37 | eval { delete $+{a} }; | |
38 | ok(index($@, "read-only") != -1, "DELETE"); | |
39 | ||
40 | # CLEAR | |
41 | eval { %+ = () }; | |
42 | ok(index($@, "read-only") != -1, "CLEAR"); | |
43 | ||
44 | # EXISTS | |
45 | ok(exists $+{e}, "EXISTS"); | |
46 | ok(!exists $+{d}, "EXISTS"); | |
47 | ||
48 | # FIRSTKEY/NEXTKEY | |
49 | is(join('|', sort keys %+), "a|b|e", "FIRSTKEY/NEXTKEY"); | |
50 | ||
51 | # SCALAR | |
52 | is(scalar(%+), 3, "SCALAR"); | |
53 | is(scalar(%-), 3, "SCALAR"); |