summaryrefslogtreecommitdiff
path: root/t/Simple.pm
diff options
context:
space:
mode:
Diffstat (limited to 't/Simple.pm')
-rw-r--r--t/Simple.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/Simple.pm b/t/Simple.pm
new file mode 100644
index 0000000..1b417df
--- /dev/null
+++ b/t/Simple.pm
@@ -0,0 +1,31 @@
+package Simple;
+use strict;
+use warnings;
+
+use Class::XPath
+ get_name => 'name',
+ get_parent => 'parent',
+ get_root => 'root',
+ get_children => 'kids',
+ get_attr_names => 'param',
+ get_attr_value => 'param',
+ get_content => 'data';
+
+
+sub name { shift->{name} }
+sub parent { shift->{parent} }
+sub root { local $_=shift;
+ while($_->{parent}) { $_ = $_->{parent} }
+ return $_; }
+sub param { if (@_ == 2) { return $_[0]->{$_[1]} }
+ else { return qw(foo bar baz) } }
+sub data { shift->{data} }
+sub kids { @{shift->{kids}} }
+
+sub new_root { my $pkg = shift; bless({kids => [], @_}, $pkg); }
+sub add_kid { my $self = shift;
+ push(@{$self->{kids}},
+ bless({kids => [], @_, parent => $self }, ref $self));
+ $self->{kids}[-1]; }
+
+1;