From 7e294c409ff76fbad8ae5ea35ec2b17915ef8005 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Tue, 6 Dec 2011 18:20:19 -0800 Subject: [PATCH] more tests for partial strictures and ver decls --- t/comp/use.t | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/t/comp/use.t b/t/comp/use.t index ddbed2e..25e2a96 100644 --- a/t/comp/use.t +++ b/t/comp/use.t @@ -6,7 +6,7 @@ BEGIN { $INC{"feature.pm"} = 1; # so we don't attempt to load feature.pm } -print "1..77\n"; +print "1..83\n"; # Can't require test.pl, as we're testing the use/require mechanism here. @@ -22,6 +22,8 @@ sub _ok { $result = $got ne $expected; } elsif ($type eq 'like') { $result = $got =~ $expected; + } elsif ($type eq 'ok') { + $result = not not $got; } else { die "Unexpected type '$type'$name"; } @@ -46,6 +48,8 @@ sub _ok { print "# Expected not '$expected'\n"; } elsif ($type eq 'like') { print "# Expected $expected\n"; + } elsif ($type eq 'ok') { + print "# Expected a true value\n"; } } $test = $test + 1; @@ -61,6 +65,9 @@ sub is ($$;$) { sub isnt ($$;$) { _ok ('isnt', @_); } +sub ok($;$) { + _ok ('ok', shift, undef, @_); +} eval "use 5"; # implicit semicolon is ($@, ''); @@ -144,6 +151,18 @@ like $@, qr/^Can't use string/, 'explicit use strict "subs" does not stop ver decl from enabling refs'; eval 'use 5.012; use 5.01; ${"foo"} = "bar"'; is $@, "", 'use 5.01 overrides implicit strict from prev ver decl'; +eval 'no strict "subs"; use 5.012; ${"foo"} = "bar"'; +ok $@, 'no strict subs allows ver decl to enable refs'; +eval 'no strict "subs"; use 5.012; $nonexistent_pack_var'; +ok $@, 'no strict subs allows ver decl to enable vars'; +eval 'no strict "refs"; use 5.012; fancy_bareword'; +ok $@, 'no strict refs allows ver decl to enable subs'; +eval 'no strict "refs"; use 5.012; $nonexistent_pack_var'; +ok $@, 'no strict refs allows ver decl to enable subs'; +eval 'no strict "vars"; use 5.012; ${"foo"} = "bar"'; +ok $@, 'no strict vars allows ver decl to enable refs'; +eval 'no strict "vars"; use 5.012; ursine_word'; +ok $@, 'no strict vars allows ver decl to enable subs'; { use test_use } # check that subparse saves pending tokens -- 2.7.4