6 use Test::Requires 'Test::Output';
11 my $source = <<'SOURCE';
15 BEGIN { warn "foo\n" }
27 } "foo\n", "BEGIN was run";
29 is($code->(), 30, "got the right sub");
34 $code2 = eval_closure(
40 } '', "BEGIN was not run twice";
42 is($code2->(), 16, "got the right sub");
46 my $source = <<'SOURCE';
50 BEGIN { warn "bar\n" }
63 } "bar\n", "BEGIN was run";
65 is($code->(), 120, "got the right sub");
69 { local $TODO = $] < 5.010 ? "description breaks memoization on 5.8"
72 $code2 = eval_closure(
79 } '', "BEGIN was not run twice";
82 is($code2->(), 46, "got the right sub");
86 my $source = <<'SOURCE';
90 BEGIN { warn "baz\n" }
97 description => 'first',
99 } "baz\n", "BEGIN was run";
101 like(exception { $code->() }, qr/baz at first line 1/,
102 "got the right description");
105 { local $TODO = $] < 5.010 ? "description breaks memoization on 5.8"
108 $code2 = eval_closure(
110 description => 'second',
112 } '', "BEGIN was not run twice";
115 like(exception { $code2->() }, qr/baz at second line 1/,
116 "got the right description");