diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-06 06:41:17 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-07-06 06:41:17 +0000 |
commit | e4d48cc9bddb8984cf12bdfbcbac9580d192b5a5 (patch) | |
tree | 3f490d6e52093c5f09c5b80a219d66b0ab159c02 /t | |
parent | 06b3afcdfc1f3e17cec01aa39ec73f3f3165a28e (diff) | |
download | perl-e4d48cc9bddb8984cf12bdfbcbac9580d192b5a5.tar.gz |
allow eval-groups in patterns only if they C<use re 'eval';>
p4raw-id: //depot/perl@1334
Diffstat (limited to 't')
-rwxr-xr-x | t/op/misc.t | 8 | ||||
-rwxr-xr-x | t/op/pat.t | 18 | ||||
-rwxr-xr-x | t/op/regexp.t | 7 | ||||
-rwxr-xr-x | t/op/subst.t | 7 |
4 files changed, 32 insertions, 8 deletions
diff --git a/t/op/misc.t b/t/op/misc.t index 9ab6831859..25f566e19b 100755 --- a/t/op/misc.t +++ b/t/op/misc.t @@ -336,16 +336,18 @@ sub foo { local $_ = shift; split; @_ } @x = foo(' x y z '); print "you die joe!\n" unless "@x" eq 'x y z'; ######## +use re 'eval'; /(?{"{"})/ # Check it outside of eval too EXPECT -Sequence (?{...}) not terminated or not {}-balanced at - line 1, within pattern -/(?{"{"})/: Sequence (?{...}) not terminated or not {}-balanced at - line 1. +Sequence (?{...}) not terminated or not {}-balanced at - line 2, within pattern +/(?{"{"})/: Sequence (?{...}) not terminated or not {}-balanced at - line 2. ######## +use re 'eval'; /(?{"{"}})/ # Check it outside of eval too EXPECT Unmatched right bracket at (re_eval 1) line 1, at end of line syntax error at (re_eval 1) line 1, near ""{"}" -Compilation failed in regexp at - line 1. +Compilation failed in regexp at - line 2. ######## BEGIN { @ARGV = qw(a b c) } BEGIN { print "argv <@ARGV>\nbegin <",shift,">\n" } diff --git a/t/op/pat.t b/t/op/pat.t index fecdf0c199..7ee1f0943c 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -6,11 +6,14 @@ # $RCSfile: pat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:12 $ -print "1..123\n"; +print "1..124\n"; -chdir 't' if -d 't'; -@INC = "../lib"; +BEGIN { + chdir 't' if -d 't'; + @INC = "../lib" if -d "../lib"; +} eval 'use Config'; # Defaults assumed if this fails +use re 'eval'; $x = "abc\ndef\n"; @@ -379,7 +382,14 @@ $test++; $code = '{$blah = 45}'; $blah = 12; -/(?$code)/; +eval { /(?$code)/ }; +print "not " unless $@ and $@ =~ /not allowed at run time/ and $blah == 12; +print "ok $test\n"; +$test++; + +$code = '{$blah = 45}'; +$blah = 12; +eval "/(?$code)/"; print "not " if $blah != 45; print "ok $test\n"; $test++; diff --git a/t/op/regexp.t b/t/op/regexp.t index 7e43526f63..244ed4ab99 100755 --- a/t/op/regexp.t +++ b/t/op/regexp.t @@ -26,6 +26,13 @@ # If you want to add a regular expression test that can't be expressed # in this format, don't add it here: put it in op/pat.t instead. +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib' if -d '../lib'; +} + +use re 'eval'; + $iters = shift || 1; # Poor man performance suite, 10000 is OK. open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') || diff --git a/t/op/subst.t b/t/op/subst.t index 92a848fe80..1323b2d004 100755 --- a/t/op/subst.t +++ b/t/op/subst.t @@ -1,6 +1,10 @@ #!./perl -# $RCSfile: s.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:22 $ + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib' if -d '../lib'; +} print "1..70\n"; @@ -276,6 +280,7 @@ $_ = <<'EOL'; EOL $^R = 'junk'; +use re 'eval'; $foo = ' $@%#lowercase $@%# lowercase UPPERCASE$@%#UPPERCASE' . ' $@%#lowercase$@%#lowercase$@%# lowercase lowercase $@%#lowercase' . ' lowercase $@%#MiXeD$@%# '; |