summaryrefslogtreecommitdiffstats
path: root/t/fun/name.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-21 16:50:34 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-21 16:50:34 -0400
commit597610ad1c915a5b004148fdb3151b0cec976790 (patch)
tree9e3e002a3b536ea943d73b51c8318d08f3f6ecb9 /t/fun/name.t
parent336e491e532144d1c8a6e367409149e8d084fa1d (diff)
downloadparse-keyword-597610ad1c915a5b004148fdb3151b0cec976790.tar.gz
parse-keyword-597610ad1c915a5b004148fdb3151b0cec976790.zip
add tests for Fun
Diffstat (limited to 't/fun/name.t')
-rw-r--r--t/fun/name.t48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/fun/name.t b/t/fun/name.t
new file mode 100644
index 0000000..3294791
--- /dev/null
+++ b/t/fun/name.t
@@ -0,0 +1,48 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use lib 't/fun/lib';
+
+use Carp;
+
+my $file = __FILE__;
+my $line = __LINE__;
+
+{
+ package Foo;
+ use Fun;
+ fun foo ($x, $y) {
+ Carp::confess "$x $y";
+ }
+
+ eval {
+ foo("abc", "123");
+ };
+
+ my $line_confess = $line + 6;
+ my $line_foo = $line + 10;
+
+ ::like($@, qr/^abc 123 at $file line $line_confess\.?\n\tFoo::foo\('abc', 123\) called at $file line $line_foo/);
+}
+
+SKIP: { skip "Sub::Name required", 1 unless eval { require Sub::Name };
+
+{
+ package Bar;
+ use Fun;
+ *bar = Sub::Name::subname(bar => fun ($a, $b) { Carp::confess($a + $b) });
+
+ eval {
+ bar(4, 5);
+ };
+
+ my $line_confess = $line + 24;
+ my $line_bar = $line + 27;
+
+ ::like($@, qr/^9 at $file line $line_confess\.?\n\tBar::bar\(4, 5\) called at $file line $line_bar/);
+}
+
+}
+
+done_testing;