1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 8;
7use Parse::ErrorString::Perl;
8
9
10# use strict;
11# use warnings;
12# use diagnostics '-traceonly';
13#
14# sub dying { my $illegal = 10 / 0;}
15# sub calling {dying()}
16#
17# calling();
18
19
20my $msg = <<'ENDofMSG';
21Uncaught exception from user code:
22	Illegal division by zero at error.pl line 5.
23 at error.pl line 5
24	main::dying() called at error.pl line 6
25	main::calling() called at error.pl line 8
26ENDofMSG
27
28my $parser = Parse::ErrorString::Perl->new;
29my @errors = $parser->parse_string($msg);
30is( scalar(@errors), 1, 'message results' );
31my @stacktrace = $errors[0]->stack;
32is( scalar(@stacktrace),          2,                 'stacktrace results' );
33is( $stacktrace[0]->sub,          'main::dying()',   'stack 1 sub' );
34is( $stacktrace[0]->file_msgpath, 'error.pl',        'stack 1 file_msgpath' );
35is( $stacktrace[0]->line,         6,                 'stack 1 line' );
36is( $stacktrace[1]->sub,          'main::calling()', 'stack 2 sub' );
37is( $stacktrace[1]->file_msgpath, 'error.pl',        'stack 2 file_msgpath' );
38is( $stacktrace[1]->line,         8,                 'stack 2 line' );
39
40
41