~ubuntu-branches/ubuntu/natty/libsignatures-perl/natty

« back to all changes in this revision

Viewing changes to t/eval.t

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-05-18 20:34:44 UTC
  • Revision ID: james.westby@ubuntu.com-20090518203444-ee3iqibpk6uxo7u8
Tags: upstream-0.05
ImportĀ upstreamĀ versionĀ 0.05

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
use warnings;
 
3
use Test::More tests => 8;
 
4
 
 
5
use signatures;
 
6
 
 
7
eval 'sub foo ($bar) { $bar }';
 
8
ok(!$@, 'signatures parse in eval');
 
9
diag $@ if $@;
 
10
ok(\&foo, 'sub declared in eval');
 
11
is(foo(42), 42, 'eval signature works');
 
12
 
 
13
no signatures;
 
14
 
 
15
$SIG{__WARN__} = sub {};
 
16
eval 'sub bar ($baz) { $baz }';
 
17
like($@, qr/requires explicit package name/, 'string eval disabled');
 
18
 
 
19
{
 
20
    use signatures;
 
21
 
 
22
    eval 'sub bar ($baz) { $baz }';
 
23
    ok(!$@, 'signatures parse in eval');
 
24
    diag $@ if $@;
 
25
    ok(\&bar, 'sub declared in eval');
 
26
    is(bar(42), 42, 'eval signature works');
 
27
}
 
28
 
 
29
$SIG{__WARN__} = sub {};
 
30
eval 'sub moo ($kooh) { $kooh }';
 
31
like($@, qr/requires explicit package name/, 'string eval disabled');