Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
second shot at the substr-out-of-range error in <alpha> rule; with test
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jun 2, 2010
1 parent 69506cb commit f65cbf3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Regex/Cursor-builtins.pir
Expand Up @@ -123,6 +123,10 @@ Regex::Cursor-builtins - builtin regexes for Cursor objects
(cur, pos, tgt) = self.'!cursor_start'()
$I0 = is_cclass .CCLASS_ALPHABETIC, tgt, pos
if $I0 goto pass

$I0 = length tgt
if pos >= $I0 goto fail

$S0 = substr tgt, pos, 1
if $S0 != '_' goto fail
pass:
Expand Down
5 changes: 4 additions & 1 deletion t/nqp/50-regex.t
@@ -1,12 +1,15 @@
#! nqp

plan(3);
plan(4);

ok(Regex::Cursor.parse('a', :rule(/<alpha>/), :p(0)),
'Can parse "a" with <alpha> and :p(0)');

ok(!Regex::Cursor.parse('a', :rule(/<alpha>/), :p(1)),
'Can parse "a" with <alpha> :p(off-range)');

ok(!Regex::Cursor.parse('a', :rule(/<alpha>/), :c(1)),
'Can parse "a" with <alpha> :c(off-range)');

ok(!Regex::Cursor.parse('a', :rule(/<alpha>/), :p(5)),
'Can parse "a" with <alpha> :p(far-off-range)');

0 comments on commit f65cbf3

Please sign in to comment.