installperl patch
[p5sagit/p5-mst-13.2.git] / t / op / reg_nc_tie.t
CommitLineData
192b9cd1 1#!./perl
2
3BEGIN {
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
11print "1..12\n";
12
13"hlagh" =~ /
14 (?<a>.)
15 (?<b>.)
16 (?<a>.)
17 .*
18 (?<e>$)
19/x;
20
21# FETCH
22is($+{a}, "h", "FETCH");
23is($+{b}, "l", "FETCH");
24is($-{a}[0], "h", "FETCH");
25is($-{a}[1], "a", "FETCH");
26
27# STORE
28eval { $+{a} = "yon" };
29ok(index($@, "read-only") != -1, "STORE");
30
31# DELETE
32eval { delete $+{a} };
33ok(index($@, "read-only") != -1, "DELETE");
34
35# CLEAR
36eval { %+ = () };
37ok(index($@, "read-only") != -1, "CLEAR");
38
39# EXISTS
40ok(exists $+{e}, "EXISTS");
41ok(!exists $+{d}, "EXISTS");
42
43# FIRSTKEY/NEXTKEY
44is(join('|', sort keys %+), "a|b|e", "FIRSTKEY/NEXTKEY");
45
46# SCALAR
47is(scalar(%+), 3, "SCALAR");
48is(scalar(%-), 3, "SCALAR");