summaryrefslogtreecommitdiff
path: root/t/lib/Delta.pm
diff options
context:
space:
mode:
Diffstat (limited to 't/lib/Delta.pm')
-rw-r--r--t/lib/Delta.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/lib/Delta.pm b/t/lib/Delta.pm
new file mode 100644
index 0000000..119bb4f
--- /dev/null
+++ b/t/lib/Delta.pm
@@ -0,0 +1,30 @@
+use 5.006;
+use strict;
+use warnings;
+
+package Delta;
+
+our $counter = 0;
+our $exception = 0;
+
+use Carp ();
+
+use Class::Tiny qw/foo bar/;
+
+sub BUILD {
+ my $self = shift;
+ my $args = shift;
+ Carp::croak("foo must be positive")
+ unless defined $self->foo && $self->foo > 0;
+
+ $self->bar(42) unless defined $self->bar;
+ $counter++;
+}
+
+sub DEMOLISH {
+ my $self = shift;
+ $counter-- if $counter > 0;
+ $exception++ if keys %$self > 2; # Echo will delete first
+}
+
+1;