Skip to content
Browse files

Revert "use Devel::Hints where possible"

This reverts commit fe890fb.

"meh", this is a lot of effort for very little real gain
  • Loading branch information...
1 parent fe890fb commit 68cb1ade6177987a8950e4cb3050c1139e802fee @doy committed
Showing with 9 additions and 100 deletions.
  1. +0 −1 dist.ini
  2. +3 −15 lib/Eval/Closure.pm
  3. +1 −1 t/03-description.t
  4. +5 −22 t/05-memoize.t
  5. +0 −61 t/11-line-differences.t
View
1 dist.ini
@@ -7,7 +7,6 @@ copyright_holder = Jesse Luehrs
dist = Eval-Closure
[Prereqs]
-Devel::Hints = 0.22
Scalar::Util = 0
Sub::Exporter = 0
Try::Tiny = 0
View
18 lib/Eval/Closure.pm
@@ -8,14 +8,11 @@ use Sub::Exporter -setup => {
# ABSTRACT: safely and cleanly create closures via string eval
use Carp;
-use Devel::Hints qw(cop_file cop_line);
use overload ();
use Memoize;
use Scalar::Util qw(reftype);
use Try::Tiny;
-use constant USE_DEVEL_HINTS => ($] >= 5.010);
-
=head1 SYNOPSIS
use Eval::Closure;
@@ -96,23 +93,14 @@ sub eval_closure {
$args{source} = _canonicalize_source($args{source});
_validate_env($args{environment} ||= {});
- if (!USE_DEVEL_HINTS) {
- $args{source} = _line_directive($args{description}) . $args{source}
- if defined $args{description};
- }
+ $args{source} = _line_directive($args{description}) . $args{source}
+ if defined $args{description};
my ($code, $e) = _clean_eval_closure(@args{qw(source environment)});
croak("Failed to compile source: $e\n\nsource:\n$args{source}")
unless $code;
- if (USE_DEVEL_HINTS) {
- if (defined $args{description}) {
- cop_file($code, $args{description});
- cop_line($code, 1);
- }
- }
-
return $code;
}
@@ -159,7 +147,7 @@ sub _validate_env {
sub _line_directive {
my ($description) = @_;
- return qq{#line 0 "$description"\n};
+ return qq{#line 1 "$description"\n};
}
sub _clean_eval_closure {
View
2 t/03-description.t
@@ -32,7 +32,7 @@ SOURCE
like(
exception { $code->() },
- qr/^foo at accessor foo \(defined at Class\.pm line 282\) line 1\n/,
+ qr/^foo at accessor foo \(defined at Class\.pm line 282\) line 2\n/,
"description is set"
);
}
View
27 t/05-memoize.t
@@ -8,12 +8,7 @@ use Test::Requires 'Test::Output';
use Eval::Closure;
{
- my $source = <<'SOURCE';
- sub {
- $foo * 2;
- };
- BEGIN { warn "foo\n" }
-SOURCE
+ my $source = 'BEGIN { warn "foo\n" } sub { $foo * 2 }';
my $code;
my $bar = 15;
@@ -43,12 +38,7 @@ SOURCE
}
{
- my $source = <<'SOURCE';
- sub {
- $bar * 2;
- };
- BEGIN { warn "bar\n" }
-SOURCE
+ my $source = 'BEGIN { warn "bar\n" } sub { $bar * 2 }';
my $code;
my $foo = 60;
@@ -66,8 +56,7 @@ SOURCE
my $code2;
my $baz = 23;
- { local $TODO = $] < 5.010 ? "description breaks memoization on 5.8"
- : undef;
+ { local $TODO = "description breaks memoization";
stderr_is {
$code2 = eval_closure(
source => $source,
@@ -83,12 +72,7 @@ SOURCE
}
{
- my $source = <<'SOURCE';
- sub {
- Carp::confess "baz";
- };
- BEGIN { warn "baz\n" }
-SOURCE
+ my $source = 'BEGIN { warn "baz\n" } sub { Carp::confess "baz" }';
my $code;
stderr_is {
@@ -102,8 +86,7 @@ SOURCE
"got the right description");
my $code2;
- { local $TODO = $] < 5.010 ? "description breaks memoization on 5.8"
- : undef;
+ { local $TODO = "description breaks memoization";
stderr_is {
$code2 = eval_closure(
source => $source,
View
61 t/11-line-differences.t
@@ -1,61 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use Test::More;
-use Test::Requires 'Test::Output';
-
-use Eval::Closure;
-
-{
- my $code = eval_closure(
- source => 'sub { warn "foo" }',
- description => 'bar',
- );
- { local $TODO = $] < 5.010 ? "line numbers from #line are slightly different" : undef;
- stderr_is { $code->() } "foo at bar line 1.\n", "got the right line";
- }
-}
-
-{
- my $code = eval_closure(
- source => <<'SOURCE',
- sub {
-
- warn "foo";
-
- }
-SOURCE
- description => 'bar',
- );
- { local $TODO = $] < 5.010 ? "line numbers from #line are slightly different" : undef;
- stderr_is { $code->() } "foo at bar line 1.\n", "got the right line";
- }
-}
-
-{
- my $code = eval_closure(
- source => <<'SOURCE',
-
- sub {
- warn "foo";
- }
-SOURCE
- description => 'bar',
- );
- { local $TODO = $] < 5.010 ? "line numbers from #line are slightly different" : undef;
- stderr_is { $code->() } "foo at bar line 1.\n", "got the right line";
- }
-}
-
-{
- my $code = eval_closure(
- source => '$sub',
- environment => { '$sub' => \sub { warn "foo" } },
- description => 'bar',
- );
- { local $TODO = $] < 5.010 ? "#line can't adjust line numbers inside non-evaled subs" : undef;
- stderr_is { $code->() } "foo at bar line 1.\n", "got the right line";
- }
-}
-
-done_testing;

0 comments on commit 68cb1ad

Please sign in to comment.
Something went wrong with that request. Please try again.