# Copyright (C) 2011-2014 Rocky Bernstein <rocky@cpan.org>
use warnings; use strict;

use Class::Struct;
no strict 'subs';
struct Devel::Trepan::Position => {pkg   => '$', filename => '$', line => '$',
				   event => '$'};
use strict 'subs';

package Devel::Trepan::Position;
sub eq($$)
{
    my ($self, $other) = @_;
    return 0 unless defined $self && defined $other;
    return (
            $self->filename eq $other->filename
            && $self->line eq $other->line
            && $self->event eq $other->event)
}

sub inspect($) {
    my $self = shift;
    return sprintf("pkg: %s, file: %s, line: %s, event: %s",
                   $self->pkg, $self->filename, $self->line, $self->event);
}

unless (caller) {
    my $line = __LINE__;
    my $pos1 = __PACKAGE__->new(pkg=>__PACKAGE__, filename=>__FILE__,
				line => $line, event=>'brkpt');
    my $pos2 = __PACKAGE__->new(pkg=>__PACKAGE__,  filename=>__FILE__,
				line => $line, event=>'brkpt');
    my $pos3 = __PACKAGE__->new(pkg=>__PACKAGE__, filename=>__FILE__,
				line => __LINE__, event=>'brkpt');
    printf "pos1 is%s pos2\n", $pos1->eq($pos2) ? '' : ' not';
    printf "pos1 is%s pos3\n", $pos1->eq($pos3) ? '' : ' not';
    print $pos1->inspect, "\n";

}
1;