From: Dominic Dunlop Date: Thu, 25 Jun 1998 17:46:55 +0000 (+0000) Subject: : Move REG_INFTY-dependent tests from op/regexp.t X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8d37f93276d8a61b3f2bde2358425cba26b9b98d;p=p5sagit%2Fp5-mst-13.2.git : Move REG_INFTY-dependent tests from op/regexp.t Message-Id: to op/pat.t; add tests for a few more regexp parse failures etc. p4raw-id: //depot/perl@1244 --- diff --git a/t/op/pat.t b/t/op/pat.t index f0bbdbc..4c4bd9e 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -1,8 +1,16 @@ #!./perl +# +# This is a home for regular expression tests that don't fit into +# the format supported by op/regexp.t. If you want to add a test +# that does fit that format, add it to op/re_tests, not here. # $RCSfile: pat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:12 $ -print "1..113\n"; +print "1..120\n"; + +chdir 't' if -d 't'; +@INC = "../lib"; +eval 'use Config'; # Defaults assumed if this fails $x = "abc\ndef\n"; @@ -233,8 +241,56 @@ $_ = 'foobar1 bar2 foobar3 barfoobar5 foobar6'; print "not " if "@out" ne 'bar2 barf'; print "ok 65\n"; +# Tests which depend on REG_INFTY +$reg_infty = defined $Config{reg_infty} ? $Config{reg_infty} : 32767; +$reg_infty_m = $reg_infty - 1; $reg_infty_p = $reg_infty + 1; + +# As well as failing if the pattern matches do unexpected things, the +# next three tests will fail if you should have picked up a lower-than- +# default value for $reg_infty from Config.pm, but have not. + +undef $@; +print "not " if eval q(('aaa' =~ /(a{1,$reg_infty_m})/)[0] ne 'aaa') || $@; +print "ok 66\n"; + +undef $@; +print "not " if eval q(('a' x $reg_infty_m) !~ /a{$reg_infty_m}/) || $@; +print "ok 67\n"; + +undef $@; +print "not " if eval q(('a' x ($reg_infty_m - 1)) =~ /a{$reg_infty_m}/) || $@; +print "ok 68\n"; + +undef $@; +eval "'aaa' =~ /a{1,$reg_infty}/"; +print "not " if $@ !~ m%^\Q/a{1,$reg_infty}/: Quantifier in {,} bigger than%; +print "ok 69\n"; + +eval "'aaa' =~ /a{1,$reg_infty_p}/"; +print "not " + if $@ !~ m%^\Q/a{1,$reg_infty_p}/: Quantifier in {,} bigger than%; +print "ok 70\n"; +undef $@; + +# Poke a couple more parse failures + +$context = 'x' x 256; +eval qq("${context}y" =~ /(?<=$context)y/); +print "not " if $@ !~ m%^\Q/(?<=\Ex+/: lookbehind longer than 255 not%; +print "ok 71\n"; + +# This one will fail when POSIX character classes do get implemented +{ + my $w; + local $^W = 1; + local $SIG{__WARN__} = sub{$w = shift}; + eval q('a' =~ /[[:alpha:]]/); + print "not " if $w !~ /^\QCharacter class syntax [: :] is reserved/; +} +print "ok 72\n"; + # Long Monsters -$test = 66; +$test = 73; for $l (125, 140, 250, 270, 300000, 30) { # Ordered to free memory $a = 'a' x $l; print "# length=$l\nnot " unless "ba$a=" =~ /a$a=/; diff --git a/t/op/re_tests b/t/op/re_tests index 6154bff..b506306 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -354,9 +354,6 @@ a(?:b|(c|e){1,2}?|d)+?(.) ace y $1$2 ce '(ab)\d\1'i Ab4ab y $1 Ab '(ab)\d\1'i ab4Ab y $1 ab foo\w*\d{4}baz foobar1234baz y $& foobar1234baz -a{1,$reg_infty_m} aaa y $& aaa -a{1,$reg_infty} - c - /a{1,$reg_infty}/: Quantifier in {,} bigger than -a{1,$reg_infty_p} - c - /a{1,$reg_infty_p}/: Quantifier in {,} bigger than a(?{})b cabd y $& ab a(?{)b - c - /a(?{)b/: Sequence (?{...}) not terminated or not {}-balanced a(?{{})b - c - /a(?{{})b/: Sequence (?{...}) not terminated or not {}-balanced @@ -440,3 +437,5 @@ $(?<=^(a)) a y $1 a ((?>a+)b) aaab y $1 aaab (?>(a+))b aaab y $1 aaa ((?>[^()]+)|\([^()]*\))+ ((abc(ade)ufh()()x y $& abc(ade)ufh()()x +(?<=x+)y - c - /(?<=x+)y/: variable length lookbehind not implemented +a{37,17} - c - /a{37,17}/: Can't do {n,m} with n > m diff --git a/t/op/regexp.t b/t/op/regexp.t index a4783ba..e3eb336 100755 --- a/t/op/regexp.t +++ b/t/op/regexp.t @@ -23,21 +23,13 @@ # # Columns 1, 2 and 5 are \n-interpolated. # -# The variables $reg_infty, $reg_infty_m and $reg_infty_m in columns 1 -# and 5 are replaced respectively with the configuration value reg_infty, -# reg_infty-1 and reg_infty+1, or if reg_infty is not defined in the -# configuration, default values. No other variables are substituted. - +# 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. $iters = shift || 1; # Poor man performance suite, 10000 is OK. -chdir 't' if -d 't'; -@INC = "../lib"; -eval 'use Config'; # Defaults assumed if this fails -$reg_infty = defined $Config{reg_infty} ? $Config{reg_infty} : 32767; -$reg_infty_m = $reg_infty - 1; $reg_infty_p = $reg_infty + 1; - -open(TESTS,'op/re_tests') || die "Can't open re_tests"; +open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') || + die "Can't open re_tests"; while () { } $numtests = $.;