Eval-Closure-0.14000755001750001750 012722471536 12521 5ustar00doydoy000000000000README100644001750001750 60212722471536 13440 0ustar00doydoy000000000000Eval-Closure-0.14 This archive contains the distribution Eval-Closure, version 0.14: safely and cleanly create closures via string eval This software is copyright (c) 2016 by Jesse Luehrs. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.005. Changes100644001750001750 437112722471536 14102 0ustar00doydoy000000000000Eval-Closure-0.14Revision history for Eval-Closure 0.14 2016-05-29 - a couple minor optimizations (dolmen, #8) 0.13 2015-05-12 - one more fix for blead (eserte, jplesnik, #6) 0.12 2015-01-17 - fix tests under blead (sprout, #4) 0.11 2013-07-30 - add "alias => 1" option for making closure variables actually alias the closed over variables (so the variable referenced in the environment hashref will actually be updated by changes made in the closure). (Toby Inkster, #3) 0.10 2013-07-10 - fix pod links 0.09 2013-07-10 - support lexical subs on 5.18+ 0.08 2012-02-09 - Remove a double layer of string eval that was introduced in 0.07 as an intermediate step in figuring out the unique package thing - it's not necessary with the final implementation, and just makes things slower and hides errors. 0.07 2012-02-03 - the given source is now evaled in a unique package for every eval_closure call (it used to always be evaled in the Eval::Closure package, which was especially buggy). this is to avoid issues where one eval_closure modifies the global environment (by, say, importing a function), which could mess up a later call. unfortunately, this means that the memoization stuff no longer works, since it will result in memoized results using the original package, which defeats the purpose. i'm open to suggestions on how to safely reenable it though. - clean up a few stray lexicals we were still closing over in the eval 0.06 2011-06-05 - The dumped source from setting $ENV{EVAL_CLOSURE_PRINT_SOURCE} didn't show the captured variable creation properly. (Dave Rolsky) 0.05 2011-04-25 - make sure Perl::Tidy doesn't look at @ARGV (rafl) 0.04 2011-04-15 - stop using Memoize, it apparently doesn't work properly under mod_perl in some situations (mateu) 0.03 2011-03-02 - don't add #line directives when the debugger is active (alh) 0.02 2011-01-26 - add terse_error option for throwing only the actual compilation error (Shawn M Moore) - allow also specifying the line number for error reporting (Shawn M Moore) 0.01 2010-11-14 - Initial release LICENSE100644001750001750 4365512722471536 13644 0ustar00doydoy000000000000Eval-Closure-0.14This software is copyright (c) 2016 by Jesse Luehrs. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2016 by Jesse Luehrs. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2016 by Jesse Luehrs. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644001750001750 75612722471536 14236 0ustar00doydoy000000000000Eval-Closure-0.14name = Eval-Closure author = Jesse Luehrs license = Perl_5 copyright_holder = Jesse Luehrs [@DOY] :version = 0.15 dist = Eval-Closure repository = github bugtracker_web = https://github.com/doy/eval-closure/issues bugtracker_mailto = Authority_authority_style = pkg [AutoPrereqs] skip = ^Perl::Tidy$ skip = ^perl$ skip = ^Devel::LexAlias$ [Prereqs / RuntimeRecommends] Perl::Tidy = 0 Devel::LexAlias = 0.05 [Prereqs / DevelopRequires] Test::Output = 0 [ContributorsFromGit] META.yml100644001750001750 2744612722471536 14110 0ustar00doydoy000000000000Eval-Closure-0.14--- abstract: 'safely and cleanly create closures via string eval' author: - 'Jesse Luehrs ' build_requires: B: '0' File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Test::Fatal: '0' Test::More: '0.88' Test::Requires: '0' blib: '1.01' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.005, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Eval-Closure provides: Eval::Closure: file: lib/Eval/Closure.pm version: '0.14' recommends: Devel::LexAlias: '0.05' Perl::Tidy: '0' requires: Carp: '0' Exporter: '0' Scalar::Util: '0' constant: '0' overload: '0' strict: '0' warnings: '0' resources: bugtracker: https://github.com/doy/eval-closure/issues homepage: http://metacpan.org/release/Eval-Closure repository: git://github.com/doy/eval-closure.git version: '0.14' x_Dist_Zilla: perl: version: '5.022000' plugins: - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@DOY/TestMoreDoneTesting' version: '6.005' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . name: '@DOY/GatherDir' version: '6.005' - class: Dist::Zilla::Plugin::PruneCruft name: '@DOY/PruneCruft' version: '6.005' - class: Dist::Zilla::Plugin::ManifestSkip name: '@DOY/ManifestSkip' version: '6.005' - class: Dist::Zilla::Plugin::MetaYAML name: '@DOY/MetaYAML' version: '6.005' - class: Dist::Zilla::Plugin::License name: '@DOY/License' version: '6.005' - class: Dist::Zilla::Plugin::Readme name: '@DOY/Readme' version: '6.005' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@DOY/RunExtraTests' version: '0.028' - class: Dist::Zilla::Plugin::ExecDir name: '@DOY/ExecDir' version: '6.005' - class: Dist::Zilla::Plugin::ShareDir name: '@DOY/ShareDir' version: '6.005' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@DOY/MakeMaker' version: '6.005' - class: Dist::Zilla::Plugin::Manifest name: '@DOY/Manifest' version: '6.005' - class: Dist::Zilla::Plugin::TestRelease name: '@DOY/TestRelease' version: '6.005' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@DOY/ConfirmRelease' version: '6.005' - class: Dist::Zilla::Plugin::MetaConfig name: '@DOY/MetaConfig' version: '6.005' - class: Dist::Zilla::Plugin::MetaJSON name: '@DOY/MetaJSON' version: '6.005' - class: Dist::Zilla::Plugin::NextRelease name: '@DOY/NextRelease' version: '6.005' - class: Dist::Zilla::Plugin::CheckChangesHasContent name: '@DOY/CheckChangesHasContent' version: '0.008' - class: Dist::Zilla::Plugin::PkgVersion name: '@DOY/PkgVersion' version: '6.005' - class: Dist::Zilla::Plugin::Authority name: '@DOY/Authority' version: '1.009' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@DOY/PodCoverageTests' version: '6.005' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@DOY/PodSyntaxTests' version: '6.005' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' name: '@DOY/Test::NoTabs' version: '0.15' - class: Dist::Zilla::Plugin::EOLTests config: Dist::Zilla::Plugin::Test::EOL: filename: xt/release/eol.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' trailing_whitespace: '1' name: '@DOY/EOLTests' version: '0.18' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: 0 filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: test script_finder: - ':PerlExecFiles' skips: [] name: '@DOY/Test::Compile' version: '2.054' - class: Dist::Zilla::Plugin::Metadata name: '@DOY/Metadata' version: '3.03' - class: Dist::Zilla::Plugin::MetaResources name: '@DOY/MetaResources' version: '6.005' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: [] allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DOY/Git::Check' version: '2.036' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: changelog Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes - dist.ini allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DOY/Git::Commit' version: '2.036' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: '0.14' tag_format: '%v' tag_message: '' Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@DOY/Git::Tag' version: '2.036' - class: Dist::Zilla::Plugin::Git::NextVersion config: Dist::Zilla::Plugin::Git::NextVersion: first_version: '0.01' version_by_branch: 0 version_regexp: (?^:^(\d+\.\d+)$) Dist::Zilla::Role::Git::Repo: repo_root: . name: '@DOY/Git::NextVersion' version: '2.036' - class: Dist::Zilla::Plugin::ContributorsFromGit name: '@DOY/ContributorsFromGit' version: '0.017' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.005' Dist::Zilla::Role::MetaProvider::Provider: inherit_missing: '1' inherit_version: '1' meta_noindex: '1' name: '@DOY/MetaProvides::Package' version: '2.003001' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.012' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.012' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Default/SingleEncoding' version: '4.012' - class: Pod::Weaver::Section::Name name: '@Default/Name' version: '4.012' - class: Pod::Weaver::Section::Version name: '@Default/Version' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Default/prelude' version: '4.012' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.012' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.012' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.012' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.012' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.012' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.012' - class: Pod::Weaver::Section::Leftovers name: '@Default/Leftovers' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Default/postlude' version: '4.012' - class: Pod::Weaver::Section::Authors name: '@Default/Authors' version: '4.012' - class: Pod::Weaver::Section::Legal name: '@Default/Legal' version: '4.012' name: '@DOY/PodWeaver' version: '4.006' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@DOY/UploadToCPAN' version: '6.005' - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs version: '6.005' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: recommends name: RuntimeRecommends version: '6.005' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: DevelopRequires version: '6.005' - class: Dist::Zilla::Plugin::ContributorsFromGit name: ContributorsFromGit version: '0.017' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.005' - class: Dist::Zilla::Plugin::FinderCode name: '@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '6.005' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '6.005' x_authority: cpan:DOY x_contributors: - 'Dave Rolsky ' - 'Olivier Mengué ' - 'Shawn M Moore ' - 'Toby Inkster ' MANIFEST100644001750001750 66312722471536 13720 0ustar00doydoy000000000000Eval-Closure-0.14# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.005. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Eval/Closure.pm t/00-compile.t t/basic.t t/canonicalize-source.t t/close-over-nonref.t t/close-over.t t/compiling-package.t t/debugger.t t/description.t t/errors.t t/lexical-subs.t t/memoize.t xt/author/no-tabs.t xt/author/pod-coverage.t xt/author/pod-syntax.t xt/release/eol.t t000755001750001750 012722471536 12705 5ustar00doydoy000000000000Eval-Closure-0.14basic.t100644001750001750 160012722471536 14310 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use Eval::Closure; { my $code = eval_closure( source => 'sub { die "called\n" }', ); ok($code, "got something"); like(exception { $code->() }, qr/^called$/, "got the right thing"); } { my $foo = []; my $code = eval_closure( source => 'sub { push @$bar, @_ }', environment => { '$bar' => \$foo, }, ); ok($code, "got something"); $code->(1); is_deeply($foo, [1], "got the right thing"); } { my $foo = [1, 2, 3]; my $code = eval_closure( # not sure if strict leaking into evals is intended, i think i remember # it being changed in newer perls source => 'do { no strict; sub { $foo } }', ); ok($code, "got something"); ok(!$code->(), "environment is clean"); } done_testing; META.json100644001750001750 4533212722471536 14252 0ustar00doydoy000000000000Eval-Closure-0.14{ "abstract" : "safely and cleanly create closures via string eval", "author" : [ "Jesse Luehrs " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.005, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Eval-Closure", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::EOL" : "0", "Test::More" : "0.88", "Test::NoTabs" : "0", "Test::Output" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "recommends" : { "Devel::LexAlias" : "0.05", "Perl::Tidy" : "0" }, "requires" : { "Carp" : "0", "Exporter" : "0", "Scalar::Util" : "0", "constant" : "0", "overload" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "B" : "0", "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::Fatal" : "0", "Test::More" : "0.88", "Test::Requires" : "0", "blib" : "1.01" } } }, "provides" : { "Eval::Closure" : { "file" : "lib/Eval/Closure.pm", "version" : "0.14" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/doy/eval-closure/issues" }, "homepage" : "http://metacpan.org/release/Eval-Closure", "repository" : { "type" : "git", "url" : "git://github.com/doy/eval-closure.git", "web" : "https://github.com/doy/eval-closure" } }, "version" : "0.14", "x_Dist_Zilla" : { "perl" : { "version" : "5.022000" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@DOY/TestMoreDoneTesting", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@DOY/GatherDir", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@DOY/PruneCruft", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@DOY/ManifestSkip", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@DOY/MetaYAML", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@DOY/License", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@DOY/Readme", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@DOY/RunExtraTests", "version" : "0.028" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@DOY/ExecDir", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@DOY/ShareDir", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@DOY/MakeMaker", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@DOY/Manifest", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@DOY/TestRelease", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@DOY/ConfirmRelease", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@DOY/MetaConfig", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@DOY/MetaJSON", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@DOY/NextRelease", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::CheckChangesHasContent", "name" : "@DOY/CheckChangesHasContent", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@DOY/PkgVersion", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@DOY/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@DOY/PodCoverageTests", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@DOY/PodSyntaxTests", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "filename" : "xt/author/no-tabs.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ] } }, "name" : "@DOY/Test::NoTabs", "version" : "0.15" }, { "class" : "Dist::Zilla::Plugin::EOLTests", "config" : { "Dist::Zilla::Plugin::Test::EOL" : { "filename" : "xt/release/eol.t", "finder" : [ ":InstallModules", ":ExecFiles", ":TestFiles" ], "trailing_whitespace" : "1" } }, "name" : "@DOY/EOLTests", "version" : "0.18" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : "0", "fail_on_warning" : "author", "fake_home" : 0, "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "test", "script_finder" : [ ":PerlExecFiles" ], "skips" : [] } }, "name" : "@DOY/Test::Compile", "version" : "2.054" }, { "class" : "Dist::Zilla::Plugin::Metadata", "name" : "@DOY/Metadata", "version" : "3.03" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@DOY/MetaResources", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DOY/Git::Check", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "changelog" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes", "dist.ini" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DOY/Git::Commit", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "0.14", "tag_format" : "%v", "tag_message" : "" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@DOY/Git::Tag", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "config" : { "Dist::Zilla::Plugin::Git::NextVersion" : { "first_version" : "0.01", "version_by_branch" : 0, "version_regexp" : "(?^:^(\\d+\\.\\d+)$)" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@DOY/Git::NextVersion", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::ContributorsFromGit", "name" : "@DOY/ContributorsFromGit", "version" : "0.017" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.005" } ] }, "Dist::Zilla::Role::MetaProvider::Provider" : { "inherit_missing" : "1", "inherit_version" : "1", "meta_noindex" : "1" } }, "name" : "@DOY/MetaProvides::Package", "version" : "2.003001" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Default/SingleEncoding", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Default/Name", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Default/Version", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/prelude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Default/Leftovers", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/postlude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Default/Authors", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Default/Legal", "version" : "4.012" } ] } }, "name" : "@DOY/PodWeaver", "version" : "4.006" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@DOY/UploadToCPAN", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "recommends" } }, "name" : "RuntimeRecommends", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "DevelopRequires", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::ContributorsFromGit", "name" : "ContributorsFromGit", "version" : "0.017" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.005" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@DOY/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "6.005" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "6.005" } }, "x_authority" : "cpan:DOY", "x_contributors" : [ "Dave Rolsky ", "Olivier Mengu\u00e9 ", "Shawn M Moore ", "Toby Inkster " ] } errors.t100644001750001750 254712722471536 14556 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use Eval::Closure; like( exception { eval_closure() }, qr/'source'.*required/, "error when source isn't declared" ); like( exception { eval_closure(source => {}) }, qr/'source'.*string or array/, "error when source isn't string or array" ); like( exception { eval_closure(source => 1) }, qr/'source'.*return.*sub/, "error when source doesn't return a sub" ); like( exception { eval_closure( source => 'sub { }', environment => { 'foo' => \1 }, ) }, qr/should start with \@, \%,/, "error from malformed env" ); like( exception { eval_closure( source => 'sub { }', environment => { '$foo' => 1 }, ) }, qr/must be.*reference/, "error from non-ref value" ); like( exception { eval_closure(source => '$1++') }, qr/Modification of a read-only value/, "gives us compile errors properly" ); like( exception { eval_closure(source => 'sub { $x }') }, qr/sub \s* { \s* \$x \s* }/x, "without terse_error, includes the source code" ); unlike( exception { eval_closure(source => 'sub { $x }', terse_error => 1) }, qr/sub \s* { \s* \$x \s* }/x, "with terse_error, does not include the source code" ); done_testing; memoize.t100644001750001750 470012722471536 14700 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use Test::Requires 'Test::Output'; use Eval::Closure; # XXX this whole test isn't very useful anymore, since we no longer do # memoization. it would be nice to bring it back at some point though, if there # was a way to do this without breaking the other tests plan skip_all => "disabling this test for now"; { my $source = 'BEGIN { warn "foo\n" } sub { $foo * 2 }'; my $code; my $bar = 15; stderr_is { $code = eval_closure( source => $source, environment => { '$foo' => \$bar, }, ); } "foo\n", "BEGIN was run"; is($code->(), 30, "got the right sub"); my $code2; my $baz = 8; stderr_is { $code2 = eval_closure( source => $source, environment => { '$foo' => \$baz, }, ); } '', "BEGIN was not run twice"; is($code2->(), 16, "got the right sub"); } { my $source = 'BEGIN { warn "bar\n" } sub { $bar * 2 }'; my $code; my $foo = 60; stderr_is { $code = eval_closure( source => $source, environment => { '$bar' => \$foo, }, description => 'foo', ); } "bar\n", "BEGIN was run"; is($code->(), 120, "got the right sub"); my $code2; my $baz = 23; { local $TODO = "description breaks memoization"; stderr_is { $code2 = eval_closure( source => $source, environment => { '$bar' => \$baz, }, description => 'baz', ); } '', "BEGIN was not run twice"; } is($code2->(), 46, "got the right sub"); } { my $source = 'BEGIN { warn "baz\n" } sub { Carp::confess "baz" }'; my $code; stderr_is { $code = eval_closure( source => $source, description => 'first', ); } "baz\n", "BEGIN was run"; like(exception { $code->() }, qr/baz at first line 1/, "got the right description"); my $code2; { local $TODO = "description breaks memoization"; stderr_is { $code2 = eval_closure( source => $source, description => 'second', ); } '', "BEGIN was not run twice"; } like(exception { $code2->() }, qr/baz at second line 1/, "got the right description"); } done_testing; Makefile.PL100644001750001750 300712722471536 14554 0ustar00doydoy000000000000Eval-Closure-0.14# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.005. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "safely and cleanly create closures via string eval", "AUTHOR" => "Jesse Luehrs ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Eval-Closure", "LICENSE" => "perl", "NAME" => "Eval::Closure", "PREREQ_PM" => { "Carp" => 0, "Exporter" => 0, "Scalar::Util" => 0, "constant" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "B" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => 0, "blib" => "1.01" }, "VERSION" => "0.14", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "B" => 0, "Carp" => 0, "Exporter" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Scalar::Util" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => 0, "blib" => "1.01", "constant" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); debugger.t100644001750001750 56612722471536 15005 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; BEGIN { $^P |= 0x210 } # PERLDBf_SUBLINE use Eval::Closure; unlike( exception { eval_closure( source => 'sub { $bar }', description => 'foo', ) }, qr/#line/, "#line directive isn't added when debugger is active" ); done_testing; close-over.t100644001750001750 343412722471536 15314 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use B; use Eval::Closure; use Test::Requires 'PadWalker'; { my $foo = []; my $env = { '$foo' => \$foo }; my $code = eval_closure( source => 'sub { push @$foo, @_ }', environment => $env, ); is_deeply(scalar(PadWalker::closed_over($code)), $env, "closed over the right things"); } { my $foo = {}; my $bar = []; my $env = { '$foo' => \$bar, '$bar' => \$foo }; my $code = eval_closure( source => 'sub { push @$foo, @_; $bar->{foo} = \@_ }', environment => $env, ); is_deeply(scalar(PadWalker::closed_over($code)), $env, "closed over the right things"); } { # i feel dirty my $c = eval_closure(source => 'sub { }'); my $b = B::svref_2object($c); my @scopes; while ($b->isa('B::CV')) { push @scopes, $b; $b = $b->OUTSIDE; } my @visible_in_outer_scope = grep { defined && length && $_ ne '&' } map { $_->PV } grep { $_->can('PV') } map { $_->PADLIST->ARRAYelt(0)->ARRAY } @scopes; # test to ensure we don't inadvertently screw up this test by rearranging # code. if the scope that encloses the eval ends up not declaring $e, then # change this test. ok(scalar(grep { $_ eq '$e' } @visible_in_outer_scope), "visible list is sane"); for my $outer_scope_pad_entry (@visible_in_outer_scope) { like( exception { eval_closure( source => "sub { $outer_scope_pad_entry }", ); }, qr/Global symbol "\Q$outer_scope_pad_entry/, "we don't close over $outer_scope_pad_entry" ); } } done_testing; 00-compile.t100644001750001750 233112722471536 15076 0ustar00doydoy000000000000Eval-Closure-0.14/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'Eval/Closure.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; description.t100644001750001750 177212722471536 15564 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; use Eval::Closure; my $source = <<'SOURCE'; sub { Carp::confess("foo") } SOURCE { my $code = eval_closure( source => $source, ); like( exception { $code->() }, qr/^foo at \(eval \d+\) line \d+/, "no location info if context isn't passed" ); } { my $code = eval_closure( source => $source, description => 'accessor foo (defined at Class.pm line 282)', ); like( exception { $code->() }, qr/^foo at accessor foo \(defined at Class\.pm line 282\) line 2/, "description is set" ); } { my $code = eval_closure( source => $source, line => 100, description => 'accessor foo (defined at Class.pm line 282)', ); like( exception { $code->() }, qr/^foo at accessor foo \(defined at Class\.pm line 282\) line 101/, "description is set" ); } done_testing; lexical-subs.t100644001750001750 60712722471536 15610 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; BEGIN { if (!eval { require 5.018; 1 }) { plan skip_all => "this test requires 5.18"; } } 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; release000755001750001750 012722471536 14515 5ustar00doydoy000000000000Eval-Closure-0.14/xteol.t100644001750001750 77112722471536 15606 0ustar00doydoy000000000000Eval-Closure-0.14/xt/releaseuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::EOLTests 0.18 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/Eval/Closure.pm', 't/00-compile.t', 't/basic.t', 't/canonicalize-source.t', 't/close-over-nonref.t', 't/close-over.t', 't/compiling-package.t', 't/debugger.t', 't/description.t', 't/errors.t', 't/lexical-subs.t', 't/memoize.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; Eval000755001750001750 012722471536 14077 5ustar00doydoy000000000000Eval-Closure-0.14/libClosure.pm100644001750001750 2327112722471536 16236 0ustar00doydoy000000000000Eval-Closure-0.14/lib/Evalpackage Eval::Closure; BEGIN { $Eval::Closure::AUTHORITY = 'cpan:DOY'; } $Eval::Closure::VERSION = '0.14'; use strict; use warnings; # ABSTRACT: safely and cleanly create closures via string eval use Exporter 'import'; @Eval::Closure::EXPORT = @Eval::Closure::EXPORT_OK = 'eval_closure'; use Carp; use overload (); use Scalar::Util qw(reftype); use constant HAS_LEXICAL_SUBS => $] >= 5.018; sub eval_closure { my (%args) = @_; # default to copying environment $args{alias} = 0 if !exists $args{alias}; $args{source} = _canonicalize_source($args{source}); _validate_env($args{environment} ||= {}); $args{source} = _line_directive(@args{qw(line description)}) . $args{source} if defined $args{description} && !($^P & 0x10); my ($code, $e) = _clean_eval_closure(@args{qw(source environment alias)}); if (!$code) { if ($args{terse_error}) { die "$e\n"; } else { croak("Failed to compile source: $e\n\nsource:\n$args{source}") } } return $code; } sub _canonicalize_source { my ($source) = @_; if (defined($source)) { if (ref($source)) { if (reftype($source) eq 'ARRAY' || overload::Method($source, '@{}')) { return join "\n", @$source; } elsif (overload::Method($source, '""')) { return "$source"; } else { croak("The 'source' parameter to eval_closure must be a " . "string or array reference"); } } else { return $source; } } else { croak("The 'source' parameter to eval_closure is required"); } } sub _validate_env { my ($env) = @_; croak("The 'environment' parameter must be a hashref") unless reftype($env) eq 'HASH'; for my $var (keys %$env) { if (HAS_LEXICAL_SUBS) { croak("Environment key '$var' should start with \@, \%, \$, or \&") if index('$@%&', substr($var, 0, 1)) < 0; } else { croak("Environment key '$var' should start with \@, \%, or \$") if index('$@%', substr($var, 0, 1)) < 0; } croak("Environment values must be references, not $env->{$var}") unless ref($env->{$var}); } } sub _line_directive { my ($line, $description) = @_; $line = 1 unless defined($line); return qq{#line $line "$description"\n}; } sub _clean_eval_closure { my ($source, $captures, $alias) = @_; my @capture_keys = keys %$captures; if ($ENV{EVAL_CLOSURE_PRINT_SOURCE}) { _dump_source(_make_compiler_source($source, $alias, @capture_keys)); } my ($compiler, $e) = _make_compiler($source, $alias, @capture_keys); return (undef, $e) unless defined $compiler; my $code = $compiler->(@$captures{@capture_keys}); if (!defined $code) { return ( undef, "The 'source' parameter must return a subroutine reference, " . "not undef" ) } if (!ref($code) || ref($code) ne 'CODE') { return ( undef, "The 'source' parameter must return a subroutine reference, not " . ref($code) ) } if ($alias) { require Devel::LexAlias; Devel::LexAlias::lexalias($code, $_, $captures->{$_}) for grep substr($_, 0, 1) ne '&', @capture_keys; } return ($code, $e); } sub _make_compiler { my $source = _make_compiler_source(@_); _clean_eval($source) } sub _clean_eval { local $@; local $SIG{__DIE__}; my $compiler = eval $_[0]; my $e = $@; ( $compiler, $e ) } $Eval::Closure::SANDBOX_ID = 0; sub _make_compiler_source { my ($source, $alias, @capture_keys) = @_; $Eval::Closure::SANDBOX_ID++; my $i = 0; return join "\n", ( "package Eval::Closure::Sandbox_$Eval::Closure::SANDBOX_ID;", 'sub {', (map { _make_lexical_assignment($_, $i++, $alias) } @capture_keys), $source, '}', ); } sub _make_lexical_assignment { my ($key, $index, $alias) = @_; my $sigil = substr($key, 0, 1); my $name = substr($key, 1); if (HAS_LEXICAL_SUBS && $sigil eq '&') { my $tmpname = '$__' . $name . '__' . $index; return 'use feature "lexical_subs"; ' . 'no warnings "experimental::lexical_subs"; ' . 'my ' . $tmpname . ' = $_[' . $index . ']; ' . 'my sub ' . $name . ' { goto ' . $tmpname . ' }'; } if ($alias) { return 'my ' . $key . ';'; } else { return 'my ' . $key . ' = ' . $sigil . '{$_[' . $index . ']};'; } } sub _dump_source { my ($source) = @_; my $output; local $@; if (eval { require Perl::Tidy; 1 }) { Perl::Tidy::perltidy( source => \$source, destination => \$output, argv => [], ); } else { $output = $source; } warn "$output\n"; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Eval::Closure - safely and cleanly create closures via string eval =head1 VERSION version 0.14 =head1 SYNOPSIS use Eval::Closure; my $code = eval_closure( source => 'sub { $foo++ }', environment => { '$foo' => \1, }, ); warn $code->(); # 1 warn $code->(); # 2 my $code2 = eval_closure( source => 'sub { $code->() }', ); # dies, $code isn't in scope =head1 DESCRIPTION String eval is often used for dynamic code generation. For instance, C uses it heavily, to generate inlined versions of accessors and constructors, which speeds code up at runtime by a significant amount. String eval is not without its issues however - it's difficult to control the scope it's used in (which determines which variables are in scope inside the eval), and it's easy to miss compilation errors, since eval catches them and sticks them in $@ instead. This module attempts to solve these problems. It provides an C function, which evals a string in a clean environment, other than a fixed list of specified variables. Compilation errors are rethrown automatically. =head1 FUNCTIONS =head2 eval_closure(%args) This function provides the main functionality of this module. It is exported by default. It takes a hash of parameters, with these keys being valid: =over 4 =item source The string to be evaled. It should end by returning a code reference. It can access any variable declared in the C parameter (and only those variables). It can be either a string, or an arrayref of lines (which will be joined with newlines to produce the string). =item environment The environment to provide to the eval. This should be a hashref, mapping variable names (including sigils) to references of the appropriate type. For instance, a valid value for environment would be C<< { '@foo' => [] } >> (which would allow the generated function to use an array named C<@foo>). Generally, this is used to allow the generated function to access externally defined variables (so you would pass in a reference to a variable that already exists). In perl 5.18 and greater, the environment hash can contain variables with a sigil of C<&>. This will create a lexical sub in the evaluated code (see L). Using a C<&> sigil on perl versions before lexical subs were available will throw an error. =item alias If set to true, the coderef returned closes over the variables referenced in the environment hashref. (This feature requires L.) If set to false, the coderef closes over a I<< shallow copy >> of the variables. If this argument is omitted, Eval::Closure will currently assume false, but this assumption may change in a future version. =item description This lets you provide a bit more information in backtraces. Normally, when a function that was generated through string eval is called, that stack frame will show up as "(eval n)", where 'n' is a sequential identifier for every string eval that has happened so far in the program. Passing a C parameter lets you override that to something more useful (for instance, L overrides the description for accessors to something like "accessor foo at MyClass.pm, line 123"). =item line This lets you override the particular line number that appears in backtraces, much like the C option. The default is 1. =item terse_error Normally, this function appends the source code that failed to compile, and prepends some explanatory text. Setting this option to true suppresses that behavior so you get only the compilation error that Perl actually reported. =back =head1 BUGS No known bugs. Please report any bugs to GitHub Issues at L. =head1 SEE ALSO =over 4 =item * L This module is a factoring out of code that used to live here =back =head1 SUPPORT You can find this documentation for this module with the perldoc command. perldoc Eval::Closure You can also look for information at: =over 4 =item * MetaCPAN L =item * Github L =item * RT: CPAN's request tracker L =item * CPAN Ratings L =back =head1 NOTES Based on code from L, by Stevan Little and the Moose Cabal. =head1 AUTHOR Jesse Luehrs =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 by Jesse Luehrs. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut author000755001750001750 012722471536 14377 5ustar00doydoy000000000000Eval-Closure-0.14/xtno-tabs.t100644001750001750 74012722471536 16250 0ustar00doydoy000000000000Eval-Closure-0.14/xt/authoruse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/Eval/Closure.pm', 't/00-compile.t', 't/basic.t', 't/canonicalize-source.t', 't/close-over-nonref.t', 't/close-over.t', 't/compiling-package.t', 't/debugger.t', 't/description.t', 't/errors.t', 't/lexical-subs.t', 't/memoize.t' ); notabs_ok($_) foreach @files; done_testing; compiling-package.t100644001750001750 205612722471536 16607 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Eval::Closure; { my $code = eval_closure( source => 'no strict "refs"; sub { keys %{__PACKAGE__ . "::"} }', ); # defining the sub { } creates __ANON__, calling 'no strict' creates BEGIN my @stash_keys = grep { $_ ne '__ANON__' && $_ ne 'BEGIN' } $code->(); is_deeply([@stash_keys], [], "compiled in an empty package"); } { # the more common case where you'd run into this is imported subs # for instance, Bread::Board::as vs Moose::Util::TypeConstraints::as my $c1 = eval_closure( source => 'no strict "vars"; sub { ++$foo }', ); my $c2 = eval_closure( source => 'no strict "vars"; sub { --$foo }', ); is($c1->(), 1); is($c1->(), 2); is($c2->(), -1); is($c2->(), -2); } { my $source = 'no strict "vars"; sub { ++$foo }'; my $c1 = eval_closure(source => $source); my $c2 = eval_closure(source => $source); is($c1->(), 1); is($c1->(), 2); is($c2->(), 1); is($c2->(), 2); } done_testing; close-over-nonref.t100644001750001750 52412722471536 16556 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Requires { "Devel::LexAlias" => "0.05" }; use Eval::Closure; my $number = 40; my $closure = eval_closure( source => 'sub { $xxx += 2 }', environment => { '$xxx' => \$number }, alias => 1, ); $closure->(); is($number, 42); done_testing; pod-syntax.t100644001750001750 25212722471536 17011 0ustar00doydoy000000000000Eval-Closure-0.14/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); canonicalize-source.t100644001750001750 76612722471536 17160 0ustar00doydoy000000000000Eval-Closure-0.14/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Eval::Closure; { my $code = eval_closure( source => 'sub {' . '"foo"' . '}', ); ok($code, "got code"); is($code->(), "foo", "got the right code"); } { my $code = eval_closure( source => [ 'sub {', '"foo"', '}', ], ); ok($code, "got code"); is($code->(), "foo", "got the right code"); } done_testing; pod-coverage.t100644001750001750 33412722471536 17257 0ustar00doydoy000000000000Eval-Closure-0.14/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });