From a55b2a20f72b216066b59557846f9fec06dbf984 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 10 Jul 2013 18:17:03 -0400 Subject: support lexical subs with the '&' sigil --- t/errors.t | 2 +- t/lexical-subs.t | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 t/lexical-subs.t (limited to 't') diff --git a/t/errors.t b/t/errors.t index 905d6c8..3f0cde2 100644 --- a/t/errors.t +++ b/t/errors.t @@ -31,7 +31,7 @@ like( environment => { 'foo' => \1 }, ) }, - qr/should start with \@, \%, or \$/, + qr/should start with \@, \%,/, "error from malformed env" ); diff --git a/t/lexical-subs.t b/t/lexical-subs.t new file mode 100644 index 0000000..dbcd178 --- /dev/null +++ b/t/lexical-subs.t @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Test::Requires '5.018'; +use 5.018; + +use Eval::Closure; + +my $sub = eval_closure( + source => 'sub { foo() }', + environment => { + '&foo' => sub { state $i++ }, + } +); + +is($sub->(), 0); +is($sub->(), 1); +is($sub->(), 2); + +done_testing; -- cgit v1.2.3-54-g00ecf