aboutsummaryrefslogtreecommitdiff
path: root/test.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-06-22 10:50:15 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-06-22 10:50:15 -0300
commit4eb4419163dd6c97665b9481e9581ff32496b392 (patch)
tree85bbac8be5fb03d340a6a901fd15599dd699d8da /test.lua
parente3f612f58dc0201beb3a86e1a5d8df9cd9158698 (diff)
downloadlpeg-4eb4419163dd6c97665b9481e9581ff32496b392.tar.gz
lpeg-4eb4419163dd6c97665b9481e9581ff32496b392.tar.bz2
lpeg-4eb4419163dd6c97665b9481e9581ff32496b392.zip
Accumulator pattern added to the 're' module
Diffstat (limited to 'test.lua')
-rwxr-xr-xtest.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/test.lua b/test.lua
index 7e61603..d0b82da 100755
--- a/test.lua
+++ b/test.lua
@@ -1517,6 +1517,13 @@ c = re.compile([[
1517]], {tonumber = tonumber, add = function (a,b) return a + b end}) 1517]], {tonumber = tonumber, add = function (a,b) return a + b end})
1518assert(c:match("3 401 50") == 3 + 401 + 50) 1518assert(c:match("3 401 50") == 3 + 401 + 50)
1519 1519
1520-- test for accumulator captures
1521c = re.compile([[
1522 S <- number (%s+ number >> add)*
1523 number <- %d+ -> tonumber
1524]], {tonumber = tonumber, add = function (a,b) return a + b end})
1525assert(c:match("3 401 50") == 3 + 401 + 50)
1526
1520-- tests for look-ahead captures 1527-- tests for look-ahead captures
1521x = {re.match("alo", "&(&{.}) !{'b'} {&(...)} &{..} {...} {!.}")} 1528x = {re.match("alo", "&(&{.}) !{'b'} {&(...)} &{..} {...} {!.}")}
1522checkeq(x, {"", "alo", ""}) 1529checkeq(x, {"", "alo", ""})